Skip to main content

Python class for reading and writing data to a GitHub repository

Project description

github-contents

PyPI CircleCI License

Read and write both small and large files to Github.

The regular GitHub Contents API can't handle files larger than 1MB - this class knows how to spot that proble and switch to the large-file-supporting low level Git Data API instead.

Note that file contents is passed and returned as bytestrings, not regular strings.

Usage

You will need a GitHub OAuth token with full repository access.

The easiest way to create one of these is using https://github.com/settings/tokens

# For repo simonw/disaster-data:
github = GithubContents(
    "simonw",
    "disaster-data",
    GITHUB_OAUTH_TOKEN
)

To read a file:

content_in_bytes, sha = github.read(path_within_repo)

To write a file:

content_sha, commit_sha = github.write(
    filepath=path_within_repo,
    content_bytes=contents_in_bytes,
    sha=previous_sha, # Optional
    commit_message=commit_message,
    committer={
        "name": COMMITTER_NAME,
        "email": COMMITTER_EMAIL,
    },
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

github_contents-0.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file github_contents-0.1-py3-none-any.whl.

File metadata

  • Download URL: github_contents-0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.8

File hashes

Hashes for github_contents-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fc1e544bb8a80069fa04269ed4fd1131d2c6a25efdd75c1c5e9db7aaa6d954e1
MD5 c1f6ac9126dfce92de0547b0ca84eadd
BLAKE2b-256 c0cabbec15ae65311cc2bfe3970a7bc1763fe0c913e10a16f47ba02ffc8882bf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page