mirror of https://gitlab.com/bashrc2/epicyon
Writing to files
parent
ab12a1e59d
commit
ef7383a6bc
|
@ -24,11 +24,12 @@ def manualDenyFollowRequest(baseDir: str,nickname: str,domain: str,denyHandle: s
|
||||||
return
|
return
|
||||||
if denyHandle not in open(approveFollowsFilename).read():
|
if denyHandle not in open(approveFollowsFilename).read():
|
||||||
return
|
return
|
||||||
with open(approveFollowsFilename+'.new', 'w+') as approvefilenew:
|
approvefilenew = open(approveFollowsFilename+'.new', 'w+'):
|
||||||
with open(approveFollowsFilename, 'r') as approvefile:
|
with open(approveFollowsFilename, 'r') as approvefile:
|
||||||
for approveHandle in approvefile:
|
for approveHandle in approvefile:
|
||||||
if not approveHandle.startswith(denyHandle):
|
if not approveHandle.startswith(denyHandle):
|
||||||
approvefilenew.write(approveHandle)
|
approvefilenew.write(approveHandle)
|
||||||
|
approvefilenew.close()
|
||||||
os.rename(approveFollowsFilename+'.new',approveFollowsFilename)
|
os.rename(approveFollowsFilename+'.new',approveFollowsFilename)
|
||||||
print('Follow request from '+denyHandle+' was denied.')
|
print('Follow request from '+denyHandle+' was denied.')
|
||||||
|
|
||||||
|
@ -42,11 +43,12 @@ def addHandleToApproveFile(baseDir: str,nickname: str,domain: str,addHandle: str
|
||||||
if os.path.isfile(approveFollowsFilename):
|
if os.path.isfile(approveFollowsFilename):
|
||||||
if addHandle in open(approveFollowsFilename).read():
|
if addHandle in open(approveFollowsFilename).read():
|
||||||
appendHandle=False
|
appendHandle=False
|
||||||
with open(approveFollowsFilename+'.add', 'w+') as approvefilenew:
|
approvefilenew = open(approveFollowsFilename+'.add', 'w+'):
|
||||||
with open(approveFollowsFilename, 'r') as approvefile:
|
with open(approveFollowsFilename, 'r') as approvefile:
|
||||||
for handle in approvefile:
|
for handle in approvefile:
|
||||||
approvefilenew.write(handle)
|
approvefilenew.write(handle)
|
||||||
approvefilenew.write(addHandle)
|
approvefilenew.write(addHandle)
|
||||||
|
approvefilenew.close()
|
||||||
os.rename(approveFollowsFilename+'.add',approveFollowsFilename)
|
os.rename(approveFollowsFilename+'.add',approveFollowsFilename)
|
||||||
|
|
||||||
def manualApproveFollowRequest(session,baseDir: str, \
|
def manualApproveFollowRequest(session,baseDir: str, \
|
||||||
|
@ -71,7 +73,7 @@ def manualApproveFollowRequest(session,baseDir: str, \
|
||||||
if debug:
|
if debug:
|
||||||
print(handle+' not in '+approveFollowsFilename)
|
print(handle+' not in '+approveFollowsFilename)
|
||||||
return
|
return
|
||||||
with open(approveFollowsFilename+'.new', 'w+') as approvefilenew:
|
approvefilenew = with open(approveFollowsFilename+'.new', 'w+'):
|
||||||
with open(approveFollowsFilename, 'r') as approvefile:
|
with open(approveFollowsFilename, 'r') as approvefile:
|
||||||
for handle in approvefile:
|
for handle in approvefile:
|
||||||
if handle.startswith(approveHandle):
|
if handle.startswith(approveHandle):
|
||||||
|
@ -100,4 +102,5 @@ def manualApproveFollowRequest(session,baseDir: str, \
|
||||||
os.remove(followActivityfilename)
|
os.remove(followActivityfilename)
|
||||||
else:
|
else:
|
||||||
approvefilenew.write(handle)
|
approvefilenew.write(handle)
|
||||||
|
approvefilenew.close()
|
||||||
os.rename(approveFollowsFilename+'.new',approveFollowsFilename)
|
os.rename(approveFollowsFilename+'.new',approveFollowsFilename)
|
||||||
|
|
Loading…
Reference in New Issue