Skip to content

Commit

Permalink
Fix various syntax issues and a jinja2 API break
Browse files Browse the repository at this point in the history
- Update a jinja2 import to avoid removed methods (removal in 3.1,
  new method appeared in 3.0 - so bump requirement to 3.0 too)
- Fix a few python syntax warnings.
- Update README's mention of what this repo can parse.
- Fix a Practitioner typo in a comment. Fix by Kevin Wood (kwood16).
  • Loading branch information
mikix committed Jul 12, 2024
1 parent 5d2945e commit c419fa4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Default/mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Which class names to map to resources and elements
classmap = {
'Any': 'Resource',
'Practitioner.role': 'PractRole', # to avoid Practinioner.role and PractitionerRole generating the same class
'Practitioner.role': 'PractRole', # to avoid Practitioner.role and PractitionerRole generating the same class

'boolean': 'bool',
'integer': 'int',
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ If you've come here because you want _Swift_ or _Python_ classes for FHIR data m
- [Swift-FHIR][] and [Swift-SMART][]
- Python [client-py][]

The `master` branch is currently capable of parsing _STU 3, v3.0.0_.
The `develop` branch should be capable of parsing the continuous integration build and will be merged into master on new major FHIR releases.
There may be tags for specific freezes, see [releases](https://github.com/smart-on-fhir/fhir-parser/releases).
The `master` branch is currently capable of parsing _R5_.

This work is licensed under the [APACHE license][license].
FHIR® is the registered trademark of [HL7][] and is used with the permission of HL7.
Expand Down
8 changes: 4 additions & 4 deletions fhirrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import textwrap

from jinja2 import Environment, PackageLoader, TemplateNotFound
from jinja2.filters import environmentfilter
from jinja2.filters import pass_environment
from logger import logger


Expand Down Expand Up @@ -202,7 +202,7 @@ def render(self):
# ignores existing linebreaks when applying the wrap:
# https://github.com/mitsuhiko/jinja2/issues/175
# Here's the workaround:
@environmentfilter
@pass_environment
def do_wordwrap(environment, s, width=79, break_long_words=True, wrapstring=None):
"""
Return a copy of the string passed to the filter wrapped after
Expand All @@ -211,7 +211,7 @@ def do_wordwrap(environment, s, width=79, break_long_words=True, wrapstring=None
split words apart if they are longer than `width`.
"""
if not s:
return s
return s

if not wrapstring:
wrapstring = environment.newline_sequence
Expand All @@ -220,7 +220,7 @@ def do_wordwrap(environment, s, width=79, break_long_words=True, wrapstring=None
# Workaround: pre-split the string on \r, \r\n and \n
for component in re.split(r"\r\n|\n|\r", s):
# textwrap will eat empty strings for breakfirst. Therefore we route them around it.
if len(component) is 0:
if len(component) == 0:
accumulator.append(component)
continue
accumulator.extend(
Expand Down
2 changes: 1 addition & 1 deletion fhirspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ def needed_external_classes(self):
raise Exception('There is no class "{}" for property "{}" on "{}" in {}'.format(prop_cls_name, prop.name, klass.name, self.name))
else:
prop.module_name = prop_cls.module
if not prop_cls_name in needed:
if prop_cls_name not in needed:
needed.add(prop_cls_name)
needs.append(prop_cls)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Jinja2>=2.9.5
Jinja2>=3.0
MarkupSafe==0.23
requests>=2.13.0
colorlog==2.10.0

0 comments on commit c419fa4

Please sign in to comment.