Improve whitespace elimination with re.sub()
This commit is contained in:
parent
24cd974129
commit
7bd02f37db
@ -3,6 +3,7 @@ from unidecode import unidecode
|
|||||||
from os import rename
|
from os import rename
|
||||||
from os.path import basename, dirname
|
from os.path import basename, dirname
|
||||||
from os.path import join as joinpath
|
from os.path import join as joinpath
|
||||||
|
from re import sub as substitute
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from sys import exit
|
from sys import exit
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ class normalisename:
|
|||||||
return file == self.normalname(file)
|
return file == self.normalname(file)
|
||||||
|
|
||||||
def normalname(self, filename):
|
def normalname(self, filename):
|
||||||
return unidecode(''.join(ch for ch in filename.replace(' ', self.separator)
|
return unidecode(''.join(ch for ch in substitute('\s+', self.separator, filename)
|
||||||
if ch.isalnum()
|
if ch.isalnum()
|
||||||
or ch in self.whitelist))
|
or ch in self.whitelist))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user