Updates for new hosting.
[python-collate.git] / collate / codepoint.py
1 """Codepoint-based collation.
2
3 This collation backend sorts using only the basic codepoint order. It
4 is primarily intended to be used as a baseline and example for other
5 collation backends.
6
7 Use this collation backend if...
8 - You are writing tests for pycollate.
9 - You are writing specialized Unicode software.
10 - You are on a system with no locale module.
11
12 Avoid this backend if...
13 - You are writing a normal program for a normal runtime environment.
14 - You are sorting strings to show normal humans.
15
16 """
17
18 __all__ = ["Collator"]
19
20 import collate._abcollator
21 import collate._locale
22
23 class Collator(collate._abcollator.Collator):
24 """Codepoint-based collation.
25
26 Arguments
27 locale - all parts but encoding ignored, always 'C'
28 encoding - try to use this string encoding
29 """
30
31 def __init__(self, locale=None, encoding=None):
32 super(Collator, self).__init__(locale, encoding)
33 dummy, self.encoding = collate._locale.getpair(locale, encoding)
34 self.locale = "C"