Package ganeti :: Module compat
[hide private]
[frames] | no frames]

Module compat

source code

Module containing backported language/library functionality.

Functions [hide private]
 
_all(seq)
Returns True if all elements in the iterable are True.
source code
 
_any(seq)
Returns True if any element of the iterable are True.
source code
 
all(seq)
Returns True if all elements in the iterable are True.
source code
 
any(seq)
Returns True if any element of the iterable are True.
source code
 
partition(seq, pred=bool)
Partition a list in two, based on the given predicate.
source code
 
_partial(func, *args, **keywords)
Decorator with partial application of arguments and keywords.
source code
string
RomanOrRounded(value, rounding, convert=True)
Try to round the value to the closest integer and return it as a roman numeral.
source code
string or typeof(val)
TryToRoman(val, convert=True)
Try to convert a value to roman numerals
source code
 
UniqueFrozenset(seq)
Makes frozenset from sequence after checking for duplicate elements.
source code
Variables [hide private]
  functools = None
hash(x)
  roman = None
hash(x)
  sha1 = sha
  sha1_hash = sha.new
  partial = functools.partial
  fst = operator.itemgetter(0)
returns the first element of a list-like value
  snd = operator.itemgetter(1)
returns the second element of a list-like value

Imports: itertools, operator, md5_hash, sha


Function Details [hide private]

_partial(func, *args, **keywords)

source code 

Decorator with partial application of arguments and keywords.

This function was copied from Python's documentation.

RomanOrRounded(value, rounding, convert=True)

source code 

Try to round the value to the closest integer and return it as a roman numeral. If the conversion is disabled, or if the roman module could not be loaded, round the value to the specified level and return it.

Parameters:
  • value (number) - value to convert
  • rounding (integer) - how many decimal digits the number should be rounded to
  • convert (boolean) - if False, don't try conversion at all
Returns: string
roman numeral for val, or formatted string representing val if conversion didn't succeed

TryToRoman(val, convert=True)

source code 

Try to convert a value to roman numerals

If the roman module could be loaded convert the given value to a roman numeral. Gracefully fail back to leaving the value untouched.

Parameters:
  • val (integer) - value to convert
  • convert (boolean) - if False, don't try conversion at all
Returns: string or typeof(val)
roman numeral for val, or val if conversion didn't succeed

UniqueFrozenset(seq)

source code 

Makes frozenset from sequence after checking for duplicate elements.

Raises:
  • ValueError - When there are duplicate elements