Created
September 26, 2019 08:25
-
-
Save brighteyed/114d1203fc89c4f2a05f7c2726497a66 to your computer and use it in GitHub Desktop.
Backup all gists. Copied from https://jpmens.net/2019/04/03/backup-all-my-gists/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from github import Github # pip install PyGithub | |
import json | |
import os | |
all = [] | |
g = Github(open(os.path.expanduser("~/.gist")).read()) | |
for gist in g.get_user().get_gists(): | |
all.append({ | |
"id" : gist.id, | |
"description" : gist.description, | |
"public" : gist.public, | |
"clone" : gist.git_pull_url, | |
"updated" : gist.updated_at.isoformat(), | |
"url" : gist.url, | |
}) | |
# yuck | |
os.system("git clone '{0}' repos/{1}".format(gist.git_pull_url, gist.id)) | |
with open("index.json", "w") as f: | |
f.write(json.dumps(all, indent=4) + "\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment