Beispiel #1
0
def generate_metadata_xml(cargs, kwargs):
    logging.info('generating metadata')
    md = MyMetadata(cargs, kwargs)
    xml = md.get_xml_output()
    if cargs.outputfile:
        output_file = open(cargs.outputfile, "w+")
        output_file.write(xml)
        output_file.close()
    else:
        print(xml)
Beispiel #2
0
def generate_json_config(conf, cargs):
    logging.info('generating json config')
    cdict = CONF.__dict__
    json_dump = json.dumps(cdict, indent=1)
    configdir = cargs.configdir
    json_ready = json_dump.replace(configdir, '.')

    md = MyMetadata(cargs, kwargs)
    xml = md.get_xml_output()

    generated_dir = os.path.join(configdir, 'generated')
    if not os.path.exists(generated_dir):
        os.makedirs(generated_dir)
    fpath = os.path.join(generated_dir, 'config.json')
    with open(fpath, "w") as fd:
        fd.write(json_ready)
        logging.info('Created ' + fpath)
    fpath = os.path.join(generated_dir, 'metadata.xml')
    with open(fpath, "w") as fd:
        fd.write(xml)
        logging.info('Created ' + fpath)