From f15d6630fa06d52e689e6f1eef1c958f9a9f8cd5 Mon Sep 17 00:00:00 2001 From: Lazlo Westerhof Date: Thu, 1 Aug 2024 15:41:05 +0200 Subject: [PATCH] Folder: small style improvements --- folder.py | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/folder.py b/folder.py index 38553aeaa..af4bc32c9 100644 --- a/folder.py +++ b/folder.py @@ -203,11 +203,8 @@ def precheck_folder_secure(ctx, coll): return False found, last_run = get_last_run_time(ctx, coll) - if (not correct_copytovault_start_status(ctx, coll) - or not misc.last_run_time_acceptable(coll, found, last_run, config.vault_copy_backoff_time)): - return False - - return True + return (not correct_copytovault_start_status(ctx, coll) + or not misc.last_run_time_acceptable(coll, found, last_run, config.vault_copy_backoff_time)) def folder_secure(ctx, coll): @@ -301,21 +298,15 @@ def check_folder_secure(ctx, coll): :returns: True when successful """ - if (not set_can_modify(ctx, coll) + return (not set_can_modify(ctx, coll) or not retry_attempts(ctx, coll) - or not set_last_run_time(ctx, coll)): - return False - - return True + or not set_last_run_time(ctx, coll)) def correct_copytovault_start_status(ctx, coll): """Confirm that the copytovault cronjob avu status is correct state to start securing""" cronjob_status = get_cronjob_status(ctx, coll) - if cronjob_status in (constants.CRONJOB_STATE['PENDING'], constants.CRONJOB_STATE['RETRY']): - return True - - return False + return cronjob_status in (constants.CRONJOB_STATE['PENDING'], constants.CRONJOB_STATE['RETRY']) def get_last_run_time(ctx, coll): @@ -357,7 +348,13 @@ def set_can_modify(ctx, coll): def get_retry_count(ctx, coll): - """ Get the retry count, if not such AVU, return 0 """ + """Get the retry count, if not such AVU, return 0. + + :param ctx: Combined type of a callback and rei struct + :param coll: Folder to secure + + :returns: Retry count + """ retry_count = 0 iter = genquery.row_iterator( "META_COLL_ATTR_VALUE, COLL_NAME", @@ -371,13 +368,15 @@ def get_retry_count(ctx, coll): def retry_attempts(ctx, coll): - """ Check if there have been too many retries. """ - retry_count = get_retry_count(ctx, coll) + """Check if there have been too many retries. - if retry_count >= config.vault_copy_max_retries: - return False + :param ctx: Combined type of a callback and rei struct + :param coll: Folder to secure - return True + :returns: Boolean indicating if there have been too many retries + """ + retry_count = get_retry_count(ctx, coll) + return retry_count >= config.vault_copy_max_retries def folder_secure_succeed_avus(ctx, coll, group_name):