Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use relative paths for access to modules (avoid sys.path fiddling) #151

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ jobs:
coverage report -m --skip-covered

- name: Check coverage report
if: github.ref != 'refs/heads/main'
# Disable coverage checking from forks until there is a secure fix for:
# https://github.com/orgoro/coverage/issues/259
if: github.ref != 'refs/heads/main' && ${{ ! github.event.pull_request.head.repo.fork }}
Comment on lines -45 to +47
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated, but I noticed this problem when trying to to land #109 -- coverage fails on fork branches 😦

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh fascinating - i guess that should probably be something we do elsewhere.

uses: orgoro/[email protected]
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
thresholdAll: .35
thresholdAll: .45
thresholdNew: 1
thresholdModified: 0
thresholdModified: .40
13 changes: 2 additions & 11 deletions fhir-parser-resources/template-resource.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Generated from FHIR {{ info.version }} ({{ profile.url }}) on {{ info.date }}.
# {{ info.year }}, SMART Health IT.

Expand Down Expand Up @@ -79,13 +76,7 @@ def elementProperties(self):
{%- endif %}
{%- endfor %}

{% if imports|length > 0 and imported|length != imports|length %}
import sys
{%- endif %}
{%- for imp in imports %}{% if imp.module not in imported %}
try:
from . import {{ imp.module }}
except ImportError:
{{ imp.module }} = sys.modules[__package__ + '.{{ imp.module }}']
{% for imp in imports %}{% if imp.module not in imported %}
from . import {{ imp.module }}
{%- endif %}{% endfor %}

5 changes: 0 additions & 5 deletions fhirclient/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
import sys
import os.path
abspath = os.path.abspath(os.path.dirname(__file__))
if abspath not in sys.path:
sys.path.insert(0, abspath)
10 changes: 2 additions & 8 deletions fhirclient/auth.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# -*- coding: utf-8 -*-

import uuid
import logging
from datetime import datetime, timedelta
try: # Python 2.x
import urlparse
from urllib import urlencode
except Exception as e: # Python 3
import urllib.parse as urlparse
from urllib.parse import urlencode
import urllib.parse as urlparse
from urllib.parse import urlencode

logger = logging.getLogger(__name__)

Expand Down
4 changes: 1 addition & 3 deletions fhirclient/client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-

import logging

from server import FHIRServer, FHIRUnauthorizedException, FHIRNotFoundException
from .server import FHIRServer, FHIRUnauthorizedException, FHIRNotFoundException

__version__ = '4.2.0'
__author__ = 'SMART Platforms Team'
Expand Down
24 changes: 4 additions & 20 deletions fhirclient/models/account.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Generated from FHIR 4.0.1-9346c8cc45 (http://hl7.org/fhir/StructureDefinition/Account) on 2024-07-15.
# 2024, SMART Health IT.

Expand Down Expand Up @@ -168,20 +165,7 @@ def elementProperties(self):
return js


import sys
try:
from . import codeableconcept
except ImportError:
codeableconcept = sys.modules[__package__ + '.codeableconcept']
try:
from . import fhirreference
except ImportError:
fhirreference = sys.modules[__package__ + '.fhirreference']
try:
from . import identifier
except ImportError:
identifier = sys.modules[__package__ + '.identifier']
try:
from . import period
except ImportError:
period = sys.modules[__package__ + '.period']
from . import codeableconcept
from . import fhirreference
from . import identifier
from . import period
79 changes: 15 additions & 64 deletions fhirclient/models/activitydefinition.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Generated from FHIR 4.0.1-9346c8cc45 (http://hl7.org/fhir/StructureDefinition/ActivityDefinition) on 2024-07-15.
# 2024, SMART Health IT.

Expand Down Expand Up @@ -378,64 +375,18 @@ def elementProperties(self):
return js


import sys
try:
from . import age
except ImportError:
age = sys.modules[__package__ + '.age']
try:
from . import codeableconcept
except ImportError:
codeableconcept = sys.modules[__package__ + '.codeableconcept']
try:
from . import contactdetail
except ImportError:
contactdetail = sys.modules[__package__ + '.contactdetail']
try:
from . import dosage
except ImportError:
dosage = sys.modules[__package__ + '.dosage']
try:
from . import duration
except ImportError:
duration = sys.modules[__package__ + '.duration']
try:
from . import expression
except ImportError:
expression = sys.modules[__package__ + '.expression']
try:
from . import fhirdate
except ImportError:
fhirdate = sys.modules[__package__ + '.fhirdate']
try:
from . import fhirreference
except ImportError:
fhirreference = sys.modules[__package__ + '.fhirreference']
try:
from . import identifier
except ImportError:
identifier = sys.modules[__package__ + '.identifier']
try:
from . import period
except ImportError:
period = sys.modules[__package__ + '.period']
try:
from . import quantity
except ImportError:
quantity = sys.modules[__package__ + '.quantity']
try:
from . import range
except ImportError:
range = sys.modules[__package__ + '.range']
try:
from . import relatedartifact
except ImportError:
relatedartifact = sys.modules[__package__ + '.relatedartifact']
try:
from . import timing
except ImportError:
timing = sys.modules[__package__ + '.timing']
try:
from . import usagecontext
except ImportError:
usagecontext = sys.modules[__package__ + '.usagecontext']
from . import age
from . import codeableconcept
from . import contactdetail
from . import dosage
from . import duration
from . import expression
from . import fhirdate
from . import fhirreference
from . import identifier
from . import period
from . import quantity
from . import range
from . import relatedartifact
from . import timing
from . import usagecontext
9 changes: 1 addition & 8 deletions fhirclient/models/address.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Generated from FHIR 4.0.1-9346c8cc45 (http://hl7.org/fhir/StructureDefinition/Address) on 2024-07-15.
# 2024, SMART Health IT.

Expand Down Expand Up @@ -87,8 +84,4 @@ def elementProperties(self):
return js


import sys
try:
from . import period
except ImportError:
period = sys.modules[__package__ + '.period']
from . import period
24 changes: 4 additions & 20 deletions fhirclient/models/adverseevent.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Generated from FHIR 4.0.1-9346c8cc45 (http://hl7.org/fhir/StructureDefinition/AdverseEvent) on 2024-07-15.
# 2024, SMART Health IT.

Expand Down Expand Up @@ -222,20 +219,7 @@ def elementProperties(self):
return js


import sys
try:
from . import codeableconcept
except ImportError:
codeableconcept = sys.modules[__package__ + '.codeableconcept']
try:
from . import fhirdate
except ImportError:
fhirdate = sys.modules[__package__ + '.fhirdate']
try:
from . import fhirreference
except ImportError:
fhirreference = sys.modules[__package__ + '.fhirreference']
try:
from . import identifier
except ImportError:
identifier = sys.modules[__package__ + '.identifier']
from . import codeableconcept
from . import fhirdate
from . import fhirreference
from . import identifier
3 changes: 0 additions & 3 deletions fhirclient/models/age.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Generated from FHIR 4.0.1-9346c8cc45 (http://hl7.org/fhir/StructureDefinition/Age) on 2024-07-15.
# 2024, SMART Health IT.

Expand Down
44 changes: 8 additions & 36 deletions fhirclient/models/allergyintolerance.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Generated from FHIR 4.0.1-9346c8cc45 (http://hl7.org/fhir/StructureDefinition/AllergyIntolerance) on 2024-07-15.
# 2024, SMART Health IT.

Expand Down Expand Up @@ -197,36 +194,11 @@ def elementProperties(self):
return js


import sys
try:
from . import age
except ImportError:
age = sys.modules[__package__ + '.age']
try:
from . import annotation
except ImportError:
annotation = sys.modules[__package__ + '.annotation']
try:
from . import codeableconcept
except ImportError:
codeableconcept = sys.modules[__package__ + '.codeableconcept']
try:
from . import fhirdate
except ImportError:
fhirdate = sys.modules[__package__ + '.fhirdate']
try:
from . import fhirreference
except ImportError:
fhirreference = sys.modules[__package__ + '.fhirreference']
try:
from . import identifier
except ImportError:
identifier = sys.modules[__package__ + '.identifier']
try:
from . import period
except ImportError:
period = sys.modules[__package__ + '.period']
try:
from . import range
except ImportError:
range = sys.modules[__package__ + '.range']
from . import age
from . import annotation
from . import codeableconcept
from . import fhirdate
from . import fhirreference
from . import identifier
from . import period
from . import range
14 changes: 2 additions & 12 deletions fhirclient/models/annotation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Generated from FHIR 4.0.1-9346c8cc45 (http://hl7.org/fhir/StructureDefinition/Annotation) on 2024-07-15.
# 2024, SMART Health IT.

Expand Down Expand Up @@ -53,12 +50,5 @@ def elementProperties(self):
return js


import sys
try:
from . import fhirdate
except ImportError:
fhirdate = sys.modules[__package__ + '.fhirdate']
try:
from . import fhirreference
except ImportError:
fhirreference = sys.modules[__package__ + '.fhirreference']
from . import fhirdate
from . import fhirreference
29 changes: 5 additions & 24 deletions fhirclient/models/appointment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Generated from FHIR 4.0.1-9346c8cc45 (http://hl7.org/fhir/StructureDefinition/Appointment) on 2024-07-15.
# 2024, SMART Health IT.

Expand Down Expand Up @@ -200,24 +197,8 @@ def elementProperties(self):
return js


import sys
try:
from . import codeableconcept
except ImportError:
codeableconcept = sys.modules[__package__ + '.codeableconcept']
try:
from . import fhirdate
except ImportError:
fhirdate = sys.modules[__package__ + '.fhirdate']
try:
from . import fhirreference
except ImportError:
fhirreference = sys.modules[__package__ + '.fhirreference']
try:
from . import identifier
except ImportError:
identifier = sys.modules[__package__ + '.identifier']
try:
from . import period
except ImportError:
period = sys.modules[__package__ + '.period']
from . import codeableconcept
from . import fhirdate
from . import fhirreference
from . import identifier
from . import period
24 changes: 4 additions & 20 deletions fhirclient/models/appointmentresponse.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Generated from FHIR 4.0.1-9346c8cc45 (http://hl7.org/fhir/StructureDefinition/AppointmentResponse) on 2024-07-15.
# 2024, SMART Health IT.

Expand Down Expand Up @@ -71,20 +68,7 @@ def elementProperties(self):
return js


import sys
try:
from . import codeableconcept
except ImportError:
codeableconcept = sys.modules[__package__ + '.codeableconcept']
try:
from . import fhirdate
except ImportError:
fhirdate = sys.modules[__package__ + '.fhirdate']
try:
from . import fhirreference
except ImportError:
fhirreference = sys.modules[__package__ + '.fhirreference']
try:
from . import identifier
except ImportError:
identifier = sys.modules[__package__ + '.identifier']
from . import codeableconcept
from . import fhirdate
from . import fhirreference
from . import identifier
Loading