Optimise algorithm by reducing number of invocations
This commit is contained in:
parent
a47777ce23
commit
cac52effa8
@ -29,16 +29,16 @@ class Normalisename:
|
|||||||
def whitelist(self):
|
def whitelist(self):
|
||||||
return self._whitelist.union({self.separator})
|
return self._whitelist.union({self.separator})
|
||||||
|
|
||||||
def __call__(self, files):
|
def __call__(self, paths):
|
||||||
for path in files:
|
for path in paths:
|
||||||
if not self.check_normal(path):
|
directory = dirname(path)
|
||||||
directory = dirname(path)
|
filename = basename(path)
|
||||||
filename = basename(path)
|
normalpath = joinpath(directory, self.normalname(filename))
|
||||||
normalpath = joinpath(directory, self.normalname(filename))
|
if path != normalpath:
|
||||||
self.operation(path, normalpath) # pylint: disable=not-callable
|
self.operation(path, normalpath) # pylint: disable=not-callable
|
||||||
|
|
||||||
def check_normal(self, filename):
|
def check_normal(self, path):
|
||||||
filename = basename(filename)
|
filename = basename(path)
|
||||||
return filename == self.normalname(filename)
|
return filename == self.normalname(filename)
|
||||||
|
|
||||||
def normalname(self, filename):
|
def normalname(self, filename):
|
||||||
|
Loading…
Reference in New Issue
Block a user