SickGear/lib/fuzzywuzzy/string_processing.py
Prinz23 07d72e05f1 Add Fuzzywuzzy lib to sort search results.
Change remove search results filtering from tv info source.
Change suppress startup warnings for Fuzzywuzzy and Cheetah libs.
Change show name aliases get a score -1 to give the main names priority.
Change replace findCertainShow with find_show_by_id for mapped multi-indexer.
Change add Trakt info source search interface.
Change directly send image after it's been cached.
Fix loading CachedImages images with TVDB API v2 changes.
2017-09-04 01:23:30 +01:00

30 lines
780 B
Python

from __future__ import unicode_literals
import re
import string
import sys
PY3 = sys.version_info[0] == 3
if PY3:
string = str
class StringProcessor(object):
"""
This class defines method to process strings in the most
efficient way. Ideally all the methods below use unicode strings
for both input and output.
"""
regex = re.compile(r"(?ui)\W")
@classmethod
def replace_non_letters_non_numbers_with_whitespace(cls, a_string):
"""
This function replaces any sequence of non letters and non
numbers with a single white space.
"""
return cls.regex.sub(" ", a_string)
strip = staticmethod(string.strip)
to_lower_case = staticmethod(string.lower)
to_upper_case = staticmethod(string.upper)