github-contents
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 problem 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.
Installation
pip install github-contents
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
from github_contents import GithubContents
# For repo simonw/disaster-data:
github = GithubContents(
"simonw",
"disaster-data",
token=GITHUB_OAUTH_TOKEN,
branch="main"
)
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,
},
)
Metadata
Release files for github-contents 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| github-contents-0.2.tar.gz | 3.6 kB | Without provenance | Details for github-contents-0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| github_contents-0.2-py3-none-any.whl | Python 3 | none | any | Details for github_contents-0.2-py3-none-any.whl |
Total release size: 7.2 kB
Release files / github-contents-0.2.tar.gz
| Download URL | github-contents-0.2.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8693bca4111bc52f2f8e752619fd06b4a00b22b609a5fb97285d622b7c891086
|
|
BLAKE2b-256 checksum How to use checksums |
673930cec2610e796447fa416f941a8351e0c14ac715f22d17c7f2c63ef3e144
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1
|
Release files / github_contents-0.2-py3-none-any.whl
| Download URL | github_contents-0.2-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
042918b0680ac76764006f99d95784b1c27bcd702eff4a3adecd077009da6660
|
|
BLAKE2b-256 checksum How to use checksums |
b41fa8e06c2ce2f7438d557031eae2fb7f5d9cc02dad726f233d3cc205565b71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1
|
Security for github-contents 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.