Revision 1463
Added by Aaron Marcuse-Kubitza over 12 years ago
xml_func.py | ||
---|---|---|
6 | 6 |
|
7 | 7 |
import dates |
8 | 8 |
import exc |
9 |
import format |
|
9 | 10 |
import maps |
10 | 11 |
import strings |
11 | 12 |
import term |
... | ... | |
149 | 150 |
|
150 | 151 |
def _units(items): |
151 | 152 |
items = dict(conv_items(str, items)) |
152 |
try: |
|
153 |
units = items['units'] |
|
154 |
value = items['value'] |
|
153 |
try: value = items['value'] |
|
155 | 154 |
except KeyError, e: raise SyntaxException(e) |
156 |
return value#+' '+units # don't add yet because unit conversion isn't ready |
|
155 |
default_units = items.get('units', None) |
|
156 |
# DB unit conversion isn't ready yet, so just return number |
|
157 |
try: return format.cleanup_units(value, default_units).split(' ')[0] |
|
158 |
except format.MissingUnitsException, e: raise SyntaxException(e) |
|
157 | 159 |
funcs['_units'] = _units |
158 | 160 |
|
159 | 161 |
def _range(items): |
Also available in: Unified diff
xml_func.py: _units: Use new format.cleanup_units() to do units parsing