Example #1
0
def load(settings: fhirspec.Configuration, force_download: bool,
         cache_only: bool):
    """ """
    loader = fhirloader.FHIRLoader(
        settings,
        settings.BASE_PATH / _cache_path / settings.CURRENT_RELEASE_NAME)
    spec_source = loader.load(force_download=force_download,
                              force_cache=cache_only)
    return spec_source
Example #2
0
def main():
    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, _cache)
    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()
Example #3
0
    parser.add_argument(
        '--output',
        help='The path to the directory with all generated models',
        default='models')
    return parser


if '__main__' == __name__:
    params = vars(args().parse_args())

    if params['ln'] == 'python':
        from Python import settings
        settings.write_resources = params['resources']
        settings.write_factory = params['element_factory']
        settings.write_unittests = params['tests']
    elif params['ln'] == 'swift':
        from Swift import settings
        settings.write_resources = params['resources']
        settings.write_factory = params['resources']
        settings.write_unittests = params['tests']
    else:
        sys.exit(1)

    # assure we have all files
    loader = fhirloader.FHIRLoader(settings, params['cache'])
    spec_source = loader.load(params['force'])

    # parse
    spec = fhirspec.FHIRSpec(spec_source, settings)
    spec.write(os.path.expanduser(params['output']))
Example #4
0
            fp.write(txt)


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)
    keep_previous_versions = len(sys.argv) > 1 and (
        "-k" in sys.argv or "--keep-previous-versions" in sys.argv)

    # assure we have all files
    loader = fhirloader.FHIRLoader(settings, _cache)
    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()
            # ensure init py has been created
            ensure_init_py(settings, spec.info)

    # checks for previous version maintain handler
    previous_version_info = getattr(settings, "previous_versions", [])

    if previous_version_info and keep_previous_versions:
Example #5
0
#  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()
Example #6
0
#  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

_cache = 'downloads'

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, _cache)
    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()