[PATCH] Be more liberal in what is accepted as a size unit.
David Shea
dshea at redhat.com
Tue Jan 21 15:15:28 UTC 2014
Not all size specifications will end with a letter. For example: the
translation of "B" for byte in Telugu ends with a vowel sign,
categorized in Unicode as a non-spacing mark. Instead check whether the
size string ends with a [0-9]: if so, the unit is missing.
---
pyanaconda/ui/gui/spokes/custom.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index 4b94628..c9acb8b 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -31,6 +31,7 @@
from contextlib import contextmanager
import re
+import locale
from pykickstart.constants import CLEARPART_TYPE_NONE, AUTOPART_TYPE_PLAIN, AUTOPART_TYPE_BTRFS, AUTOPART_TYPE_LVM, AUTOPART_TYPE_LVM_THINP
@@ -162,10 +163,15 @@ partition_only_format_types = ["efi", "macefi", "prepboot", "biosboot",
"appleboot"]
def size_from_entry(entry):
- size_text = entry.get_text().strip()
+ size_text = entry.get_text().decode("utf-8").strip()
- # if no unit was specified, default to MiB
- if not re.search(r'[A-Za-z]+$', size_text):
+ # Nothing to parse
+ if not size_text:
+ return None
+
+ # if no unit was specified, default to MiB. Assume that a string
+ # ending with anything other than a digit has a unit suffix
+ if re.search(r'[\d.%s]$' % locale.nl_langinfo(locale.RADIXCHAR), size_text):
size_text += "MiB"
try:
--
1.8.4.2
More information about the anaconda-patches
mailing list