diff --git a/importFollowing.py b/importFollowing.py
index 9848983f3..55a5c854e 100644
--- a/importFollowing.py
+++ b/importFollowing.py
@@ -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('
', '\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
diff --git a/person.py b/person.py
index 95e66adb4..c78db305e 100644
--- a/person.py
+++ b/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
"""
diff --git a/webapp_person_options.py b/webapp_person_options.py
index 4fb09ea1e..1f0573a8f 100644
--- a/webapp_person_options.py
+++ b/webapp_person_options.py
@@ -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 += \
'
' + translate['Notes'] + ': \n'
diff --git a/webapp_utils.py b/webapp_utils.py
index 9a6497799..14d3ee955 100644
--- a/webapp_utils.py
+++ b/webapp_utils.py
@@ -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,18 +138,15 @@ 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 = person_notes.replace(',', ' ')
- person_notes = person_notes.replace('"', "'")
- person_notes = person_notes.replace('\n', '
')
- person_notes = person_notes.replace(' ', ' ')
+ 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', '
')
+ person_notes = person_notes.replace(' ', ' ')
if not following_list_csv:
following_list_csv = \
'Account address,Show boosts,' + \