X-Git-Url: https://git.korewanetadesu.com/?p=python-collate.git;a=blobdiff_plain;f=collate%2Fsyslocale.py;fp=collate%2Fsyslocale.py;h=5b8adcac87a22a5db3d815289d8d1880a7284163;hp=e2aeed9bdeaba636098c13a5a8e41bf90186569c;hb=7644110ce07ec8a78003ee7db9dcdfe5cbca3854;hpb=92fc0878bc7b75741a3434d17310e390a9304e70 diff --git a/collate/syslocale.py b/collate/syslocale.py index e2aeed9..5b8adca 100644 --- a/collate/syslocale.py +++ b/collate/syslocale.py @@ -22,6 +22,8 @@ Avoid this backend if... """ +__all__ = ["Collator"] + import locale import re @@ -33,6 +35,7 @@ class Collator(collate._abcollator.Collator): """C library locale-based collation.""" def __init__(self, locale_code, encoding=None): + super(Collator, self).__init__(locale, encoding) locale_code, encoding = collate._locale.getpair(locale_code, encoding) try: setlocale = locale_code + "." + encoding @@ -54,22 +57,9 @@ class Collator(collate._abcollator.Collator): except UnicodeEncodeError: return locale.strxfrm(string.encode(self.encoding, "replace")) - def cmp(self, a, b): - """Return negative if a < b, zero if a == b, positive if a > b. - - If strs rather than unicodes are passed in, they are first - decoded according to the 'encoding' attribute of the Collator. - """ - if isinstance(a, str): - a = a.decode(self.encoding, "replace") - if isinstance(b, str): - b = b.decode(self.encoding, "replace") - return locale.strcoll(a, b) - def words(self, string, sep=re.compile(r"\W+", re.UNICODE)): - """Split the string into separate words. - - This split is done using the locale's notion of a word boundry. - """ + """Split the string into separate words.""" + if isinstance(string, str): + string = string.decode(self.encoding, 'replace') return re.split(sep, string)