summaryrefslogtreecommitdiffstats
path: root/storage/__init__.py
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2009-03-25 14:48:24 -0400
committerChris Lumens <clumens@redhat.com>2009-03-25 15:42:08 -0400
commit4fc6b22471f4d0534ba46811509ec1cd1a60e7fb (patch)
tree5194cc68e2f2981cb75afb9353aef913fe38815d /storage/__init__.py
parent67eb3b98f2cb351fe7d88d6c250faba3fe222f30 (diff)
downloadanaconda-4fc6b22471f4d0534ba46811509ec1cd1a60e7fb.tar.gz
anaconda-4fc6b22471f4d0534ba46811509ec1cd1a60e7fb.tar.xz
anaconda-4fc6b22471f4d0534ba46811509ec1cd1a60e7fb.zip
Rework CryptTab.parse (dlehman).
Diffstat (limited to 'storage/__init__.py')
-rw-r--r--storage/__init__.py51
1 files changed, 25 insertions, 26 deletions
diff --git a/storage/__init__.py b/storage/__init__.py
index 3fefbb5e9..16a69222d 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -1051,33 +1051,32 @@ class CryptTab(object):
path = "%s/etc/crypttab" % chroot
log.debug("parsing %s" % path)
with open(path) as f:
+ if not self.blkidTab:
+ try:
+ self.blkidTab = BlkidTab(chroot=chroot)
+ self.blkidTab.parse()
+ except Exception:
+ self.blkidTab = None
+
for line in f.readlines():
- if not self.blkidTab:
- try:
- self.blkidTab = BlkidTab(chroot=chroot)
- self.blkidTab.parse()
- except Exception:
- self.blkidTab = None
-
- for line in lines:
- (line, pound, comment) = line.partition("#")
- fields = line.split()
- if not 2 <= len(fields) <= 4:
- continue
- elif len(fields) == 2:
- fields.extend(['none', ''])
- elif len(fields) == 3:
- fields.append('')
-
- (name, devspec, keyfile, options) = fields
-
- # resolve devspec to a device in the tree
- device = self.devicetree.resolveDevice(devspec,
- blkidTab=self.blkidTab)
- if device:
- self.mappings[name] = {"device": device,
- "keyfile": keyfile,
- "options": options}
+ (line, pound, comment) = line.partition("#")
+ fields = line.split()
+ if not 2 <= len(fields) <= 4:
+ continue
+ elif len(fields) == 2:
+ fields.extend(['none', ''])
+ elif len(fields) == 3:
+ fields.append('')
+
+ (name, devspec, keyfile, options) = fields
+
+ # resolve devspec to a device in the tree
+ device = self.devicetree.resolveDevice(devspec,
+ blkidTab=self.blkidTab)
+ if device:
+ self.mappings[name] = {"device": device,
+ "keyfile": keyfile,
+ "options": options}
def populate(self):
""" Populate the instance based on the device tree's contents. """