コード例 #1
0
    def test_output_schema(self):
        """test output schema"""

        with self.assertRaises(InvalidSchemaError):
            load_schema('404')

        iso_os = load_schema('iso19139')
        self.assertIsInstance(iso_os, ISO19139OutputSchema)
        self.assertEqual(iso_os.name, 'iso19139', 'Expected specific name')
        self.assertEqual(iso_os.outputformat, 'xml',
                         'Expected specific output format')
コード例 #2
0
ファイル: core.py プロジェクト: kalxas/pygeometa
def import_(ctx, metadata_file, schema, output, verbosity):
    """import metadata"""

    LOGGER.info(f'Importing {metadata_file} into {schema}')
    schema_object = load_schema(schema)

    try:
        content = schema_object.import_(metadata_file.read())
    except NotImplementedError:
        raise click.ClickException(f'Import not support for {schema}')
    except NotImplementedError as err:
        raise click.ClickException(err)

    if output is None:
        click.echo(content)
    else:
        output.write(content)
コード例 #3
0
ファイル: core.py プロジェクト: kalxas/pygeometa
def generate(ctx, mcf, schema, schema_local, output, verbosity):
    """generate metadata"""

    if schema is None and schema_local is None:
        raise click.UsageError('Missing arguments')
    elif None not in [schema, schema_local]:
        raise click.UsageError('schema / schema_local are mutually exclusive')

    mcf_dict = read_mcf(mcf)

    if schema is not None:
        LOGGER.info(f'Processing {mcf} into {schema}')
        schema_object = load_schema(schema)
        content = schema_object.write(mcf_dict)
    else:
        content = render_j2_template(mcf_dict, template_dir=schema_local)

    if output is None:
        click.echo(content)
    else:
        output.write(content)
コード例 #4
0
ファイル: core.py プロジェクト: pvgenuchten/pygeometa
def generate_metadata(ctx, mcf, schema, schema_local, output, verbosity):
    """generate metadata"""

    if verbosity is not None:
        logging.basicConfig(level=getattr(logging, verbosity))

    if mcf is None or all([schema is None, schema_local is None]):
        raise click.UsageError('Missing arguments')
    elif None not in [schema, schema_local]:
        raise click.UsageError('schema / schema_local are mutually exclusive')

    mcf_dict = read_mcf(mcf)

    if schema is not None:
        LOGGER.info('Processing {} into {}'.format(mcf, schema))
        schema_object = load_schema(schema)
        content = schema_object.write(mcf_dict)
    else:
        content = render_j2_template(mcf_dict, template_dir=schema_local)

    if output is None:
        click.echo(content)
    else:
        output.write(content)