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

Sheldon shaohef at linux.vnet.ibm.com
Mon Jan 6 15:26:00 UTC 2014


Reviewed-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>

On 01/06/2014 11:05 PM, Aline Manera wrote:
> 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 |   27 ++++++++++++++++-----------
>   2 files changed, 17 insertions(+), 11 deletions(-)
>
> diff --git a/Makefile.am b/Makefile.am
> index 7ab1bd8..04ad696 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -51,6 +51,7 @@ PEP8_WHITELIST = \
>   	src/kimchi/exception.py \
>   	src/kimchi/featuretests.py \
>   	src/kimchi/iscsi.py \
> +	src/kimchi/isoinfo.py \
>   	src/kimchi/kvmusertests.py \
>   	src/kimchi/rollbackcontext.py \
>   	src/kimchi/root.py \
> diff --git a/src/kimchi/isoinfo.py b/src/kimchi/isoinfo.py
> index a992a68..7e6d733 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 check_url_path, kimchi_log
>
> +
>   iso_dir = [
>       ##
>       # Portions of this data from libosinfo: http://libosinfo.org/
> @@ -165,8 +166,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')
>
> @@ -177,9 +178,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):
> @@ -199,7 +200,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
> @@ -227,8 +229,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:
> @@ -238,7 +240,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:
> @@ -310,13 +313,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))
>       print iso_list


-- 
Thanks and best regards!

Sheldon Feng(冯少合)<shaohef at linux.vnet.ibm.com>
IBM Linux Technology Center




More information about the Kimchi-devel mailing list