Example #1
0
File: alias.py Project: podhmo/cctm
def main(config, name, alias, store=None):
    config.load_config()
    lookup = services.PackageLookup(config)
    data = lookup.lookup_loose(name)
    if not data:
        sys.stderr.write("{} is not found".format(name))
    alias_store = services.aliases_store(config, path=store)

    data = {"name": alias, "link": name}
    store_data = alias_store.update(data, alias_store.load())
    alias_store.save(store_data)

    if store is None:
        local_store = services.aliases_store(config, path=config.control.resolve_path("local.alias.json"))
        store_data = local_store.update(data, local_store.load())
        local_store.save(store_data)
Example #2
0
 def gen():
     sys.stderr.write("-- template --\n")
     store = services.packages_store(config)
     for data in store.load():
         yield ("{data[name]}({data[star]}) -- {data[description]:.60}".format(data=data))
     sys.stderr.write("-- alias --\n")
     store = services.aliases_store(config)
     for data in store.load():
         yield("{data[name]} -> {data[link]}".format(data=data))
Example #3
0
def selfupdate(config):
    config.load_config()
    logger.info("selfupdate")
    logger.info("updating store=%s", config.store_path)
    package_store = services.packages_store(config)
    alias_store = services.aliases_store(config)
    repository_store = services.RepositoriesStore(config)
    package_store.save(repository_store.extract_packages(config.repositories))
    alias_store.save(repository_store.extract_packages(config.aliases))
Example #4
0
def main(config, installed=False, alias=False):
    config.load_config()
    if installed:
        for path in safe_listdir(config.store_dir):
            print(path.replace(".", "/", 1))
    elif alias:
        store = services.aliases_store(config)
        for data in store.load():
            print("{data[name]} -> {data[link]}".format(data=data))
    else:
        def gen():
            sys.stderr.write("-- template --\n")
            store = services.packages_store(config)
            for data in store.load():
                yield ("{data[name]}({data[star]}) -- {data[description]:.60}".format(data=data))
            sys.stderr.write("-- alias --\n")
            store = services.aliases_store(config)
            for data in store.load():
                yield("{data[name]} -> {data[link]}".format(data=data))

        for line in gen():
            print(line)