mirror of https://gitlab.com/bashrc2/epicyon
File open attribute style
parent
d502cd89f9
commit
5e2b02ad81
6
auth.py
6
auth.py
|
@ -132,7 +132,7 @@ def authorizeBasic(baseDir: str, path: str, authHeader: str,
|
|||
print('DEBUG: passwords file missing')
|
||||
return False
|
||||
providedPassword = plain.split(':')[1]
|
||||
passfile = open(passwordFile, "r")
|
||||
passfile = open(passwordFile, 'r')
|
||||
for line in passfile:
|
||||
if line.startswith(nickname + ':'):
|
||||
storedPassword = \
|
||||
|
@ -162,7 +162,7 @@ def storeBasicCredentials(baseDir: str, nickname: str, password: str) -> bool:
|
|||
storeStr = nickname + ':' + _hashPassword(password)
|
||||
if os.path.isfile(passwordFile):
|
||||
if nickname + ':' in open(passwordFile).read():
|
||||
with open(passwordFile, "r") as fin:
|
||||
with open(passwordFile, 'r') as fin:
|
||||
with open(passwordFile + '.new', 'w+') as fout:
|
||||
for line in fin:
|
||||
if not line.startswith(nickname + ':'):
|
||||
|
@ -186,7 +186,7 @@ def removePassword(baseDir: str, nickname: str) -> None:
|
|||
"""
|
||||
passwordFile = baseDir + '/accounts/passwords'
|
||||
if os.path.isfile(passwordFile):
|
||||
with open(passwordFile, "r") as fin:
|
||||
with open(passwordFile, 'r') as fin:
|
||||
with open(passwordFile + '.new', 'w+') as fout:
|
||||
for line in fin:
|
||||
if not line.startswith(nickname + ':'):
|
||||
|
|
|
@ -720,7 +720,7 @@ def setBrochMode(baseDir: str, domainFull: str, enabled: bool) -> None:
|
|||
followingFilename = accountDir + '/' + followFileType
|
||||
if not os.path.isfile(followingFilename):
|
||||
continue
|
||||
with open(followingFilename, "r") as f:
|
||||
with open(followingFilename, 'r') as f:
|
||||
followList = f.readlines()
|
||||
for handle in followList:
|
||||
if '@' not in handle:
|
||||
|
|
8
blog.py
8
blog.py
|
@ -65,7 +65,7 @@ def _noOfBlogReplies(baseDir: str, httpPrefix: str, translate: {},
|
|||
removals = []
|
||||
replies = 0
|
||||
lines = []
|
||||
with open(postFilename, "r") as f:
|
||||
with open(postFilename, 'r') as f:
|
||||
lines = f.readlines()
|
||||
for replyPostId in lines:
|
||||
replyPostId = replyPostId.replace('\n', '').replace('\r', '')
|
||||
|
@ -124,11 +124,11 @@ def _getBlogReplies(baseDir: str, httpPrefix: str, translate: {},
|
|||
'/postcache/' + \
|
||||
postId.replace('/', '#') + '.html'
|
||||
if os.path.isfile(postFilename):
|
||||
with open(postFilename, "r") as postFile:
|
||||
with open(postFilename, 'r') as postFile:
|
||||
return postFile.read() + '\n'
|
||||
return ''
|
||||
|
||||
with open(postFilename, "r") as f:
|
||||
with open(postFilename, 'r') as f:
|
||||
lines = f.readlines()
|
||||
repliesStr = ''
|
||||
for replyPostId in lines:
|
||||
|
@ -141,7 +141,7 @@ def _getBlogReplies(baseDir: str, httpPrefix: str, translate: {},
|
|||
replyPostId.replace('/', '#') + '.html'
|
||||
if not os.path.isfile(postFilename):
|
||||
continue
|
||||
with open(postFilename, "r") as postFile:
|
||||
with open(postFilename, 'r') as postFile:
|
||||
repliesStr += postFile.read() + '\n'
|
||||
rply = _getBlogReplies(baseDir, httpPrefix, translate,
|
||||
nickname, domain, domainFull,
|
||||
|
|
4
city.py
4
city.py
|
@ -195,7 +195,7 @@ def spoofGeolocation(baseDir: str,
|
|||
default_latdirection, default_longdirection,
|
||||
"", "", 0)
|
||||
cities = []
|
||||
with open(locationsFilename, "r") as f:
|
||||
with open(locationsFilename, 'r') as f:
|
||||
cities = f.readlines()
|
||||
|
||||
nogo = []
|
||||
|
@ -203,7 +203,7 @@ def spoofGeolocation(baseDir: str,
|
|||
nogo = nogoList
|
||||
else:
|
||||
if os.path.isfile(nogoFilename):
|
||||
with open(nogoFilename, "r") as f:
|
||||
with open(nogoFilename, 'r') as f:
|
||||
nogoList = f.readlines()
|
||||
for line in nogoList:
|
||||
if line.startswith(city + ':'):
|
||||
|
|
|
@ -709,7 +709,7 @@ def _loadAutoTags(baseDir: str, nickname: str, domain: str) -> []:
|
|||
nickname + '@' + domain + '/autotags.txt'
|
||||
if not os.path.isfile(filename):
|
||||
return []
|
||||
with open(filename, "r") as f:
|
||||
with open(filename, 'r') as f:
|
||||
return f.readlines()
|
||||
return []
|
||||
|
||||
|
@ -784,7 +784,7 @@ def addHtmlTags(baseDir: str, httpPrefix: str,
|
|||
petnames = None
|
||||
if '@' in words:
|
||||
if os.path.isfile(followingFilename):
|
||||
with open(followingFilename, "r") as f:
|
||||
with open(followingFilename, 'r') as f:
|
||||
following = f.readlines()
|
||||
for handle in following:
|
||||
pet = getPetName(baseDir, nickname, domain, handle)
|
||||
|
|
14
follow.py
14
follow.py
|
@ -257,7 +257,7 @@ def unfollowAccount(baseDir: str, nickname: str, domain: str,
|
|||
print('DEBUG: handle to unfollow ' + handleToUnfollow +
|
||||
' is not in ' + filename)
|
||||
return
|
||||
with open(filename, "r") as f:
|
||||
with open(filename, 'r') as f:
|
||||
lines = f.readlines()
|
||||
with open(filename, 'w+') as f:
|
||||
for line in lines:
|
||||
|
@ -271,10 +271,10 @@ def unfollowAccount(baseDir: str, nickname: str, domain: str,
|
|||
if os.path.isfile(unfollowedFilename):
|
||||
if handleToUnfollowLower not in \
|
||||
open(unfollowedFilename).read().lower():
|
||||
with open(unfollowedFilename, "a+") as f:
|
||||
with open(unfollowedFilename, 'a+') as f:
|
||||
f.write(handleToUnfollow + '\n')
|
||||
else:
|
||||
with open(unfollowedFilename, "w+") as f:
|
||||
with open(unfollowedFilename, 'w+') as f:
|
||||
f.write(handleToUnfollow + '\n')
|
||||
|
||||
return True
|
||||
|
@ -324,7 +324,7 @@ def _getNoOfFollows(baseDir: str, nickname: str, domain: str,
|
|||
if not os.path.isfile(filename):
|
||||
return 0
|
||||
ctr = 0
|
||||
with open(filename, "r") as f:
|
||||
with open(filename, 'r') as f:
|
||||
lines = f.readlines()
|
||||
for line in lines:
|
||||
if '#' in line:
|
||||
|
@ -435,7 +435,7 @@ def getFollowingFeed(baseDir: str, domain: str, port: int, path: str,
|
|||
currPage = 1
|
||||
pageCtr = 0
|
||||
totalCtr = 0
|
||||
with open(filename, "r") as f:
|
||||
with open(filename, 'r') as f:
|
||||
lines = f.readlines()
|
||||
for line in lines:
|
||||
if '#' not in line:
|
||||
|
@ -516,7 +516,7 @@ def _noOfFollowRequests(baseDir: str,
|
|||
if not os.path.isfile(approveFollowsFilename):
|
||||
return 0
|
||||
ctr = 0
|
||||
with open(approveFollowsFilename, "r") as f:
|
||||
with open(approveFollowsFilename, 'r') as f:
|
||||
lines = f.readlines()
|
||||
if followType == "onion":
|
||||
for fileLine in lines:
|
||||
|
@ -600,7 +600,7 @@ def _storeFollowRequest(baseDir: str,
|
|||
print('DEBUG: ' + approveHandleStored +
|
||||
' is already awaiting approval')
|
||||
else:
|
||||
with open(approveFollowsFilename, "w+") as fp:
|
||||
with open(approveFollowsFilename, 'w+') as fp:
|
||||
fp.write(approveHandleStored + '\n')
|
||||
|
||||
# store the follow request in its own directory
|
||||
|
|
|
@ -441,11 +441,11 @@ def removeCalendarEvent(baseDir: str, nickname: str, domain: str,
|
|||
if messageId not in open(calendarFilename).read():
|
||||
return
|
||||
lines = None
|
||||
with open(calendarFilename, "r") as f:
|
||||
with open(calendarFilename, 'r') as f:
|
||||
lines = f.readlines()
|
||||
if not lines:
|
||||
return
|
||||
with open(calendarFilename, "w+") as f:
|
||||
with open(calendarFilename, 'w+') as f:
|
||||
for line in lines:
|
||||
if messageId not in line:
|
||||
f.write(line)
|
||||
|
|
|
@ -29,7 +29,7 @@ def _moveFollowingHandlesForAccount(baseDir: str, nickname: str, domain: str,
|
|||
baseDir + '/accounts/' + nickname + '@' + domain + '/following.txt'
|
||||
if not os.path.isfile(followingFilename):
|
||||
return ctr
|
||||
with open(followingFilename, "r") as f:
|
||||
with open(followingFilename, 'r') as f:
|
||||
followingHandles = f.readlines()
|
||||
for followHandle in followingHandles:
|
||||
followHandle = followHandle.strip("\n").strip("\r")
|
||||
|
@ -114,7 +114,7 @@ def _updateMovedHandle(baseDir: str, nickname: str, domain: str,
|
|||
followingFilename = \
|
||||
baseDir + '/accounts/' + nickname + '@' + domain + '/following.txt'
|
||||
if os.path.isfile(followingFilename):
|
||||
with open(followingFilename, "r") as f:
|
||||
with open(followingFilename, 'r') as f:
|
||||
followingHandles = f.readlines()
|
||||
|
||||
movedToHandle = movedToNickname + '@' + movedToDomainFull
|
||||
|
@ -152,7 +152,7 @@ def _updateMovedHandle(baseDir: str, nickname: str, domain: str,
|
|||
followersFilename = \
|
||||
baseDir + '/accounts/' + nickname + '@' + domain + '/followers.txt'
|
||||
if os.path.isfile(followersFilename):
|
||||
with open(followersFilename, "r") as f:
|
||||
with open(followersFilename, 'r') as f:
|
||||
followerHandles = f.readlines()
|
||||
|
||||
handleLower = handle.lower()
|
||||
|
|
|
@ -374,7 +374,7 @@ def _newswireHashtagProcessing(session, baseDir: str, postJsonObject: {},
|
|||
if not os.path.isfile(rulesFilename):
|
||||
return True
|
||||
rules = []
|
||||
with open(rulesFilename, "r") as f:
|
||||
with open(rulesFilename, 'r') as f:
|
||||
rules = f.readlines()
|
||||
|
||||
domainFull = getFullDomain(domain, port)
|
||||
|
@ -471,7 +471,7 @@ def _createNewsMirror(baseDir: str, domain: str,
|
|||
for removePostId in removals:
|
||||
indexContent = \
|
||||
indexContent.replace(removePostId + '\n', '')
|
||||
with open(mirrorIndexFilename, "w+") as indexFile:
|
||||
with open(mirrorIndexFilename, 'w+') as indexFile:
|
||||
indexFile.write(indexContent)
|
||||
|
||||
mirrorArticleDir = mirrorDir + '/' + postIdNumber
|
||||
|
|
12
person.py
12
person.py
|
@ -872,7 +872,7 @@ def reenableAccount(baseDir: str, nickname: str) -> None:
|
|||
suspendedFilename = baseDir + '/accounts/suspended.txt'
|
||||
if os.path.isfile(suspendedFilename):
|
||||
lines = []
|
||||
with open(suspendedFilename, "r") as f:
|
||||
with open(suspendedFilename, 'r') as f:
|
||||
lines = f.readlines()
|
||||
with open(suspendedFilename, 'w+') as suspendedFile:
|
||||
for suspended in lines:
|
||||
|
@ -893,7 +893,7 @@ def suspendAccount(baseDir: str, nickname: str, domain: str) -> None:
|
|||
# Don't suspend moderators
|
||||
moderatorsFile = baseDir + '/accounts/moderators.txt'
|
||||
if os.path.isfile(moderatorsFile):
|
||||
with open(moderatorsFile, "r") as f:
|
||||
with open(moderatorsFile, 'r') as f:
|
||||
lines = f.readlines()
|
||||
for moderator in lines:
|
||||
if moderator.strip('\n').strip('\r') == nickname:
|
||||
|
@ -910,7 +910,7 @@ def suspendAccount(baseDir: str, nickname: str, domain: str) -> None:
|
|||
|
||||
suspendedFilename = baseDir + '/accounts/suspended.txt'
|
||||
if os.path.isfile(suspendedFilename):
|
||||
with open(suspendedFilename, "r") as f:
|
||||
with open(suspendedFilename, 'r') as f:
|
||||
lines = f.readlines()
|
||||
for suspended in lines:
|
||||
if suspended.strip('\n').strip('\r') == nickname:
|
||||
|
@ -941,7 +941,7 @@ def canRemovePost(baseDir: str, nickname: str,
|
|||
# is the post by a moderator?
|
||||
moderatorsFile = baseDir + '/accounts/moderators.txt'
|
||||
if os.path.isfile(moderatorsFile):
|
||||
with open(moderatorsFile, "r") as f:
|
||||
with open(moderatorsFile, 'r') as f:
|
||||
lines = f.readlines()
|
||||
for moderator in lines:
|
||||
if domainFull + '/users/' + moderator.strip('\n') + '/' in postId:
|
||||
|
@ -972,7 +972,7 @@ def _removeTagsForNickname(baseDir: str, nickname: str,
|
|||
if matchStr not in open(tagFilename).read():
|
||||
continue
|
||||
lines = []
|
||||
with open(tagFilename, "r") as f:
|
||||
with open(tagFilename, 'r') as f:
|
||||
lines = f.readlines()
|
||||
with open(tagFilename, 'w+') as tagFile:
|
||||
for tagline in lines:
|
||||
|
@ -994,7 +994,7 @@ def removeAccount(baseDir: str, nickname: str,
|
|||
# Don't remove moderators
|
||||
moderatorsFile = baseDir + '/accounts/moderators.txt'
|
||||
if os.path.isfile(moderatorsFile):
|
||||
with open(moderatorsFile, "r") as f:
|
||||
with open(moderatorsFile, 'r') as f:
|
||||
lines = f.readlines()
|
||||
for moderator in lines:
|
||||
if moderator.strip('\n') == nickname:
|
||||
|
|
20
posts.py
20
posts.py
|
@ -89,7 +89,7 @@ def isModerator(baseDir: str, nickname: str) -> bool:
|
|||
return True
|
||||
return False
|
||||
|
||||
with open(moderatorsFile, "r") as f:
|
||||
with open(moderatorsFile, 'r') as f:
|
||||
lines = f.readlines()
|
||||
if len(lines) == 0:
|
||||
adminName = getConfigParam(baseDir, 'admin')
|
||||
|
@ -113,7 +113,7 @@ def noOfFollowersOnDomain(baseDir: str, handle: str,
|
|||
return 0
|
||||
|
||||
ctr = 0
|
||||
with open(filename, "r") as followersFilename:
|
||||
with open(filename, 'r') as followersFilename:
|
||||
for followerHandle in followersFilename:
|
||||
if '@' in followerHandle:
|
||||
followerDomain = followerHandle.split('@')[1]
|
||||
|
@ -135,7 +135,7 @@ def _getPersonKey(nickname: str, domain: str, baseDir: str,
|
|||
print('DEBUG: private key file not found: ' + keyFilename)
|
||||
return ''
|
||||
keyPem = ''
|
||||
with open(keyFilename, "r") as pemFile:
|
||||
with open(keyFilename, 'r') as pemFile:
|
||||
keyPem = pemFile.read()
|
||||
if len(keyPem) < 20:
|
||||
if debug:
|
||||
|
@ -779,7 +779,7 @@ def _loadAutoCW(baseDir: str, nickname: str, domain: str) -> []:
|
|||
nickname + '@' + domain + '/autocw.txt'
|
||||
if not os.path.isfile(filename):
|
||||
return []
|
||||
with open(filename, "r") as f:
|
||||
with open(filename, 'r') as f:
|
||||
return f.readlines()
|
||||
return []
|
||||
|
||||
|
@ -1350,7 +1350,7 @@ def getPinnedPostAsJson(baseDir: str, httpPrefix: str,
|
|||
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
||||
if os.path.isfile(pinnedFilename):
|
||||
pinnedContent = None
|
||||
with open(pinnedFilename, "r") as pinFile:
|
||||
with open(pinnedFilename, 'r') as pinFile:
|
||||
pinnedContent = pinFile.read()
|
||||
if pinnedContent:
|
||||
pinnedPostJson = {
|
||||
|
@ -1469,7 +1469,7 @@ def _appendCitationsToBlogPost(baseDir: str,
|
|||
if not os.path.isfile(citationsFilename):
|
||||
return
|
||||
citationsSeparator = '#####'
|
||||
with open(citationsFilename, "r") as f:
|
||||
with open(citationsFilename, 'r') as f:
|
||||
citations = f.readlines()
|
||||
for line in citations:
|
||||
if citationsSeparator not in line:
|
||||
|
@ -1753,7 +1753,7 @@ def createReportPost(baseDir: str,
|
|||
moderatorsList = []
|
||||
moderatorsFile = baseDir + '/accounts/moderators.txt'
|
||||
if os.path.isfile(moderatorsFile):
|
||||
with open(moderatorsFile, "r") as fileHandler:
|
||||
with open(moderatorsFile, 'r') as fileHandler:
|
||||
for line in fileHandler:
|
||||
line = line.strip('\n').strip('\r')
|
||||
if line.startswith('#'):
|
||||
|
@ -1865,7 +1865,7 @@ def threadSendPost(session, postJsonStr: str, federationList: [],
|
|||
if debug:
|
||||
# save the log file
|
||||
postLogFilename = baseDir + '/post.log'
|
||||
with open(postLogFilename, "a+") as logFile:
|
||||
with open(postLogFilename, 'a+') as logFile:
|
||||
logFile.write(logStr + '\n')
|
||||
|
||||
if postResult:
|
||||
|
@ -2138,7 +2138,7 @@ def groupFollowersByDomain(baseDir: str, nickname: str, domain: str) -> {}:
|
|||
if not os.path.isfile(followersFilename):
|
||||
return None
|
||||
grouped = {}
|
||||
with open(followersFilename, "r") as f:
|
||||
with open(followersFilename, 'r') as f:
|
||||
for followerHandle in f:
|
||||
if '@' not in followerHandle:
|
||||
continue
|
||||
|
@ -2889,7 +2889,7 @@ def createModeration(baseDir: str, nickname: str, domain: str, port: int,
|
|||
if isModerator(baseDir, nickname):
|
||||
moderationIndexFile = baseDir + '/accounts/moderation.txt'
|
||||
if os.path.isfile(moderationIndexFile):
|
||||
with open(moderationIndexFile, "r") as f:
|
||||
with open(moderationIndexFile, 'r') as f:
|
||||
lines = f.readlines()
|
||||
boxHeader['totalItems'] = len(lines)
|
||||
if headerOnly:
|
||||
|
|
|
@ -77,7 +77,7 @@ def questionUpdateVotes(baseDir: str, nickname: str, domain: str,
|
|||
foundAnswer + '\n')
|
||||
else:
|
||||
# change an entry in the voters file
|
||||
with open(votersFilename, "r") as votersFile:
|
||||
with open(votersFilename, 'r') as votersFile:
|
||||
lines = votersFile.readlines()
|
||||
newlines = []
|
||||
saveVotersFile = False
|
||||
|
@ -104,7 +104,7 @@ def questionUpdateVotes(baseDir: str, nickname: str, domain: str,
|
|||
if not possibleAnswer.get('name'):
|
||||
continue
|
||||
totalItems = 0
|
||||
with open(votersFilename, "r") as votersFile:
|
||||
with open(votersFilename, 'r') as votersFile:
|
||||
lines = votersFile.readlines()
|
||||
for voteLine in lines:
|
||||
if voteLine.endswith(votersFileSeparator +
|
||||
|
|
6
roles.py
6
roles.py
|
@ -81,7 +81,7 @@ def _addRole(baseDir: str, nickname: str, domain: str,
|
|||
roleFile = baseDir + '/accounts/' + roleFilename
|
||||
if os.path.isfile(roleFile):
|
||||
# is this nickname already in the file?
|
||||
with open(roleFile, "r") as f:
|
||||
with open(roleFile, 'r') as f:
|
||||
lines = f.readlines()
|
||||
for roleNickname in lines:
|
||||
roleNickname = roleNickname.strip('\n').strip('\r')
|
||||
|
@ -97,7 +97,7 @@ def _addRole(baseDir: str, nickname: str, domain: str,
|
|||
roleNickname + '@' + domain):
|
||||
f.write(roleNickname + '\n')
|
||||
else:
|
||||
with open(roleFile, "w+") as f:
|
||||
with open(roleFile, 'w+') as f:
|
||||
if os.path.isdir(baseDir + '/accounts/' +
|
||||
nickname + '@' + domain):
|
||||
f.write(nickname + '\n')
|
||||
|
@ -110,7 +110,7 @@ def _removeRole(baseDir: str, nickname: str, roleFilename: str) -> None:
|
|||
roleFile = baseDir + '/accounts/' + roleFilename
|
||||
if not os.path.isfile(roleFile):
|
||||
return
|
||||
with open(roleFile, "r") as f:
|
||||
with open(roleFile, 'r') as f:
|
||||
lines = f.readlines()
|
||||
with open(roleFile, 'w+') as f:
|
||||
for roleNickname in lines:
|
||||
|
|
8
tests.py
8
tests.py
|
@ -1406,7 +1406,7 @@ def _testFollows():
|
|||
federationList, False)
|
||||
|
||||
f = open(baseDir + '/accounts/' + nickname + '@' + domain +
|
||||
'/following.txt', "r")
|
||||
'/following.txt', 'r')
|
||||
domainFound = False
|
||||
for followingDomain in f:
|
||||
testDomain = followingDomain.split('@')[1]
|
||||
|
@ -1441,7 +1441,7 @@ def _testFollows():
|
|||
federationList, False)
|
||||
|
||||
f = open(baseDir + '/accounts/' + nickname + '@' + domain +
|
||||
'/followers.txt', "r")
|
||||
'/followers.txt', 'r')
|
||||
for followerDomain in f:
|
||||
testDomain = followerDomain.split('@')[1]
|
||||
testDomain = testDomain.replace('\n', '').replace('\r', '')
|
||||
|
@ -3083,10 +3083,10 @@ def _testFunctions():
|
|||
'functions': []
|
||||
}
|
||||
sourceStr = ''
|
||||
with open(sourceFile, "r") as f:
|
||||
with open(sourceFile, 'r') as f:
|
||||
sourceStr = f.read()
|
||||
modules[modName]['source'] = sourceStr
|
||||
with open(sourceFile, "r") as f:
|
||||
with open(sourceFile, 'r') as f:
|
||||
lines = f.readlines()
|
||||
modules[modName]['lines'] = lines
|
||||
lineCount = 0
|
||||
|
|
|
@ -141,7 +141,7 @@ def removeDormantThreads(baseDir: str, threadsList: [], debug: bool,
|
|||
if debug:
|
||||
sendLogFilename = baseDir + '/send.csv'
|
||||
try:
|
||||
with open(sendLogFilename, "a+") as logFile:
|
||||
with open(sendLogFilename, 'a+') as logFile:
|
||||
logFile.write(currTime.strftime("%Y-%m-%dT%H:%M:%SZ") +
|
||||
',' + str(noOfActiveThreads) +
|
||||
',' + str(len(threadsList)) + '\n')
|
||||
|
|
18
utils.py
18
utils.py
|
@ -189,7 +189,7 @@ def isEditor(baseDir: str, nickname: str) -> bool:
|
|||
return True
|
||||
return False
|
||||
|
||||
with open(editorsFile, "r") as f:
|
||||
with open(editorsFile, 'r') as f:
|
||||
lines = f.readlines()
|
||||
if len(lines) == 0:
|
||||
adminName = getConfigParam(baseDir, 'admin')
|
||||
|
@ -217,7 +217,7 @@ def isArtist(baseDir: str, nickname: str) -> bool:
|
|||
return True
|
||||
return False
|
||||
|
||||
with open(artistsFile, "r") as f:
|
||||
with open(artistsFile, 'r') as f:
|
||||
lines = f.readlines()
|
||||
if len(lines) == 0:
|
||||
adminName = getConfigParam(baseDir, 'admin')
|
||||
|
@ -427,7 +427,7 @@ def isSuspended(baseDir: str, nickname: str) -> bool:
|
|||
|
||||
suspendedFilename = baseDir + '/accounts/suspended.txt'
|
||||
if os.path.isfile(suspendedFilename):
|
||||
with open(suspendedFilename, "r") as f:
|
||||
with open(suspendedFilename, 'r') as f:
|
||||
lines = f.readlines()
|
||||
for suspended in lines:
|
||||
if suspended.strip('\n').strip('\r') == nickname:
|
||||
|
@ -446,7 +446,7 @@ def getFollowersList(baseDir: str,
|
|||
if not os.path.isfile(filename):
|
||||
return []
|
||||
|
||||
with open(filename, "r") as f:
|
||||
with open(filename, 'r') as f:
|
||||
lines = f.readlines()
|
||||
for i in range(len(lines)):
|
||||
lines[i] = lines[i].strip()
|
||||
|
@ -1012,7 +1012,7 @@ def followPerson(baseDir: str, nickname: str, domain: str,
|
|||
if handleToFollow in open(unfollowedFilename).read():
|
||||
# remove them from the unfollowed file
|
||||
newLines = ''
|
||||
with open(unfollowedFilename, "r") as f:
|
||||
with open(unfollowedFilename, 'r') as f:
|
||||
lines = f.readlines()
|
||||
for line in lines:
|
||||
if handleToFollow not in line:
|
||||
|
@ -1229,9 +1229,9 @@ def removeModerationPostFromIndex(baseDir: str, postUrl: str,
|
|||
return
|
||||
postId = removeIdEnding(postUrl)
|
||||
if postId in open(moderationIndexFile).read():
|
||||
with open(moderationIndexFile, "r") as f:
|
||||
with open(moderationIndexFile, 'r') as f:
|
||||
lines = f.readlines()
|
||||
with open(moderationIndexFile, "w+") as f:
|
||||
with open(moderationIndexFile, 'w+') as f:
|
||||
for line in lines:
|
||||
if line.strip("\n").strip("\r") != postId:
|
||||
f.write(line)
|
||||
|
@ -1371,7 +1371,7 @@ def _deleteHashtagsOnPost(baseDir: str, postJsonObject: {}) -> None:
|
|||
continue
|
||||
# remove postId from the tag index file
|
||||
lines = None
|
||||
with open(tagIndexFilename, "r") as f:
|
||||
with open(tagIndexFilename, 'r') as f:
|
||||
lines = f.readlines()
|
||||
if not lines:
|
||||
continue
|
||||
|
@ -1386,7 +1386,7 @@ def _deleteHashtagsOnPost(baseDir: str, postJsonObject: {}) -> None:
|
|||
os.remove(tagIndexFilename)
|
||||
else:
|
||||
# write the new hashtag index without the given post in it
|
||||
with open(tagIndexFilename, "w+") as f:
|
||||
with open(tagIndexFilename, 'w+') as f:
|
||||
f.write(newlines)
|
||||
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ def getLeftColumnContent(baseDir: str, nickname: str, domainFull: str,
|
|||
linksFileContainsEntries = False
|
||||
linksList = None
|
||||
if os.path.isfile(linksFilename):
|
||||
with open(linksFilename, "r") as f:
|
||||
with open(linksFilename, 'r') as f:
|
||||
linksList = f.readlines()
|
||||
|
||||
if not frontPage:
|
||||
|
|
|
@ -342,7 +342,7 @@ def htmlCitations(baseDir: str, nickname: str, domain: str,
|
|||
citationsSelected = []
|
||||
if os.path.isfile(citationsFilename):
|
||||
citationsSeparator = '#####'
|
||||
with open(citationsFilename, "r") as f:
|
||||
with open(citationsFilename, 'r') as f:
|
||||
citations = f.readlines()
|
||||
for line in citations:
|
||||
if citationsSeparator not in line:
|
||||
|
|
|
@ -411,7 +411,7 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
|
|||
translate['Citations'] + ':</label></p>\n'
|
||||
citationsStr += ' <ul>\n'
|
||||
citationsSeparator = '#####'
|
||||
with open(citationsFilename, "r") as f:
|
||||
with open(citationsFilename, 'r') as f:
|
||||
citations = f.readlines()
|
||||
for line in citations:
|
||||
if citationsSeparator not in line:
|
||||
|
|
|
@ -329,7 +329,7 @@ def htmlModerationInfo(cssCache: {}, translate: {},
|
|||
|
||||
suspendedFilename = baseDir + '/accounts/suspended.txt'
|
||||
if os.path.isfile(suspendedFilename):
|
||||
with open(suspendedFilename, "r") as f:
|
||||
with open(suspendedFilename, 'r') as f:
|
||||
suspendedStr = f.read()
|
||||
infoForm += '<div class="container">\n'
|
||||
infoForm += ' <br><b>' + \
|
||||
|
@ -345,7 +345,7 @@ def htmlModerationInfo(cssCache: {}, translate: {},
|
|||
|
||||
blockingFilename = baseDir + '/accounts/blocking.txt'
|
||||
if os.path.isfile(blockingFilename):
|
||||
with open(blockingFilename, "r") as f:
|
||||
with open(blockingFilename, 'r') as f:
|
||||
blockedStr = f.read()
|
||||
infoForm += '<div class="container">\n'
|
||||
infoForm += \
|
||||
|
@ -363,7 +363,7 @@ def htmlModerationInfo(cssCache: {}, translate: {},
|
|||
|
||||
filtersFilename = baseDir + '/accounts/filters.txt'
|
||||
if os.path.isfile(filtersFilename):
|
||||
with open(filtersFilename, "r") as f:
|
||||
with open(filtersFilename, 'r') as f:
|
||||
filteredStr = f.read()
|
||||
infoForm += '<div class="container">\n'
|
||||
infoForm += \
|
||||
|
|
|
@ -1231,7 +1231,7 @@ def _htmlEditProfileInstance(baseDir: str, translate: {},
|
|||
moderators = ''
|
||||
moderatorsFile = baseDir + '/accounts/moderators.txt'
|
||||
if os.path.isfile(moderatorsFile):
|
||||
with open(moderatorsFile, "r") as f:
|
||||
with open(moderatorsFile, 'r') as f:
|
||||
moderators = f.read()
|
||||
# site moderators
|
||||
roleAssignStr = '<details><summary class="cw">' + \
|
||||
|
@ -1251,7 +1251,7 @@ def _htmlEditProfileInstance(baseDir: str, translate: {},
|
|||
editors = ''
|
||||
editorsFile = baseDir + '/accounts/editors.txt'
|
||||
if os.path.isfile(editorsFile):
|
||||
with open(editorsFile, "r") as f:
|
||||
with open(editorsFile, 'r') as f:
|
||||
editors = f.read()
|
||||
roleAssignStr += ' <b><label class="labels">' + \
|
||||
translate['Site Editors'] + '</label></b><br>\n'
|
||||
|
@ -1266,7 +1266,7 @@ def _htmlEditProfileInstance(baseDir: str, translate: {},
|
|||
counselors = ''
|
||||
counselorsFile = baseDir + '/accounts/counselors.txt'
|
||||
if os.path.isfile(counselorsFile):
|
||||
with open(counselorsFile, "r") as f:
|
||||
with open(counselorsFile, 'r') as f:
|
||||
counselors = f.read()
|
||||
roleAssignStr += ' <b><label class="labels">' + \
|
||||
translate['Counselors'] + '</label></b><br>\n'
|
||||
|
@ -1280,7 +1280,7 @@ def _htmlEditProfileInstance(baseDir: str, translate: {},
|
|||
artists = ''
|
||||
artistsFile = baseDir + '/accounts/artists.txt'
|
||||
if os.path.isfile(artistsFile):
|
||||
with open(artistsFile, "r") as f:
|
||||
with open(artistsFile, 'r') as f:
|
||||
artists = f.read()
|
||||
roleAssignStr += ' <b><label class="labels">' + \
|
||||
translate['Artists'] + '</label></b><br>\n'
|
||||
|
@ -1490,7 +1490,7 @@ def _htmlEditProfileFiltering(baseDir: str, nickname: str, domain: str,
|
|||
if not os.path.isfile(locationsFilename):
|
||||
locationsFilename = baseDir + '/locations.txt'
|
||||
cities = []
|
||||
with open(locationsFilename, "r") as f:
|
||||
with open(locationsFilename, 'r') as f:
|
||||
cities = f.readlines()
|
||||
cities.sort()
|
||||
editProfileForm += ' <select id="cityDropdown" ' + \
|
||||
|
|
|
@ -662,7 +662,7 @@ def htmlHashtagSearch(cssCache: {},
|
|||
nickname = None
|
||||
|
||||
# read the index
|
||||
with open(hashtagIndexFile, "r") as f:
|
||||
with open(hashtagIndexFile, 'r') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
# read the css
|
||||
|
@ -841,7 +841,7 @@ def rssHashtagSearch(nickname: str, domain: str, port: int,
|
|||
|
||||
# read the index
|
||||
lines = []
|
||||
with open(hashtagIndexFile, "r") as f:
|
||||
with open(hashtagIndexFile, 'r') as f:
|
||||
lines = f.readlines()
|
||||
if not lines:
|
||||
return None
|
||||
|
|
Loading…
Reference in New Issue