Example #1
0
def xwotd():
    """
    xwot description builder command
    """

    parser = argparse.ArgumentParser(description='xwot description builder')
    parser.add_argument('xwot_file', metavar='xwot file', type=str, nargs=1, help='a xwot file')

    parser.add_argument('-o', dest='output_filepath', type=str, default=None, nargs='?',
                        help='path of the output file')

    args = parser.parse_args()

    xml_filepath = args.xwot_file[0]
    description_builder = JSONLDDescriptionBuilder()
    out = description_builder.build(xml_file=xml_filepath)

    output_filepath = args.output_filepath
    if output_filepath is None:
        output_filepath = os.path.basename(xml_filepath) + ".jsonld"

    with open(output_filepath, "w+") as f:
        f.write(out)
Example #2
0
def create_description(xwot_file, site='', base=None):
    description_builder = JSONLDDescriptionBuilder()
    out = description_builder.build(xml_file=xwot_file, site=site, base=base)
    return out