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