Skip to content

Commit a9d35c0

Browse files
committed
Ran black.
1 parent 20f5fd7 commit a9d35c0

1 file changed

Lines changed: 36 additions & 15 deletions

File tree

github_backup/github_backup.py

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ def parse_args(args=None):
127127
"-t",
128128
"--token",
129129
dest="token_classic",
130-
help="personal access, OAuth, or JSON Web token, or path to token (file://...)"
130+
help="personal access, OAuth, or JSON Web token, or path to token (file://...)",
131131
) # noqa
132132
parser.add_argument(
133133
"-f",
134-
'--token-fine',
134+
"--token-fine",
135135
dest="token_fine",
136-
help="fine-grained personal access token (github_pat_....), or path to token (file://...)"
136+
help="fine-grained personal access token (github_pat_....), or path to token (file://...)",
137137
) # noqa
138138
parser.add_argument(
139139
"--as-app",
@@ -436,22 +436,28 @@ def get_auth(args, encode=True, for_git_cli=False):
436436
elif args.osx_keychain_item_account:
437437
raise Exception(
438438
"You must specify both name and account fields for osx keychain password items"
439-
)
439+
)
440440
elif args.token_fine:
441441
_path_specifier = "file://"
442442
if args.token_fine.startswith(_path_specifier):
443-
args.token_fine = open(args.token_fine[len(_path_specifier):],
444-
"rt").readline().strip()
443+
args.token_fine = (
444+
open(args.token_fine[len(_path_specifier) :], "rt").readline().strip()
445+
)
445446

446447
if args.token_fine.startswith("github_pat_"):
447448
auth = args.token_fine
448449
else:
449-
raise Exception("Fine-grained token supplied does not look like a GitHub PAT")
450+
raise Exception(
451+
"Fine-grained token supplied does not look like a GitHub PAT"
452+
)
450453
elif args.token_classic:
451454
_path_specifier = "file://"
452455
if args.token_classic.startswith(_path_specifier):
453-
args.token_classic = open(args.token_classic[len(_path_specifier):],
454-
"rt").readline().strip()
456+
args.token_classic = (
457+
open(args.token_classic[len(_path_specifier) :], "rt")
458+
.readline()
459+
.strip()
460+
)
455461

456462
if not args.as_app:
457463
auth = args.token_classic + ":" + "x-oauth-basic"
@@ -518,7 +524,7 @@ def get_github_repo_url(args, repository):
518524
return repository["ssh_url"]
519525

520526
auth = get_auth(args, encode=False, for_git_cli=True)
521-
if auth:
527+
if auth:
522528
if args.token_fine is None:
523529
repo_url = "https://{0}@{1}/{2}/{3}.git".format(
524530
auth,
@@ -528,7 +534,7 @@ def get_github_repo_url(args, repository):
528534
)
529535
else:
530536
repo_url = "https://{0}@{1}/{2}/{3}.git".format(
531-
"oauth2:"+auth,
537+
"oauth2:" + auth,
532538
get_github_host(args),
533539
repository["owner"]["login"],
534540
repository["name"],
@@ -548,7 +554,13 @@ def retrieve_data_gen(args, template, query_args=None, single_request=False):
548554
while True:
549555
page = page + 1
550556
request = _construct_request(
551-
per_page, page, query_args, template, auth, as_app=args.as_app, fine=True if args.token_fine is not None else False
557+
per_page,
558+
page,
559+
query_args,
560+
template,
561+
auth,
562+
as_app=args.as_app,
563+
fine=True if args.token_fine is not None else False,
552564
) # noqa
553565
r, errors = _get_response(request, auth, template)
554566

@@ -584,7 +596,13 @@ def retrieve_data_gen(args, template, query_args=None, single_request=False):
584596
retries += 1
585597
time.sleep(5)
586598
request = _construct_request(
587-
per_page, page, query_args, template, auth, as_app=args.as_app, fine=True if args.token_fine is not None else False
599+
per_page,
600+
page,
601+
query_args,
602+
template,
603+
auth,
604+
as_app=args.as_app,
605+
fine=True if args.token_fine is not None else False,
588606
) # noqa
589607
r, errors = _get_response(request, auth, template)
590608

@@ -668,10 +686,13 @@ def _get_response(request, auth, template):
668686
return r, errors
669687

670688

671-
def _construct_request(per_page, page, query_args, template, auth, as_app=None, fine=False):
689+
def _construct_request(
690+
per_page, page, query_args, template, auth, as_app=None, fine=False
691+
):
672692
querystring = urlencode(
673693
dict(
674-
list({"per_page": per_page, "page": page}.items()) + list(query_args.items())
694+
list({"per_page": per_page, "page": page}.items())
695+
+ list(query_args.items())
675696
)
676697
)
677698

0 commit comments

Comments
 (0)