GitHub - simonw/github-contents: Python class for reading and writing data to a GitHub repository | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

simonw/github-contents

Repository files navigation

github-contents

PyPI Changelog Tests 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 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,
    },
)

About

Python class for reading and writing data to a GitHub repository

Topics

Resources

Stars

Watchers

Forks

Sponsor this project

 

Languages

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.