diff --git a/add_to_team_drive.py b/add_to_team_drive.py index ab0df2057dd..2e2d461d41d 100644 --- a/add_to_team_drive.py +++ b/add_to_team_drive.py @@ -66,7 +66,7 @@ drive = googleapiclient.discovery.build("drive", "v3", credentials=creds) batch = drive.new_batch_http_request() -aa = glob.glob('%s/*.json' % acc_dir) +aa = glob.glob(f'{acc_dir}/*.json') pbar = progress.bar.Bar("Readying accounts", max=len(aa)) for i in aa: ce = json.loads(open(i, 'r').read())['client_email'] diff --git a/bot/helper/ext_utils/bot_utils.py b/bot/helper/ext_utils/bot_utils.py index cab240d630a..952b4a9d754 100644 --- a/bot/helper/ext_utils/bot_utils.py +++ b/bot/helper/ext_utils/bot_utils.py @@ -38,12 +38,12 @@ def create_help_buttons(): buttons = ButtonMaker() for name in list(MIRROR_HELP_DICT.keys())[1:]: buttons.ibutton(name, f"help m {name}") - buttons.ibutton("Close", f"help close") + buttons.ibutton("Close", "help close") COMMAND_USAGE["mirror"] = [MIRROR_HELP_DICT["main"], buttons.build_menu(3)] buttons.reset() for name in list(YT_HELP_DICT.keys())[1:]: buttons.ibutton(name, f"help yt {name}") - buttons.ibutton("Close", f"help close") + buttons.ibutton("Close", "help close") COMMAND_USAGE["yt"] = [YT_HELP_DICT["main"], buttons.build_menu(3)] diff --git a/bot/helper/listeners/jdownloader_listener.py b/bot/helper/listeners/jdownloader_listener.py index c63ab62cb9b..73a1d097a27 100644 --- a/bot/helper/listeners/jdownloader_listener.py +++ b/bot/helper/listeners/jdownloader_listener.py @@ -41,16 +41,10 @@ async def _jd_listener(): ) except: continue - finished = [] - for pack in packages: - if pack.get("finished", False): - finished.append(pack["uuid"]) + finished = [pack["uuid"] for pack in packages if pack.get("finished", False)] for gid in finished: if gid in jd_downloads and jd_downloads[gid]["status"] != "done": - is_finished = True - for did in jd_downloads[gid]["ids"]: - if did not in finished: - is_finished = False + is_finished = all(did in finished for did in jd_downloads[gid]["ids"]) if is_finished: jd_downloads[gid]["status"] = "done" _onDownloadComplete(gid) diff --git a/bot/modules/help.py b/bot/modules/help.py index 8dfe202fcd8..e76280e49a4 100644 --- a/bot/modules/help.py +++ b/bot/modules/help.py @@ -27,7 +27,7 @@ async def argUsage(_, query): await editMessage(message, MIRROR_HELP_DICT[data[2]], button) elif data[1] == "yt": buttons = ButtonMaker() - buttons.ibutton("Back", f"help back y") + buttons.ibutton("Back", "help back y") button = buttons.build_menu() await editMessage(message, YT_HELP_DICT[data[2]], button) diff --git a/gen_sa_accounts.py b/gen_sa_accounts.py index a93bd828561..81d4d869356 100644 --- a/gen_sa_accounts.py +++ b/gen_sa_accounts.py @@ -25,15 +25,23 @@ def _create_accounts(service, project, count): batch = service.new_batch_http_request(callback=_def_batch_resp) for _ in range(count): aid = _generate_id('mfc-') - batch.add(service.projects().serviceAccounts().create(name='projects/' + project, body={'accountId': aid, - 'serviceAccount': { - 'displayName': aid}})) + batch.add( + service.projects() + .serviceAccounts() + .create( + name=f'projects/{project}', + body={ + 'accountId': aid, + 'serviceAccount': {'displayName': aid}, + }, + ) + ) batch.execute() # Create accounts needed to fill project def _create_remaining_accounts(iam, project): - print('Creating accounts in %s' % project) + print(f'Creating accounts in {project}') sa_count = len(_list_sas(iam, project)) while sa_count != 100: _create_accounts(iam, project, 100 - sa_count) @@ -57,14 +65,14 @@ def _def_batch_resp(id, resp, exception): if str(exception).startswith(' 0: current_count = len(_get_projects(cloud)) if current_count + create_projects <= max_projects: @@ -237,7 +252,7 @@ def serviceaccountfactory( ste = selected_projects elif enable_services == '*': ste = _get_projects(cloud) - services = [i + '.googleapis.com' for i in services] + services = [f'{i}.googleapis.com' for i in services] print('Enabling services') _enable_services(serviceusage, ste, services) if create_sas: @@ -268,7 +283,7 @@ def serviceaccountfactory( elif delete_sas == '*': std = _get_projects(cloud) for i in std: - print('Deleting service accounts in %s' % i) + print(f'Deleting service accounts in {i}') _delete_sas(iam, i) @@ -310,7 +325,7 @@ def serviceaccountfactory( print('No credentials found at %s. Please enable the Drive API in:\n' 'https://developers.google.com/drive/api/v3/quickstart/python\n' 'and save the json file as credentials.json' % args.credentials) - if len(options) < 1: + if not options: exit(-1) else: print('Select a credentials file below.') @@ -324,8 +339,9 @@ def serviceaccountfactory( if inp in inp_options: break args.credentials = inp if inp in options else options[int(inp) - 1] - print('Use --credentials %s next time to use this credentials file.' % - args.credentials) + print( + f'Use --credentials {args.credentials} next time to use this credentials file.' + ) if args.quick_setup: opt = '~' if args.new_only else '*' args.services = ['iam', 'drive'] @@ -352,7 +368,7 @@ def serviceaccountfactory( if resp: print('Projects (%d):' % len(resp)) for i in resp: - print(' ' + i) + print(f' {i}') else: print('No projects.') elif args.list_sas: @@ -360,6 +376,6 @@ def serviceaccountfactory( print('Service accounts in %s (%d):' % (args.list_sas, len(resp))) for i in resp: - print(' %s (%s)' % (i['email'], i['uniqueId'])) + print(f" {i['email']} ({i['uniqueId']})") else: print('No service accounts.')