[PATCH] Don't use OrderedDict.
Chris Lumens
clumens at redhat.com
Tue Nov 12 20:55:20 UTC 2013
This doesn't exist in the python shipped with RHEL6, and pykickstart is
still being used on those systems for testing purposes.
---
pykickstart/commands/autopart.py | 36 ++++++++++++++++++++----------------
1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/pykickstart/commands/autopart.py b/pykickstart/commands/autopart.py
index 089788c..fd1512d 100644
--- a/pykickstart/commands/autopart.py
+++ b/pykickstart/commands/autopart.py
@@ -21,8 +21,6 @@ from pykickstart.base import *
from pykickstart.errors import *
from pykickstart.options import *
-from collections import OrderedDict
-
import gettext
_ = lambda x: gettext.ldgettext("pykickstart", x)
@@ -215,28 +213,34 @@ class F17_AutoPart(F16_AutoPart):
def __init__(self, writePriority=100, *args, **kwargs):
F16_AutoPart.__init__(self, writePriority=writePriority, *args, **kwargs)
self.type = kwargs.get("type", None)
- # This uses OrderedDict because we want to always output --type=plain
- # (as opposed to --type=partition) in __str__ when self.type is
- # AUTOPART_TYPE_PLAIN.
- self.typeMap = OrderedDict([("lvm", AUTOPART_TYPE_LVM),
- ("btrfs", AUTOPART_TYPE_BTRFS),
- ("plain", AUTOPART_TYPE_PLAIN),
- ("partition", AUTOPART_TYPE_PLAIN)])
+ self.typeMap = { "lvm": AUTOPART_TYPE_LVM,
+ "btrfs": AUTOPART_TYPE_BTRFS,
+ "plain": AUTOPART_TYPE_PLAIN,
+ "partition": AUTOPART_TYPE_PLAIN }
+
+ def _typeAsStr(self):
+ retval = None
+
+ for (key, value) in self.typeMap.items():
+ if value == self.type:
+ retval = key
+ break
+
+ if retval == "partition":
+ retval = "plain"
+
+ return retval
def __str__(self):
retval = F16_AutoPart.__str__(self)
if not self.autopart:
return retval
- if self.type is not None:
+ ty = self._typeAsStr()
+ if ty:
# remove any trailing newline
retval = retval.strip()
- retval += " --type="
- for s, n in self.typeMap.items():
- if self.type == n:
- retval += s
- break
- retval += "\n"
+ retval += " --type=%s\n" % ty
return retval
--
1.8.3.1
More information about the anaconda-patches
mailing list