Return dictionary with repo name and url (used external)
179857
def custom_repository(self):
        
        custom_dict_repo = {}
        for line in self.custom_repositories_list.splitlines():
            line = line.lstrip()
            if not line.startswith("#"):
                custom_dict_repo[line.split()[0]] = line.split()[1]
        return custom_dict_repo
775915
def as_dict(self, absolute=False):
        
        return {
            'name': self.absolute_name() if absolute else self.name,
            'path': self.path,
            'dependencies': [{
                # 'source': d.source.absolute_name(),  # redundant
                'target': d.target if d.external else d.target.absolute_name(),
                'lineno': d.lineno,
                'what': d.what,
                'external': d.external
            } for d in self.dependencies]
        }
1350819
def from_url(cls, path):
        
        if os.path.isfile(path):
            with open(path) as fd:
                data = fd.read()
        else:
            try:
                response = urllib.urlopen(path)
                if response.code >= 300:
                    raise RuntimeError('Unable to load repo from %s' % path)

                data = response.read()
                response.close()
            except IOError:
                raise RuntimeError(
                    'Unable to load repo from %s (IO error)' % path
                )

        return cls(json.loads(data), path)
1235004
def _load_github_repo():
    
    if 'TRAVIS' in os.environ:
        raise RuntimeError('Detected that we are running in Travis. '
                           'Stopping to prevent infinite loops.')
    try:
        with open(os.path.join(config_dir, 'repo'), 'r') as f:
            return f.read()
    except (OSError, IOError):
        raise RuntimeError('Could not find your repository. '
                           'Have you ran `trytravis --repo`?')
858272
def _get_repo_details(saltenv):
    '''
    
    '''
    contextkey = 'winrepo._get_repo_details.{0}'.format(saltenv)

    if contextkey in __context__:
        (winrepo_source_dir, local_dest, winrepo_file) = __context__[contextkey]
    else:
        winrepo_source_dir = __opts__['winrepo_source_dir']
        dirs = [__opts__['cachedir'], 'files', saltenv]
        url_parts = _urlparse(winrepo_source_dir)
        dirs.append(url_parts.netloc)
        dirs.extend(url_parts.path.strip('/').split('/'))
        local_dest = os.sep.join(dirs)

        winrepo_file = os.path.join(local_dest, 'winrepo.p')  # Default
        # Check for a valid windows file name
        if not re.search(r'[\/:*?"<>|]',
                         __opts__['winrepo_cachefile'],
                         flags=re.IGNORECASE):
            winrepo_file = os.path.join(
                local_dest,
                __opts__['winrepo_cachefile']
                )
        else:
            log.error(
                'minion configuration option \'winrepo_cachefile\' has been '
                'ignored as its value (%s) is invalid. Please ensure this '
                'option is set to a valid filename.',
                __opts__['winrepo_cachefile']
            )

        # Do some safety checks on the repo_path as its contents can be removed,
        # this includes check for bad coding
        system_root = os.environ.get('SystemRoot', r'C:\Windows')
        if not salt.utils.path.safe_path(
                path=local_dest,
                allow_path='\\'.join([system_root, 'TEMP'])):

            raise CommandExecutionError(
                'Attempting to delete files from a possibly unsafe location: '
                '{0}'.format(local_dest)
            )

        __context__[contextkey] = (winrepo_source_dir, local_dest, winrepo_file)

    try:
        os.makedirs(local_dest)
    except OSError as exc:
        if exc.errno != errno.EEXIST:
            raise CommandExecutionError(
                'Failed to create {0}: {1}'.format(local_dest, exc)
            )

    winrepo_age = -1
    try:
        stat_result = os.stat(winrepo_file)
        mtime = stat_result.st_mtime
        winrepo_age = time.time() - mtime
    except OSError as exc:
        if exc.errno != errno.ENOENT:
            raise CommandExecutionError(
                'Failed to get age of {0}: {1}'.format(winrepo_file, exc)
            )
    except AttributeError:
        # Shouldn't happen but log if it does
        log.warning('st_mtime missing from stat result %s', stat_result)
    except TypeError:
        # Shouldn't happen but log if it does
        log.warning('mtime of %s (%s) is an invalid type', winrepo_file, mtime)

    repo_details = collections.namedtuple(
        'RepoDetails',
        ('winrepo_source_dir', 'local_dest', 'winrepo_file', 'winrepo_age')
    )
    return repo_details(winrepo_source_dir, local_dest, winrepo_file, winrepo_age)
708219
def get_repo(self, name):
        
        assert isinstance(name, (str, unicode)), name
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            "/repos/" + self.login + "/" + name
        )
        return github.Repository.Repository(self._requester, headers, data, completed=True)
266980
def repository(namespace, name, branch='master'):
    ''''''
    with TemporaryDirectory() as download_path:
        old_directory = str(pwd()).strip()
        try:
            git.clone('https://github.com/{0}/{1}.git'.format(namespace, name), download_path)
            cd(download_path)
            git.fetch('origin', branch)
            git.checkout(branch)
            yield (download_path, git('rev-parse', 'HEAD'), redis.Dict(key="{0}.{1}".format(namespace, name)))
        except ErrorReturnCode_128:
            mkdir(download_path)
            yield (None, None, None)
        cd(old_directory)
117872
def git_repo():
    
    try:
        reldir = subprocess.check_output(
            ["git", "rev-parse", "--git-dir"])
        reldir = reldir.decode("utf-8")
        return os.path.basename(os.path.dirname(os.path.abspath(reldir)))
    except subprocess.CalledProcessError:
        return None
888180
def url_for(self, operation, _external=True, **kwargs):
        
        return url_for(self.endpoint_for(operation), _external=_external, **kwargs)
278404
function getUrl(repo, clone) {
	let url;

	if (repo.type === 'github') {
		url = github(repo, clone);
	} else if (repo.type === 'gitlab') {
		url = gitlab(repo, clone);
	} else if (repo.type === 'bitbucket') {
		url = bitbucket(repo, clone);
	} else if (repo.type === 'oschina') {
		url = oschina(repo, clone);
	} else {
		url = github(repo, clone);
	}

	return url;
}
628500
def get_configuration_dict(self, secret_attrs=False):
        """"""
        rd = {'name': self.name,
              'path': self.path,
              'git_dir': self.git_dir,
              'assumed_doc_version': self.assumed_doc_version,
              'doc_dir': self.doc_dir,
              'git_ssh': self.git_ssh, }
        if secret_attrs:
            rd['pkey'] = self.pkey
        with self._index_lock:
            si = self._doc_index
        r = _invert_dict_list_val(si)
        key_list = list(r.keys())
        rd['number of documents'] = len(key_list)
        key_list.sort()
        m = []
        for k in key_list:
            v = r[k]
            fp = k[2]
            assert fp.startswith(self.doc_dir)
            rp = fp[len(self.doc_dir) + 1:]
            m.append({'keys': v, 'relpath': rp})
        rd['documents'] = m
        return rd
1215945
def repository(self, owner, repository):
        
        json = None
        if owner and repository:
            url = self._build_url('repos', owner, repository)
            json = self._json(self._get(url), 200)
        return Repository(json, self) if json else None
378828
def get_repos(self):
        
        return github.PaginatedList.PaginatedList(
            github.Repository.Repository,
            self._requester,
            self.url + "/repos",
            None
        )
910189
def repo_name(self):
        

        ds = [[x.repo_name] for x in self.repos]
        df = pd.DataFrame(ds, columns=['repository'])
        return df
804880
def get_commit_url(repo_url):
    """"""
    if "github.com" in repo_url:
        return repo_url[:-4] if repo_url.endswith(".git") else repo_url
    if "git.openstack.org" in repo_url:
        uri = '/'.join(repo_url.split('/')[-2:])
        return "https://github.com/{0}".format(uri)

    # If it didn't match these conditions, just return it.
    return repo_url
1057097
def to_package(self, repo_url):
        """"""
        return Package(name=self.name, url=repo_url + self.name)
53232
def to_juicer_repo(self):
        """"""
        repo_def = {}
        defaults = juicer.common.Constants.REPO_DEF_DEFAULTS
        repo_def['name'] = self['name']
        for key in juicer.common.Constants.REPO_DEF_OPT_KEYS:
            repo_def[key] = self.spec.get(key, defaults[key])
            juicer.utils.Log.log_debug("Defined %s as %s" % (key, str(self[key])))
        return JuicerRepo(None, repo_def=repo_def)