diff options
author | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-09-03 16:02:50 +0000 |
---|---|---|
committer | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-09-04 16:10:28 +0000 |
commit | 65b8156aa2a0c86e8eb6d0d88e9f91c75b250960 (patch) | |
tree | 8108932fce4556664f4fd9a8e971c9751c7c296e | |
parent | 9ccfb38951daa3614014b568e6af8af10153fd83 (diff) | |
download | morph-65b8156aa2a0c86e8eb6d0d88e9f91c75b250960.tar.gz |
Allow 'disk-size' in system morphologies to be an integer
This is needed for being able to write morphologies to disk
programmatically after making automatic changes to them using
morph.
-rw-r--r-- | morphlib/morph2.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/morphlib/morph2.py b/morphlib/morph2.py index a707030d..801b6c3a 100644 --- a/morphlib/morph2.py +++ b/morphlib/morph2.py @@ -96,14 +96,17 @@ class Morphology(object): if 'disk-size' in self: size = self['disk-size'] - size = size.lower() - if size.endswith('g'): - size = int(size[:-1]) * 1024 ** 3 - elif size.endswith('m'): # pragma: no cover - size = int(size[:-1]) * 1024 ** 2 - elif size.endswith('k'): # pragma: no cover - size = int(size[:-1]) * 1024 - else: # pragma: no cover + if isinstance(size, basestring): + size = size.lower() + if size.endswith('g'): + size = int(size[:-1]) * 1024 ** 3 + elif size.endswith('m'): # pragma: no cover + size = int(size[:-1]) * 1024 ** 2 + elif size.endswith('k'): # pragma: no cover + size = int(size[:-1]) * 1024 + else: # pragma: no cover + size = int(size) + else: # pragma: no cover size = int(size) self._dict['disk-size'] = size |