[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
booty - more bootloaderInfo.py cleanup
- From: Shandy Brown <sjbrown vmware com>
- To: Discussion of Development and Customization of the Red Hat Linux Installer <anaconda-devel-list redhat com>
- Subject: booty - more bootloaderInfo.py cleanup
- Date: Wed, 08 Aug 2007 13:22:23 -0700
cleaned a few things:
"dict" should not be used as a variable name - also took this
opportunity to shorten the code down to a quick call to copy()
__init__ should go at the beginning of classes
added a class-level docstring
moved comment to docstring for getImages()
clarified & shortened code in setImageLabel()
Shandy
--- ../orig_booty/bootloaderInfo.py 2007-08-08 12:31:22.000000000 -0700
+++ bootloaderInfo.py 2007-08-08 13:15:46.000000000 -0700
@@ -21,6 +21,7 @@
import random
import shutil
import string
+from copy import copy
from lilo import LiloConfigFile
import rhpl
@@ -132,27 +133,31 @@
class BootImages:
- # returns dictionary of (label, longlabel, devtype) pairs indexed by device
+ """A collection to keep track of boot images available on the system.
+ Examples would be:
+ ('linux', 'Red Hat Linux', 'ext2'),
+ ('Other', 'Other', 'fat32'), ...
+ """
+ def __init__(self):
+ self.default = None
+ self.images = {}
+
def getImages(self):
+ """returns dictionary of (label, longlabel, devtype) pairs
+ indexed by device"""
# return a copy so users can modify it w/o affecting us
+ return copy(self.images)
- dict = {}
- for key in self.images.keys():
- dict[key] = self.images[key]
-
- return dict
def setImageLabel(self, dev, label, setLong = 0):
+ orig = self.images[dev]
if setLong:
- self.images[dev] = (self.images[dev][0], label,
- self.images[dev][2])
+ self.images[dev] = (orig[0], label, orig[2])
else:
- self.images[dev] = (label, self.images[dev][1],
- self.images[dev][2])
+ self.images[dev] = (label, orig[1], orig[2])
-
- # default is a device
def setDefault(self, default):
+ # default is a device
self.default = default
def getDefault(self):
@@ -233,11 +238,6 @@
return devs
-
-
- def __init__(self):
- self.default = None
- self.images = {}
class bootloaderInfo:
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]