summaryrefslogtreecommitdiff
path: root/morphlib/morph2.py
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-09-03 16:02:50 +0000
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-09-04 16:10:28 +0000
commit65b8156aa2a0c86e8eb6d0d88e9f91c75b250960 (patch)
tree8108932fce4556664f4fd9a8e971c9751c7c296e /morphlib/morph2.py
parent9ccfb38951daa3614014b568e6af8af10153fd83 (diff)
downloadmorph-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.
Diffstat (limited to 'morphlib/morph2.py')
-rw-r--r--morphlib/morph2.py19
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