diff --git a/.gitignore b/.gitignore index f84b8a2..47031aa 100644 --- a/.gitignore +++ b/.gitignore @@ -150,5 +150,5 @@ crashlytics.properties crashlytics-build.properties fabric.properties -.idea/*.iml -.idea/misc.xml +.idea +.vscode diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 73f69e0..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index b62cf7f..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index 28fc147..d30222a 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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 @@ -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)
- do not serialize null ID for POST (#2)
- include option for only certain resource types(#6)
- fix XML handling (#6)
- add LICENSE | +| v1.1.1 | 2021-06-09 | - explicitly open files with UTF-8 encoding (#12)
- ignore pycharm and vscode (#11)| diff --git a/setup.cfg b/setup.cfg index d96fcef..2b03fc4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = fhir-populator -version = 1.1.0 +version = 1.1.1 author = Joshua Wiedekopf author_email = j.wiedekopf@uni-luebeck.de description = Load Simplifier packages into a FHIR server, quickly and consistently. diff --git a/src/fhir_populator/populator.py b/src/fhir_populator/populator.py index 3d7b2b2..0eaca40 100644 --- a/src/fhir_populator/populator.py +++ b/src/fhir_populator/populator.py @@ -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) @@ -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 @@ -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: @@ -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}!") @@ -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