mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
4c1eccc628
commit
369a9f311f
|
@ -11,7 +11,6 @@ import os
|
|||
import time
|
||||
import random
|
||||
from utils import get_full_domain
|
||||
from utils import acct_dir
|
||||
from utils import is_account_dir
|
||||
from utils import get_nickname_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 set_session_for_sender
|
||||
from threads import begin_thread
|
||||
from person import set_person_notes
|
||||
|
||||
|
||||
def _establish_import_session(httpd,
|
||||
|
@ -89,16 +89,8 @@ def _update_import_following(base_dir: str,
|
|||
get_full_domain(following_domain, following_port)
|
||||
if notes:
|
||||
notes = notes.replace('<br>', '\n')
|
||||
person_notes_filename = \
|
||||
acct_dir(base_dir, nickname, domain) + \
|
||||
'/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)
|
||||
set_person_notes(base_dir, nickname, domain,
|
||||
following_handle, notes)
|
||||
if is_following_actor(base_dir, nickname, domain,
|
||||
following_handle_full):
|
||||
# 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
|
||||
|
||||
|
||||
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:
|
||||
"""Tries to detect the /users/ path
|
||||
"""
|
||||
|
|
|
@ -27,6 +27,7 @@ from follow import is_follower_of_person
|
|||
from follow import is_following_actor
|
||||
from followingCalendar import receiving_calendar_events
|
||||
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_footer
|
||||
from webapp_utils import get_broken_link_substitute
|
||||
|
@ -628,13 +629,8 @@ def html_person_options(default_timeline: str,
|
|||
|
||||
person_notes = ''
|
||||
if origin_path_str == '/users/' + nickname:
|
||||
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()
|
||||
person_notes = \
|
||||
get_person_notes(base_dir, nickname, domain, handle)
|
||||
|
||||
options_str += \
|
||||
' <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 replace_emoji_from_tags
|
||||
from person import get_person_avatar_url
|
||||
from person import get_person_notes
|
||||
from posts import is_moderator
|
||||
from blocking import is_blocked
|
||||
from blocking import allowed_announce
|
||||
|
@ -137,14 +138,11 @@ def csv_following_list(following_filename: str,
|
|||
following_domain)
|
||||
notify_on_new = 'false'
|
||||
languages = ''
|
||||
person_notes = ''
|
||||
person_notes_filename = \
|
||||
acct_dir(base_dir, nickname, domain) + \
|
||||
'/notes/' + following_address + '.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()
|
||||
person_notes = \
|
||||
get_person_notes(base_dir, nickname, domain,
|
||||
following_address)
|
||||
if person_notes:
|
||||
# make notes suitable for csv file
|
||||
person_notes = person_notes.replace(',', ' ')
|
||||
person_notes = person_notes.replace('"', "'")
|
||||
person_notes = person_notes.replace('\n', '<br>')
|
||||
|
|
Loading…
Reference in New Issue