[blivet:master+? 5/9] Add new method getSpecifiers().

mulhern amulhern at redhat.com
Thu Oct 23 17:57:05 UTC 2014


Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/size.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/blivet/size.py b/blivet/size.py
index 24d359c..03ca084 100644
--- a/blivet/size.py
+++ b/blivet/size.py
@@ -74,6 +74,19 @@ _EMPTY_PREFIX = _Prefix(1, b"", b"")
 _BYTES = [N_(b'B'), N_(b'b'), N_(b'byte'), N_(b'bytes')]
 _PREFIXES = _BINARY_PREFIXES + _DECIMAL_PREFIXES
 
+def getSpecifiers(units, xlate=False):
+    """ Get the valid units specifiers for units.
+
+        :param any units: any object, but should be a number like 1024
+        :param bool xlate: if True, translate specifiers for current locale
+        :returns: a list of valid specifiers for the units, or None
+        :rtype: list of str or NoneType
+    """
+    for factor, prefix, abbr in [_EMPTY_PREFIX] + _BINARY_PREFIXES + _DECIMAL_PREFIXES:
+        if units == factor:
+            return _makeSpecs(prefix, abbr, xlate)
+    return None
+
 # Translated versions of the byte and prefix arrays as lazy comprehensions
 def _xlated_bytes():
     return (_(b) for b in _BYTES)
-- 
1.9.3



More information about the anaconda-patches mailing list