Package pytils :: Module utils
[hide private]

Module utils

source code

Misc utils for internal use

Functions [hide private]
 
provide_unicode(stext, encoding, default=u'\u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e')
Provide Unicode from text
source code
 
provide_str(utext, encoding, default='unknown')
Provide text from Unicode
source code
 
get_value_by_name(variable_name, depth=1)
Return value of variable by it's name
source code
 
check_type(variable_name, typ)
Checks type of variable
source code
 
check_length(variable_name, length)
Checks length of variable's value
source code
 
check_positive(variable_name, strict=False)
Checks if variable is positive
source code
 
split_values(ustring, sep=u',')
Splits unicode string with separator sep, but skips escaped separator.
source code
Variables [hide private]
  __revision__ = '$Id: utils.py 103 2007-07-12 13:10:13Z the.pyt...
  __id__ = '$Id: utils.py 103 2007-07-12 13:10:13Z the.pythy $'
  __url__ = '$URL: https://pythy.googlecode.com/svn/tags/pytils/...

Imports: sys


Function Details [hide private]

provide_unicode(stext, encoding, default=u'\u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e')

source code 
Provide Unicode from text
Parameters:
  • stext (str) - text
  • encoding (str) - encoding if input text
Returns:
unicode

provide_str(utext, encoding, default='unknown')

source code 
Provide text from Unicode
Parameters:
  • utext (unicode) - unicode text
  • encoding (str) - encoding of output text
Returns:
str

get_value_by_name(variable_name, depth=1)

source code 
Return value of variable by it's name
Parameters:
  • variable_name (str) - name of variable
  • depth (int) - stack depth
Raises:
  • RuntimeError - when unable to fetch variable

check_type(variable_name, typ)

source code 
Checks type of variable
Parameters:
  • variable_name (str) - name of variable
  • typ (type or tuple of types) - type checking for
Returns:
None when check successful
Raises:
  • TypeError - check failed

check_length(variable_name, length)

source code 
Checks length of variable's value
Parameters:
  • variable_name (str) - name of variable
  • length (int) - length checking for
Returns:
None when check successful
Raises:
  • ValueError - check failed

check_positive(variable_name, strict=False)

source code 
Checks if variable is positive
Parameters:
  • variable_name (str) - name of variable
Returns:
None when check successful
Raises:
  • ValueError - check failed

split_values(ustring, sep=u',')

source code 
Splits unicode string with separator sep, but skips escaped separator.
Parameters:
  • ustring (unicode) - string to split
  • sep (unicode) - separator (default to u',')
Returns:
tuple of splitted elements

Variables Details [hide private]

__revision__

Value:
'$Id: utils.py 103 2007-07-12 13:10:13Z the.pythy $'

__url__

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