Optimise algorithm by reducing number of invocations

This commit is contained in:
Kristóf Tóth 2018-09-02 16:47:52 +02:00
parent a47777ce23
commit cac52effa8

View File

@ -29,16 +29,16 @@ class Normalisename:
def whitelist(self):
return self._whitelist.union({self.separator})
def __call__(self, files):
for path in files:
if not self.check_normal(path):
def __call__(self, paths):
for path in paths:
directory = dirname(path)
filename = basename(path)
normalpath = joinpath(directory, self.normalname(filename))
if path != normalpath:
self.operation(path, normalpath) # pylint: disable=not-callable
def check_normal(self, filename):
filename = basename(filename)
def check_normal(self, path):
filename = basename(path)
return filename == self.normalname(filename)
def normalname(self, filename):