class documentation

class GitHubRepository(object): (source)

Constructor: GitHubRepository(repo, safe)

View In Hierarchy

Class for interacting with a GitHub repository.

Note

To interact with private GitHub repositories that you have access to, provide your GitHub personal access token by setting the GITHUB_TOKEN environment variable.

Parameters
repo

the GitHub repository or identifier, which can be:

  • a GitHub repo URL like https://github.com/<user>/<repo>
  • a GitHub ref like https://github.com/<user>/<repo>/tree/<branch> or https://github.com/<user>/<repo>/commit/<commit>
  • a GitHub ref string like <user>/<repo>[/<ref>]
safewhether to allow repo to contain a tree path like https://github.com/<user>/<repo>/tree/<branch>/<path>. If safe=True and a <path> is found, it is extracted and stored in the safe_path property
Static Method parse_identifier Undocumented
Static Method parse_url Undocumented
Method __init__ Undocumented
Method download Downloads the repository to the specified root directory.
Method get_file Downloads the file at the given path.
Method get_repo_info Returns a dict of info about the repository.
Method list_path_contents Returns the contents of the repo rooted at the given path.
Method list_repo_contents Returns a flat list of the repository's contents.
Property identifier The repository identifier string.
Property ref The ref (e.g. branch, tag, commit hash), if any.
Property repo The name of the repo.
Property safe_path The path that was extracted from the provided ref, if any.
Property user The username of the repo.
Method _get Undocumented
Method _get_session Undocumented
Method _get_token Undocumented
Method _handle_safe_path Undocumented
Method _make_session Undocumented
Instance Variable _ref Undocumented
Instance Variable _repo Undocumented
Instance Variable _safe_path Undocumented
Instance Variable _session Undocumented
Instance Variable _user Undocumented
@staticmethod
def parse_identifier(identifier): (source)

Undocumented

@staticmethod
def parse_url(url): (source)

Undocumented

def __init__(self, repo, safe=False): (source)

Undocumented

def download(self, outdir): (source)

Downloads the repository to the specified root directory.

Parameters
outdirthe output directory
def get_file(self, path, outpath=None): (source)

Downloads the file at the given path.

Parameters
paththe filepath in the repository
outpath:Nonea path on disk to write the file
Returns
the file bytes, if no outpath is provided
def get_repo_info(self): (source)

Returns a dict of info about the repository.

Returns
an info dict
def list_path_contents(self, path=None): (source)

Returns the contents of the repo rooted at the given path.

Note

This method has a limit of 1,000 files. Documentation.

Parameters
path:Nonean optional root path to start the search from
Returns
a list of file info dicts
def list_repo_contents(self, recursive=True): (source)

Returns a flat list of the repository's contents.

Note

This method has a limit of 100,000 entries and 7MB response size. Documentation.

Parameters
recursive:Truewhether to recursively traverse subdirectories
Returns
a list of file info dicts

The repository identifier string.

The ref (e.g. branch, tag, commit hash), if any.

The name of the repo.

The path that was extracted from the provided ref, if any.

The username of the repo.

def _get(self, url, json=True): (source)

Undocumented

def _get_session(self): (source)

Undocumented

def _get_token(self): (source)

Undocumented

def _handle_safe_path(self): (source)

Undocumented

def _make_session(self): (source)

Undocumented

Undocumented

Undocumented

_safe_path = (source)

Undocumented

_session = (source)

Undocumented

Undocumented