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

Module utils

source code

Misc utils for internal use

Functions [hide private]
  provide_unicode(stext, encoding, default=u"неизвестно")
Provide Unicode from text
  provide_str(utext, encoding, default="unknown")
Provide text from Unicode
  get_value_by_name(variable_name, depth=1)
Return value of variable by it's name
  check_type(variable_name, typ)
Checks type of variable
  check_length(variable_name, length)
Checks length of variable's value
  check_positive(variable_name, strict=False)
Checks if variable is positive

Variables [hide private]
  __revision__ = '$Id: utils.py 28 2006-10-21 08:03:02Z the.pythy $'
  __id__ = '$Id: utils.py 28 2006-10-21 08:03:02Z the.pythy $'
  __url__ = '$URL: https://pythy.googlecode.com/svn/trunk/pytils...

Function Details [hide private]

provide_unicode(stext, encoding, default=u"неизвестно")

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

Variables Details [hide private]

__revision__

None
Value:
'$Id: utils.py 28 2006-10-21 08:03:02Z the.pythy $'                    
      

__id__

None
Value:
'$Id: utils.py 28 2006-10-21 08:03:02Z the.pythy $'                    
      

__url__

None
Value:
'$URL: https://pythy.googlecode.com/svn/trunk/pytils/pytils/utils.py $
'