Determine the URL corresponding to Python object on GitHub
    
    This code is derived from the version used by `Numpy
    <https://github.com/numpy/numpy/blob/v1.9.2/doc/source/conf.py#L286>`_.
506175
def linkcode_resolve(domain, info):
    
    # Only link to Python source
    if domain != 'py':
        return None

    # Get a reference to the object in question
    modname = info['module']
    fullname = info['fullname']

    submod = sys.modules.get(modname)
    if submod is None:
        return None

    obj = submod
    for part in fullname.split('.'):
        try:
            obj = getattr(obj, part)
        except:
            return None

    # Find the file which contains the object
    try:
        file_name = inspect.getsourcefile(obj)
    except:
        file_name = None
    if not file_name:
        return None

    # Convert the filename into a path relative to the rig module top-level
    file_name = os.path.relpath(file_name, start=os.path.dirname(local_module_path))

    # Get the line number range that object lives on
    try:
        source, lineno = inspect.getsourcelines(obj)
    except:
        lineno = None
    if lineno:
        linespec = "#L{}-L{}".format(lineno,
                                     lineno + len(source) - 1)
    else:
        linespec = ""
    
    # Generate a link to the code in the official GitHub repository with the
    # current-version's tag.
    return ("https://github.com/{repo}/blob/v{version}/"
            "{module_path}{file_name}{linespec}".format(repo=github_repo,
                                                        version=version,
                                                        module_path=github_module_path,
                                                        file_name=file_name,
                                                        linespec=linespec))
18138
function parseGitHubTrendingRepos(err, body) {
    if (err) { return tubesio.finish(err); }

    // Load the raw HTML into a cheerio object so we can traverse
    // the data using CSS selectors ala jQuery.
    var $ = cheerio.load(body),
        result = {
            title: $('title').text(),
            trending: []
        };

    // Iterate over the trending repositories extracting the names
    // and hyperlinks.
    $('#trending-repositories > ol > li').each(function (i, e) {
        result.trending.push({
            name: us.trim($(e).find('h3').text()),
            href: 'https://github.com' + $(e).find('a').last().attr('href')
        });
    });

    // Return our results object
    tubesio.finish(result); 
}
353649
def print_download_uri(self, version, source):
        

        if version == "dev":
            pkg_type = "subversion"
            source = True
        elif source:
            pkg_type = "source"
        else:
            pkg_type = "egg"

        #Use setuptools monkey-patch to grab url
        url = get_download_uri(self.project_name, version, source,
                self.options.pypi_index)
        if url:
            print("%s" % url)
        else:
            self.logger.info("No download URL found for %s" % pkg_type)
576102
function urlFormat(obj) {
  // ensure it's an object, and not a string url.
  // If it's an obj, this is a no-op.
  // this way, you can call url_format() on strings
  // to clean up potentially wonky urls.
  if (util.isString(obj)) { obj = urlParse(obj); }
  if (!(obj instanceof Url)) { return Url.prototype.format.call(obj); }
  return obj.format();
}
1180445
def _object_contents(obj):
    
    try:
        # Test if obj is a method.
        return _function_contents(obj.__func__)

    except AttributeError:
        try:
            # Test if obj is a callable object.
            return _function_contents(obj.__call__.__func__)

        except AttributeError:
            try:
                # Test if obj is a code object.
                return _code_contents(obj)

            except AttributeError:
                try:
                    # Test if obj is a function object.
                    return _function_contents(obj)

                except AttributeError as ae:
                    # Should be a pickle-able Python object.
                    try:
                        return _object_instance_content(obj)
                        # pickling an Action instance or object doesn't yield a stable
                        # content as instance property may be dumped in different orders
                        # return pickle.dumps(obj, ACTION_SIGNATURE_PICKLE_PROTOCOL)
                    except (pickle.PicklingError, TypeError, AttributeError) as ex:
                        # This is weird, but it seems that nested classes
                        # are unpickable. The Python docs say it should
                        # always be a PicklingError, but some Python
                        # versions seem to return TypeError.  Just do
                        # the best we can.
                        return bytearray(repr(obj), 'utf-8')
946190
function githubRepo (options) {
  try {
    const url = options.data.root.package.repository.url
    const match = url.match(/.*?(:\/\/|@)github\.com[/:](.*?)(#.*?)?$/)
    if (match) {
      return match[2].replace(/\.git$/, '')
    } else {
      return null
    }
  } catch (e) {
    // No repositor-url exists
    return null
  }
}
544870
def _get_repos(url):
        
        current_page = 1
        there_is_something_left = True
        repos_list = []

        while there_is_something_left:
            api_driver = GithubRawApi(
                url,
                url_params={"page": current_page},
                get_api_content_now=True
            )  # driver to parse API content

            for repo in api_driver.api_content:  # list of raw repository
                repo_name = repo["name"]
                repo_user = repo["owner"]["login"]
                repos_list.append(
                    GithubUserRepository(repo_user, repo_name))

            there_is_something_left = bool(api_driver.api_content)
            current_page += 1

        return repos_list
459572
def get_repo_ref(repo: GithubRepository, ref: str) -> Dict[str, Any]:
    

    url = ("https://api.github.com/repos/{}/{}/git/refs/{}"
           "?access_token={}".format(repo.organization,
                                     repo.name,
                                     ref,
                                     repo.access_token))
    response = requests.get(url)
    if response.status_code != 200:
        raise RuntimeError(
            'Refs get failed. Code: {}. Content: {}.'.format(
                response.status_code, response.content))
    payload = json.JSONDecoder().decode(response.content.decode())
    return payload
1002221
def fetch_url(src, dst):
    
    # we do not use the nicer sys.version_info.major
    # for compatibility with Python < 2.7
    if sys.version_info[0] > 2:
        import urllib.request

        class URLopener(urllib.request.FancyURLopener):
            def http_error_default(self, url, fp, errcode, errmsg, headers):
                sys.stderr.write("ERROR: could not fetch {0}\n".format(url))
                sys.exit(-1)
    else:
        import urllib

        class URLopener(urllib.FancyURLopener):
            def http_error_default(self, url, fp, errcode, errmsg, headers):
                sys.stderr.write("ERROR: could not fetch {0}\n".format(url))
                sys.exit(-1)

    dirname = os.path.dirname(dst)
    if dirname != '':
        if not os.path.isdir(dirname):
            os.makedirs(dirname)

    opener = URLopener()
    opener.retrieve(src, dst)
924628
function _rawGithubUrl (resolvedPackageRoot) {
  var { packageJson, relativeFile } = resolvedPackageRoot
  const orgRepo = _githubOrgRepo(packageJson && packageJson.repository && packageJson.repository.url)
  if (orgRepo) {
    return `https://raw.githubusercontent.com/${orgRepo}/v${packageJson.version}/${relativeFile}`
  }
}
1359624
def get_code_object(x):
    """"""
    if hasattr(x, '__func__'): # Method
        x = x.__func__
    if hasattr(x, '__code__'): # Function
        x = x.__code__
    if hasattr(x, 'gi_code'):  # Generator
        x = x.gi_code
    if isinstance(x, str):     # Source code
        x = _try_compile(x, "<disassembly>")
    if hasattr(x, 'co_code'):  # Code object
        return x
    raise TypeError("don't know how to disassemble %s objects" %
                    type(x).__name__)
1184204
def _object_url(self, objtype, objid):
        
        return "{base_url}/api/{api_version}/{controller}/{obj_id}".format(
            base_url=self._base_url(),
            api_version=self.api_version,
            controller=self._controller_name(objtype),
            obj_id=objid
        )
728452
def get_github_content(repo,path,auth=None):
	
	request = requests.get(file_url.format(repo=repo, path=path), auth=auth)
	if not request.ok:
		print("There is a problem with the request")
		print(file_url.format(repo=repo, path=path))
		print(request.json())
		exit(1)
	if not request.json()['encoding'] == 'base64':
		raise RuntimeError("Unknown Encoding encountered when fetching {} from repo {}: {}".format(path,repo,request.json()['encoding']))
	return request.json()['content'].decode('base64').decode('utf8')
1031349
function getURL( repository ) {
    var repourl;

    if (typeof repository === 'object') {
        repourl = repository.url;
    } else {
        repourl = repository
    };

    return repourl;
}
1057643
def extract_from_urllib3():
    
    util.ssl_.SSLContext = orig_util_SSLContext
    util.HAS_SNI = orig_util_HAS_SNI
    util.ssl_.HAS_SNI = orig_util_HAS_SNI
    util.IS_SECURETRANSPORT = False
    util.ssl_.IS_SECURETRANSPORT = False
512599
function fetchRepoREADME (repo) {
  request({
    uri: 'https://api.github.com/repos/' + repo + '/readme',
    headers: _.extend(headers, {

      // Get raw README content
      'Accept': 'application/vnd.github.VERSION.raw'
    })
  },
  function (error, response, body) {
    if (!error && response.statusCode === 200) {
      lintMarkdown(body, repo);
    } else {
      if (response.headers['x-ratelimit-remaining'] === '0') {
        getAuthToken();
      } else {
        console.log('README for https://github.com/' + repo.blue + ' not found.'.red);
        return;
      }
    }
  });
}
949002
def _input_github_repo(url=None):
    
    if url is None:
        url = user_input('Input the URL of the GitHub repository '
                         'to use as a `trytravis` repository: ')
    url = url.strip()
    http_match = _HTTPS_REGEX.match(url)
    ssh_match = _SSH_REGEX.match(url)
    if not http_match and not ssh_match:
        raise RuntimeError('That URL doesn\'t look like a valid '
                           'GitHub URL. We expect something '
                           'of the form: `https://github.com/[USERNAME]/'
                           '[REPOSITORY]` or `ssh://git@github.com/'
                           '[USERNAME]/[REPOSITORY]')

    # Make sure that the user actually made a new repository on GitHub.
    if http_match:
        _, name = http_match.groups()
    else:
        _, name = ssh_match.groups()
    if 'trytravis' not in name:
        raise RuntimeError('You must have `trytravis` in the name of your '
                           'repository. This is a security feature to reduce '
                           'chances of running git push -f on a repository '
                           'you don\'t mean to.')

    # Make sure that the user actually wants to use this repository.
    accept = user_input('Remember that `trytravis` will make commits on your '
                        'behalf to `%s`. Are you sure you wish to use this '
                        'repository? Type `y` or `yes` to accept: ' % url)
    if accept.lower() not in ['y', 'yes']:
        raise RuntimeError('Operation aborted by user.')

    if not os.path.isdir(config_dir):
        os.makedirs(config_dir)
    with open(os.path.join(config_dir, 'repo'), 'w+') as f:
        f.truncate()
        f.write(url)
    print('Repository saved successfully.')