Beispiel #1
0
def maybe_trial_build(m):
    from shutil import copyfile
    '''Update the metadata for a trial build, then restore it'''

    if not m.args.trial:
        yield False, m.mt_file
        return

    if not m.doc._has_semver():
        raise MetapackError(
            "To use trial builds, package must have a semantic version ")

    prt('Building a trial')

    mt_file = Path(m.mt_file.fspath).parent.joinpath('trial.csv')

    copyfile(m.mt_file.fspath, mt_file)

    doc = MetapackDoc(mt_file)
    version = doc['Root'].find_first('Root.Version')
    vb = version.get_or_new_child('Version.Build')
    vb.value = 'trial'

    try:
        doc.update_name()
        doc.write()

        yield True, parse_app_url(str(mt_file), downloader)
    finally:
        mt_file.unlink()
def update_package(md):

    name = md['name']

    root = Path('packages').joinpath(name)

    if not root.exists():
        return

    doc = MetapackDoc(str(root.joinpath('metadata.csv')))

    print(doc.name, doc.ref)

    for t in md['tags']:
        t = doc['Root'].new_term('Root.Tag', t['name'])
        print(t)

    #print(json.dumps(md, indent=4))

    doc.write()