Find all external files in this repo and import them
548061
public function convert_references_to_local() {
        $fs = get_file_storage();
        $files = $fs->get_external_files($this->id);
        foreach ($files as $storedfile) {
            $fs->import_external_file($storedfile);
        }
    }
241470
def check_for_local_repos(repo):
    
    repos_dict = Repo().default_repository()
    if repo in repos_dict:
        repo_url = repos_dict[repo]
        if repo_url.startswith("file:///"):
            return True
989027
def check_exists_repositories(repo):
    
    pkg_list = "PACKAGES.TXT"
    if repo == "sbo":
        pkg_list = "SLACKBUILDS.TXT"
    if check_for_local_repos(repo) is True:
        pkg_list = "PACKAGES.TXT"
        return ""
    if not os.path.isfile("{0}{1}{2}".format(
            _meta_.lib_path, repo, "_repo/{0}".format(pkg_list))):
        return repo
    return ""
306408
def listdir_find_repos(where):
    
    stack = deque([(convert_path(where), '')])
    while stack:
        where, prefix = stack.pop()
        try:
            for name in sorted(os.listdir(where), reverse=True):
                fn = os.path.join(where, name)
                if name in REPO_PREFIXES:
                    if 1:  # os.path.exists(fn):
                        # yield name[1:], fn.rstrip(name)[:-1] # abspath
                        repo = REPO_PREFIXES[name](fn.rstrip(name)[:-1])
                        yield repo
                    stack.append((fn, prefix + name + '/'))
        except OSError as e:
            if e.errno == errno.EACCES:
                log.error("Skipping: %s", e)
            else:
                raise
419108
def list(self, path=None, with_metadata=False, include_partitions=False):
        ''''''
        from os import walk
        import json

        l = {}

        if not path:
            start_path = self.cache_dir
        else:
            start_path = os.path.join(self.cache_dir, path)

        for root, dirs, files in os.walk(start_path):

            root = root.replace(self.cache_dir, '', 1).strip('/')

            if root.startswith('meta') or root.startswith('_'):
                continue

            if not include_partitions and root.count('/') > 0:
                continue  # partition files

            for f in files:
                rel_path = os.path.join(root, f)
                d = self.metadata(rel_path) if with_metadata else {}

                if d and 'identity' in d:
                    d['identity'] = json.loads(d['identity'])

                d['caches'] = [self.repo_id]

                l[rel_path] = d

        if self.upstream:
            for k, v in self.upstream.list(path, with_metadata, include_partitions).items():
                upstreams = (l[k]['caches'] if k in l else []) + \
                    v.get('caches', self.upstream.repo_id)

                l[k] = v
                l[k]['caches'] = upstreams

        return l
1117322
def get_repo(self, cached=True):
        """"""
        module = sys.modules[self.__module__]
        # We use module.__file__ instead of module.__path__[0]
        # to include modules without a __path__ attribute.
        if hasattr(self.__class__, '_repo') and cached:
            repo = self.__class__._repo
        elif hasattr(module, '__file__'):
            path = os.path.realpath(module.__file__)
            try:
                repo = git.Repo(path, search_parent_directories=True)
            except InvalidGitRepositoryError:
                repo = None
        else:
            repo = None
        self.__class__._repo = repo
        return repo
48398
def repo_data(PACKAGES_TXT, repo, flag):
    
    (name, location, size, unsize,
     rname, rlocation, rsize, runsize) = ([] for i in range(8))
    for line in PACKAGES_TXT.splitlines():
        if _meta_.rsl_deps in ["on", "ON"] and "--resolve-off" not in flag:
            status(0.000005)
        if line.startswith("PACKAGE NAME:"):
            name.append(line[15:].strip())
        if line.startswith("PACKAGE LOCATION:"):
            location.append(line[21:].strip())
        if line.startswith("PACKAGE SIZE (compressed):"):
            size.append(line[28:-2].strip())
        if line.startswith("PACKAGE SIZE (uncompressed):"):
            unsize.append(line[30:-2].strip())
    if repo == "rlw":
        (rname,
         rlocation,
         rsize,
         runsize
         ) = rlw_filter(name, location, size, unsize)
    elif repo == "alien":
        (rname,
         rlocation,
         rsize,
         runsize
         ) = alien_filter(name, location, size, unsize)
    elif repo == "rested":
        (rname,
         rlocation,
         rsize,
         runsize
         ) = rested_filter(name, location, size, unsize)
    elif repo == "ktown":
        (rname,
         rlocation,
         rsize,
         runsize
         ) = ktown_filter(name, location, size, unsize)
    else:
        rname, rlocation, rsize, runsize = name, location, size, unsize
    return [rname, rlocation, rsize, runsize]
873106
def _traverse_repos(self, callback, repo_name=None):
        '''
        
        '''
        repo_files = []
        if os.path.exists(self.opts['spm_repos_config']):
            repo_files.append(self.opts['spm_repos_config'])

        for (dirpath, dirnames, filenames) in salt.utils.path.os_walk('{0}.d'.format(self.opts['spm_repos_config'])):
            for repo_file in filenames:
                if not repo_file.endswith('.repo'):
                    continue
                repo_files.append(repo_file)

        for repo_file in repo_files:
            repo_path = '{0}.d/{1}'.format(self.opts['spm_repos_config'], repo_file)
            with salt.utils.files.fopen(repo_path) as rph:
                repo_data = salt.utils.yaml.safe_load(rph)
                for repo in repo_data:
                    if repo_data[repo].get('enabled', True) is False:
                        continue
                    if repo_name is not None and repo != repo_name:
                        continue
                    callback(repo, repo_data[repo])
1080709
def load_repo_addons(_globals):
    '''
    '''
    repos_dir = os.path.expanduser('~/.fabsetup-addon-repos')
    if os.path.isdir(repos_dir):
        basedir, repos, _ = next(os.walk(repos_dir))
        for repo_dir in [os.path.join(basedir, repo)
                         for repo in repos
                         # omit dot dirs like '.rope'
                         # or 'fabsetup-theno-termdown.disabled'
                         if '.' not in repo]:
            sys.path.append(repo_dir)
            package_name, username = package_username(repo_dir.split('/')[-1])
            load_addon(username, package_name, _globals)
559317
def repositories(self):
        
        if self.repo == "sbo":
            self.sbo_case_insensitive()
            self.find_pkg = sbo_search_pkg(self.name)
            if self.find_pkg:
                self.dependencies_list = Requires(self.flag).sbo(self.name)
        else:
            PACKAGES_TXT = Utils().read_file(
                self.meta.lib_path + "{0}_repo/PACKAGES.TXT".format(self.repo))
            self.names = Utils().package_name(PACKAGES_TXT)
            self.bin_case_insensitive()
            self.find_pkg = search_pkg(self.name, self.repo)
            if self.find_pkg:
                self.black = BlackList().packages(self.names, self.repo)
                self.dependencies_list = Dependencies(
                    self.repo, self.black).binary(self.name, self.flag)
128329
def import_path(self):
    """"""
    return os.path.join(self.remote_root, self.pkg) if self.pkg else self.remote_root
488995
def get_package_sources(self):
        """"""
        # Checkout local modules
        for config in self.sources.get('local', []):
            self.fetch_local_package(config=config)
        # Checkout S3 repositories specified in config
        for config in self.sources.get('s3', []):
            self.fetch_s3_package(config=config)
        # Checkout git repositories specified in config
        for config in self.sources.get('git', []):
            self.fetch_git_package(config=config)
749449
def get_repos(path):
    
    p = str(path)
    ret = []
    if not os.path.exists(p):
        return ret
    for d in os.listdir(p):
        pd = os.path.join(p, d)
        if os.path.exists(pd) and is_repo(pd):
            ret.append(Local(pd))
    return ret
1014884
def import_repo(self, from_file, noop=False, query='/repositories/'):
        
        try:
            repo_defs = juicer.utils.ValidateRepoDef.validate_document(from_file)
        except JuicerRepoDefError, e:
            juicer.utils.Log.log_error("Could not load repo defs from %s:" % from_file)
            raise e
        else:
            juicer.utils.Log.log_debug("Loaded and validated repo defs from %s" % from_file)

        # All our known envs, for cases where no value is supplied for 'env'
        all_envs = juicer.utils.get_environments()

        # Repos to create/update, sorted by environment.
        repo_objects_create = []
        repo_objects_update = {}
        for env in all_envs:
            repo_objects_update[env] = []

        # All repo defs as Repo objects
        all_repos = [JuicerRepo(repo['name'], repo_def=repo) for repo in repo_defs]

        # Detailed information on all existing repos
        existing_repos = {}
        repo_pool = ThreadPool()

        # Parallelize getting the repo lists
        env_results = [repo_pool.apply_async(self.list_repos, tuple(), kwds={'envs': [er]}, callback=existing_repos.update) for er in all_envs]
        repo_pool.close()

        for result_async in env_results:
            result_async.wait()

        repo_pool.join()

        for repo in all_repos:
            # 'env' is all environments if: 'env' is not defined; 'env' is an empty list
            current_env = repo.get('env', [])
            if current_env == []:
                juicer.utils.Log.log_debug("Setting 'env' to all_envs for repo: %s" % repo['name'])
                repo['env'] = all_envs

        #  Assemble a set of all specified environments.
        defined_envs = juicer.utils.unique_repo_def_envs(all_repos)
        juicer.utils.Log.log_notice("Discovered environments: %s" % ", ".join(list(defined_envs)))

        widgets = [
            "Importing: ",
            progressbar.Percentage(),
            " ",
            "(",
            progressbar.SimpleProgress(),
            ") ",
            progressbar.ETA()
        ]
        progress_bar = JuiceBar(len(all_repos), widgets)
        repos_processed = juicer.admin.ThreaddedQuery.LookupObject()
        repos_processed.processed = 0
        # sort out new vs. existing
        # Break these into batches we can process at once
        for chunks in juicer.utils.chunks(all_repos, multiprocessing.cpu_count() - 1):
            crud_pool = ThreadPool()
            crud_args = (all_repos, all_envs, existing_repos, self, repo_objects_create, repo_objects_update, repos_processed, progress_bar)
            calculate_results = [crud_pool.apply_async(juicer.admin.ThreaddedQuery.calculate_create_and_update,
                                                       crud_args,
                                                       kwds={'repo': repo},
                                                       callback=juicer.admin.ThreaddedQuery.crud_progress_updater)
                                 for repo in chunks]
            crud_pool.close()
            to_process = len(calculate_results)
            juicer.utils.Log.log_debug("And we started the pool; items: %s" % len(calculate_results))
            while to_process > 0:
                for thingy in calculate_results:
                    thingy.wait(0.5)
                    if thingy.ready():
                        to_process -= 1
            crud_pool.join()

        juicer.utils.Log.log_debug("And we joined all threads")
        """repo_objects_update looks like this:

        {'environment': [repo_update_spec, ...]}

        repo_update_spec :: [env, repo_diff_spec, pulp_repo]

        env :: environment to apply diff to

        repo_diff_spec :: {
            'distributor': {'distributor_config': {PARAMETERS_TO_UPDATE: VALUES}},
            'importer': {'importer_config': {PARAMETERS_TO_UPDATE: VALUES}
            }
        }

        pulp_repo :: Json serialization of a repo as returned from pulp (or juicer-admin repo show --json)
        """
        return (repo_objects_create, repo_objects_update)
1265588
public function findAll()
    {
        $repos = array();
        foreach ($this->repository->findAll() as $repo) {
            $this->loadPackagistInfos($repo);
            $repos[] = $repo;
        }

        return $repos;
    }
289575
def get_versioned_files(cls):
        """"""
        files = cls._git_ls_files()
        submodules = cls._list_submodules()
        for subdir in submodules:
            subdir = os.path.relpath(subdir).replace(os.path.sep, '/')
            files += add_prefix_to_each(subdir, cls._git_ls_files(subdir))
        return add_directories(files)
897976
def find_external_files(self, run_input_dir):
        
        beam_file, geo_file, mat_file, _ = self.input_files

        # check for external files in BEAM input file
        external_beam_files = self._parse_beam_file(beam_file, run_input_dir)
        if external_beam_files:
            logger.info("External files from BEAM file: {0}".format(external_beam_files))
        else:
            logger.debug("No external files from BEAM file")

        # check for external files in MAT input file
        icru_numbers = self._parse_mat_file(mat_file)
        if icru_numbers:
            logger.info("External files from MAT file: {0}".format(icru_numbers))
        else:
            logger.debug("No external files from MAT file")
        # if ICRU+LOADEX pairs were found - get file names for external material files
        icru_files = []
        if icru_numbers:
            icru_files = self._decrypt_icru_files(icru_numbers)

        # check for external files in GEO input file
        geo_files = self._parse_geo_file(geo_file, run_input_dir)
        if geo_files:
            logger.info("External files from GEO file: {0}".format(geo_files))
        else:
            logger.debug("No external files from GEO file")

        external_files = external_beam_files + icru_files + geo_files
        return [os.path.join(self.input_path, e) for e in external_files]