Revision 7655
Added by Aaron Marcuse-Kubitza almost 12 years ago
units.py | ||
---|---|---|
7 | 7 |
import strings |
8 | 8 |
import util |
9 | 9 |
|
10 |
def parse_range(str_, range_sep='-'): |
|
11 |
default = (str_, None) |
|
12 |
start, sep, end = str_.partition(range_sep) |
|
13 |
if sep == '': return default # not a range |
|
14 |
if start == '' and range_sep == '-': return default # negative number |
|
15 |
return tuple(d.strip() for d in (start, end)) |
|
16 |
|
|
10 | 17 |
class MissingUnitsException(Exception): |
11 | 18 |
def __init__(self, quantity): |
12 | 19 |
Exception.__init__(self, 'Quantity has no units: ' |
Also available in: Unified diff
Moved parse_range() from xml_func.py to units.py