mirror of https://gitlab.com/bashrc2/epicyon
Add exception for file read
parent
8c30b537ab
commit
e95f6b8261
|
@ -138,48 +138,52 @@ def html_hash_tag_swarm(base_dir: str, actor: str, translate: {}) -> str:
|
||||||
tags_filename)
|
tags_filename)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
with open(tags_filename, 'r', encoding='utf-8') as fp_tags:
|
try:
|
||||||
while True:
|
with open(tags_filename, 'r', encoding='utf-8') as fp_tags:
|
||||||
line = fp_tags.readline()
|
while True:
|
||||||
if not line:
|
line = fp_tags.readline()
|
||||||
break
|
if not line:
|
||||||
if ' ' not in line:
|
break
|
||||||
break
|
if ' ' not in line:
|
||||||
sections = line.split(' ')
|
break
|
||||||
if len(sections) != 3:
|
sections = line.split(' ')
|
||||||
break
|
if len(sections) != 3:
|
||||||
post_days_since_epoch_str = sections[0]
|
break
|
||||||
if not post_days_since_epoch_str.isdigit():
|
post_days_since_epoch_str = sections[0]
|
||||||
break
|
if not post_days_since_epoch_str.isdigit():
|
||||||
post_days_since_epoch = int(post_days_since_epoch_str)
|
break
|
||||||
if post_days_since_epoch < recently:
|
post_days_since_epoch = int(post_days_since_epoch_str)
|
||||||
break
|
if post_days_since_epoch < recently:
|
||||||
post_url = sections[2]
|
break
|
||||||
if '##' not in post_url:
|
post_url = sections[2]
|
||||||
break
|
if '##' not in post_url:
|
||||||
post_domain = post_url.split('##')[1]
|
break
|
||||||
if '#' in post_domain:
|
post_domain = post_url.split('##')[1]
|
||||||
post_domain = post_domain.split('#')[0]
|
if '#' in post_domain:
|
||||||
|
post_domain = post_domain.split('#')[0]
|
||||||
|
|
||||||
if domain_histogram.get(post_domain):
|
if domain_histogram.get(post_domain):
|
||||||
domain_histogram[post_domain] = \
|
domain_histogram[post_domain] = \
|
||||||
domain_histogram[post_domain] + 1
|
domain_histogram[post_domain] + 1
|
||||||
else:
|
else:
|
||||||
domain_histogram[post_domain] = 1
|
domain_histogram[post_domain] = 1
|
||||||
tag_swarm.append(hash_tag_name)
|
tag_swarm.append(hash_tag_name)
|
||||||
category_filename = \
|
category_filename = \
|
||||||
tags_filename.replace('.txt', '.category')
|
tags_filename.replace('.txt', '.category')
|
||||||
if os.path.isfile(category_filename):
|
if os.path.isfile(category_filename):
|
||||||
category_str = \
|
category_str = \
|
||||||
get_hashtag_category(base_dir, hash_tag_name)
|
get_hashtag_category(base_dir, hash_tag_name)
|
||||||
if len(category_str) < max_tag_length:
|
if len(category_str) < max_tag_length:
|
||||||
if '#' not in category_str and \
|
if '#' not in category_str and \
|
||||||
'&' not in category_str and \
|
'&' not in category_str and \
|
||||||
'"' not in category_str and \
|
'"' not in category_str and \
|
||||||
"'" not in category_str:
|
"'" not in category_str:
|
||||||
if category_str not in category_swarm:
|
if category_str not in category_swarm:
|
||||||
category_swarm.append(category_str)
|
category_swarm.append(category_str)
|
||||||
break
|
break
|
||||||
|
except OSError as exc:
|
||||||
|
print('EX: html_hash_tag_swarm unable to read ' +
|
||||||
|
tags_filename + ' ' + str(exc))
|
||||||
break
|
break
|
||||||
|
|
||||||
if not tag_swarm:
|
if not tag_swarm:
|
||||||
|
|
Loading…
Reference in New Issue