Package pytils :: Module translit
[hide private]
[frames] | no frames]

Module translit

source code

Simple transliteration

Functions [hide private]
str translify(in_string)
Translify russian text
str detranslify(in_string)
Detranslify
str slugify(in_string)
Prepare string for slug (i.e.
  dirify(in_string)
Alias for slugify

Variables [hide private]
  __revision__ = '$Id: translit.py 32 2006-10-28 07:10:43Z the.pythy $'
  __id__ = '$Id: translit.py 32 2006-10-28 07:10:43Z the.pythy $'
  __url__ = '$URL: https://pythy.googlecode.com/svn/trunk/pytils...
  TRANSTABLE = ((u'\u2018', u"'"), (u'\u2019', u"'"), (u'\xab', u'"...
Translation table
  RU_ALPHABET = [u'\u2018', u'\u2019', u'\xab', u'\xbb', u'\u2013', ...
Russian alphabet that we can translate
  EN_ALPHABET = [u"'", u"'", u'"', u'"', u'-', u'...', u'#', u'Sch',...
English alphabet that we can detransliterate
  ALPHABET = [u'\u2018', u'\u2019', u'\xab', u'\xbb', u'\u2013', ...
Alphabet that we can (de)transliterate
  x = (u'0', u'0')

Function Details [hide private]

translify(in_string)

source code 
Translify russian text
Parameters:
  • in_string (unicode) - input string
Returns: str
transliterated string
Raises:
  • TypeError - when in_string is not unicode
  • ValueError - when string doesn't transliterate completely

detranslify(in_string)

source code 
Detranslify
Parameters:
  • in_string (basestring) - input string
Returns: str
detransliterated string
Raises:
  • TypeError - when in_string neither str, no unicode
  • ValueError - if in_string is str, but it isn't ascii

slugify(in_string)

source code 
Prepare string for slug (i.e. URL or file/dir name)
Parameters:
  • in_string (basestring) - input string
Returns: str
slug-string
Raises:
  • TypeError - when in_string isn't unicode or str
  • ValueError - if in_string is str, but it isn't ascii

dirify(in_string)

source code 
Alias for slugify

Variables Details [hide private]

__revision__

None
Value:
'$Id: translit.py 32 2006-10-28 07:10:43Z the.pythy $'                 
      

__id__

None
Value:
'$Id: translit.py 32 2006-10-28 07:10:43Z the.pythy $'                 
      

__url__

None
Value:
'$URL: https://pythy.googlecode.com/svn/trunk/pytils/pytils/translit.p
y $'                                                                   
      

TRANSTABLE

Translation table
Value:
((u'\u2018', u"'"),
 (u'\u2019', u"'"),
 (u'\xab', u'"'),
 (u'\xbb', u'"'),
 (u'\u2013', u'-'),
 (u'\u2026', u'...'),
 (u'\u2116', u'#'),
 (u'\u0429', u'Sch'),
...                                                                    
      

RU_ALPHABET

Russian alphabet that we can translate
Value:
[u'\u2018',
 u'\u2019',
 u'\xab',
 u'\xbb',
 u'\u2013',
 u'\u2026',
 u'\u2116',
 u'\u0429',
...                                                                    
      

EN_ALPHABET

English alphabet that we can detransliterate
Value:
[u"'", u"'", u'"', u'"', u'-', u'...', u'#', u'Sch', u'SCH']           
      

ALPHABET

Alphabet that we can (de)transliterate
Value:
[u'\u2018',
 u'\u2019',
 u'\xab',
 u'\xbb',
 u'\u2013',
 u'\u2026',
 u'\u2116',
 u'\u0429',
...                                                                    
      

x

None
Value:
(u'0', u'0')