From 08a1b05a76efd535d16299a1fcc6494ce6679092 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 3 Apr 2020 17:01:25 +0000 Subject: [PATCH] flake8 format --- migrate.py | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/migrate.py b/migrate.py index 9d561c30..ac9502e0 100644 --- a/migrate.py +++ b/migrate.py @@ -1,50 +1,53 @@ -__filename__="migrate.py" -__author__="Bob Mottram" -__license__="AGPL3+" -__version__="1.1.0" -__maintainer__="Bob Mottram" -__email__="bob@freedombone.net" -__status__="Production" +__filename__ = "migrate.py" +__author__ = "Bob Mottram" +__license__ = "AGPL3+" +__version__ = "1.1.0" +__maintainer__ = "Bob Mottram" +__email__ = "bob@freedombone.net" +__status__ = "Production" import os -def migrateFollows(followFilename: str,oldHandle: str,newHandle: str) -> None: + +def migrateFollows(followFilename: str, oldHandle: str, + newHandle: str) -> None: """Changes a handle within following or followers list """ if not os.path.isfile(followFilename): return if oldHandle not in open(followFilename).read(): return - followData=None + followData = None with open(followFilename, 'r') as followFile: - followData=followFile.read() + followData = followFile.read() if not followData: return - newFollowData=followData.replace(oldHandle,newHandle) - if followData==newFollowData: + newFollowData = followData.replace(oldHandle, newHandle) + if followData == newFollowData: return with open(followFilename, 'w') as followFile: followFile.write(newFollowData) -def migrateAccount(baseDir: str,oldHandle: str,newHandle: str) -> None: + +def migrateAccount(baseDir: str, oldHandle: str, newHandle: str) -> None: """If a followed account changes then this modifies the following and followers lists for each account accordingly """ if oldHandle.startswith('@'): - oldHandle=oldHandle[1:] + oldHandle = oldHandle[1:] if '@' not in oldHandle: return if newHandle.startswith('@'): - ewHandle=newHandle[1:] + newHandle = newHandle[1:] if '@' not in newHandle: return # update followers and following lists for each account - for subdir, dirs, files in os.walk(baseDir+'/accounts'): + for subdir, dirs, files in os.walk(baseDir + '/accounts'): for handle in dirs: if '@' in handle: - accountDir=baseDir+'/accounts/'+handle - followFilename=accountDir+'/following.txt' - migrateFollows(followFilename,oldHandle,newHandle) - followFilename=accountDir+'/followers.txt' - migrateFollows(followFilename,oldHandle,newHandle) + accountDir = baseDir + '/accounts/' + handle + followFilename = accountDir + '/following.txt' + migrateFollows(followFilename, oldHandle, newHandle) + followFilename = accountDir + '/followers.txt' + migrateFollows(followFilename, oldHandle, newHandle)