Esempio n. 1
0
def installed_repository_iterator(galaxy_context,
                                  namespace_match_filter=None,
                                  repository_match_filter=None):
    '''For each repository in galaxy_context.content_path, yield matching repositories'''

    namespace_match_filter = namespace_match_filter or matchers.MatchAll()
    repository_match_filter = repository_match_filter or matchers.MatchAll()

    installed_namespace_db = installed_namespaces_db.InstalledNamespaceDatabase(
        galaxy_context)

    # TODO: iterate/filter per namespace, then per repository, then per collection/role/etc
    for namespace in installed_namespace_db.select(
            namespace_match_filter=namespace_match_filter):
        log.debug('Looking for repos in namespace "%s"', namespace.namespace)

        # TODO: filter potential repository_paths based on repository_match_filer before we
        #       try to listdir() instead of after
        repository_paths = get_repository_paths(namespace.path)

        for repository_path in repository_paths:

            # TODO: if we need to distinquish repo from collection or role, we could do it here
            repository_ = repository.load_from_dir(
                galaxy_context.content_path,
                namespace=namespace.namespace,
                name=repository_path,
                installed=True)

            # log.debug('candidate installed repo (pre filter): %s', repository_)

            if repository_match_filter(repository_):
                log.debug('Found repository "%s" in namespace "%s"',
                          repository_path, namespace.namespace)
                yield repository_
Esempio n. 2
0
def repository_spec_iterator(galaxy_context, repository_spec):

    # should only be one match here...
    log.debug('Looking for repos  "%s"', repository_spec)

    #    path_name = os.path.join(galaxy_context.content_path,
    #                             repository_spec.namespace,
    #                             repository_spec.name)

    repository_ = repository.load_from_dir(galaxy_context.content_path,
                                           namespace=repository_spec.namespace,
                                           name=repository_spec.name,
                                           installed=True)

    log.debug('loaded repository_ %s', repository_)
    if not repository_:
        return

    # Verify the repo matches what we asked for.
    # no version specified
    if repository_spec.version is None:
        repository_match_filter = matchers.MatchRepositorySpecNamespaceName(
            [repository_spec])
    else:
        repository_match_filter = matchers.MatchRepositorySpecNamespaceNameVersion(
            [repository_spec])

    if repository_match_filter(repository_):
        log.debug('Found repository "%s" in namespace "%s" at %s',
                  repository_.repository_spec.name,
                  repository_.repository_spec.namespace, repository_.path)
        yield repository_
Esempio n. 3
0
def test_load_from_dir_no_dir():
    res = repository.load_from_dir('/dev/null/doesntexist', 'ns/path',
                                   'some_namespace', 'some_name')

    log.debug('res: %s', res)

    assert res is None, 'load_from_dir() on a dir that does not exist should have returned None'