Back to index

python3.2  3.2.2
Functions | Variables
mkstringprep Namespace Reference

Functions

def gen_category
def gen_bidirectional
def compact_set
def map_table_b3
def map_table_b2

Variables

tuple data = open("rfc3454.txt")
 Read the tables in the RFC #######################.
list tables = []
 curname = None
tuple l = l.strip()
tuple m = re.match("----- (Start|End) Table ([A-Z](.[0-9])+) -----", l)
dictionary table = {}
 Generate compact Python versions of the tables #############.
tuple fields = l.split(";")
list start = endfields[0]
tuple end = int(end, 16)
tuple value = value.strip()
tuple Cn = set(gen_category(["Cn"]))
dictionary b3_exceptions = {}
tuple b3 = sorted(b3_exceptions.items())
dictionary specials = {}
tuple Cc = set(gen_category(["Cc"]))
tuple Cc_ascii = Cc&set(range(128))
tuple table_c21 = set(table_c21.keys())
 Cc_nonascii = Cc-Cc_ascii
tuple table_c22 = set(table_c22.keys())
tuple Co = set(gen_category(["Co"]))
tuple nonchar = set(range(0xFDD0,0xFDF0))
tuple Cs = set(gen_category(["Cs"]))
tuple RandAL = set(gen_bidirectional(["R","AL"]))
tuple L = set(gen_bidirectional(["L"]))

Function Documentation

Definition at line 16 of file mkstringprep.py.

00016 
00017 def compact_set(l):
00018     single = []
00019     tuple = []
00020     prev = None
00021     span = 0
00022     for e in l:
00023         if prev is None:
00024             prev = e
00025             span = 0
00026             continue
00027         if prev+span+1 != e:
00028             if span > 2:
00029                 tuple.append((prev,prev+span+1))
00030             else:
00031                 for i in range(prev, prev+span+1):
00032                     single.append(i)
00033             prev = e
00034             span = 0
00035         else:
00036             span += 1
00037     if span:
00038         tuple.append((prev,prev+span+1))
00039     else:
00040         single.append(prev)
00041     tuple = " + ".join(["list(range(%d,%d))" % t for t in tuple])
00042     if not single:
00043         return "set(%s)" % tuple
00044     if not tuple:
00045         return "set(%s)" % repr(single)
00046     return "set(%s + %s)" % (repr(single),tuple)

Definition at line 11 of file mkstringprep.py.

00011 
00012 def gen_bidirectional(cats):
00013     for i in range(0, 0x110000):
00014         if unicodedata.bidirectional(chr(i)) in cats:
00015             yield(i)

Here is the call graph for this function:

def mkstringprep.gen_category (   cats)

Definition at line 6 of file mkstringprep.py.

00006 
00007 def gen_category(cats):
00008     for i in range(0, 0x110000):
00009         if unicodedata.category(chr(i)) in cats:
00010             yield(i)

Here is the call graph for this function:

Definition at line 205 of file mkstringprep.py.

00205 
00206 def map_table_b2(a):
00207     al = map_table_b3(a)
00208     b = unicodedata.normalize("NFKC", al)
00209     bl = "".join([map_table_b3(ch) for ch in b])
00210     c = unicodedata.normalize("NFKC", bl)
00211     if b != c:
00212         return c
00213     else:
00214         return al

Here is the call graph for this function:

def mkstringprep.map_table_b3 (   code)

Definition at line 196 of file mkstringprep.py.

00196 
00197 def map_table_b3(code):
00198     r = b3_exceptions.get(ord(code))
00199     if r is not None: return r
00200     return code.lower()
00201 
00202 # B.2 is case folding for NFKC. This is the same as B.3,
00203 # except where NormalizeWithKC(Fold(a)) !=
00204 # NormalizeWithKC(Fold(NormalizeWithKC(Fold(a))))

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

tuple mkstringprep.b3 = sorted(b3_exceptions.items())

Definition at line 179 of file mkstringprep.py.

Definition at line 173 of file mkstringprep.py.

tuple mkstringprep.Cc = set(gen_category(["Cc"]))

Definition at line 268 of file mkstringprep.py.

tuple mkstringprep.Cc_ascii = Cc&set(range(128))

Definition at line 269 of file mkstringprep.py.

Definition at line 284 of file mkstringprep.py.

tuple mkstringprep.Cn = set(gen_category(["Cn"]))

Definition at line 127 of file mkstringprep.py.

tuple mkstringprep.Co = set(gen_category(["Co"]))

Definition at line 308 of file mkstringprep.py.

tuple mkstringprep.Cs = set(gen_category(["Cs"]))

Definition at line 341 of file mkstringprep.py.

tuple mkstringprep.curname = None

Definition at line 52 of file mkstringprep.py.

tuple mkstringprep.data = open("rfc3454.txt")

Read the tables in the RFC #######################.

Definition at line 49 of file mkstringprep.py.

tuple mkstringprep.end = int(end, 16)

Definition at line 94 of file mkstringprep.py.

Definition at line 79 of file mkstringprep.py.

tuple mkstringprep.l = l.strip()

Definition at line 54 of file mkstringprep.py.

tuple mkstringprep.L = set(gen_bidirectional(["L"]))

Definition at line 419 of file mkstringprep.py.

tuple mkstringprep.m = re.match("----- (Start|End) Table ([A-Z](.[0-9])+) -----", l)

Definition at line 62 of file mkstringprep.py.

tuple mkstringprep.nonchar = set(range(0xFDD0,0xFDF0))

Definition at line 322 of file mkstringprep.py.

tuple mkstringprep.RandAL = set(gen_bidirectional(["R","AL"]))

Definition at line 406 of file mkstringprep.py.

Definition at line 215 of file mkstringprep.py.

tuple mkstringprep.start = endfields[0]

Definition at line 92 of file mkstringprep.py.

tuple mkstringprep.table = {}

Generate compact Python versions of the tables #############.

Definition at line 68 of file mkstringprep.py.

tuple mkstringprep.table_c21 = set(table_c21.keys())

Definition at line 270 of file mkstringprep.py.

tuple mkstringprep.table_c22 = set(table_c22.keys())

Definition at line 285 of file mkstringprep.py.

Definition at line 51 of file mkstringprep.py.

list mkstringprep.value = value.strip()

Definition at line 99 of file mkstringprep.py.