[blivet:master 02/12] Changes to _parseOneLine() and its single invocation.

mulhern amulhern at redhat.com
Mon Apr 28 22:26:40 UTC 2014


* Make the parameters the usual kind of parameters.
* Give the standard defaults for _dump and _passno.
* Don't bother to extend fields since _parseOneLine() will do the right thing.
* Add a small comment to _parseOneLine.
* Make the default fields strings instead of numbers since they will certainly
be strings if read from the file.

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/__init__.py | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/blivet/__init__.py b/blivet/__init__.py
index b2f408e..b4e057f 100644
--- a/blivet/__init__.py
+++ b/blivet/__init__.py
@@ -2436,7 +2436,16 @@ class FSSet(object):
                 filesystems[device.format.mountpoint] = device
         return filesystems
 
-    def _parseOneLine(self, (devspec, mountpoint, fstype, options, dump, passno)):
+    def _parseOneLine(self, devspec, mountpoint, fstype, options, _dump="0", _passno="0"):
+        """Parse an fstab entry for a device, return the corresponding device.
+
+           The parameters correspond to the items in a single entry in the
+           order in which they occur in the entry.
+
+           :returns: the device corresponding to the entry
+           :rtype: :class:`devices.Device`
+        """
+
         # no sense in doing any legwork for a noauto entry
         if "noauto" in options.split(","):
             log.info("ignoring noauto entry")
@@ -2590,15 +2599,9 @@ class FSSet(object):
 
                 if not 4 <= len(fields) <= 6:
                     continue
-                elif len(fields) == 4:
-                    fields.extend([0, 0])
-                elif len(fields) == 5:
-                    fields.append(0)
-
-                (devspec, mountpoint, fstype, options, dump, passno) = fields
 
                 try:
-                    device = self._parseOneLine((devspec, mountpoint, fstype, options, dump, passno))
+                    device = self._parseOneLine(*fields)
                 except UnrecognizedFSTabEntryError:
                     # just write the line back out as-is after upgrade
                     self.preserveLines.append(line)
-- 
1.8.3.1



More information about the anaconda-patches mailing list