Skip to content

Commit

Permalink
Merge pull request #13 from itcr-uni-luebeck/release/v1.1.1
Browse files Browse the repository at this point in the history
Release/v1.1.1
  • Loading branch information
jpwiedekopf authored Jun 9, 2021
2 parents 7fea2b8 + c5f9dd3 commit d0aa637
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,5 @@ crashlytics.properties
crashlytics-build.properties
fabric.properties

.idea/*.iml
.idea/misc.xml
.idea
.vscode
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/inspectionProfiles/profiles_settings.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ python -m venv .venv
source .venv/bin/activate
```

On Windows without Windows Subsystem for Linux, you will need to change the last command to `.venv\bin\activate.bat`.

These commands will create a new directory, visit it, create the virtual environment, and activate it.

Next, load the package from PyPI:
Expand Down Expand Up @@ -119,7 +121,7 @@ There are a number of configuration options, which are (hopefully) mostly self-e
* `--non-interactive`: If provided, errors returned by the FHIR server will be ignored, and only a warning will be printed out.
* `--only-put`: FHIR requires that IDs are present for all resources that are uploaded via HTTP PUT. Hence, if IDs are missing, a HTTP POST request is used by the script. This does not generate stable, or nice, IDs by default. You can provide this parameter to make the script generate IDs from the file name of the resource, which should be stable across reruns. This uses a "slugified" version of the filename without unsafe characters, and restricted to 64 characters, as per the specification.
* `--registry-url`: While the script was only tested using the Simplifier registry, it should be compatible to other implementations of the [FHIR NPM Package Spec](https://wiki.hl7.org/FHIR_NPM_Package_Spec), which is implemented by the Simplifier software. You can provide the endpoint of an alternative registry hence.
* `--rewrite-versions`: If provided, all `version` attributes of the resources will be rewritten to match the version in the `package.json`, to separate these definitions from previous versions. You will need to think about the versions numbers you use when communicating with others, who might not use the same versions - ⚠️ use with caution! ⚠️
* `--rewrite-versions`: If provided, all `version` attributes of the resources will be rewritten to match the version in the `package.json`, to separate these definitions from previous versions. You will need to think about the versions numbers you use when communicating with others, who might not use the same versions - ⚠️ use with caution! ⚠️
* `--versioned-ids`: To separate versions of the resources on the same FHIR server, you can override the IDs provided in the resources, by including the slugified version of the package in the ID. If combined with the `--only-put` switch, this will work the same, versioning existing IDs, and slugifying + versioning the filename of resources without IDs.

## Updating
Expand Down Expand Up @@ -147,3 +149,4 @@ If you want to customize the program, you should:
|-|-|-|
| v1.0.10 | 2021-06-03 | Initial release |
| v1.1.0 | 2021-06-08 | - handle Unicode filenames, especially on BSD/macOS (#1)<br>- do not serialize null ID for POST (#2)<br>- include option for only certain resource types(#6)<br>- fix XML handling (#6)<br>- add LICENSE |
| v1.1.1 | 2021-06-09 | - explicitly open files with UTF-8 encoding (#12)<br>- ignore pycharm and vscode (#11)|
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = fhir-populator
version = 1.1.0
version = 1.1.1
author = Joshua Wiedekopf
author_email = [email protected]
description = Load Simplifier packages into a FHIR server, quickly and consistently.
Expand Down
10 changes: 5 additions & 5 deletions src/fhir_populator/populator.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def get_argument(self, argument: str, raise_on_missing: bool = False) -> str:

def get_payload(self, rewrite_version: Optional[str] = None) -> str:
# if rewrite_version is None:
# with open(self.file_path, "r") as fs:
# with open(self.file_path, "r", encoding="utf8") as fs:
# return fs.read()
if self.type == FhirResource.FileType.XML:
return self.get_payload_rewrite_xml(rewrite_version)
Expand All @@ -79,7 +79,7 @@ def get_filetype(self) -> FileType:
https://codereview.stackexchange.com/a/137926
:return: FhirResource.FileType enum member
"""
with open(self.file_path) as unknown_file:
with open(self.file_path, encoding="utf8") as unknown_file:
c = unknown_file.read(1)
if c != '<':
return FhirResource.FileType.JSON
Expand All @@ -101,7 +101,7 @@ def get_payload_rewrite_xml(self, rewrite_version: Optional[str]) -> str:
return ElementTree.tostring(root, encoding="unicode")

def get_payload_rewrite_json(self, rewrite_version: Optional[str], indent: int = 2) -> str:
with open(self.file_path, "r") as jf:
with open(self.file_path, "r", encoding="utf8") as jf:
json_dict = json.load(jf)
if rewrite_version is not None:
if "version" in json_dict:
Expand Down Expand Up @@ -129,7 +129,7 @@ def get_argument_xml(self, argument: str, raise_on_missing: bool = False):
return res_node.text

def get_argument_json(self, argument: str, raise_on_missing: bool = False) -> Optional[str]:
with open(self.file_path) as jf:
with open(self.file_path, encoding="utf8") as jf:
json_dict = json.load(jf)
if argument not in json_dict and raise_on_missing:
raise LookupError(f"the resource {self.file_path} does not have an attribute {argument}!")
Expand Down Expand Up @@ -567,7 +567,7 @@ def read_package_json(self, package_path: str) -> Optional[dict]:
if len(package_json_file) != 1:
self.log.error(f"Within the package {package_path}, one and only one package.json must be present")
return None
with open(package_json_file[0]) as jf:
with open(package_json_file[0], encoding="utf8") as jf:
package_json = json.load(jf)
return package_json

Expand Down

0 comments on commit d0aa637

Please sign in to comment.