FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add option to fetch followers/following JSON data · msgpo/python-github-backup@eca9f0f · GitHub

Commit eca9f0f

Browse files
committed
Add option to fetch followers/following JSON data
1 parent b77ea48 commit eca9f0f

2 files changed

Lines changed: 46 additions & 18 deletions

File tree

‎README.rst‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ Usage
2828
CLI Usage is as follows::
2929

3030
github-backup [-h] [-u USERNAME] [-p PASSWORD] [-t TOKEN]
31-
[-o OUTPUT_DIRECTORY] [-i] [--starred] [--watched]
32-
[--all] [--issues] [--issue-comments] [--issue-events]
33-
[--pulls] [--pull-comments] [--pull-commits] [--labels]
34-
[--hooks] [--milestones] [--repositories] [--bare] [--lfs]
35-
[--wikis] [--skip-existing] [--all-starred]
36-
[--gists] [--starred-gists]
31+
[-o OUTPUT_DIRECTORY] [-i] [--starred] [--all-starred]
32+
[--watched] [--followers] [--following] [--all]
33+
[--issues] [--issue-comments] [--issue-events] [--pulls]
34+
[--pull-comments] [--pull-commits] [--labels] [--hooks]
35+
[--milestones] [--repositories] [--bare] [--lfs]
36+
[--wikis] [--gists] [--starred-gists] [--skip-existing]
3737
[-L [LANGUAGES [LANGUAGES ...]]] [-N NAME_REGEX]
3838
[-H GITHUB_HOST] [-O] [-R REPOSITORY] [-P] [-F]
3939
[--prefer-ssh] [-v]
@@ -54,12 +54,16 @@ CLI Usage is as follows::
5454
password for basic auth. If a username is given but
5555
not a password, the password will be prompted for.
5656
-t TOKEN, --token TOKEN
57-
personal access or OAuth token
57+
personal access or OAuth token, or path to token
58+
(file://...)
5859
-o OUTPUT_DIRECTORY, --output-directory OUTPUT_DIRECTORY
5960
directory at which to backup the repositories
6061
-i, --incremental incremental backup
6162
--starred include JSON output of starred repositories in backup
63+
--all-starred include starred repositories in backup
6264
--watched include watched repositories in backup
65+
--followers include JSON output of followers in backup
66+
--following include JSON output of following users in backup
6367
--all include everything in backup
6468
--issues include issues in backup
6569
--issue-comments include issue comments in backup
@@ -73,12 +77,12 @@ CLI Usage is as follows::
7377
--milestones include milestones in backup
7478
--repositories include repository clone in backup
7579
--bare clone bare repositories
76-
--lfs clone LFS repositories (requires Git LFS to be installed, https://git-lfs.github.com)
80+
--lfs clone LFS repositories (requires Git LFS to be
81+
installed, https://git-lfs.github.com)
7782
--wikis include wiki clone in backup
78-
--skip-existing skip project if a backup directory exists
79-
--all-starred include starred repositories in backup
8083
--gists include gists in backup
8184
--starred-gists include starred gists in backup
85+
--skip-existing skip project if a backup directory exists
8286
-L [LANGUAGES [LANGUAGES ...]], --languages [LANGUAGES [LANGUAGES ...]]
8387
only allow these languages
8488
-N NAME_REGEX, --name-regex NAME_REGEX

‎bin/github-backup‎

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ def parse_args():
168168
action='store_true',
169169
dest='include_watched',
170170
help='include watched repositories in backup')
171+
parser.add_argument('--followers',
172+
action='store_true',
173+
dest='include_followers',
174+
help='include JSON output of followers in backup')
175+
parser.add_argument('--following',
176+
action='store_true',
177+
dest='include_following',
178+
help='include JSON output of following users in backup')
171179
parser.add_argument('--all',
172180
action='store_true',
173181
dest='include_everything',
@@ -886,25 +894,41 @@ def backup_account(args, output_directory):
886894
account_cwd = os.path.join(output_directory, 'account')
887895

888896
if args.include_starred or args.include_everything:
889-
output_file = '{0}/starred.json'.format(account_cwd)
890-
template = "https://{0}/users/{1}/starred"
891-
template = template.format(get_github_api_host(args), args.user)
897+
output_file = "{0}/starred.json".format(account_cwd)
898+
template = "https://{0}/users/{1}/starred".format(get_github_api_host(args), args.user)
892899
_backup_data(args,
893-
'starred repositories',
900+
"starred repositories",
894901
template,
895902
output_file,
896903
account_cwd)
897904

898905
if args.include_watched or args.include_everything:
899-
output_file = '{0}/watched.json'.format(account_cwd)
900-
template = "https://{0}/users/{1}/subscriptions"
901-
template = template.format(get_github_api_host(args), args.user)
906+
output_file = "{0}/watched.json".format(account_cwd)
907+
template = "https://{0}/users/{1}/subscriptions".format(get_github_api_host(args), args.user)
902908
_backup_data(args,
903-
'watched repositories',
909+
"watched repositories",
904910
template,
905911
output_file,
906912
account_cwd)
907913

914+
if args.include_followers or args.include_everything:
915+
output_file = "{0}/followers.json".format(account_cwd)
916+
template = "https://{0}/users/{1}/followers".format(get_github_api_host(args), args.user)
917+
_backup_data(args,
918+
"followers",
919+
template,
920+
output_file,
921+
account_cwd)
922+
923+
if args.include_following or args.include_everything:
924+
output_file = "{0}/following.json".format(account_cwd)
925+
template = "https://{0}/users/{1}/following".format(get_github_api_host(args), args.user)
926+
_backup_data(args,
927+
"following",
928+
template,
929+
output_file,
930+
account_cwd)
931+
908932

909933
def _backup_data(args, name, template, output_file, output_directory):
910934
skip_existing = args.skip_existing

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL