[Kimchi-devel] [PATCHv5 6/6] Multiple pep8 fixes

lvroyce at linux.vnet.ibm.com lvroyce at linux.vnet.ibm.com
Tue Mar 4 07:38:48 UTC 2014


From: Royce Lv <lvroyce at linux.vnet.ibm.com>

These can be diagnosed by pep8 1.3.3,
but may not report error in some version,
These errors does not comply:
    http://www.python.org/dev/peps/pep-0008/
so fix them.

Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
---
 src/kimchi/isoinfo.py              | 4 ++--
 src/kimchi/mockmodel.py            | 7 ++++---
 src/kimchi/model/debugreports.py   | 2 +-
 src/kimchi/model/storageservers.py | 4 ++--
 src/kimchi/model/storagevolumes.py | 3 ++-
 src/kimchi/model/templates.py      | 2 +-
 tests/test_model.py                | 6 +++---
 7 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/kimchi/isoinfo.py b/src/kimchi/isoinfo.py
index 1e9e02d..8d423ad 100644
--- a/src/kimchi/isoinfo.py
+++ b/src/kimchi/isoinfo.py
@@ -183,7 +183,7 @@ class IsoImage(object):
         for i in xrange(1, 4):
             fmt = IsoImage.EL_TORITO_BOOT_RECORD
             ptr = i * IsoImage.SECTOR_SIZE
-            tmp_data = data[ptr:ptr+fmt.size]
+            tmp_data = data[ptr:ptr + fmt.size]
             if len(tmp_data) < fmt.size:
                 return
 
@@ -212,7 +212,7 @@ class IsoImage(object):
                                  {'filename': self.path})
 
         fmt = IsoImage.EL_TORITO_BOOT_ENTRY
-        tmp_data = data[ptr:ptr+fmt.size]
+        tmp_data = data[ptr:ptr + fmt.size]
         (boot, media_type, load_seg, sys_type,
          pad0, sectors, load_rba) = self._unpack(fmt, tmp_data)
         if boot == 0x88:
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index d69a58a..d909b14 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -220,7 +220,7 @@ class MockModel(object):
         if not name:
             iso = params['cdrom']
             iso_name = os.path.splitext(iso[iso.rfind('/') + 1:])[0]
-            name = iso_name + str(int(time.time()*1000))
+            name = iso_name + str(int(time.time() * 1000))
             params['name'] = name
 
         if name in self._mock_templates:
@@ -915,7 +915,8 @@ class MockVMIface(object):
 
     @classmethod
     def get_mac(cls):
-        mac = ":".join(["52", "54"] + ["%02x" % (cls.counter/(256**i) % 256)
+        mac = ":".join(["52", "54"] +
+                       ["%02x" % (cls.counter / (256 ** i) % 256)
                        for i in range(3, -1, -1)])
         return mac
 
@@ -1042,7 +1043,7 @@ class MockVMScreenshot(VMScreenshot):
         self.coord = (self.coord[0],
                       self.coord[1],
                       min(MockVMScreenshot.BOX_COORD[2],
-                          self.coord[2]+random.randrange(50)),
+                          self.coord[2] + random.randrange(50)),
                       self.coord[3])
 
         image = Image.new("RGB", (256, 256), self.background)
diff --git a/src/kimchi/model/debugreports.py b/src/kimchi/model/debugreports.py
index 3e14848..c6e698b 100644
--- a/src/kimchi/model/debugreports.py
+++ b/src/kimchi/model/debugreports.py
@@ -41,7 +41,7 @@ class DebugReportsModel(object):
         ident = params.get('name').strip()
         # Generate a name with time and millisec precision, if necessary
         if ident is None or ident == "":
-            ident = 'report-' + str(int(time.time()*1000))
+            ident = 'report-' + str(int(time.time() * 1000))
         taskid = self._gen_debugreport_file(ident)
         return self.task.lookup(taskid)
 
diff --git a/src/kimchi/model/storageservers.py b/src/kimchi/model/storageservers.py
index d4fba9d..167fedd 100644
--- a/src/kimchi/model/storageservers.py
+++ b/src/kimchi/model/storageservers.py
@@ -64,8 +64,8 @@ class StorageServerModel(object):
         for pool in pools:
             try:
                 pool_info = self.pool.lookup(pool)
-                if pool_info['source'] and \
-                   pool_info['source']['addr'] == server:
+                if (pool_info['source'] and
+                        pool_info['source']['addr'] == server):
                     return dict(host=server)
             except NotFoundError:
                 # Avoid inconsistent pool result because of lease between list
diff --git a/src/kimchi/model/storagevolumes.py b/src/kimchi/model/storagevolumes.py
index e9ce736..ec569ca 100644
--- a/src/kimchi/model/storagevolumes.py
+++ b/src/kimchi/model/storagevolumes.py
@@ -124,7 +124,8 @@ class StorageVolumeModel(object):
                 for vm in vms:
                     storages = VMStoragesModel(**args).get_list(vm)
                     for disk in storages:
-                        if path == VMStorageModel(**args).lookup(vm, disk)['path']:
+                        d_info = VMStorageModel(**args).lookup(vm, disk)
+                        if path == d_info['path']:
                             ref_cnt = ref_cnt + 1
                 session.store('storagevolume', vol_id, {'ref_cnt': ref_cnt})
 
diff --git a/src/kimchi/model/templates.py b/src/kimchi/model/templates.py
index 3062bd7..145e643 100644
--- a/src/kimchi/model/templates.py
+++ b/src/kimchi/model/templates.py
@@ -39,7 +39,7 @@ class TemplatesModel(object):
         if not name:
             iso = params['cdrom']
             iso_name = os.path.splitext(iso[iso.rfind('/') + 1:])[0]
-            name = iso_name + str(int(time.time()*1000))
+            name = iso_name + str(int(time.time() * 1000))
             params['name'] = name
 
         conn = self.conn.get()
diff --git a/tests/test_model.py b/tests/test_model.py
index e2ed273..8499056 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -975,7 +975,7 @@ class ModelTests(unittest.TestCase):
         for repo in test_repos:
             inst.repositories_create(repo)
         host_repos = inst.repositories_get_list()
-        self.assertEquals(system_host_repos+len(test_repos), len(host_repos))
+        self.assertEquals(system_host_repos + len(test_repos), len(host_repos))
 
         for repo in test_repos:
             repo_info = inst.repository_lookup(repo.get('repo_id'))
@@ -1013,7 +1013,7 @@ class ModelTests(unittest.TestCase):
         inst.repositories_create(repo)
 
         host_repos = inst.repositories_get_list()
-        self.assertEquals(system_host_repos+1, len(host_repos))
+        self.assertEquals(system_host_repos + 1, len(host_repos))
 
         new_repo = {'repo_id': 'fedora-fake',
                     'repo_name': 'Fedora 19 Update FAKE',
@@ -1043,7 +1043,7 @@ class ModelTests(unittest.TestCase):
         inst.repositories_create(repo)
 
         host_repos = inst.repositories_get_list()
-        self.assertEquals(system_host_repos+1, len(host_repos))
+        self.assertEquals(system_host_repos + 1, len(host_repos))
 
         repo_info = inst.repository_lookup(repo.get('repo_id'))
         self.assertEquals(True, repo_info.get('enabled'))
-- 
1.8.1.2




More information about the Kimchi-devel mailing list