mirror of https://gitlab.com/bashrc2/epicyon
Import notes from following csv
parent
a6d90d0ae6
commit
5a9ef67775
|
@ -10,6 +10,7 @@ __module_group__ = "Core"
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import random
|
import random
|
||||||
|
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
|
||||||
|
@ -58,9 +59,13 @@ def _update_import_following(base_dir: str,
|
||||||
domain = handle.split('@')[1]
|
domain = handle.split('@')[1]
|
||||||
for line in lines:
|
for line in lines:
|
||||||
orig_line = line
|
orig_line = line
|
||||||
|
notes = None
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if ',' in line:
|
if ',' in line:
|
||||||
line = line.split(',')[0].strip()
|
fields = line.split(',')
|
||||||
|
line = fields[0].strip()
|
||||||
|
if len(fields) >= 3:
|
||||||
|
notes = fields[2]
|
||||||
if line.startswith('#'):
|
if line.startswith('#'):
|
||||||
continue
|
continue
|
||||||
following_nickname = get_nickname_from_actor(line)
|
following_nickname = get_nickname_from_actor(line)
|
||||||
|
@ -74,6 +79,17 @@ def _update_import_following(base_dir: str,
|
||||||
# don't follow yourself
|
# don't follow yourself
|
||||||
continue
|
continue
|
||||||
following_handle = following_nickname + '@' + following_domain
|
following_handle = following_nickname + '@' + following_domain
|
||||||
|
if notes:
|
||||||
|
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)
|
||||||
if is_following_actor(base_dir,
|
if is_following_actor(base_dir,
|
||||||
nickname, domain, following_handle):
|
nickname, domain, following_handle):
|
||||||
# remove the followed handle from the import list
|
# remove the followed handle from the import list
|
||||||
|
|
|
@ -122,6 +122,8 @@ def csv_following_list(following_filename: str,
|
||||||
with open(person_notes_filename, 'r',
|
with open(person_notes_filename, 'r',
|
||||||
encoding='utf-8') as fp_notes:
|
encoding='utf-8') as fp_notes:
|
||||||
person_notes = fp_notes.read()
|
person_notes = fp_notes.read()
|
||||||
|
person_notes = person_notes.replace(',', ' ')
|
||||||
|
person_notes = person_notes.replace(' ', ' ')
|
||||||
following_list_csv += person_notes
|
following_list_csv += person_notes
|
||||||
msg = 'Account address,Show boosts,Notes\n' + following_list_csv
|
msg = 'Account address,Show boosts,Notes\n' + following_list_csv
|
||||||
return msg
|
return msg
|
||||||
|
|
Loading…
Reference in New Issue