[Kimchi-devel] [PATCH 6/6] pep8 cleanup for isoinfo.py

Aline Manera alinefm at linux.vnet.ibm.com
Mon Dec 30 17:09:44 UTC 2013


From: Aline Manera <alinefm at br.ibm.com>

This patch cleans up pep8 style issue in isoinfo.py

Signed-off-by: Aline Manera <alinefm at br.ibm.com>
---
 Makefile.am           |    1 +
 src/kimchi/isoinfo.py |   29 +++++++++++++++++------------
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 0fd92c8..9ed9aec 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -43,6 +43,7 @@ PEP8_WHITELIST = \
 	src/kimchi/cachebust.py \
 	src/kimchi/config.py.in \
 	src/kimchi/disks.py \
+	src/kimchi/isoinfo.py \
 	src/kimchi/root.py \
 	src/kimchi/server.py \
 	plugins/__init__.py \
diff --git a/src/kimchi/isoinfo.py b/src/kimchi/isoinfo.py
index 6f3ad7d..1a0b359 100644
--- a/src/kimchi/isoinfo.py
+++ b/src/kimchi/isoinfo.py
@@ -18,7 +18,7 @@
 #
 # You should have received a copy of the GNU Lesser General Public
 # License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 
 import glob
 import os
@@ -31,6 +31,7 @@ import urllib2
 from kimchi.exception import IsoFormatError
 from kimchi.utils import kimchi_log
 
+
 iso_dir = [
     ##
     # Portions of this data from libosinfo: http://libosinfo.org/
@@ -134,7 +135,7 @@ class IsoImage(object):
     EL_TORITO_VALIDATION_ENTRY = struct.Struct("=BBH24sHBB")
     EL_TORITO_BOOT_ENTRY = struct.Struct("=BBHBBHL20x")
 
-    def __init__(self, path, remote = None):
+    def __init__(self, path, remote=None):
         self.path = path
         self.volume_id = None
         self.bootable = False
@@ -180,8 +181,8 @@ class IsoImage(object):
                     version = v
                 return (distro, version)
 
-        kimchi_log.debug("probe_iso: Unable to identify ISO %s with Volume ID: %s"
-                     % (self.path, self.volume_id))
+        msg = "probe_iso: Unable to identify ISO %s with Volume ID: %s"
+        kimchi_log.debug(msg % (self.path, self.volume_id))
 
         return ('unknown', 'unknown')
 
@@ -192,9 +193,9 @@ class IsoImage(object):
         """
         Search the Volume Descriptor Table for an El Torito boot record.  If
         found, the boot record will provide a link to a boot catalogue.  The
-        first entry in the boot catalogue is a validation entry.  The next entry
-        contains the default boot entry.  The default boot entry will indicate
-        whether the image is considered bootable.
+        first entry in the boot catalogue is a validation entry.  The next
+        entry contains the default boot entry. The default boot entry will
+        indicate whether the image is considered bootable.
         """
         vd_type = -1
         for i in xrange(1, 4):
@@ -214,7 +215,8 @@ class IsoImage(object):
             raise IsoFormatError("Invalid El Torito boot record")
 
         offset = IsoImage.SECTOR_SIZE * boot_cat
-        size = IsoImage.EL_TORITO_VALIDATION_ENTRY.size + IsoImage.EL_TORITO_BOOT_ENTRY.size
+        size = IsoImage.EL_TORITO_VALIDATION_ENTRY.size + \
+            IsoImage.EL_TORITO_BOOT_ENTRY.size
         data = self._get_iso_data(offset, size)
 
         fmt = IsoImage.EL_TORITO_VALIDATION_ENTRY
@@ -242,8 +244,8 @@ class IsoImage(object):
         Volume ID from the table
         """
         primary_vol_data = data[0: -1]
-        (vd_type, vd_ident, vd_ver,
-         pad0, sys_id, vol_id) = self._unpack(IsoImage.VOL_DESC, primary_vol_data)
+        info = self._unpack(IsoImage.VOL_DESC, primary_vol_data)
+        (vd_type, vd_ident, vd_ver, pad0, sys_id, vol_id) = info
         if vd_type != 1:
             raise IsoFormatError("Unexpected volume type for primary volume")
         if vd_ident != 'CD001' or vd_ver != 1:
@@ -253,7 +255,8 @@ class IsoImage(object):
     def _get_iso_data(self, offset, size):
         if self.remote:
             request = urllib2.Request(self.path)
-            request.add_header("range", "bytes=%d-%d" % (offset, offset + size -1))
+            range_header = "bytes=%d-%d" % (offset, offset + size - 1)
+            request.add_header("range", range_header)
             response = urllib2.urlopen(request)
             data = response.read()
         else:
@@ -325,13 +328,15 @@ def probe_iso(status_helper, params):
         ret = iso_img.probe()
         update_result(loc, ret)
 
-    if status_helper != None:
+    if status_helper is not None:
         status_helper('', True)
 
 
 if __name__ == '__main__':
     iso_list = []
+
     def updater(iso_info):
         iso_list.append(iso_info)
+
     probe_iso(None, dict(path=sys.argv[1], updater=updater, ignore_list=[]))
     print iso_list
-- 
1.7.10.4




More information about the Kimchi-devel mailing list