refactor: replace string concatenations with f-strings
All checks were successful
CI / test (push) Successful in 50s
All checks were successful
CI / test (push) Successful in 50s
This commit is contained in:
@@ -212,7 +212,7 @@ def extract_date(date_text):
|
||||
month, day, year = parts[-3:]
|
||||
month = MONTH_ABBREVIATIONS.get(month[0:3]) # slicing in case they start writing out the full month name
|
||||
if month and (re.fullmatch(r'\d\d?', day) is not None) and (re.fullmatch(r'\d{4}', year) is not None):
|
||||
return year + '-' + month + '-' + day
|
||||
return f'{year}-{month}-{day}'
|
||||
return None
|
||||
|
||||
def check_missing_keys(object, *key_sequences):
|
||||
@@ -222,7 +222,7 @@ def check_missing_keys(object, *key_sequences):
|
||||
for key in key_sequence:
|
||||
_object = _object[key]
|
||||
except (KeyError, IndexError, TypeError):
|
||||
return 'Could not find ' + key
|
||||
return f'Could not find {key}'
|
||||
|
||||
return None
|
||||
|
||||
@@ -467,7 +467,7 @@ def extract_item_info(item, additional_info={}):
|
||||
['shortBylineText', 'runs', 0, 'navigationEndpoint', 'browseEndpoint', 'browseId'],
|
||||
['ownerText', 'runs', 0, 'navigationEndpoint', 'browseEndpoint', 'browseId']
|
||||
))
|
||||
info['author_url'] = ('https://www.youtube.com/channel/' + info['author_id']) if info['author_id'] else None
|
||||
info['author_url'] = f'https://www.youtube.com/channel/{info["author_id"]}' if info['author_id'] else None
|
||||
info['description'] = extract_formatted_text(multi_deep_get(
|
||||
item,
|
||||
['descriptionText'], ['descriptionSnippet'],
|
||||
|
||||
Reference in New Issue
Block a user