mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
4c1eccc628
commit
369a9f311f
|
@ -11,7 +11,6 @@ import os
|
||||||
import time
|
import time
|
||||||
import random
|
import random
|
||||||
from utils import get_full_domain
|
from utils import get_full_domain
|
||||||
from utils import acct_dir
|
|
||||||
from utils import is_account_dir
|
from utils import is_account_dir
|
||||||
from utils import get_nickname_from_actor
|
from utils import get_nickname_from_actor
|
||||||
from utils import get_domain_from_actor
|
from utils import get_domain_from_actor
|
||||||
|
@ -20,6 +19,7 @@ from follow import send_follow_request
|
||||||
from session import create_session
|
from session import create_session
|
||||||
from session import set_session_for_sender
|
from session import set_session_for_sender
|
||||||
from threads import begin_thread
|
from threads import begin_thread
|
||||||
|
from person import set_person_notes
|
||||||
|
|
||||||
|
|
||||||
def _establish_import_session(httpd,
|
def _establish_import_session(httpd,
|
||||||
|
@ -89,16 +89,8 @@ def _update_import_following(base_dir: str,
|
||||||
get_full_domain(following_domain, following_port)
|
get_full_domain(following_domain, following_port)
|
||||||
if notes:
|
if notes:
|
||||||
notes = notes.replace('<br>', '\n')
|
notes = notes.replace('<br>', '\n')
|
||||||
person_notes_filename = \
|
set_person_notes(base_dir, nickname, domain,
|
||||||
acct_dir(base_dir, nickname, domain) + \
|
following_handle, notes)
|
||||||
'/notes/' + following_handle + '.txt'
|
|
||||||
try:
|
|
||||||
with open(person_notes_filename, 'w+',
|
|
||||||
encoding='utf-8') as fp_notes:
|
|
||||||
fp_notes.write(notes)
|
|
||||||
except OSError:
|
|
||||||
print('EX: Unable to import notes for ' +
|
|
||||||
following_handle)
|
|
||||||
if is_following_actor(base_dir, nickname, domain,
|
if is_following_actor(base_dir, nickname, domain,
|
||||||
following_handle_full):
|
following_handle_full):
|
||||||
# remove the followed handle from the import list
|
# remove the followed handle from the import list
|
||||||
|
|
15
person.py
15
person.py
|
@ -1600,6 +1600,21 @@ def set_person_notes(base_dir: str, nickname: str, domain: str,
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def get_person_notes(base_dir: str, nickname: str, domain: str,
|
||||||
|
handle: str) -> str:
|
||||||
|
"""Returns notes about a person
|
||||||
|
"""
|
||||||
|
person_notes = ''
|
||||||
|
person_notes_filename = \
|
||||||
|
acct_dir(base_dir, nickname, domain) + \
|
||||||
|
'/notes/' + handle + '.txt'
|
||||||
|
if os.path.isfile(person_notes_filename):
|
||||||
|
with open(person_notes_filename, 'r',
|
||||||
|
encoding='utf-8') as fp_notes:
|
||||||
|
person_notes = fp_notes.read()
|
||||||
|
return person_notes
|
||||||
|
|
||||||
|
|
||||||
def _detect_users_path(url: str) -> str:
|
def _detect_users_path(url: str) -> str:
|
||||||
"""Tries to detect the /users/ path
|
"""Tries to detect the /users/ path
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -27,6 +27,7 @@ from follow import is_follower_of_person
|
||||||
from follow import is_following_actor
|
from follow import is_following_actor
|
||||||
from followingCalendar import receiving_calendar_events
|
from followingCalendar import receiving_calendar_events
|
||||||
from notifyOnPost import notify_when_person_posts
|
from notifyOnPost import notify_when_person_posts
|
||||||
|
from person import get_person_notes
|
||||||
from webapp_utils import html_header_with_external_style
|
from webapp_utils import html_header_with_external_style
|
||||||
from webapp_utils import html_footer
|
from webapp_utils import html_footer
|
||||||
from webapp_utils import get_broken_link_substitute
|
from webapp_utils import get_broken_link_substitute
|
||||||
|
@ -628,13 +629,8 @@ def html_person_options(default_timeline: str,
|
||||||
|
|
||||||
person_notes = ''
|
person_notes = ''
|
||||||
if origin_path_str == '/users/' + nickname:
|
if origin_path_str == '/users/' + nickname:
|
||||||
person_notes_filename = \
|
person_notes = \
|
||||||
acct_dir(base_dir, nickname, domain) + \
|
get_person_notes(base_dir, nickname, domain, handle)
|
||||||
'/notes/' + handle + '.txt'
|
|
||||||
if os.path.isfile(person_notes_filename):
|
|
||||||
with open(person_notes_filename, 'r',
|
|
||||||
encoding='utf-8') as fp_notes:
|
|
||||||
person_notes = fp_notes.read()
|
|
||||||
|
|
||||||
options_str += \
|
options_str += \
|
||||||
' <br><br>' + translate['Notes'] + ': \n'
|
' <br><br>' + translate['Notes'] + ': \n'
|
||||||
|
|
|
@ -43,6 +43,7 @@ from cache import store_person_in_cache
|
||||||
from content import add_html_tags
|
from content import add_html_tags
|
||||||
from content import replace_emoji_from_tags
|
from content import replace_emoji_from_tags
|
||||||
from person import get_person_avatar_url
|
from person import get_person_avatar_url
|
||||||
|
from person import get_person_notes
|
||||||
from posts import is_moderator
|
from posts import is_moderator
|
||||||
from blocking import is_blocked
|
from blocking import is_blocked
|
||||||
from blocking import allowed_announce
|
from blocking import allowed_announce
|
||||||
|
@ -137,14 +138,11 @@ def csv_following_list(following_filename: str,
|
||||||
following_domain)
|
following_domain)
|
||||||
notify_on_new = 'false'
|
notify_on_new = 'false'
|
||||||
languages = ''
|
languages = ''
|
||||||
person_notes = ''
|
person_notes = \
|
||||||
person_notes_filename = \
|
get_person_notes(base_dir, nickname, domain,
|
||||||
acct_dir(base_dir, nickname, domain) + \
|
following_address)
|
||||||
'/notes/' + following_address + '.txt'
|
if person_notes:
|
||||||
if os.path.isfile(person_notes_filename):
|
# make notes suitable for csv file
|
||||||
with open(person_notes_filename, 'r',
|
|
||||||
encoding='utf-8') as fp_notes:
|
|
||||||
person_notes = fp_notes.read()
|
|
||||||
person_notes = person_notes.replace(',', ' ')
|
person_notes = person_notes.replace(',', ' ')
|
||||||
person_notes = person_notes.replace('"', "'")
|
person_notes = person_notes.replace('"', "'")
|
||||||
person_notes = person_notes.replace('\n', '<br>')
|
person_notes = person_notes.replace('\n', '<br>')
|
||||||
|
|
Loading…
Reference in New Issue