Back to index

plone3  3.1.7
Functions | Variables
wicked.normalize Namespace Reference

Functions

def normalizeISO
def titleToNormalizedId

Variables

string __authors__ = 'Anders Pearson <anders@columbia.edu>'
 Licensed under the terms of the GNU Public License (see docs/LICENSE.GPL)
string __docformat__ = 'restructuredtext'
dictionary mapping
tuple pattern1 = re.compile(r"^([^\.]+)\.(\w{,4})$")
tuple pattern2 = re.compile(r'r"([\W\-]+)"')
list tests
tuple sanitized = titleToNormalizedId(original)

Function Documentation

def wicked.normalize.normalizeISO (   text = "")

Definition at line 27 of file normalize.py.

00027 
00028 def normalizeISO(text=""):
00029     fixed = []
00030     for c in list(text):
00031         if ord(c) < 256:
00032             c = mapping.get(ord(c),c)
00033         else:
00034             c = "%x" % ord(c)
00035         fixed.append(c)
00036     return "".join(fixed)
00037 

Here is the caller graph for this function:

Definition at line 40 of file normalize.py.

00040 
00041 def titleToNormalizedId(title=""):
00042     title = title.lower()
00043     title = title.strip()
00044     title = normalizeISO(title)
00045     base = title
00046     ext = ""
00047     m = pattern1.match(title)
00048     if m:
00049         base = m.groups()[0]
00050         ext = m.groups()[1]
00051     parts = pattern2.split(base)
00052         
00053     slug = re.sub(r"[\W\-]+","-",base)
00054     slug = re.sub(r"^\-+","",slug)
00055     slug = re.sub(r"\-+$","",slug)
00056     if ext != "":
00057         slug = slug + "." + ext
00058     return slug
00059 

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

string wicked.normalize.__authors__ = 'Anders Pearson <anders@columbia.edu>'

Licensed under the terms of the GNU Public License (see docs/LICENSE.GPL)

Copyright (c) 2005:

Definition at line 12 of file normalize.py.

string wicked.normalize.__docformat__ = 'restructuredtext'

Definition at line 13 of file normalize.py.

Initial value:
00001 {138: 's', 140: 'OE', 142: 'z', 154: 's', 156: 'oe', 158: 'z', 159: 'Y', 
00002 192: 'A', 193: 'A', 194: 'A', 195: 'A', 196: 'A', 197: 'a', 198: 'E', 199: 'C', 
00003 200: 'E', 201: 'E', 202: 'E', 203: 'E', 204: 'I', 205: 'I', 206: 'I', 207: 'I', 
00004 208: 'D', 209: 'n', 211: 'O', 212: 'O', 214: 'O', 216: 'O', 217: 'U', 218: 'U', 
00005 219: 'U', 220: 'U', 221: 'y', 223: 'ss', 224: 'a', 225: 'a', 226: 'a', 227: 'a', 
00006 228: 'a', 229: 'a', 230: 'e', 231: 'c', 232: 'e', 233: 'e', 234: 'e', 235: 'e', 
00007 236: 'i', 237: 'i', 238: 'i', 239: 'i', 240: 'd', 241: 'n', 243: 'o', 244: 'o', 
00008 246: 'o', 248: 'o', 249: 'u', 250: 'u', 251: 'u', 252: 'u', 253: 'y', 255: 'y'}

Definition at line 17 of file normalize.py.

tuple wicked.normalize.pattern1 = re.compile(r"^([^\.]+)\.(\w{,4})$")

Definition at line 38 of file normalize.py.

tuple wicked.normalize.pattern2 = re.compile(r'r"([\W\-]+)"')

Definition at line 39 of file normalize.py.

Definition at line 75 of file normalize.py.

Initial value:
00001 [
00002 (u"This is a normal title.", "this-is-a-normal-title"),
00003 (u"Short sentence. Big thoughts.", "short-sentence-big-thoughts"),
00004 (u"Some298374NUMBER", "some298374number"),
00005 (u'Eksempel \xe6\xf8\xe5 norsk \xc6\xd8\xc5', u'eksempel-aoa-norsk-aoa'), 
00006 (u'\u9ad8\u8054\u5408 Chinese', u'2837821-chinese'), 
00007 (u'\u30a2\u30ec\u30af\u30b5\u30f3\u30c0\u30fc\u3000\u30ea\u30df Japanese', u'23987643-japanese'), 
00008 (u'\uc774\ubbf8\uc9f1 Korean', u'987342-korean'), 
00009 (u'\u0e2d\u0e40\u0e25\u0e47\u0e01\u0e0b\u0e32\u0e19\u0e40\u0e14\u0e2d\u0e23\u0e4c \u0e25\u0e35\u0e21 Thai', u'7265837-thai'), 
00010 (u'About folder.gif', u'about-folder.gif')]

Definition at line 60 of file normalize.py.