Package wtf :: Module _wtf_cutil
[hide private]
[frames] | no frames]

Module _wtf_cutil

This module provides some misc util implementations for WTF.


Author: Andr\xe9 Malo

Functions [hide private]
int
hash32(s)
Replacement for str.__hash__
 
initgroups(username, gid)
Execute initgroups(3).
str
quote(s, safe='/', encoding='utf-8', errors='strict')
Fast replacement for urllib.quote, which also handles unicode.
str
quote_plus(s, safe='/', encoding='utf-8', errors='strict')
Fast replacement for urllib.quote_plus, which also handles unicode.
basestring
unquote(s)
Fast replacement for urllib.unquote
basestring
unquote_plus(s)
Fast replacement for urllib.unquote_plus
Variables [hide private]
bool HAVE_INITGROUPS = True
Is initgroups(3) on this system implemented?
  __package__ = None
Function Details [hide private]

hash32(s)

 

Replacement for str.__hash__

The function which is supposed to give identical results on 32 and 64 bit systems.

Parameters:
  • s (str) - The string to hash
Returns: int
The hash value

initgroups(username, gid)

 

Execute initgroups(3). If initgroups is not available on this system, this function is a no-op.

Parameters

  • username: The user name
  • gid: The group id

Types

  • username: str
  • gid: int
Raises:
  • OSError - initgroups() didn't succeed

See Also: HAVE_INITGROUPS

quote(s, safe='/', encoding='utf-8', errors='strict')

 
Fast replacement for urllib.quote, which also handles unicode.
Parameters:
  • s (basestring) - The string to quote
  • safe (str) - safe characters (not quoted)
  • encoding (str) - Encoding to apply in case s is unicode
  • errors (str) - Error handling in case s is unicode
Returns: str
The quoted string
Raises:
  • UnicodeError - Encoding error

quote_plus(s, safe='/', encoding='utf-8', errors='strict')

 
Fast replacement for urllib.quote_plus, which also handles unicode.
Parameters:
  • s (basestring) - The string to quote
  • safe (str) - safe characters (not quoted)
  • encoding (str) - Encoding to apply in case s is unicode
  • errors (str) - Error handling in case s is unicode
Returns: str
The quoted string
Raises:
  • UnicodeError - Encoding error

unquote(s)

 
Fast replacement for urllib.unquote
Parameters:
  • s (basestring) - The string to quote
Returns: basestring
The unquoted string

unquote_plus(s)

 
Fast replacement for urllib.unquote_plus
Parameters:
  • s (basestring) - The string to unquote
Returns: basestring
The unquoted string