Use unicodedata for cleaning up whitespace names
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
from typing import Awaitable, Any, Dict, Iterable, Optional, Union, TYPE_CHECKING
|
from typing import Awaitable, Any, Dict, Iterable, Optional, Union, TYPE_CHECKING
|
||||||
from difflib import SequenceMatcher
|
from difflib import SequenceMatcher
|
||||||
|
import unicodedata
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@@ -194,7 +195,7 @@ class Puppet(CustomPuppetMixin):
|
|||||||
whitespace = ("\t\n\r\v\f \u00a0\u034f\u180e\u2063\u202f\u205f\u2800\u3000\u3164\ufeff"
|
whitespace = ("\t\n\r\v\f \u00a0\u034f\u180e\u2063\u202f\u205f\u2800\u3000\u3164\ufeff"
|
||||||
"\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b"
|
"\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b"
|
||||||
"\u200c\u200d\u200e\u200f")
|
"\u200c\u200d\u200e\u200f")
|
||||||
name = name.strip(whitespace)
|
name = str(filter(lambda c: unicodedata.category(c) != 'Cf', name.strip(whitespace)))
|
||||||
return name
|
return name
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user