mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
69efdba68f
commit
865c316254
8
maps.py
8
maps.py
|
@ -202,13 +202,13 @@ def geocoords_from_map_link(url: str,
|
||||||
"""
|
"""
|
||||||
if osm_domain in url:
|
if osm_domain in url:
|
||||||
return _geocoords_from_osm_link(url, osm_domain)
|
return _geocoords_from_osm_link(url, osm_domain)
|
||||||
elif '.google.co' in url:
|
if '.google.co' in url:
|
||||||
return _geocoords_from_gmaps_link(url)
|
return _geocoords_from_gmaps_link(url)
|
||||||
elif '.bing.co' in url:
|
if '.bing.co' in url:
|
||||||
return _geocoords_from_bmaps_link(url)
|
return _geocoords_from_bmaps_link(url)
|
||||||
elif '.waze.co' in url:
|
if '.waze.co' in url:
|
||||||
return _geocoords_from_waze_link(url)
|
return _geocoords_from_waze_link(url)
|
||||||
elif 'wego.here.co' in url:
|
if 'wego.here.co' in url:
|
||||||
return _geocoords_from_wego_link(url)
|
return _geocoords_from_wego_link(url)
|
||||||
return None, None, None
|
return None, None, None
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ def meta_data_node_info(base_dir: str,
|
||||||
about_url: str,
|
about_url: str,
|
||||||
terms_of_service_url: str,
|
terms_of_service_url: str,
|
||||||
registration: bool, version: str,
|
registration: bool, version: str,
|
||||||
showAccounts: bool) -> {}:
|
show_accounts: bool) -> {}:
|
||||||
""" /nodeinfo/2.0 endpoint
|
""" /nodeinfo/2.0 endpoint
|
||||||
Also see https://socialhub.activitypub.rocks/t/
|
Also see https://socialhub.activitypub.rocks/t/
|
||||||
fep-f1d5-nodeinfo-in-fediverse-software/1190/4
|
fep-f1d5-nodeinfo-in-fediverse-software/1190/4
|
||||||
|
@ -46,7 +46,7 @@ def meta_data_node_info(base_dir: str,
|
||||||
Also exposure of the version number and number of accounts could be
|
Also exposure of the version number and number of accounts could be
|
||||||
sensitive
|
sensitive
|
||||||
"""
|
"""
|
||||||
if showAccounts:
|
if show_accounts:
|
||||||
active_accounts = no_of_accounts(base_dir)
|
active_accounts = no_of_accounts(base_dir)
|
||||||
active_accounts_monthly = no_of_active_accounts_monthly(base_dir, 1)
|
active_accounts_monthly = no_of_active_accounts_monthly(base_dir, 1)
|
||||||
active_accounts_half_year = no_of_active_accounts_monthly(base_dir, 6)
|
active_accounts_half_year = no_of_active_accounts_monthly(base_dir, 6)
|
||||||
|
@ -81,7 +81,7 @@ def meta_data_node_info(base_dir: str,
|
||||||
return nodeinfo
|
return nodeinfo
|
||||||
|
|
||||||
|
|
||||||
def meta_data_instance(showAccounts: bool,
|
def meta_data_instance(show_accounts: bool,
|
||||||
instance_title: str,
|
instance_title: str,
|
||||||
instance_description_short: str,
|
instance_description_short: str,
|
||||||
instance_description: str,
|
instance_description: str,
|
||||||
|
@ -131,7 +131,7 @@ def meta_data_instance(showAccounts: bool,
|
||||||
http_prefix + '://' + domain_full + '/@' + \
|
http_prefix + '://' + domain_full + '/@' + \
|
||||||
admin_actor['preferredUsername']
|
admin_actor['preferredUsername']
|
||||||
|
|
||||||
if showAccounts:
|
if show_accounts:
|
||||||
active_accounts = no_of_accounts(base_dir)
|
active_accounts = no_of_accounts(base_dir)
|
||||||
local_posts = _get_status_count(base_dir)
|
local_posts = _get_status_count(base_dir)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -54,7 +54,7 @@ def _update_feeds_outbox_index(base_dir: str, domain: str,
|
||||||
feeds_file.seek(0, 0)
|
feeds_file.seek(0, 0)
|
||||||
feeds_file.write(post_id + '\n' + content)
|
feeds_file.write(post_id + '\n' + content)
|
||||||
print('DEBUG: feeds post added to index')
|
print('DEBUG: feeds post added to index')
|
||||||
except BaseException as ex:
|
except OSError as ex:
|
||||||
print('EX: Failed to write entry to feeds posts index ' +
|
print('EX: Failed to write entry to feeds posts index ' +
|
||||||
index_filename + ' ' + str(ex))
|
index_filename + ' ' + str(ex))
|
||||||
else:
|
else:
|
||||||
|
@ -803,7 +803,6 @@ def run_newswire_daemon(base_dir: str, httpd,
|
||||||
print('Newswire daemon has no session')
|
print('Newswire daemon has no session')
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
continue
|
continue
|
||||||
else:
|
|
||||||
print('Newswire daemon session established')
|
print('Newswire daemon session established')
|
||||||
|
|
||||||
# try to update the feeds
|
# try to update the feeds
|
||||||
|
|
|
@ -471,7 +471,7 @@ def _valid_podcast_entry(base_dir: str, key: str, entry: {}) -> bool:
|
||||||
https://github.com/Podcastindex-org/podcast-namespace/
|
https://github.com/Podcastindex-org/podcast-namespace/
|
||||||
blob/main/proposal-docs/social/social.md#socialinteract-element
|
blob/main/proposal-docs/social/social.md#socialinteract-element
|
||||||
"""
|
"""
|
||||||
if key == 'socialInteract' or key == 'discussion':
|
if key in ('socialInteract', 'discussion'):
|
||||||
if not entry.get('protocol'):
|
if not entry.get('protocol'):
|
||||||
return False
|
return False
|
||||||
if not entry.get('uri'):
|
if not entry.get('uri'):
|
||||||
|
@ -678,7 +678,6 @@ def get_link_from_rss_item(rss_item: str,
|
||||||
'.i2p/' not in link:
|
'.i2p/' not in link:
|
||||||
continue
|
continue
|
||||||
return link, mime_type
|
return link, mime_type
|
||||||
else:
|
|
||||||
if '.onion/' not in link and \
|
if '.onion/' not in link and \
|
||||||
'.i2p/' not in link:
|
'.i2p/' not in link:
|
||||||
return link, mime_type
|
return link, mime_type
|
||||||
|
@ -1322,7 +1321,6 @@ def get_rss(base_dir: str, domain: str, session, url: str,
|
||||||
max_categories_feedItem_size_kb,
|
max_categories_feedItem_size_kb,
|
||||||
session, debug,
|
session, debug,
|
||||||
preferred_podcast_formats)
|
preferred_podcast_formats)
|
||||||
else:
|
|
||||||
print('WARN: feed is too large, ' +
|
print('WARN: feed is too large, ' +
|
||||||
'or contains invalid characters: ' + url)
|
'or contains invalid characters: ' + url)
|
||||||
else:
|
else:
|
||||||
|
|
4
pgp.py
4
pgp.py
|
@ -220,7 +220,7 @@ def set_pgp_pub_key(actor_json: {}, pgp_pub_key: str) -> None:
|
||||||
property_found = property_value
|
property_found = property_value
|
||||||
break
|
break
|
||||||
if property_found:
|
if property_found:
|
||||||
actor_json['attachment'].remove(property_value)
|
actor_json['attachment'].remove(property_found)
|
||||||
if remove_key:
|
if remove_key:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ def set_pgp_fingerprint(actor_json: {}, fingerprint: str) -> None:
|
||||||
property_found = property_value
|
property_found = property_value
|
||||||
break
|
break
|
||||||
if property_found:
|
if property_found:
|
||||||
actor_json['attachment'].remove(property_value)
|
actor_json['attachment'].remove(property_found)
|
||||||
if remove_fingerprint:
|
if remove_fingerprint:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
16
posts.py
16
posts.py
|
@ -1451,7 +1451,7 @@ def _create_post_base(base_dir: str,
|
||||||
break
|
break
|
||||||
if music_metadata:
|
if music_metadata:
|
||||||
for audio_tag, audio_value in music_metadata.items():
|
for audio_tag, audio_value in music_metadata.items():
|
||||||
if audio_tag == 'title' or audio_tag == 'track':
|
if audio_tag in ('title', 'track'):
|
||||||
continue
|
continue
|
||||||
# capitalize and remove any spaces
|
# capitalize and remove any spaces
|
||||||
audio_value = audio_value.title().replace(' ', '')
|
audio_value = audio_value.title().replace(' ', '')
|
||||||
|
@ -1984,7 +1984,7 @@ def create_question_post(base_dir: str,
|
||||||
client_to_server: bool, comments_enabled: bool,
|
client_to_server: bool, comments_enabled: bool,
|
||||||
attach_image_filename: str, media_type: str,
|
attach_image_filename: str, media_type: str,
|
||||||
image_description: str, city: str,
|
image_description: str, city: str,
|
||||||
subject: str, durationDays: int,
|
subject: str, duration_days: int,
|
||||||
system_language: str, low_bandwidth: bool,
|
system_language: str, low_bandwidth: bool,
|
||||||
content_license_url: str,
|
content_license_url: str,
|
||||||
languages_understood: []) -> {}:
|
languages_understood: []) -> {}:
|
||||||
|
@ -2011,7 +2011,7 @@ def create_question_post(base_dir: str,
|
||||||
message_json['object']['votersCount'] = 0
|
message_json['object']['votersCount'] = 0
|
||||||
curr_time = datetime.datetime.utcnow()
|
curr_time = datetime.datetime.utcnow()
|
||||||
days_since_epoch = \
|
days_since_epoch = \
|
||||||
int((curr_time - datetime.datetime(1970, 1, 1)).days + durationDays)
|
int((curr_time - datetime.datetime(1970, 1, 1)).days + duration_days)
|
||||||
end_time = datetime.datetime(1970, 1, 1) + \
|
end_time = datetime.datetime(1970, 1, 1) + \
|
||||||
datetime.timedelta(days_since_epoch)
|
datetime.timedelta(days_since_epoch)
|
||||||
message_json['object']['endTime'] = end_time.strftime("%Y-%m-%dT%H:%M:%SZ")
|
message_json['object']['endTime'] = end_time.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
@ -2559,7 +2559,7 @@ def send_post_via_server(signing_priv_key_pem: str, project_version: str,
|
||||||
from_nickname: str, password: str,
|
from_nickname: str, password: str,
|
||||||
from_domain: str, from_port: int,
|
from_domain: str, from_port: int,
|
||||||
to_nickname: str, to_domain: str, to_port: int,
|
to_nickname: str, to_domain: str, to_port: int,
|
||||||
cc: str,
|
cc_str: str,
|
||||||
http_prefix: str, content: str, followers_only: bool,
|
http_prefix: str, content: str, followers_only: bool,
|
||||||
comments_enabled: bool,
|
comments_enabled: bool,
|
||||||
attach_image_filename: str, media_type: str,
|
attach_image_filename: str, media_type: str,
|
||||||
|
@ -2631,7 +2631,8 @@ def send_post_via_server(signing_priv_key_pem: str, project_version: str,
|
||||||
client_to_server = True
|
client_to_server = True
|
||||||
if to_domain.lower().endswith('public'):
|
if to_domain.lower().endswith('public'):
|
||||||
to_person_id = 'https://www.w3.org/ns/activitystreams#Public'
|
to_person_id = 'https://www.w3.org/ns/activitystreams#Public'
|
||||||
cc = local_actor_url(http_prefix, from_nickname, from_domain_full) + \
|
cc_str = \
|
||||||
|
local_actor_url(http_prefix, from_nickname, from_domain_full) + \
|
||||||
'/followers'
|
'/followers'
|
||||||
else:
|
else:
|
||||||
if to_domain.lower().endswith('followers') or \
|
if to_domain.lower().endswith('followers') or \
|
||||||
|
@ -2648,7 +2649,7 @@ def send_post_via_server(signing_priv_key_pem: str, project_version: str,
|
||||||
post_json_object = \
|
post_json_object = \
|
||||||
_create_post_base(base_dir,
|
_create_post_base(base_dir,
|
||||||
from_nickname, from_domain, from_port,
|
from_nickname, from_domain, from_port,
|
||||||
to_person_id, cc, http_prefix, content,
|
to_person_id, cc_str, http_prefix, content,
|
||||||
followers_only, save_to_file, client_to_server,
|
followers_only, save_to_file, client_to_server,
|
||||||
comments_enabled,
|
comments_enabled,
|
||||||
attach_image_filename, media_type,
|
attach_image_filename, media_type,
|
||||||
|
@ -2760,7 +2761,8 @@ def _add_followers_to_public_post(post_json_object: {}) -> None:
|
||||||
|
|
||||||
def send_signed_json(post_json_object: {}, session, base_dir: str,
|
def send_signed_json(post_json_object: {}, session, base_dir: str,
|
||||||
nickname: str, domain: str, port: int,
|
nickname: str, domain: str, port: int,
|
||||||
to_nickname: str, to_domain: str, to_port: int, cc: str,
|
to_nickname: str, to_domain: str,
|
||||||
|
to_port: int, cc_str: str,
|
||||||
http_prefix: str, save_to_file: bool,
|
http_prefix: str, save_to_file: bool,
|
||||||
client_to_server: bool, federation_list: [],
|
client_to_server: bool, federation_list: [],
|
||||||
send_threads: [], post_log: [], cached_webfingers: {},
|
send_threads: [], post_log: [], cached_webfingers: {},
|
||||||
|
|
Loading…
Reference in New Issue