[blivet:master 10/20] Add unitStr() method.
mulhern
amulhern at redhat.com
Tue Dec 23 23:42:23 UTC 2014
Signed-off-by: mulhern <amulhern at redhat.com>
---
blivet/size.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/blivet/size.py b/blivet/size.py
index a09c277..79564c2 100644
--- a/blivet/size.py
+++ b/blivet/size.py
@@ -105,6 +105,16 @@ def _makeSpec(prefix, suffix, xlate, lowercase=True):
word = prefix + suffix
return _lowerASCII(word) if lowercase else word
+def unitStr(unit, xlate=False):
+ """ Return a string representation of unit.
+
+ :param unit: a named unit, e.g., KiB
+ :param bool xlate: if True, translate to current locale
+ :rtype: some kind of string type
+ :returns: string representation of unit
+ """
+ return _makeSpec(unit.abbr, _BYTES_SYMBOL, xlate, lowercase=False)
+
def _parseUnits(units, xlate):
""" Parse a unit specification and return corresponding factor.
--
1.9.3
More information about the anaconda-patches
mailing list