"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cloudkitty/utils/__init__.py" between
cloudkitty-16.0.0.tar.gz and cloudkitty-17.0.0.tar.gz

About: OpenStack CloudKitty provides Rating-as-a-Service for OpenStack.
The "Zed" series (latest release).

__init__.py  (cloudkitty-16.0.0):__init__.py  (cloudkitty-17.0.0)
skipping to change at line 230 skipping to change at line 230
def tempdir(**kwargs): def tempdir(**kwargs):
tmpdir = tempfile.mkdtemp(**kwargs) tmpdir = tempfile.mkdtemp(**kwargs)
try: try:
yield tmpdir yield tmpdir
finally: finally:
try: try:
shutil.rmtree(tmpdir) shutil.rmtree(tmpdir)
except OSError as e: except OSError as e:
LOG.debug('Could not remove tmpdir: %s', e) LOG.debug('Could not remove tmpdir: %s', e)
def mutate(value, mode='NONE'): def mutate(value, mode='NONE', mutate_map=None):
"""Mutate value according provided mode.""" """Mutate value according to provided mode."""
if mode == 'NUMBOOL': if mode == 'NUMBOOL':
return float(value != 0.0) return float(value != 0.0)
if mode == 'NOTNUMBOOL': if mode == 'NOTNUMBOOL':
return float(value == 0.0) return float(value == 0.0)
if mode == 'FLOOR': if mode == 'FLOOR':
return math.floor(value) return math.floor(value)
if mode == 'CEIL': if mode == 'CEIL':
return math.ceil(value) return math.ceil(value)
if mode == 'MAP':
ret = 0.0
if mutate_map is not None:
ret = mutate_map.get(value, 0.0)
return ret
return value return value
def num2decimal(num): def num2decimal(num):
"""Converts a number into a decimal.Decimal. """Converts a number into a decimal.Decimal.
The number may be an str in float, int or fraction format; The number may be an str in float, int or fraction format;
a fraction.Fraction, a decimal.Decimal, an int or a float. a fraction.Fraction, a decimal.Decimal, an int or a float.
""" """
if isinstance(num, decimal.Decimal): if isinstance(num, decimal.Decimal):
return num return num
 End of changes. 2 change blocks. 
2 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)