mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of ssh://code.freedombone.net:2222/bashrc/epicyon
commit
e5557f01dc
|
|
@ -9,6 +9,7 @@ __status__ = "Production"
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from utils import isAccountDir
|
||||||
from utils import getCachedPostFilename
|
from utils import getCachedPostFilename
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import saveJson
|
from utils import saveJson
|
||||||
|
|
@ -660,9 +661,7 @@ def setBrochMode(baseDir: str, domainFull: str, enabled: bool) -> None:
|
||||||
followFiles = ('following.txt', 'followers.txt')
|
followFiles = ('following.txt', 'followers.txt')
|
||||||
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
||||||
for acct in dirs:
|
for acct in dirs:
|
||||||
if '@' not in acct:
|
if not isAccountDir(acct):
|
||||||
continue
|
|
||||||
if 'inbox@' in acct or 'news@' in acct:
|
|
||||||
continue
|
continue
|
||||||
accountDir = os.path.join(baseDir + '/accounts', acct)
|
accountDir = os.path.join(baseDir + '/accounts', acct)
|
||||||
for followFileType in followFiles:
|
for followFileType in followFiles:
|
||||||
|
|
|
||||||
|
|
@ -203,6 +203,7 @@ from shares import addShare
|
||||||
from shares import removeShare
|
from shares import removeShare
|
||||||
from shares import expireShares
|
from shares import expireShares
|
||||||
from categories import setHashtagCategory
|
from categories import setHashtagCategory
|
||||||
|
from utils import isAccountDir
|
||||||
from utils import getOccupationSkills
|
from utils import getOccupationSkills
|
||||||
from utils import getOccupationName
|
from utils import getOccupationName
|
||||||
from utils import setOccupationName
|
from utils import setOccupationName
|
||||||
|
|
@ -5700,9 +5701,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
msg = ''
|
msg = ''
|
||||||
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
||||||
for acct in dirs:
|
for acct in dirs:
|
||||||
if '@' not in acct:
|
if not isAccountDir(acct):
|
||||||
continue
|
|
||||||
if 'inbox@' in acct or 'news@' in acct:
|
|
||||||
continue
|
continue
|
||||||
nickname = acct.split('@')[0]
|
nickname = acct.split('@')[0]
|
||||||
domain = acct.split('@')[1]
|
domain = acct.split('@')[1]
|
||||||
|
|
|
||||||
26
filters.py
26
filters.py
|
|
@ -47,16 +47,19 @@ def removeFilter(baseDir: str, nickname: str, domain: str,
|
||||||
"""
|
"""
|
||||||
filtersFilename = baseDir + '/accounts/' + \
|
filtersFilename = baseDir + '/accounts/' + \
|
||||||
nickname + '@' + domain + '/filters.txt'
|
nickname + '@' + domain + '/filters.txt'
|
||||||
if os.path.isfile(filtersFilename):
|
if not os.path.isfile(filtersFilename):
|
||||||
if words in open(filtersFilename).read():
|
return False
|
||||||
|
if words not in open(filtersFilename).read():
|
||||||
|
return False
|
||||||
|
newFiltersFilename = filtersFilename + '.new'
|
||||||
with open(filtersFilename, 'r') as fp:
|
with open(filtersFilename, 'r') as fp:
|
||||||
with open(filtersFilename + '.new', 'w+') as fpnew:
|
with open(newFiltersFilename, 'w+') as fpnew:
|
||||||
for line in fp:
|
for line in fp:
|
||||||
line = line.replace('\n', '')
|
line = line.replace('\n', '')
|
||||||
if line != words:
|
if line != words:
|
||||||
fpnew.write(line + '\n')
|
fpnew.write(line + '\n')
|
||||||
if os.path.isfile(filtersFilename + '.new'):
|
if os.path.isfile(newFiltersFilename):
|
||||||
os.rename(filtersFilename + '.new', filtersFilename)
|
os.rename(newFiltersFilename, filtersFilename)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
@ -65,16 +68,19 @@ def removeGlobalFilter(baseDir: str, words: str) -> bool:
|
||||||
"""Removes a global word filter
|
"""Removes a global word filter
|
||||||
"""
|
"""
|
||||||
filtersFilename = baseDir + '/accounts/filters.txt'
|
filtersFilename = baseDir + '/accounts/filters.txt'
|
||||||
if os.path.isfile(filtersFilename):
|
if not os.path.isfile(filtersFilename):
|
||||||
if words in open(filtersFilename).read():
|
return False
|
||||||
|
if words not in open(filtersFilename).read():
|
||||||
|
return False
|
||||||
|
newFiltersFilename = filtersFilename + '.new'
|
||||||
with open(filtersFilename, 'r') as fp:
|
with open(filtersFilename, 'r') as fp:
|
||||||
with open(filtersFilename + '.new', 'w+') as fpnew:
|
with open(newFiltersFilename, 'w+') as fpnew:
|
||||||
for line in fp:
|
for line in fp:
|
||||||
line = line.replace('\n', '')
|
line = line.replace('\n', '')
|
||||||
if line != words:
|
if line != words:
|
||||||
fpnew.write(line + '\n')
|
fpnew.write(line + '\n')
|
||||||
if os.path.isfile(filtersFilename + '.new'):
|
if os.path.isfile(newFiltersFilename):
|
||||||
os.rename(filtersFilename + '.new', filtersFilename)
|
os.rename(newFiltersFilename, filtersFilename)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ from posts import sendSignedJson
|
||||||
from posts import getPersonBox
|
from posts import getPersonBox
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import saveJson
|
from utils import saveJson
|
||||||
|
from utils import isAccountDir
|
||||||
from acceptreject import createAccept
|
from acceptreject import createAccept
|
||||||
from acceptreject import createReject
|
from acceptreject import createReject
|
||||||
from webfinger import webfingerHandle
|
from webfinger import webfingerHandle
|
||||||
|
|
@ -31,13 +32,13 @@ from session import postJson
|
||||||
|
|
||||||
|
|
||||||
def createInitialLastSeen(baseDir: str, httpPrefix: str) -> None:
|
def createInitialLastSeen(baseDir: str, httpPrefix: str) -> None:
|
||||||
"""Creates initial lastseen files for all follows
|
"""Creates initial lastseen files for all follows.
|
||||||
|
The lastseen files are used to generate the Zzz icons on
|
||||||
|
follows/following lists on the profile screen.
|
||||||
"""
|
"""
|
||||||
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
||||||
for acct in dirs:
|
for acct in dirs:
|
||||||
if '@' not in acct:
|
if not isAccountDir(acct):
|
||||||
continue
|
|
||||||
if 'inbox@' in acct or 'news@' in acct:
|
|
||||||
continue
|
continue
|
||||||
accountDir = os.path.join(baseDir + '/accounts', acct)
|
accountDir = os.path.join(baseDir + '/accounts', acct)
|
||||||
followingFilename = accountDir + '/following.txt'
|
followingFilename = accountDir + '/following.txt'
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ __email__ = "bob@freedombone.net"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from utils import isAccountDir
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import noOfAccounts
|
from utils import noOfAccounts
|
||||||
from utils import noOfActiveAccountsMonthly
|
from utils import noOfActiveAccountsMonthly
|
||||||
|
|
@ -19,9 +20,7 @@ def _getStatusCount(baseDir: str) -> int:
|
||||||
accountsDir = baseDir + '/accounts'
|
accountsDir = baseDir + '/accounts'
|
||||||
for subdir, dirs, files in os.walk(accountsDir):
|
for subdir, dirs, files in os.walk(accountsDir):
|
||||||
for acct in dirs:
|
for acct in dirs:
|
||||||
if '@' not in acct:
|
if not isAccountDir(acct):
|
||||||
continue
|
|
||||||
if 'inbox@' in acct or 'news@' in acct:
|
|
||||||
continue
|
continue
|
||||||
acctDir = os.path.join(accountsDir, acct + '/outbox')
|
acctDir = os.path.join(accountsDir, acct + '/outbox')
|
||||||
for subdir2, dirs2, files2 in os.walk(acctDir):
|
for subdir2, dirs2, files2 in os.walk(acctDir):
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,11 @@ def setActorSkillLevel(actorJson: {},
|
||||||
]
|
]
|
||||||
ocSkillsList = getOccupationSkills(actorJson)
|
ocSkillsList = getOccupationSkills(actorJson)
|
||||||
skillsDict = getSkillsFromList(ocSkillsList)
|
skillsDict = getSkillsFromList(ocSkillsList)
|
||||||
|
if not skillsDict.get(skill):
|
||||||
|
if len(skillsDict.items()) >= 32:
|
||||||
|
print('WARN: Maximum number of skills reached for ' +
|
||||||
|
actorJson['id'])
|
||||||
|
return False
|
||||||
if skillLevelPercent > 0:
|
if skillLevelPercent > 0:
|
||||||
skillsDict[skill] = skillLevelPercent
|
skillsDict[skill] = skillLevelPercent
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
10
utils.py
10
utils.py
|
|
@ -2400,3 +2400,13 @@ def setOccupationSkillsList(actorJson: {}, skillsList: []) -> bool:
|
||||||
occupationItem['skills'] = skillsList
|
occupationItem['skills'] = skillsList
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def isAccountDir(dirName: str) -> bool:
|
||||||
|
"""Is the given directory an account within /accounts ?
|
||||||
|
"""
|
||||||
|
if '@' not in dirName:
|
||||||
|
return False
|
||||||
|
if 'inbox@' in dirName or 'news@' in dirName:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ __email__ = "bob@freedombone.net"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from utils import isAccountDir
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import getConfigParam
|
from utils import getConfigParam
|
||||||
from webapp_utils import htmlHeaderWithExternalStyle
|
from webapp_utils import htmlHeaderWithExternalStyle
|
||||||
|
|
@ -19,9 +20,7 @@ def loadAccessKeysForAccounts(baseDir: str, keyShortcuts: {},
|
||||||
"""
|
"""
|
||||||
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
||||||
for acct in dirs:
|
for acct in dirs:
|
||||||
if '@' not in acct:
|
if not isAccountDir(acct):
|
||||||
continue
|
|
||||||
if 'inbox@' in acct or 'news@' in acct:
|
|
||||||
continue
|
continue
|
||||||
accountDir = os.path.join(baseDir + '/accounts', acct)
|
accountDir = os.path.join(baseDir + '/accounts', acct)
|
||||||
accessKeysFilename = accountDir + '/accessKeys.json'
|
accessKeysFilename = accountDir + '/accessKeys.json'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue