Appease pylint, cleanup (#1109)

* Appease pylint, cleanup

* Fix typo
This commit is contained in:
Ross Scroggs
2020-03-02 04:53:36 -08:00
committed by GitHub
parent 8cc401a5bf
commit ee89aa649a
2 changed files with 10 additions and 9 deletions

View File

@@ -22,14 +22,15 @@ def print_json(object_value, spacing=''):
return return
if spacing: if spacing:
sys.stdout.write('\n') sys.stdout.write('\n')
for i in range(0, len(object_value)): for i, a_value in enumerate(object_value):
if isinstance(object_value[i], (str, int, bool)): if isinstance(a_value, (str, int, bool)):
sys.stdout.write(f' {spacing}{i+1}) {a_value}\n') sys.stdout.write(f' {spacing}{i+1}) {a_value}\n')
else: else:
sys.stdout.write(f' {spacing}{i+1}) ') sys.stdout.write(f' {spacing}{i+1}) ')
print_json(object_value[i], f' {spacing}') print_json(a_value, f' {spacing}')
elif isinstance(object_value, dict): elif isinstance(object_value, dict):
[object_value.pop(key, None) for key in ['kind', 'etag', 'etags']] for key in ['kind', 'etag', 'etags']:
object_value.pop(key, None)
for another_object, another_value in object_value.items(): for another_object, another_value in object_value.items():
sys.stdout.write(f' {spacing}{another_object}: ') sys.stdout.write(f' {spacing}{another_object}: ')
print_json(another_value, f' {spacing}') print_json(another_value, f' {spacing}')

View File

@@ -1203,8 +1203,8 @@ def doCheckServiceAccount(users):
# Tack on email scope for more accurate checking # Tack on email scope for more accurate checking
check_scopes.append(USERINFO_EMAIL_SCOPE) check_scopes.append(USERINFO_EMAIL_SCOPE)
long_url = (f'https://admin.google.com/{user_domain}/ManageOauthClients' long_url = (f'https://admin.google.com/{user_domain}/ManageOauthClients'
f'?clientScopeToAdd={",".join(check_scopes)}' f'?clientScopeToAdd={",".join(check_scopes)}'
f'&clientNameToAdd={service_account}') f'&clientNameToAdd={service_account}')
short_url = shorten_url(long_url) short_url = shorten_url(long_url)
scopes_failed = f'''Some scopes failed! To authorize them, please go to: scopes_failed = f'''Some scopes failed! To authorize them, please go to:
@@ -7366,14 +7366,14 @@ def shorten_url(long_url):
'User-Agent': GAM_INFO} 'User-Agent': GAM_INFO}
try: try:
resp, content = simplehttp.request(url_shortnr, 'POST', resp, content = simplehttp.request(url_shortnr, 'POST',
f'{{"long_url": "{long_url}"}}', headers=headers) f'{{"long_url": "{long_url}"}}', headers=headers)
except Exception as e: except Exception:
return long_url return long_url
if resp.status != 200: if resp.status != 200:
return long_url return long_url
try: try:
return json.loads(content).get('short_url', long_url) return json.loads(content).get('short_url', long_url)
except Exception as e: except Exception:
print(content) print(content)
return long_url return long_url