forked from smart-on-fhir/fhir-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.py
executable file
·31 lines (25 loc) · 1019 Bytes
/
generate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Download and parse FHIR resource definitions
# Supply "-f" to force a redownload of the spec
# Supply "-c" to force using the cached spec (incompatible with "-f")
# Supply "-d" to load and parse but not write resources
# Supply "-l" to only download the spec
import sys
import settings
import fhirloader
import fhirspec
if '__main__' == __name__:
force_download = len(sys.argv) > 1 and '-f' in sys.argv
dry = len(sys.argv) > 1 and ('-d' in sys.argv or '--dry-run' in sys.argv)
load_only = len(sys.argv) > 1 and ('-l' in sys.argv or '--load-only' in sys.argv)
force_cache = len(sys.argv) > 1 and ('-c' in sys.argv or '--cache-only' in sys.argv)
# assure we have all files
loader = fhirloader.FHIRLoader(settings)
spec_source = loader.load(force_download=force_download, force_cache=force_cache)
# parse
if not load_only:
spec = fhirspec.FHIRSpec(spec_source, settings)
if not dry:
spec.write()