mirror of https://gitlab.com/bashrc2/epicyon
Use enumerations
parent
5341e5a274
commit
1085f97070
|
@ -290,7 +290,7 @@ def update_blocked_cache(base_dir: str,
|
|||
with open(global_blocking_filename, 'r') as fp_blocked:
|
||||
blocked_lines = fp_blocked.readlines()
|
||||
# remove newlines
|
||||
for index in range(len(blocked_lines)):
|
||||
for index, _ in enumerate(blocked_lines):
|
||||
blocked_lines[index] = blocked_lines[index].replace('\n', '')
|
||||
# update the cache
|
||||
blocked_cache.clear()
|
||||
|
|
|
@ -143,7 +143,7 @@ def _person_receive_update_outbox(recent_posts_cache: {},
|
|||
if 'attachment' not in actor_json:
|
||||
continue
|
||||
found = False
|
||||
for attach_idx in range(len(actor_json['attachment'])):
|
||||
for attach_idx, _ in enumerate(actor_json['attachment']):
|
||||
if actor_json['attachment'][attach_idx]['type'] != \
|
||||
'PropertyValue':
|
||||
continue
|
||||
|
|
|
@ -797,7 +797,7 @@ def person_upgrade_actor(base_dir: str, person_json: {},
|
|||
update_actor = True
|
||||
else:
|
||||
# add location if it is missing
|
||||
for index in range(len(person_json['hasOccupation'])):
|
||||
for index, _ in enumerate(person_json['hasOccupation']):
|
||||
oc_item = person_json['hasOccupation'][index]
|
||||
if oc_item.get('hasOccupation'):
|
||||
oc_item = oc_item['hasOccupation']
|
||||
|
|
2
roles.py
2
roles.py
|
@ -163,7 +163,7 @@ def _set_actor_role(actor_json: {}, role_name: str) -> bool:
|
|||
if not category:
|
||||
return False
|
||||
|
||||
for index in range(len(actor_json['hasOccupation'])):
|
||||
for index, _ in enumerate(actor_json['hasOccupation']):
|
||||
occupation_item = actor_json['hasOccupation'][index]
|
||||
if not isinstance(occupation_item, dict):
|
||||
continue
|
||||
|
|
|
@ -503,7 +503,7 @@ def _post_to_speaker_json(base_dir: str, http_prefix: str,
|
|||
follows = fp_foll.readlines()
|
||||
if len(follows) > 0:
|
||||
follow_requests_exist = True
|
||||
for i in range(len(follows)):
|
||||
for i, _ in enumerate(follows):
|
||||
follows[i] = follows[i].strip()
|
||||
follow_requests_list = follows
|
||||
post_dm = False
|
||||
|
|
10
utils.py
10
utils.py
|
@ -559,7 +559,7 @@ def get_followers_list(base_dir: str,
|
|||
|
||||
with open(filename, 'r') as foll_file:
|
||||
lines = foll_file.readlines()
|
||||
for i in range(len(lines)):
|
||||
for i, _ in enumerate(lines):
|
||||
lines[i] = lines[i].strip()
|
||||
return lines
|
||||
return []
|
||||
|
@ -2126,7 +2126,7 @@ def _search_virtual_box_posts(base_dir: str, nickname: str, domain: str,
|
|||
|
||||
if '+' in search_str:
|
||||
search_words = search_str.split('+')
|
||||
for index in range(len(search_words)):
|
||||
for index, _ in enumerate(search_words):
|
||||
search_words[index] = search_words[index].strip()
|
||||
print('SEARCH: ' + str(search_words))
|
||||
else:
|
||||
|
@ -2178,7 +2178,7 @@ def search_box_posts(base_dir: str, nickname: str, domain: str,
|
|||
|
||||
if '+' in search_str:
|
||||
search_words = search_str.split('+')
|
||||
for index in range(len(search_words)):
|
||||
for index, _ in enumerate(search_words):
|
||||
search_words[index] = search_words[index].strip()
|
||||
print('SEARCH: ' + str(search_words))
|
||||
else:
|
||||
|
@ -2811,7 +2811,7 @@ def set_occupation_name(actor_json: {}, name: str) -> bool:
|
|||
return False
|
||||
if not isinstance(actor_json['hasOccupation'], list):
|
||||
return False
|
||||
for index in range(len(actor_json['hasOccupation'])):
|
||||
for index, _ in enumerate(actor_json['hasOccupation']):
|
||||
occupation_item = actor_json['hasOccupation'][index]
|
||||
if not isinstance(occupation_item, dict):
|
||||
continue
|
||||
|
@ -2831,7 +2831,7 @@ def set_occupation_skills_list(actor_json: {}, skills_list: []) -> bool:
|
|||
return False
|
||||
if not isinstance(actor_json['hasOccupation'], list):
|
||||
return False
|
||||
for index in range(len(actor_json['hasOccupation'])):
|
||||
for index, _ in enumerate(actor_json['hasOccupation']):
|
||||
occupation_item = actor_json['hasOccupation'][index]
|
||||
if not isinstance(occupation_item, dict):
|
||||
continue
|
||||
|
|
|
@ -941,9 +941,8 @@ def rss_hashtag_search(nickname: str, domain: str, port: int,
|
|||
domain_full = get_full_domain(domain, port)
|
||||
|
||||
max_feed_length = 10
|
||||
hashtag_feed = \
|
||||
rss2tag_header(hashtag, http_prefix, domain_full)
|
||||
for index in range(len(lines)):
|
||||
hashtag_feed = rss2tag_header(hashtag, http_prefix, domain_full)
|
||||
for index, _ in enumerate(lines):
|
||||
post_id = lines[index].strip('\n').strip('\r')
|
||||
if ' ' not in post_id:
|
||||
nickname = get_nickname_from_actor(post_id)
|
||||
|
|
Loading…
Reference in New Issue