forked from indymedia/epicyon
Directories must be created first
parent
77c5f810f9
commit
7635652ac5
6
auth.py
6
auth.py
|
@ -121,7 +121,7 @@ def storeBasicCredentials(baseDir: str, nickname: str, password: str) -> bool:
|
||||||
if os.path.isfile(passwordFile):
|
if os.path.isfile(passwordFile):
|
||||||
if nickname + ':' in open(passwordFile).read():
|
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:
|
with open(passwordFile + '.new', 'w+') as fout:
|
||||||
for line in fin:
|
for line in fin:
|
||||||
if not line.startswith(nickname + ':'):
|
if not line.startswith(nickname + ':'):
|
||||||
fout.write(line)
|
fout.write(line)
|
||||||
|
@ -133,7 +133,7 @@ def storeBasicCredentials(baseDir: str, nickname: str, password: str) -> bool:
|
||||||
with open(passwordFile, 'a+') as passfile:
|
with open(passwordFile, 'a+') as passfile:
|
||||||
passfile.write(storeStr + '\n')
|
passfile.write(storeStr + '\n')
|
||||||
else:
|
else:
|
||||||
with open(passwordFile, "w") as passfile:
|
with open(passwordFile, 'w+') as passfile:
|
||||||
passfile.write(storeStr + '\n')
|
passfile.write(storeStr + '\n')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ def removePassword(baseDir: str, nickname: str) -> None:
|
||||||
passwordFile = baseDir + '/accounts/passwords'
|
passwordFile = baseDir + '/accounts/passwords'
|
||||||
if os.path.isfile(passwordFile):
|
if os.path.isfile(passwordFile):
|
||||||
with open(passwordFile, "r") as fin:
|
with open(passwordFile, "r") as fin:
|
||||||
with open(passwordFile + '.new', "w") as fout:
|
with open(passwordFile + '.new', 'w+') as fout:
|
||||||
for line in fin:
|
for line in fin:
|
||||||
if not line.startswith(nickname + ':'):
|
if not line.startswith(nickname + ':'):
|
||||||
fout.write(line)
|
fout.write(line)
|
||||||
|
|
2
blog.py
2
blog.py
|
@ -73,7 +73,7 @@ def noOfBlogReplies(baseDir: str, httpPrefix: str, translate: {},
|
||||||
if lines and removals:
|
if lines and removals:
|
||||||
print('Rewriting ' + postFilename + ' to remove ' +
|
print('Rewriting ' + postFilename + ' to remove ' +
|
||||||
str(len(removals)) + ' entries')
|
str(len(removals)) + ' entries')
|
||||||
with open(postFilename, "w") as f:
|
with open(postFilename, 'w+') as f:
|
||||||
for replyPostId in lines:
|
for replyPostId in lines:
|
||||||
replyPostId = replyPostId.replace('\n', '').replace('\r', '')
|
replyPostId = replyPostId.replace('\n', '').replace('\r', '')
|
||||||
if replyPostId not in removals:
|
if replyPostId not in removals:
|
||||||
|
|
18
daemon.py
18
daemon.py
|
@ -7502,7 +7502,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if fields.get('followDMs'):
|
if fields.get('followDMs'):
|
||||||
if fields['followDMs'] == 'on':
|
if fields['followDMs'] == 'on':
|
||||||
followDMsActive = True
|
followDMsActive = True
|
||||||
with open(followDMsFilename, "w") as fFile:
|
with open(followDMsFilename, 'w+') as fFile:
|
||||||
fFile.write('\n')
|
fFile.write('\n')
|
||||||
if not followDMsActive:
|
if not followDMsActive:
|
||||||
if os.path.isfile(followDMsFilename):
|
if os.path.isfile(followDMsFilename):
|
||||||
|
@ -7516,7 +7516,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if fields.get('removeTwitter'):
|
if fields.get('removeTwitter'):
|
||||||
if fields['removeTwitter'] == 'on':
|
if fields['removeTwitter'] == 'on':
|
||||||
removeTwitterActive = True
|
removeTwitterActive = True
|
||||||
with open(removeTwitterFilename, "w") as rFile:
|
with open(removeTwitterFilename, 'w+') as rFile:
|
||||||
rFile.write('\n')
|
rFile.write('\n')
|
||||||
if not removeTwitterActive:
|
if not removeTwitterActive:
|
||||||
if os.path.isfile(removeTwitterFilename):
|
if os.path.isfile(removeTwitterFilename):
|
||||||
|
@ -7534,7 +7534,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if fields.get('hideLikeButton'):
|
if fields.get('hideLikeButton'):
|
||||||
if fields['hideLikeButton'] == 'on':
|
if fields['hideLikeButton'] == 'on':
|
||||||
hideLikeButtonActive = True
|
hideLikeButtonActive = True
|
||||||
with open(hideLikeButtonFile, "w") as rFile:
|
with open(hideLikeButtonFile, 'w+') as rFile:
|
||||||
rFile.write('\n')
|
rFile.write('\n')
|
||||||
# remove notify likes selection
|
# remove notify likes selection
|
||||||
if os.path.isfile(notifyLikesFilename):
|
if os.path.isfile(notifyLikesFilename):
|
||||||
|
@ -7548,7 +7548,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if fields['notifyLikes'] == 'on' and \
|
if fields['notifyLikes'] == 'on' and \
|
||||||
not hideLikeButtonActive:
|
not hideLikeButtonActive:
|
||||||
notifyLikesActive = True
|
notifyLikesActive = True
|
||||||
with open(notifyLikesFilename, "w") as rFile:
|
with open(notifyLikesFilename, 'w+') as rFile:
|
||||||
rFile.write('\n')
|
rFile.write('\n')
|
||||||
if not notifyLikesActive:
|
if not notifyLikesActive:
|
||||||
if os.path.isfile(notifyLikesFilename):
|
if os.path.isfile(notifyLikesFilename):
|
||||||
|
@ -7585,7 +7585,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nickname + '@' + self.server.domain + \
|
nickname + '@' + self.server.domain + \
|
||||||
'/filters.txt'
|
'/filters.txt'
|
||||||
if fields.get('filteredWords'):
|
if fields.get('filteredWords'):
|
||||||
with open(filterFilename, "w") as filterfile:
|
with open(filterFilename, 'w+') as filterfile:
|
||||||
filterfile.write(fields['filteredWords'])
|
filterfile.write(fields['filteredWords'])
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(filterFilename):
|
if os.path.isfile(filterFilename):
|
||||||
|
@ -7596,7 +7596,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nickname + '@' + self.server.domain + \
|
nickname + '@' + self.server.domain + \
|
||||||
'/replacewords.txt'
|
'/replacewords.txt'
|
||||||
if fields.get('switchWords'):
|
if fields.get('switchWords'):
|
||||||
with open(switchFilename, "w") as switchfile:
|
with open(switchFilename, 'w+') as switchfile:
|
||||||
switchfile.write(fields['switchWords'])
|
switchfile.write(fields['switchWords'])
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(switchFilename):
|
if os.path.isfile(switchFilename):
|
||||||
|
@ -7607,7 +7607,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nickname + '@' + self.server.domain + \
|
nickname + '@' + self.server.domain + \
|
||||||
'/blocking.txt'
|
'/blocking.txt'
|
||||||
if fields.get('blocked'):
|
if fields.get('blocked'):
|
||||||
with open(blockedFilename, "w") as blockedfile:
|
with open(blockedFilename, 'w+') as blockedfile:
|
||||||
blockedfile.write(fields['blocked'])
|
blockedfile.write(fields['blocked'])
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(blockedFilename):
|
if os.path.isfile(blockedFilename):
|
||||||
|
@ -7618,7 +7618,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nickname + '@' + self.server.domain + \
|
nickname + '@' + self.server.domain + \
|
||||||
'/allowedinstances.txt'
|
'/allowedinstances.txt'
|
||||||
if fields.get('allowedInstances'):
|
if fields.get('allowedInstances'):
|
||||||
with open(allowedInstancesFilename, "w") as aFile:
|
with open(allowedInstancesFilename, 'w+') as aFile:
|
||||||
aFile.write(fields['allowedInstances'])
|
aFile.write(fields['allowedInstances'])
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(allowedInstancesFilename):
|
if os.path.isfile(allowedInstancesFilename):
|
||||||
|
@ -7629,7 +7629,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nickname + '@' + self.server.domain + \
|
nickname + '@' + self.server.domain + \
|
||||||
'/gitprojects.txt'
|
'/gitprojects.txt'
|
||||||
if fields.get('gitProjects'):
|
if fields.get('gitProjects'):
|
||||||
with open(gitProjectsFilename, "w") as aFile:
|
with open(gitProjectsFilename, 'w+') as aFile:
|
||||||
aFile.write(fields['gitProjects'].lower())
|
aFile.write(fields['gitProjects'].lower())
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(gitProjectsFilename):
|
if os.path.isfile(gitProjectsFilename):
|
||||||
|
|
|
@ -210,7 +210,7 @@ def unfollowPerson(baseDir: str, nickname: str, domain: str,
|
||||||
return
|
return
|
||||||
with open(filename, "r") as f:
|
with open(filename, "r") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
with open(filename, "w") as f:
|
with open(filename, 'w+') as f:
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if line.strip("\n").strip("\r").lower() != handleToUnfollowLower:
|
if line.strip("\n").strip("\r").lower() != handleToUnfollowLower:
|
||||||
f.write(line)
|
f.write(line)
|
||||||
|
|
4
git.py
4
git.py
|
@ -210,12 +210,12 @@ def receiveGitPatch(baseDir: str, nickname: str, domain: str,
|
||||||
return False
|
return False
|
||||||
patchStr = \
|
patchStr = \
|
||||||
gitAddFromHandle(patchStr, '@' + fromNickname + '@' + fromDomain)
|
gitAddFromHandle(patchStr, '@' + fromNickname + '@' + fromDomain)
|
||||||
with open(patchFilename, "w") as patchFile:
|
with open(patchFilename, 'w+') as patchFile:
|
||||||
patchFile.write(patchStr)
|
patchFile.write(patchStr)
|
||||||
patchNotifyFilename = \
|
patchNotifyFilename = \
|
||||||
baseDir + '/accounts/' + \
|
baseDir + '/accounts/' + \
|
||||||
nickname + '@' + domain + '/.newPatchContent'
|
nickname + '@' + domain + '/.newPatchContent'
|
||||||
with open(patchNotifyFilename, "w") as patchFile:
|
with open(patchNotifyFilename, 'w+') as patchFile:
|
||||||
patchFile.write(patchStr)
|
patchFile.write(patchStr)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -244,7 +244,7 @@ def getTodaysEvents(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
# if some posts have been deleted then regenerate the calendar file
|
# if some posts have been deleted then regenerate the calendar file
|
||||||
if recreateEventsFile:
|
if recreateEventsFile:
|
||||||
calendarFile = open(calendarFilename, "w")
|
calendarFile = open(calendarFilename, 'w+')
|
||||||
for postId in calendarPostIds:
|
for postId in calendarPostIds:
|
||||||
calendarFile.write(postId + '\n')
|
calendarFile.write(postId + '\n')
|
||||||
calendarFile.close()
|
calendarFile.close()
|
||||||
|
@ -412,7 +412,7 @@ def getThisWeeksEvents(baseDir: str, nickname: str, domain: str) -> {}:
|
||||||
|
|
||||||
# if some posts have been deleted then regenerate the calendar file
|
# if some posts have been deleted then regenerate the calendar file
|
||||||
if recreateEventsFile:
|
if recreateEventsFile:
|
||||||
calendarFile = open(calendarFilename, "w")
|
calendarFile = open(calendarFilename, 'w+')
|
||||||
for postId in calendarPostIds:
|
for postId in calendarPostIds:
|
||||||
calendarFile.write(postId + '\n')
|
calendarFile.write(postId + '\n')
|
||||||
calendarFile.close()
|
calendarFile.close()
|
||||||
|
@ -494,7 +494,7 @@ def getCalendarEvents(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
# if some posts have been deleted then regenerate the calendar file
|
# if some posts have been deleted then regenerate the calendar file
|
||||||
if recreateEventsFile:
|
if recreateEventsFile:
|
||||||
calendarFile = open(calendarFilename, "w")
|
calendarFile = open(calendarFilename, 'w+')
|
||||||
for postId in calendarPostIds:
|
for postId in calendarPostIds:
|
||||||
calendarFile.write(postId + '\n')
|
calendarFile.write(postId + '\n')
|
||||||
calendarFile.close()
|
calendarFile.close()
|
||||||
|
|
4
inbox.py
4
inbox.py
|
@ -1642,7 +1642,7 @@ def populateReplies(baseDir: str, httpPrefix: str, domain: str,
|
||||||
repliesFile.write(messageId + '\n')
|
repliesFile.write(messageId + '\n')
|
||||||
repliesFile.close()
|
repliesFile.close()
|
||||||
else:
|
else:
|
||||||
repliesFile = open(postRepliesFilename, "w")
|
repliesFile = open(postRepliesFilename, 'w+')
|
||||||
repliesFile.write(messageId + '\n')
|
repliesFile.write(messageId + '\n')
|
||||||
repliesFile.close()
|
repliesFile.close()
|
||||||
return True
|
return True
|
||||||
|
@ -2399,7 +2399,7 @@ def inboxAfterCapabilities(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
# This enables you to ignore a threat that's getting boring
|
# This enables you to ignore a threat that's getting boring
|
||||||
if isReplyToMutedPost:
|
if isReplyToMutedPost:
|
||||||
print('MUTE REPLY: ' + destinationFilename)
|
print('MUTE REPLY: ' + destinationFilename)
|
||||||
muteFile = open(destinationFilename + '.muted', "w")
|
muteFile = open(destinationFilename + '.muted', 'w+')
|
||||||
if muteFile:
|
if muteFile:
|
||||||
muteFile.write('\n')
|
muteFile.write('\n')
|
||||||
muteFile.close()
|
muteFile.close()
|
||||||
|
|
20
person.py
20
person.py
|
@ -350,7 +350,7 @@ def createPersonBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
if not os.path.isdir(baseDir + privateKeysSubdir):
|
if not os.path.isdir(baseDir + privateKeysSubdir):
|
||||||
os.mkdir(baseDir + privateKeysSubdir)
|
os.mkdir(baseDir + privateKeysSubdir)
|
||||||
filename = baseDir + privateKeysSubdir + '/' + handle + '.key'
|
filename = baseDir + privateKeysSubdir + '/' + handle + '.key'
|
||||||
with open(filename, "w") as text_file:
|
with open(filename, 'w+') as text_file:
|
||||||
print(privateKeyPem, file=text_file)
|
print(privateKeyPem, file=text_file)
|
||||||
|
|
||||||
# save the public key
|
# save the public key
|
||||||
|
@ -358,7 +358,7 @@ def createPersonBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
if not os.path.isdir(baseDir + publicKeysSubdir):
|
if not os.path.isdir(baseDir + publicKeysSubdir):
|
||||||
os.mkdir(baseDir + publicKeysSubdir)
|
os.mkdir(baseDir + publicKeysSubdir)
|
||||||
filename = baseDir + publicKeysSubdir + '/' + handle + '.pem'
|
filename = baseDir + publicKeysSubdir + '/' + handle + '.pem'
|
||||||
with open(filename, "w") as text_file:
|
with open(filename, 'w+') as text_file:
|
||||||
print(publicKeyPem, file=text_file)
|
print(publicKeyPem, file=text_file)
|
||||||
|
|
||||||
if password:
|
if password:
|
||||||
|
@ -454,22 +454,22 @@ def createPerson(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
setRole(baseDir, nickname, domain, 'instance', 'delegator')
|
setRole(baseDir, nickname, domain, 'instance', 'delegator')
|
||||||
setConfigParam(baseDir, 'admin', nickname)
|
setConfigParam(baseDir, 'admin', nickname)
|
||||||
|
|
||||||
|
if not os.path.isdir(baseDir + '/accounts'):
|
||||||
|
os.mkdir(baseDir + '/accounts')
|
||||||
|
if not os.path.isdir(baseDir + '/accounts/' + nickname + '@' + domain):
|
||||||
|
os.mkdir(baseDir + '/accounts/' + nickname + '@' + domain)
|
||||||
|
|
||||||
if manualFollowerApproval:
|
if manualFollowerApproval:
|
||||||
followDMsFilename = baseDir + '/accounts/' + \
|
followDMsFilename = baseDir + '/accounts/' + \
|
||||||
nickname + '@' + domain + '/.followDMs'
|
nickname + '@' + domain + '/.followDMs'
|
||||||
with open(followDMsFilename, "w") as fFile:
|
with open(followDMsFilename, 'w+') as fFile:
|
||||||
fFile.write('\n')
|
fFile.write('\n')
|
||||||
|
|
||||||
# notify when posts are liked
|
# notify when posts are liked
|
||||||
notifyLikesFilename = baseDir + '/accounts/' + \
|
notifyLikesFilename = baseDir + '/accounts/' + \
|
||||||
nickname + '@' + domain + '/.notifyLikes'
|
nickname + '@' + domain + '/.notifyLikes'
|
||||||
with open(notifyLikesFilename, "w") as fFile:
|
with open(notifyLikesFilename, 'w+') as nFile:
|
||||||
fFile.write('\n')
|
nFile.write('\n')
|
||||||
|
|
||||||
if not os.path.isdir(baseDir + '/accounts'):
|
|
||||||
os.mkdir(baseDir + '/accounts')
|
|
||||||
if not os.path.isdir(baseDir + '/accounts/' + nickname + '@' + domain):
|
|
||||||
os.mkdir(baseDir + '/accounts/' + nickname + '@' + domain)
|
|
||||||
|
|
||||||
if os.path.isfile(baseDir + '/img/default-avatar.png'):
|
if os.path.isfile(baseDir + '/img/default-avatar.png'):
|
||||||
copyfile(baseDir + '/img/default-avatar.png',
|
copyfile(baseDir + '/img/default-avatar.png',
|
||||||
|
|
2
posts.py
2
posts.py
|
@ -3536,7 +3536,7 @@ def mutePost(baseDir: str, nickname: str, domain: str, postId: str,
|
||||||
return
|
return
|
||||||
|
|
||||||
print('MUTE: ' + postFilename)
|
print('MUTE: ' + postFilename)
|
||||||
muteFile = open(postFilename + '.muted', "w")
|
muteFile = open(postFilename + '.muted', 'w+')
|
||||||
if muteFile:
|
if muteFile:
|
||||||
muteFile.write('\n')
|
muteFile.write('\n')
|
||||||
muteFile.close()
|
muteFile.close()
|
||||||
|
|
|
@ -66,7 +66,7 @@ def questionUpdateVotes(baseDir: str, nickname: str, domain: str,
|
||||||
votersFilename = questionPostFilename.replace('.json', '.voters')
|
votersFilename = questionPostFilename.replace('.json', '.voters')
|
||||||
if not os.path.isfile(votersFilename):
|
if not os.path.isfile(votersFilename):
|
||||||
# create a new voters file
|
# create a new voters file
|
||||||
votersFile = open(votersFilename, "w")
|
votersFile = open(votersFilename, 'w+')
|
||||||
if votersFile:
|
if votersFile:
|
||||||
votersFile.write(replyJson['actor'] +
|
votersFile.write(replyJson['actor'] +
|
||||||
votersFileSeparator +
|
votersFileSeparator +
|
||||||
|
@ -99,7 +99,7 @@ def questionUpdateVotes(baseDir: str, nickname: str, domain: str,
|
||||||
else:
|
else:
|
||||||
newlines.append(voteLine)
|
newlines.append(voteLine)
|
||||||
if saveVotersFile:
|
if saveVotersFile:
|
||||||
with open(votersFilename, "w") as votersFile:
|
with open(votersFilename, 'w+') as votersFile:
|
||||||
for voteLine in newlines:
|
for voteLine in newlines:
|
||||||
votersFile.write(voteLine)
|
votersFile.write(voteLine)
|
||||||
else:
|
else:
|
||||||
|
|
4
roles.py
4
roles.py
|
@ -52,7 +52,7 @@ def addModerator(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
if moderator == nickname:
|
if moderator == nickname:
|
||||||
return
|
return
|
||||||
lines.append(nickname)
|
lines.append(nickname)
|
||||||
with open(moderatorsFile, "w") as f:
|
with open(moderatorsFile, 'w+') as f:
|
||||||
for moderator in lines:
|
for moderator in lines:
|
||||||
moderator = moderator.strip('\n').strip('\r')
|
moderator = moderator.strip('\n').strip('\r')
|
||||||
if len(moderator) > 1:
|
if len(moderator) > 1:
|
||||||
|
@ -74,7 +74,7 @@ def removeModerator(baseDir: str, nickname: str):
|
||||||
return
|
return
|
||||||
with open(moderatorsFile, "r") as f:
|
with open(moderatorsFile, "r") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
with open(moderatorsFile, "w") as f:
|
with open(moderatorsFile, 'w+') as f:
|
||||||
for moderator in lines:
|
for moderator in lines:
|
||||||
moderator = moderator.strip('\n').strip('\r')
|
moderator = moderator.strip('\n').strip('\r')
|
||||||
if len(moderator) > 1 and moderator != nickname:
|
if len(moderator) > 1 and moderator != nickname:
|
||||||
|
|
3
tests.py
3
tests.py
|
@ -2064,6 +2064,9 @@ def testTranslations():
|
||||||
langDict = {}
|
langDict = {}
|
||||||
for lang in languagesStr:
|
for lang in languagesStr:
|
||||||
langJson = loadJson('translations/' + lang + '.json')
|
langJson = loadJson('translations/' + lang + '.json')
|
||||||
|
if not langJson:
|
||||||
|
print('Missing language file ' +
|
||||||
|
'translations/' + lang + '.json')
|
||||||
assert langJson
|
assert langJson
|
||||||
langDict[lang] = langJson
|
langDict[lang] = langJson
|
||||||
|
|
||||||
|
|
|
@ -283,5 +283,5 @@
|
||||||
"Moderation policy or code of conduct": "Moderationsrichtlinie oder Verhaltenskodex",
|
"Moderation policy or code of conduct": "Moderationsrichtlinie oder Verhaltenskodex",
|
||||||
"Edit event": "Ereignis bearbeiten",
|
"Edit event": "Ereignis bearbeiten",
|
||||||
"Notify when posts are liked": "Benachrichtigen, wenn Beiträge gefallen",
|
"Notify when posts are liked": "Benachrichtigen, wenn Beiträge gefallen",
|
||||||
"Don't show the Like button": "Zeigen Sie nicht die Schaltfläche "Gefällt mir" an"
|
"Don't show the Like button": "Zeigen Sie nicht die Schaltfläche \"Gefällt mir\" an"
|
||||||
}
|
}
|
||||||
|
|
18
utils.py
18
utils.py
|
@ -351,7 +351,7 @@ def followPerson(baseDir: str, nickname: str, domain: str,
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if handleToFollow not in line:
|
if handleToFollow not in line:
|
||||||
newLines += line
|
newLines += line
|
||||||
with open(unfollowedFilename, "w") as f:
|
with open(unfollowedFilename, 'w+') as f:
|
||||||
f.write(newLines)
|
f.write(newLines)
|
||||||
|
|
||||||
if not os.path.isdir(baseDir + '/accounts'):
|
if not os.path.isdir(baseDir + '/accounts'):
|
||||||
|
@ -383,7 +383,7 @@ def followPerson(baseDir: str, nickname: str, domain: str,
|
||||||
followNickname, followDomain)
|
followNickname, followDomain)
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: creating new following file to follow ' + handleToFollow)
|
print('DEBUG: creating new following file to follow ' + handleToFollow)
|
||||||
with open(filename, "w") as followfile:
|
with open(filename, 'w+') as followfile:
|
||||||
followfile.write(handleToFollow + '\n')
|
followfile.write(handleToFollow + '\n')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -907,12 +907,20 @@ def searchBoxPosts(baseDir: str, nickname: str, domain: str,
|
||||||
def getFileCaseInsensitive(path: str) -> str:
|
def getFileCaseInsensitive(path: str) -> str:
|
||||||
"""Returns a case specific filename given a case insensitive version of it
|
"""Returns a case specific filename given a case insensitive version of it
|
||||||
"""
|
"""
|
||||||
|
# does the given file exist? If so then we don't need
|
||||||
|
# to do a directory search
|
||||||
|
if os.path.isfile(path):
|
||||||
|
return path
|
||||||
|
if path != path.lower():
|
||||||
|
if os.path.isfile(path.lower()):
|
||||||
|
return path.lower()
|
||||||
directory, filename = os.path.split(path)
|
directory, filename = os.path.split(path)
|
||||||
directory, filename = (directory or '.'), filename.lower()
|
directory, filename = (directory or '.'), filename.lower()
|
||||||
for f in os.listdir(directory):
|
for f in os.listdir(directory):
|
||||||
newpath = os.path.join(directory, f)
|
if f.lower() == filename:
|
||||||
if os.path.isfile(newpath) and f.lower() == filename:
|
newpath = os.path.join(directory, f)
|
||||||
return newpath
|
if os.path.isfile(newpath):
|
||||||
|
return newpath
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue