mirror of https://gitlab.com/bashrc2/epicyon
More efficient detection of non-empty strings
parent
a895212a04
commit
7b6eb5a414
|
@ -110,7 +110,6 @@ def _create_accept_reject(federation_list: [],
|
||||||
'object': object_json
|
'object': object_json
|
||||||
}
|
}
|
||||||
if cc_url:
|
if cc_url:
|
||||||
if len(cc_url) > 0:
|
|
||||||
new_accept['cc'] = [cc_url]
|
new_accept['cc'] = [cc_url]
|
||||||
return new_accept
|
return new_accept
|
||||||
|
|
||||||
|
|
|
@ -206,7 +206,6 @@ def create_announce(session, base_dir: str, federation_list: [],
|
||||||
'type': 'Announce'
|
'type': 'Announce'
|
||||||
}
|
}
|
||||||
if cc_url:
|
if cc_url:
|
||||||
if len(cc_url) > 0:
|
|
||||||
new_announce['cc'] = [cc_url]
|
new_announce['cc'] = [cc_url]
|
||||||
if save_to_file:
|
if save_to_file:
|
||||||
outbox_dir = create_outbox_dir(nickname, domain, base_dir)
|
outbox_dir = create_outbox_dir(nickname, domain, base_dir)
|
||||||
|
|
|
@ -234,7 +234,7 @@ def post_login_screen(self, calling_domain: str, cookie: str,
|
||||||
login_str += login_prm + '='
|
login_str += login_prm + '='
|
||||||
else:
|
else:
|
||||||
len_str = login_prm.split('&')[0]
|
len_str = login_prm.split('&')[0]
|
||||||
if len(len_str) > 0:
|
if len_str:
|
||||||
login_str += login_prm + '*'
|
login_str += login_prm + '*'
|
||||||
len_str = ''
|
len_str = ''
|
||||||
if '&' in login_prm:
|
if '&' in login_prm:
|
||||||
|
|
1
like.py
1
like.py
|
@ -104,7 +104,6 @@ def _create_like(recent_posts_cache: {},
|
||||||
'object': object_url
|
'object': object_url
|
||||||
}
|
}
|
||||||
if cc_list:
|
if cc_list:
|
||||||
if len(cc_list) > 0:
|
|
||||||
new_like_json['cc'] = cc_list
|
new_like_json['cc'] = cc_list
|
||||||
|
|
||||||
# Extract the domain and nickname from a statuses link
|
# Extract the domain and nickname from a statuses link
|
||||||
|
|
4
pgp.py
4
pgp.py
|
@ -917,7 +917,7 @@ def actor_to_vcard(actor: {}, domain: str, translate: {}) -> str:
|
||||||
vcard_str += \
|
vcard_str += \
|
||||||
'EXPERTISE;LEVEL=' + level_str + ':' + skill_name + '\n'
|
'EXPERTISE;LEVEL=' + level_str + ':' + skill_name + '\n'
|
||||||
if actor.get('hasOccupation'):
|
if actor.get('hasOccupation'):
|
||||||
if len(actor['hasOccupation']) > 0:
|
if actor['hasOccupation']:
|
||||||
if actor['hasOccupation'][0].get('name'):
|
if actor['hasOccupation'][0].get('name'):
|
||||||
vcard_str += \
|
vcard_str += \
|
||||||
'ROLE:' + \
|
'ROLE:' + \
|
||||||
|
@ -1048,7 +1048,7 @@ def actor_to_vcard_xml(actor: {}, domain: str, translate: {}) -> str:
|
||||||
'</parameters>' + \
|
'</parameters>' + \
|
||||||
'<text>' + pgp_key_encoded + '</text></key>\n'
|
'<text>' + pgp_key_encoded + '</text></key>\n'
|
||||||
if actor.get('hasOccupation'):
|
if actor.get('hasOccupation'):
|
||||||
if len(actor['hasOccupation']) > 0:
|
if actor['hasOccupation']:
|
||||||
if actor['hasOccupation'][0].get('name'):
|
if actor['hasOccupation'][0].get('name'):
|
||||||
vcard_str += \
|
vcard_str += \
|
||||||
' <role><text>' + \
|
' <role><text>' + \
|
||||||
|
|
2
posts.py
2
posts.py
|
@ -5692,7 +5692,7 @@ def archive_posts_for_person(http_prefix: str, nickname: str, domain: str,
|
||||||
print('EX: archive_posts_for_person unable to read ' +
|
print('EX: archive_posts_for_person unable to read ' +
|
||||||
index_filename + ' ' + str(ex))
|
index_filename + ' ' + str(ex))
|
||||||
# save the new index file
|
# save the new index file
|
||||||
if len(new_index) > 0:
|
if new_index:
|
||||||
try:
|
try:
|
||||||
with open(index_filename, 'w+',
|
with open(index_filename, 'w+',
|
||||||
encoding='utf-8') as fp_index:
|
encoding='utf-8') as fp_index:
|
||||||
|
|
|
@ -567,7 +567,7 @@ def prepend_base(base, iri):
|
||||||
# directory from base
|
# directory from base
|
||||||
if rel.path != '':
|
if rel.path != '':
|
||||||
path = path[0:path.rfind('/') + 1]
|
path = path[0:path.rfind('/') + 1]
|
||||||
if len(path) > 0 and not path.endswith('/'):
|
if path and not path.endswith('/'):
|
||||||
path += '/'
|
path += '/'
|
||||||
path += rel.path
|
path += rel.path
|
||||||
|
|
||||||
|
@ -779,7 +779,7 @@ class JsonLdProcessor(object):
|
||||||
tmp = ctx
|
tmp = ctx
|
||||||
ctx = []
|
ctx = []
|
||||||
for v in tmp:
|
for v in tmp:
|
||||||
if not _is_object(v) or len(v) > 0:
|
if not _is_object(v) or v:
|
||||||
ctx.append(v)
|
ctx.append(v)
|
||||||
|
|
||||||
# remove array if only one context
|
# remove array if only one context
|
||||||
|
@ -1265,7 +1265,7 @@ class JsonLdProcessor(object):
|
||||||
"""
|
"""
|
||||||
if property in subject:
|
if property in subject:
|
||||||
value = subject[property]
|
value = subject[property]
|
||||||
return not _is_array(value) or len(value) > 0
|
return not _is_array(value) or value
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -190,7 +190,7 @@ def get_instance_software(base_dir: str, session,
|
||||||
nodeinfo_url = None
|
nodeinfo_url = None
|
||||||
if nodeinfo1_json.get('links'):
|
if nodeinfo1_json.get('links'):
|
||||||
if isinstance(nodeinfo1_json['links'], list):
|
if isinstance(nodeinfo1_json['links'], list):
|
||||||
if len(nodeinfo1_json['links']) > 0:
|
if nodeinfo1_json['links']:
|
||||||
if nodeinfo1_json['links'][0].get('href'):
|
if nodeinfo1_json['links'][0].get('href'):
|
||||||
href = nodeinfo1_json['links'][0]['href']
|
href = nodeinfo1_json['links'][0]['href']
|
||||||
if isinstance(href, str):
|
if isinstance(href, str):
|
||||||
|
|
|
@ -1336,7 +1336,8 @@ def html_profile(signing_priv_key_pem: str,
|
||||||
with open(follow_requests_filename, 'r',
|
with open(follow_requests_filename, 'r',
|
||||||
encoding='utf-8') as fp_foll:
|
encoding='utf-8') as fp_foll:
|
||||||
for line in fp_foll:
|
for line in fp_foll:
|
||||||
if len(line) > 0:
|
if not line:
|
||||||
|
continue
|
||||||
follow_approvals = True
|
follow_approvals = True
|
||||||
followers_button = 'buttonhighlighted'
|
followers_button = 'buttonhighlighted'
|
||||||
if selected == 'followers':
|
if selected == 'followers':
|
||||||
|
@ -1352,7 +1353,8 @@ def html_profile(signing_priv_key_pem: str,
|
||||||
with open(follow_requests_filename, 'r',
|
with open(follow_requests_filename, 'r',
|
||||||
encoding='utf-8') as fp_req:
|
encoding='utf-8') as fp_req:
|
||||||
for follower_handle in fp_req:
|
for follower_handle in fp_req:
|
||||||
if len(follower_handle) > 0:
|
if not follower_handle:
|
||||||
|
continue
|
||||||
follower_handle = \
|
follower_handle = \
|
||||||
remove_eol(follower_handle)
|
remove_eol(follower_handle)
|
||||||
if '://' in follower_handle:
|
if '://' in follower_handle:
|
||||||
|
@ -1950,7 +1952,7 @@ def _html_profile_roles(translate: {}, nickname: str, domain: str,
|
||||||
else:
|
else:
|
||||||
profile_str += '<h3>' + role + '</h3>\n'
|
profile_str += '<h3>' + role + '</h3>\n'
|
||||||
profile_str += '</div></div>\n'
|
profile_str += '</div></div>\n'
|
||||||
if len(profile_str) == 0:
|
if not profile_str:
|
||||||
profile_str += \
|
profile_str += \
|
||||||
'<p>@' + nickname + '@' + domain + ' has no roles assigned</p>\n'
|
'<p>@' + nickname + '@' + domain + ' has no roles assigned</p>\n'
|
||||||
else:
|
else:
|
||||||
|
@ -1967,7 +1969,7 @@ def _html_profile_skills(skills_json: {}) -> str:
|
||||||
'<div>' + skill + \
|
'<div>' + skill + \
|
||||||
'<br><div id="myProgress"><div id="myBar" style="width:' + \
|
'<br><div id="myProgress"><div id="myBar" style="width:' + \
|
||||||
str(level) + '%"></div></div></div>\n<br>\n'
|
str(level) + '%"></div></div></div>\n<br>\n'
|
||||||
if len(profile_str) > 0:
|
if profile_str:
|
||||||
profile_str = '<center><div class="skill-title">' + \
|
profile_str = '<center><div class="skill-title">' + \
|
||||||
profile_str + '</div></center>\n'
|
profile_str + '</div></center>\n'
|
||||||
return profile_str
|
return profile_str
|
||||||
|
@ -1984,7 +1986,7 @@ def _html_profile_shares(actor: str, translate: {},
|
||||||
actor, item, translate,
|
actor, item, translate,
|
||||||
False, False,
|
False, False,
|
||||||
shares_file_type)
|
shares_file_type)
|
||||||
if len(profile_str) > 0:
|
if profile_str:
|
||||||
profile_str = '<div class="share-title">' + profile_str + '</div>\n'
|
profile_str = '<div class="share-title">' + profile_str + '</div>\n'
|
||||||
return profile_str
|
return profile_str
|
||||||
|
|
||||||
|
|
|
@ -707,7 +707,8 @@ def html_timeline(default_timeline: str,
|
||||||
with open(follow_requests_filename, 'r',
|
with open(follow_requests_filename, 'r',
|
||||||
encoding='utf-8') as fp_foll:
|
encoding='utf-8') as fp_foll:
|
||||||
for line in fp_foll:
|
for line in fp_foll:
|
||||||
if len(line) > 0:
|
if not line:
|
||||||
|
continue
|
||||||
# show follow approvals icon
|
# show follow approvals icon
|
||||||
follow_approvals = \
|
follow_approvals = \
|
||||||
'<a href="' + users_path + \
|
'<a href="' + users_path + \
|
||||||
|
|
|
@ -1457,7 +1457,7 @@ def get_post_attachments_as_html(base_dir: str,
|
||||||
media_creator = attach['schema:creator']
|
media_creator = attach['schema:creator']
|
||||||
elif attach.get('attribution'):
|
elif attach.get('attribution'):
|
||||||
if isinstance(attach['attribution'], list):
|
if isinstance(attach['attribution'], list):
|
||||||
if len(attach['attribution']) > 0:
|
if attach['attribution']:
|
||||||
attrib_str = attach['attribution'][0]
|
attrib_str = attach['attribution'][0]
|
||||||
if not dangerous_markup(attrib_str, False, []):
|
if not dangerous_markup(attrib_str, False, []):
|
||||||
if not is_filtered(base_dir, nickname, domain,
|
if not is_filtered(base_dir, nickname, domain,
|
||||||
|
|
Loading…
Reference in New Issue