Skip to main content

A Python Module to create and access GitHub Gists

Project description

PythonGists is a Python 2/3 module to create, view and access data from GitHub Gists. It uses requests and oauth to function and is based on the GitHub v3 API.

Why PythonGists?

There are numerous Python modules available for the GitHub v3 API but PythonGists is different. For starters, it is aimed only at the Gists part of the GitHub API and not the entire API. And it will never feature non Gists part of the GitHub API.

So you might be thinking that you could have used python3-github or any other module for Gists. Technically, you could but PythonGistss is more specific. In Systems where saving even a tiny amount of space matters (like your VPS), PythonGistss will take less space and do the same (provided you only want GitHub Gists Access).

Note

This module is not to be confused with PyGist which is just a CLI. This is a python module (actually I would have picked up a different name if I knew about that module) ###Installation

Installation is done through PIP:

pip install PythonGists

Usage

You can use PythonGists either by signing into GitHub or anonymously. Note that the syntax for logged in usage and anonymous usage is different. Here are some demos:

Create Gist Anonymously

from PythonGists import PythonGists
link = PythonGists.Gist(description='a sample gist',content='Hey GitHub',name='demo.txt')

print("The link is {0}".format(link))

Create Gist as a logged in user

from PythonGists import PythonGists
gistObject=PythonGists(username='youruser',password='somepass')
print(gistObject.createGist(description='a sample gist',content='Hey GitHub',name='demo.txt'))
'This will print the link'

Create Gist from File Anonymously

from PythonGists import PythonGists
link = PythonGists.GistFromFile(description='a sample gist',file='demo.py')

print("The link is {0}".format(link))

Create Gist from File (logged in)

from PythonGists import PythonGists
gistObject=PythonGists(username='youruser',password='somepass')
print(gistObject.createGistFromFile(description='a sample gist',file='demo.py'))
'This will print the link'

Get User Gists Data (same for both)

Here just replace GitHubGist in the print line with your gistObject for logged in users.

from PythonGists import PythonGists
gistArray = PythonGists.getGistsData('geekpradd')

Note that gistArray will contain objects of the Gist Class which has access to the Gist data. Now, I’ll show you how to access Gist data from the Gist Object.

Get Single Gist Data

```python from PythonGists import Gist gistObj = Gist(’https://gist.github.com/geekpradd/a3e7a590887cf7bbf161’) print (gistObj.getFileContent()) #Will retutn a Dictionary with keys = File names and values = file content

About

This module is created by Pradipta (geekpradd) using the GitHub API and requests.

Project details


Download files

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

Source Distribution

PythonGists-1.1.1.tar.gz (3.8 kB view details)

Uploaded Source

File details

Details for the file PythonGists-1.1.1.tar.gz.

File metadata

  • Download URL: PythonGists-1.1.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PythonGists-1.1.1.tar.gz
Algorithm Hash digest
SHA256 a2e2c95a04f055752effc7fae620bd26f6de46e09bc98c8c30b252c28dc518eb
MD5 50d1a5aabdbafb452e728d90e475fa13
BLAKE2b-256 26d2ded987c6c454523a98ebcf860b6d24ce996cf64039cee38f473af2f08ec0

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