Revision 3c98e3a5

b/snf-common/synnefo/util/units.py
34 34
from synnefo.lib.ordereddict import OrderedDict
35 35
import re
36 36

  
37
PRACTICALLY_INFINITE = 2**63 - 1
37 38
DEFAULT_PARSE_BASE = 1024
38 39
PARSE_EXPONENTS = {
39 40
    '':      0,
......
76 77

  
77 78

  
78 79
def parse_with_style(s):
80
    if s in ['inf', 'infinite']:
81
        return PRACTICALLY_INFINITE, 0
82

  
79 83
    n, unit = _parse_number_with_unit(s)
80 84
    try:
81 85
        exponent = PARSE_EXPONENTS[unit]
......
136 140

  
137 141

  
138 142
def show(n, unit, style=None):
143
    if style == 'none':
144
        return str(n)
145

  
146
    if n == PRACTICALLY_INFINITE:
147
        return 'inf'
148

  
139 149
    try:
140 150
        unit_dict = UNITS[unit]
141 151
    except KeyError:
142 152
        return str(n)
143 153

  
144
    if style == 'none':
145
        return str(n)
146

  
147 154
    BASE = unit_dict['BASE']
148 155
    DISPLAY = unit_dict['DISPLAY']
149 156

  

Also available in: Unified diff