Indentation

master
Bob Mottram 2019-08-07 14:51:54 +01:00
parent b88ca1564e
commit a893b9d629
1 changed files with 36 additions and 36 deletions

View File

@ -25,10 +25,10 @@ def manualDenyFollowRequest(baseDir: str,nickname: str,domain: str,denyHandle: s
if denyHandle not in open(approveFollowsFilename).read(): if denyHandle not in open(approveFollowsFilename).read():
return return
approvefilenew = open(approveFollowsFilename+'.new', 'w+') 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() 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.')
@ -44,10 +44,10 @@ def addHandleToApproveFile(baseDir: str,nickname: str,domain: str,addHandle: str
if addHandle in open(approveFollowsFilename).read(): if addHandle in open(approveFollowsFilename).read():
appendHandle=False appendHandle=False
approvefilenew = open(approveFollowsFilename+'.add', 'w+') 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() approvefilenew.close()
os.rename(approveFollowsFilename+'.add',approveFollowsFilename) os.rename(approveFollowsFilename+'.add',approveFollowsFilename)
@ -74,33 +74,33 @@ def manualApproveFollowRequest(session,baseDir: str, \
print(handle+' not in '+approveFollowsFilename) print(handle+' not in '+approveFollowsFilename)
return return
approvefilenew = with open(approveFollowsFilename+'.new', 'w+') 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):
port2=port port2=port
if ':' in handle: if ':' in handle:
port2=int(handle.split(':')[1].replace('\n','')) port2=int(handle.split(':')[1].replace('\n',''))
requestsDir=accountsDir+'/requests' requestsDir=accountsDir+'/requests'
followActivityfilename=requestsDir+'/'+handle+'.follow' followActivityfilename=requestsDir+'/'+handle+'.follow'
if os.path.isfile(followActivityfilename): if os.path.isfile(followActivityfilename):
with open(followActivityfilename, 'r') as fp: with open(followActivityfilename, 'r') as fp:
followJson=commentjson.load(fp) followJson=commentjson.load(fp)
approveNickname=approveHandle.split('@')[0] approveNickname=approveHandle.split('@')[0]
approveDomain=approveHandle.split('@')[1].replace('\n','') approveDomain=approveHandle.split('@')[1].replace('\n','')
approvePort=port2 approvePort=port2
if ':' in approveDomain: if ':' in approveDomain:
approvePort=approveDomain.split(':')[1] approvePort=approveDomain.split(':')[1]
approveDomain=approveDomain.split(':')[0] approveDomain=approveDomain.split(':')[0]
followedAccountAccepts(session,baseDir,httpPrefix, \ followedAccountAccepts(session,baseDir,httpPrefix, \
nickname,domain,port, \ nickname,domain,port, \
approveNickname,approveDomain,approvePort, \ approveNickname,approveDomain,approvePort, \
followJson['actor'],federationList, \ followJson['actor'],federationList, \
followJson,acceptedCaps, \ followJson,acceptedCaps, \
sendThreads,postLog, \ sendThreads,postLog, \
cachedWebfingers,personCache, \ cachedWebfingers,personCache, \
debug) debug)
os.remove(followActivityfilename) os.remove(followActivityfilename)
else: else:
approvefilenew.write(handle) approvefilenew.write(handle)
approvefilenew.close() approvefilenew.close()
os.rename(approveFollowsFilename+'.new',approveFollowsFilename) os.rename(approveFollowsFilename+'.new',approveFollowsFilename)