Skip to content

Instantly share code, notes, and snippets.

@bnikanjam
Created April 27, 2019 04:12
Show Gist options
  • Save bnikanjam/5d6f3c4752dfa3543ebd9bd1c71e4a32 to your computer and use it in GitHub Desktop.
Save bnikanjam/5d6f3c4752dfa3543ebd9bd1c71e4a32 to your computer and use it in GitHub Desktop.
Post input function source code to your Github gist.
def post_gist(func_name, git_token, gist_description=None, public=True):
"""Post input function source code to your Github gist."""
from inspect import getsource
from github import Github, InputFileContent
if not gist_description:
gist_description = func_name.__doc__
me = Github(git_token).get_user()
code = {func_name.__name__ + '.py': InputFileContent(getsource(func_name))}
me.create_gist(public, code, gist_description)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment