From ced5acc8f6031906c900540b2f3ec57efe011750 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 4 Jan 2022 10:33:30 +0000 Subject: [PATCH] Snake case --- webapp_person_options.py | 371 ++++++++++++++++++++------------------- 1 file changed, 186 insertions(+), 185 deletions(-) diff --git a/webapp_person_options.py b/webapp_person_options.py index 2dd005a90..dde38c44b 100644 --- a/webapp_person_options.py +++ b/webapp_person_options.py @@ -34,13 +34,13 @@ from webapp_utils import html_keyboard_navigation def html_person_options(default_timeline: str, css_cache: {}, translate: {}, base_dir: str, domain: str, domain_full: str, - originPathStr: str, - optionsActor: str, - optionsProfileUrl: str, - optionsLink: str, - pageNumber: int, + origin_path_str: str, + options_actor: str, + options_profile_url: str, + options_link: str, + page_number: int, donate_url: str, - webAddress: str, + web_address: str, xmpp_address: str, matrix_address: str, ssb_address: str, @@ -54,19 +54,19 @@ def html_person_options(default_timeline: str, pgp_fingerprint: str, email_address: str, dormant_months: int, - backToPath: str, - lockedAccount: bool, - movedTo: str, - alsoKnownAs: [], + back_to_path: str, + locked_account: bool, + moved_to: str, + also_known_as: [], text_mode_banner: str, news_instance: bool, authorized: bool, access_keys: {}, - isGroup: bool) -> str: + is_group: bool) -> str: """Show options for a person: view/follow/block/report """ - optionsDomain, optionsPort = get_domain_from_actor(optionsActor) - optionsDomainFull = get_full_domain(optionsDomain, optionsPort) + options_domain, options_port = get_domain_from_actor(options_actor) + options_domain_full = get_full_domain(options_domain, options_port) if os.path.isfile(base_dir + '/accounts/options-background-custom.jpg'): if not os.path.isfile(base_dir + '/accounts/options-background.jpg'): @@ -74,184 +74,184 @@ def html_person_options(default_timeline: str, base_dir + '/accounts/options-background.jpg') dormant = False - followStr = 'Follow' - if isGroup: - followStr = 'Join' - blockStr = 'Block' + follow_str = 'Follow' + if is_group: + follow_str = 'Join' + block_str = 'Block' nickname = None - optionsNickname = None - followsYou = False - if originPathStr.startswith('/users/'): - nickname = originPathStr.split('/users/')[1] + options_nickname = None + follows_you = False + if origin_path_str.startswith('/users/'): + nickname = origin_path_str.split('/users/')[1] if '/' in nickname: nickname = nickname.split('/')[0] if '?' in nickname: nickname = nickname.split('?')[0] - followerDomain, followerPort = get_domain_from_actor(optionsActor) - if is_following_actor(base_dir, nickname, domain, optionsActor): - followStr = 'Unfollow' - if isGroup: - followStr = 'Leave' +# follower_domain, follower_port = get_domain_from_actor(options_actor) + if is_following_actor(base_dir, nickname, domain, options_actor): + follow_str = 'Unfollow' + if is_group: + follow_str = 'Leave' dormant = \ - is_dormant(base_dir, nickname, domain, optionsActor, + is_dormant(base_dir, nickname, domain, options_actor, dormant_months) - optionsNickname = get_nickname_from_actor(optionsActor) - optionsDomainFull = get_full_domain(optionsDomain, optionsPort) - followsYou = \ + options_nickname = get_nickname_from_actor(options_actor) + options_domain_full = get_full_domain(options_domain, options_port) + follows_you = \ is_follower_of_person(base_dir, nickname, domain, - optionsNickname, optionsDomainFull) + options_nickname, options_domain_full) if is_blocked(base_dir, nickname, domain, - optionsNickname, optionsDomainFull): - blockStr = 'Block' + options_nickname, options_domain_full): + block_str = 'Block' - optionsLinkStr = '' - if optionsLink: - optionsLinkStr = \ + options_link_str = '' + if options_link: + options_link_str = \ ' \n' + options_link + '">\n' css_filename = base_dir + '/epicyon-options.css' if os.path.isfile(base_dir + '/options.css'): css_filename = base_dir + '/options.css' # To snooze, or not to snooze? That is the question - snoozeButtonStr = 'Snooze' + snooze_button_str = 'Snooze' if nickname: - if is_person_snoozed(base_dir, nickname, domain, optionsActor): - snoozeButtonStr = 'Unsnooze' + if is_person_snoozed(base_dir, nickname, domain, options_actor): + snooze_button_str = 'Unsnooze' - donateStr = '' + donate_str = '' if donate_url: - donateStr = \ + donate_str = \ ' \n' - instanceTitle = \ + instance_title = \ get_config_param(base_dir, 'instanceTitle') - optionsStr = \ - html_header_with_external_style(css_filename, instanceTitle, None) - optionsStr += html_keyboard_navigation(text_mode_banner, {}, {}) - optionsStr += '

\n' - optionsStr += '
\n' - optionsStr += '
\n' - optionsStr += '
\n' - optionsStr += ' \n' - optionsStr += ' \n' + options_str += '
\n' + options_str += '
\n' + options_str += ' \n' + options_str += ' \n' - handle = get_nickname_from_actor(optionsActor) + '@' + optionsDomain - handleShown = handle - if lockedAccount: - handleShown += '🔒' - if movedTo: - handleShown += ' ⌂' + handle = get_nickname_from_actor(options_actor) + '@' + options_domain + handle_shown = handle + if locked_account: + handle_shown += '🔒' + if moved_to: + handle_shown += ' ⌂' if dormant: - handleShown += ' 💤' - optionsStr += \ + handle_shown += ' 💤' + options_str += \ '

' + translate['Options for'] + \ - ' @' + handleShown + '

\n' - if followsYou: - optionsStr += \ + ' @' + handle_shown + '

\n' + if follows_you: + options_str += \ '

' + translate['Follows you'] + '

\n' - if movedTo: - newNickname = get_nickname_from_actor(movedTo) - newDomain, newPort = get_domain_from_actor(movedTo) - if newNickname and newDomain: - newHandle = newNickname + '@' + newDomain - optionsStr += \ + if moved_to: + new_nickname = get_nickname_from_actor(moved_to) + new_domain, _ = get_domain_from_actor(moved_to) + if new_nickname and new_domain: + new_handle = new_nickname + '@' + new_domain + options_str += \ '

' + \ translate['New account'] + \ - ': @' + newHandle + '

\n' - elif alsoKnownAs: - otherAccountsHtml = \ + ': @' + new_handle + '

\n' + elif also_known_as: + other_accounts_html = \ '

' + \ translate['Other accounts'] + ': ' ctr = 0 - if isinstance(alsoKnownAs, list): - for altActor in alsoKnownAs: - if altActor == optionsActor: + if isinstance(also_known_as, list): + for alt_actor in also_known_as: + if alt_actor == options_actor: continue if ctr > 0: - otherAccountsHtml += ' ' + other_accounts_html += ' ' ctr += 1 - altDomain, altPort = get_domain_from_actor(altActor) - otherAccountsHtml += \ - '' + altDomain + '' - elif isinstance(alsoKnownAs, str): - if alsoKnownAs != optionsActor: + alt_domain, _ = get_domain_from_actor(alt_actor) + other_accounts_html += \ + '' + alt_domain + '' + elif isinstance(also_known_as, str): + if also_known_as != options_actor: ctr += 1 - altDomain, altPort = get_domain_from_actor(alsoKnownAs) - otherAccountsHtml += \ - '' + altDomain + '' - otherAccountsHtml += '

\n' + alt_domain, _ = get_domain_from_actor(also_known_as) + other_accounts_html += \ + '' + alt_domain + '' + other_accounts_html += '

\n' if ctr > 0: - optionsStr += otherAccountsHtml + options_str += other_accounts_html if email_address: - optionsStr += \ + options_str += \ '

' + translate['Email'] + \ ': ' + remove_html(email_address) + '

\n' if xmpp_address: - optionsStr += \ + options_str += \ '

' + translate['XMPP'] + \ ': ' + \ xmpp_address + '

\n' if matrix_address: - optionsStr += \ + options_str += \ '

' + translate['Matrix'] + ': ' + \ remove_html(matrix_address) + '

\n' if ssb_address: - optionsStr += \ + options_str += \ '

SSB: ' + remove_html(ssb_address) + '

\n' if blog_address: - optionsStr += \ + options_str += \ '

Blog: ' + \ remove_html(blog_address) + '

\n' if tox_address: - optionsStr += \ + options_str += \ '

Tox: ' + remove_html(tox_address) + '

\n' if briar_address: if briar_address.startswith('briar://'): - optionsStr += \ + options_str += \ '

' + \ remove_html(briar_address) + '

\n' else: - optionsStr += \ + options_str += \ '

briar://' + \ remove_html(briar_address) + '

\n' if jami_address: - optionsStr += \ + options_str += \ '

Jami: ' + remove_html(jami_address) + '

\n' if cwtch_address: - optionsStr += \ + options_str += \ '

Cwtch: ' + remove_html(cwtch_address) + '

\n' if enigma_pub_key: - optionsStr += \ + options_str += \ '

Enigma: ' + \ remove_html(enigma_pub_key) + '

\n' if pgp_fingerprint: - optionsStr += '

PGP: ' + \ + options_str += '

PGP: ' + \ remove_html(pgp_fingerprint).replace('\n', '
') + '

\n' if pgp_pub_key: - optionsStr += '

' + \ + options_str += '

' + \ remove_html(pgp_pub_key).replace('\n', '
') + '

\n' - optionsStr += '
\n' - optionsStr += ' \n' - optionsStr += ' \n' - optionsStr += ' \n' + options_str += ' \n' + options_str += ' \n' + options_str += ' \n' + options_str += ' \n' if authorized: - if originPathStr == '/users/' + nickname: - if optionsNickname: - # handle = optionsNickname + '@' + optionsDomainFull + if origin_path_str == '/users/' + nickname: + if options_nickname: + # handle = options_nickname + '@' + options_domain_full petname = get_pet_name(base_dir, nickname, domain, handle) - optionsStr += \ + options_str += \ ' ' + translate['Petname'] + ': \n' + \ '
\n' # Notify when a post arrives from this person - if is_following_actor(base_dir, nickname, domain, optionsActor): - checkboxStr = \ + if is_following_actor(base_dir, nickname, domain, options_actor): + checkbox_str = \ ' 🔔' + \ translate['Notify me when this account posts'] + \ @@ -270,12 +270,12 @@ def html_person_options(default_timeline: str, 'name="submitNotifyOnPost">' + \ translate['Submit'] + '
\n' if not notify_when_person_posts(base_dir, nickname, domain, - optionsNickname, - optionsDomainFull): - checkboxStr = checkboxStr.replace(' checked>', '>') - optionsStr += checkboxStr + options_nickname, + options_domain_full): + checkbox_str = checkbox_str.replace(' checked>', '>') + options_str += checkbox_str - checkboxStr = \ + checkbox_str = \ ' ' + \ translate['Receive calendar events from this account'] + \ @@ -283,22 +283,23 @@ def html_person_options(default_timeline: str, 'name="submitOnCalendar">' + \ translate['Submit'] + '
\n' if not receiving_calendar_events(base_dir, nickname, domain, - optionsNickname, - optionsDomainFull): - checkboxStr = checkboxStr.replace(' checked>', '>') - optionsStr += checkboxStr + options_nickname, + options_domain_full): + checkbox_str = checkbox_str.replace(' checked>', '>') + options_str += checkbox_str # checkbox for permission to post to newswire - newswirePostsPermitted = False - if optionsDomainFull == domain_full: + newswire_posts_permitted = False + if options_domain_full == domain_full: admin_nickname = get_config_param(base_dir, 'admin') if (nickname == admin_nickname or (is_moderator(base_dir, nickname) and - not is_moderator(base_dir, optionsNickname))): - newswireBlockedFilename = \ + not is_moderator(base_dir, options_nickname))): + newswire_blocked_filename = \ base_dir + '/accounts/' + \ - optionsNickname + '@' + optionsDomain + '/.nonewswire' - checkboxStr = \ + options_nickname + '@' + options_domain + \ + '/.nonewswire' + checkbox_str = \ ' ' + \ @@ -306,37 +307,37 @@ def html_person_options(default_timeline: str, '\n
\n' - if os.path.isfile(newswireBlockedFilename): - checkboxStr = checkboxStr.replace(' checked>', '>') + if os.path.isfile(newswire_blocked_filename): + checkbox_str = checkbox_str.replace(' checked>', '>') else: - newswirePostsPermitted = True - optionsStr += checkboxStr + newswire_posts_permitted = True + options_str += checkbox_str # whether blogs created by this account are moderated on # the newswire - if newswirePostsPermitted: - moderatedFilename = \ + if newswire_posts_permitted: + moderated_filename = \ base_dir + '/accounts/' + \ - optionsNickname + '@' + \ - optionsDomain + '/.newswiremoderated' - checkboxStr = \ + options_nickname + '@' + \ + options_domain + '/.newswiremoderated' + checkbox_str = \ ' ' + \ translate['News posts are moderated'] + \ '\n
\n' - if not os.path.isfile(moderatedFilename): - checkboxStr = checkboxStr.replace(' checked>', '>') - optionsStr += checkboxStr + if not os.path.isfile(moderated_filename): + checkbox_str = checkbox_str.replace(' checked>', '>') + options_str += checkbox_str # checkbox for permission to post to featured articles - if news_instance and optionsDomainFull == domain_full: + if news_instance and options_domain_full == domain_full: admin_nickname = get_config_param(base_dir, 'admin') if (nickname == admin_nickname or (is_moderator(base_dir, nickname) and - not is_moderator(base_dir, optionsNickname))): - checkboxStr = \ + not is_moderator(base_dir, options_nickname))): + checkbox_str = \ ' ' + \ @@ -344,92 +345,92 @@ def html_person_options(default_timeline: str, '\n
\n' - if not is_featured_writer(base_dir, optionsNickname, - optionsDomain): - checkboxStr = checkboxStr.replace(' checked>', '>') - optionsStr += checkboxStr + if not is_featured_writer(base_dir, options_nickname, + options_domain): + checkbox_str = checkbox_str.replace(' checked>', '>') + options_str += checkbox_str - optionsStr += optionsLinkStr - backPath = '/' + options_str += options_link_str + back_path = '/' if nickname: - backPath = '/users/' + nickname + '/' + default_timeline - if 'moderation' in backToPath: - backPath = '/users/' + nickname + '/moderation' - if authorized and originPathStr == '/users/' + nickname: - optionsStr += \ - ' \n' else: - optionsStr += \ - ' \n' if authorized: - optionsStr += \ + options_str += \ ' \n' - optionsStr += donateStr + options_str += donate_str if authorized: - optionsStr += \ + options_str += \ ' \n' - optionsStr += \ + translate[follow_str] + '\n' + options_str += \ ' \n' - optionsStr += \ + block_str + '" accesskey="' + access_keys['blockButton'] + '">' + \ + translate[block_str] + '\n' + options_str += \ ' \n' - optionsStr += \ + options_str += \ ' \n' - optionsStr += \ + snooze_button_str + '" accesskey="' + \ + access_keys['snoozeButton'] + '">' + \ + translate[snooze_button_str] + '\n' + options_str += \ ' \n' if is_moderator(base_dir, nickname): - optionsStr += \ + options_str += \ ' \n' - personNotes = '' - if originPathStr == '/users/' + nickname: - personNotesFilename = \ + person_notes = '' + if origin_path_str == '/users/' + nickname: + person_notes_filename = \ acct_dir(base_dir, nickname, domain) + \ '/notes/' + handle + '.txt' - if os.path.isfile(personNotesFilename): - with open(personNotesFilename, 'r') as fp: - personNotes = fp.read() + if os.path.isfile(person_notes_filename): + with open(person_notes_filename, 'r') as fp_notes: + person_notes = fp_notes.read() - optionsStr += \ + options_str += \ '

' + translate['Notes'] + ': \n' - optionsStr += '
\n' - optionsStr += \ + options_str += \ ' \n' + person_notes + '\n' - optionsStr += \ + options_str += \ '
\n' + \ '
\n' + \ '
\n' + \ '
\n' - optionsStr += html_footer() - return optionsStr + options_str += html_footer() + return options_str