Package pytils :: Module translit
[hide private]

Module translit

source code

Simple transliteration

Functions [hide private]
str
translify(in_string)
Translify russian text
source code
str
detranslify(in_string)
Detranslify
source code
str
slugify(in_string)
Prepare string for slug (i.e.
source code
 
dirify(in_string)
Alias for slugify
source code
Variables [hide private]
  __revision__ = '$Id: translit.py 102 2007-07-12 12:33:36Z the....
  __id__ = '$Id: translit.py 102 2007-07-12 12:33:36Z the.pythy $'
  __url__ = '$URL: https://pythy.googlecode.com/svn/tags/pytils/...
  TRANSTABLE = ((u''', u'''), (u'"', u'"'), (u'\u2018', u'''), (...
Translation table
  RU_ALPHABET = [u''', u'"', u'\u2018', u'\u2019', u'\xab', u'\x...
Russian alphabet that we can translate
  EN_ALPHABET = [u''', u'"', u''', u''', u'"', u'"', u'-', u'......
English alphabet that we can detransliterate
  ALPHABET = [u''', u'"', u'\u2018', u'\u2019', u'\xab', u'\xbb'...
Alphabet that we can (de)transliterate
  x = (u'0', u'0')

Imports: re, utils


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

Variables Details [hide private]

__revision__

Value:
'$Id: translit.py 102 2007-07-12 12:33:36Z the.pythy $'

__url__

Value:
'$URL: https://pythy.googlecode.com/svn/tags/pytils/0_2_2/pytils/trans\
lit.py $'

TRANSTABLE

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

RU_ALPHABET

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

EN_ALPHABET

English alphabet that we can detransliterate
Value:
[u''',
 u'"',
 u''',
 u''',
 u'"',
 u'"',
 u'-',
 u'...',
...

ALPHABET

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