[Kimchi-devel] [PATCH 4/4] pep8: Use consistent line spacing

Aline Manera alinefm at linux.vnet.ibm.com
Mon Jan 20 15:38:01 UTC 2014


On 01/15/2014 12:05 AM, Crístian Viana wrote:
> According to the PEP8 Style Guide[1], top-level definitions should be
> separated by two blank lines. The import groups should be separated by
> only one blank line, not two, as they are still the same
> top-level definition.
>
> [1]: http://www.python.org/dev/peps/pep-0008/#blank-lines
>
> Signed-off-by: Crístian Viana <vianac at linux.vnet.ibm.com>
> ---
>   plugins/sample/__init__.py         | 2 --
>   src/kimchi/asynctask.py            | 2 --
>   src/kimchi/auth.py                 | 2 --
>   src/kimchi/cachebust.py            | 1 -
>   src/kimchi/control/base.py         | 2 --
>   src/kimchi/control/config.py       | 1 -
>   src/kimchi/control/storagepools.py | 1 -
>   src/kimchi/control/utils.py        | 2 --
>   src/kimchi/distroloader.py         | 1 -
>   src/kimchi/featuretests.py         | 1 -
>   src/kimchi/iscsi.py                | 1 -
>   src/kimchi/isoinfo.py              | 1 -
>   src/kimchi/kvmusertests.py         | 2 --
>   src/kimchi/mockmodel.py            | 2 --
>   src/kimchi/model.py                | 2 --
>   src/kimchi/objectstore.py          | 2 --
>   src/kimchi/root.py                 | 2 --
>   src/kimchi/scan.py                 | 2 +-
>   src/kimchi/screenshot.py           | 3 +--
>   src/kimchi/server.py               | 2 --
>   src/kimchi/sslcert.py              | 1 -
>   src/kimchi/template.py             | 2 --
>   src/kimchi/utils.py                | 3 +--
>   src/kimchi/vmtemplate.py           | 2 +-
>   src/kimchi/vnc.py                  | 1 -
>   tests/iso_gen.py                   | 1 +
>   tests/test_exception.py            | 1 -
>   tests/test_mockmodel.py            | 2 --
>   tests/test_model.py                | 1 -
>   tests/test_networkxml.py           | 1 -
>   tests/test_osinfo.py               | 1 -
>   tests/test_plugin.py               | 1 -
>   tests/test_rest.py                 | 1 -
>   tests/test_server.py               | 1 -
>   tests/test_storagepool.py          | 1 -
>   tests/test_vmtemplate.py           | 1 -
>   tests/utils.py                     | 5 +++--
>   37 files changed, 8 insertions(+), 52 deletions(-)
>
> diff --git a/plugins/sample/__init__.py b/plugins/sample/__init__.py
> index a1fe44e..7c9c93f 100644
> --- a/plugins/sample/__init__.py
> +++ b/plugins/sample/__init__.py
> @@ -23,10 +23,8 @@
>   import json
>   import os
>   
> -
>   from cherrypy import expose
>   
> -
>   from kimchi.control.base import Collection, Resource
>   from model import Model
>   
> diff --git a/src/kimchi/asynctask.py b/src/kimchi/asynctask.py
> index 3b7d505..f524e5d 100644
> --- a/src/kimchi/asynctask.py
> +++ b/src/kimchi/asynctask.py
> @@ -23,10 +23,8 @@
>   import threading
>   import traceback
>   
> -
>   import cherrypy
>   
> -
>   from kimchi.exception import OperationFailed
>   
>   
> diff --git a/src/kimchi/auth.py b/src/kimchi/auth.py
> index d0a1318..c7934dc 100644
> --- a/src/kimchi/auth.py
> +++ b/src/kimchi/auth.py
> @@ -26,10 +26,8 @@ import base64
>   import PAM
>   import re
>   
> -
>   import cherrypy
>   
> -
>   from kimchi import template
>   from kimchi.exception import OperationFailed
>   
> diff --git a/src/kimchi/cachebust.py b/src/kimchi/cachebust.py
> index 9a71f4f..ad34b16 100644
> --- a/src/kimchi/cachebust.py
> +++ b/src/kimchi/cachebust.py
> @@ -22,7 +22,6 @@
>   
>   import os
>   
> -
>   from kimchi.config import get_prefix
>   
>   
> diff --git a/src/kimchi/control/base.py b/src/kimchi/control/base.py
> index 031bf59..91b364c 100644
> --- a/src/kimchi/control/base.py
> +++ b/src/kimchi/control/base.py
> @@ -24,10 +24,8 @@
>   
>   import urllib2
>   
> -
>   import cherrypy
>   
> -
>   import kimchi.template
>   from kimchi.control.utils import get_class_name, internal_redirect, model_fn
>   from kimchi.control.utils import parse_request, validate_method
> diff --git a/src/kimchi/control/config.py b/src/kimchi/control/config.py
> index 5186ddd..c92f578 100644
> --- a/src/kimchi/control/config.py
> +++ b/src/kimchi/control/config.py
> @@ -24,7 +24,6 @@
>   
>   import cherrypy
>   
> -
>   from kimchi.config import config
>   from kimchi.control.base import Collection, Resource
>   
> diff --git a/src/kimchi/control/storagepools.py b/src/kimchi/control/storagepools.py
> index 782f5a6..b7afeb4 100644
> --- a/src/kimchi/control/storagepools.py
> +++ b/src/kimchi/control/storagepools.py
> @@ -25,7 +25,6 @@
>   
>   import cherrypy
>   
> -
>   from kimchi.control.base import Collection, Resource
>   from kimchi.control.storagevolumes import IsoVolumes, StorageVolumes
>   from kimchi.control.utils import get_class_name, model_fn, parse_request
> diff --git a/src/kimchi/control/utils.py b/src/kimchi/control/utils.py
> index 894f35b..54dc309 100644
> --- a/src/kimchi/control/utils.py
> +++ b/src/kimchi/control/utils.py
> @@ -25,11 +25,9 @@
>   
>   import json
>   
> -
>   import cherrypy
>   from jsonschema import Draft3Validator, ValidationError
>   
> -
>   from kimchi.exception import InvalidParameter
>   
>   
> diff --git a/src/kimchi/distroloader.py b/src/kimchi/distroloader.py
> index 98fd764..3f9587e 100644
> --- a/src/kimchi/distroloader.py
> +++ b/src/kimchi/distroloader.py
> @@ -25,7 +25,6 @@ import glob
>   import json
>   import os
>   
> -
>   from kimchi import config
>   from kimchi.exception import NotFoundError, OperationFailed
>   from kimchi.utils import kimchi_log
> diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py
> index 9fc709a..c1da0d9 100644
> --- a/src/kimchi/featuretests.py
> +++ b/src/kimchi/featuretests.py
> @@ -23,7 +23,6 @@
>   import subprocess
>   import threading
>   
> -
>   import cherrypy
>   import libvirt
>   
> diff --git a/src/kimchi/iscsi.py b/src/kimchi/iscsi.py
> index 35c0b8a..c265283 100644
> --- a/src/kimchi/iscsi.py
> +++ b/src/kimchi/iscsi.py
> @@ -22,7 +22,6 @@
>   
>   import subprocess
>   
> -
>   from kimchi.exception import OperationFailed
>   
>   
> diff --git a/src/kimchi/isoinfo.py b/src/kimchi/isoinfo.py
> index 7e6d733..16d5446 100644
> --- a/src/kimchi/isoinfo.py
> +++ b/src/kimchi/isoinfo.py
> @@ -27,7 +27,6 @@ import struct
>   import sys
>   import urllib2
>   
> -
>   from kimchi.exception import IsoFormatError
>   from kimchi.utils import check_url_path, kimchi_log
>   
> diff --git a/src/kimchi/kvmusertests.py b/src/kimchi/kvmusertests.py
> index 82e3862..069350b 100644
> --- a/src/kimchi/kvmusertests.py
> +++ b/src/kimchi/kvmusertests.py
> @@ -23,10 +23,8 @@
>   import psutil
>   import uuid
>   
> -
>   import libvirt
>   
> -
>   from kimchi.rollbackcontext import RollbackContext
>   
>   
> diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
> index 544b7de..f8b67f7 100644
> --- a/src/kimchi/mockmodel.py
> +++ b/src/kimchi/mockmodel.py
> @@ -30,7 +30,6 @@ import random
>   import time
>   import uuid
>   
> -
>   try:
>       from PIL import Image
>       from PIL import ImageDraw
> @@ -38,7 +37,6 @@ except ImportError:
>       import Image
>       import ImageDraw
>   
> -
>   import cherrypy
>   
>   import kimchi.model
> diff --git a/src/kimchi/model.py b/src/kimchi/model.py
> index 93a2764..13e40b4 100644
> --- a/src/kimchi/model.py
> +++ b/src/kimchi/model.py
> @@ -40,11 +40,9 @@ import uuid
>   from collections import defaultdict
>   from xml.etree import ElementTree
>   
> -
>   import cherrypy
>   from cherrypy.process.plugins import BackgroundTask
>   
> -
>   from kimchi import config
>   from kimchi import netinfo
>   from kimchi import network
> diff --git a/src/kimchi/objectstore.py b/src/kimchi/objectstore.py
> index 7b567f3..4e6d1f0 100644
> --- a/src/kimchi/objectstore.py
> +++ b/src/kimchi/objectstore.py
> @@ -24,13 +24,11 @@ import json
>   import sqlite3
>   import threading
>   
> -
>   try:
>       from collections import OrderedDict
>   except ImportError:
>       from ordereddict import OrderedDict
>   
> -
>   from kimchi import config
>   from kimchi.exception import NotFoundError
>   
> diff --git a/src/kimchi/root.py b/src/kimchi/root.py
> index ae06bc3..7647152 100644
> --- a/src/kimchi/root.py
> +++ b/src/kimchi/root.py
> @@ -23,10 +23,8 @@
>   
>   import json
>   
> -
>   import cherrypy
>   
> -
>   from kimchi import auth
>   from kimchi import template
>   from kimchi.config import get_api_schema_file
> diff --git a/src/kimchi/scan.py b/src/kimchi/scan.py
> index e192f01..8d0e6e6 100644
> --- a/src/kimchi/scan.py
> +++ b/src/kimchi/scan.py
> @@ -28,13 +28,13 @@ import shutil
>   import tempfile
>   import time
>   
> -
>   from kimchi.isoinfo import IsoImage, probe_iso
>   from kimchi.utils import kimchi_log
>   
>   
>   SCAN_IGNORE = ['/tmp/kimchi-scan-*']
>   
> +
>   class Scanner(object):
>       SCAN_TTL = 300
>   
> diff --git a/src/kimchi/screenshot.py b/src/kimchi/screenshot.py
> index e65a752..5b1395c 100644
> --- a/src/kimchi/screenshot.py
> +++ b/src/kimchi/screenshot.py
> @@ -28,13 +28,11 @@ import tempfile
>   import time
>   import uuid
>   
> -
>   try:
>       from PIL import Image
>   except ImportError:
>       import Image
>   
> -
>   from kimchi import config
>   from kimchi.utils import kimchi_log
>   
> @@ -42,6 +40,7 @@ from kimchi.utils import kimchi_log
>   (fd, pipe) = tempfile.mkstemp()
>   stream_test_result = None
>   
> +
>   class VMScreenshot(object):
>       OUTDATED_SECS = 5
>       THUMBNAIL_SIZE = (256, 256)
> diff --git a/src/kimchi/server.py b/src/kimchi/server.py
> index 53fe889..7eee5e4 100644
> --- a/src/kimchi/server.py
> +++ b/src/kimchi/server.py
> @@ -27,10 +27,8 @@ import logging.handlers
>   import os
>   import sslcert
>   
> -
>   import cherrypy
>   
> -
>   from kimchi import auth
>   from kimchi import config
>   from kimchi import model
> diff --git a/src/kimchi/sslcert.py b/src/kimchi/sslcert.py
> index 529699d..c8be8c1 100644
> --- a/src/kimchi/sslcert.py
> +++ b/src/kimchi/sslcert.py
> @@ -27,7 +27,6 @@
>   
>   import time
>   
> -
>   from M2Crypto import ASN1, EVP, RSA, X509
>   
>   
> diff --git a/src/kimchi/template.py b/src/kimchi/template.py
> index adc9c62..3f331ff 100644
> --- a/src/kimchi/template.py
> +++ b/src/kimchi/template.py
> @@ -24,11 +24,9 @@
>   import errno
>   import json
>   
> -
>   import cherrypy
>   from Cheetah.Template import Template
>   
> -
>   from kimchi import config
>   
>   
> diff --git a/src/kimchi/utils.py b/src/kimchi/utils.py
> index ac7dee5..56bccd9 100644
> --- a/src/kimchi/utils.py
> +++ b/src/kimchi/utils.py
> @@ -24,16 +24,15 @@
>   import os
>   import urllib2
>   
> -
>   import cherrypy
>   from cherrypy.lib.reprconf import Parser
>   
> -
>   from kimchi import config
>   
>   
>   kimchi_log = cherrypy.log.error_log
>   
> +
>   def is_digit(value):
>       if isinstance(value, int):
>           return True
> diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
> index 9097a05..e22c6b7 100644
> --- a/src/kimchi/vmtemplate.py
> +++ b/src/kimchi/vmtemplate.py
> @@ -25,7 +25,6 @@ import string
>   import socket
>   import urlparse
>   
> -
>   from kimchi import osinfo
>   from kimchi.exception import InvalidParameter, IsoFormatError
>   from kimchi.isoinfo import IsoImage
> @@ -33,6 +32,7 @@ from kimchi.isoinfo import IsoImage
>   
>   QEMU_NAMESPACE = "xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'"
>   
> +
>   class VMTemplate(object):
>       _bus_to_dev = {'ide': 'hd', 'virtio': 'vd', 'scsi': 'sd'}
>   
> diff --git a/src/kimchi/vnc.py b/src/kimchi/vnc.py
> index dc70b46..52d6598 100644
> --- a/src/kimchi/vnc.py
> +++ b/src/kimchi/vnc.py
> @@ -25,7 +25,6 @@ import errno
>   import os
>   import subprocess
>   
> -
>   from kimchi.config import config
>   
>   
> diff --git a/tests/iso_gen.py b/tests/iso_gen.py
> index c773bd6..d49e2b4 100644
> --- a/tests/iso_gen.py
> +++ b/tests/iso_gen.py
> @@ -24,6 +24,7 @@ import struct
>   
>   from kimchi.isoinfo import IsoImage
>   
> +
>   iso_des = [
>       ('openbsd', lambda v: True,
>           lambda v: 'OpenBSD/i386    %s Install CD' % v),
> diff --git a/tests/test_exception.py b/tests/test_exception.py
> index 2757a11..396dfa7 100644
> --- a/tests/test_exception.py
> +++ b/tests/test_exception.py
> @@ -24,7 +24,6 @@ import json
>   import os
>   import unittest
>   
> -
>   import kimchi.mockmodel
>   from utils import get_free_port, patch_auth, request, run_server
>   
> diff --git a/tests/test_mockmodel.py b/tests/test_mockmodel.py
> index 3e0701f..26f25ac 100644
> --- a/tests/test_mockmodel.py
> +++ b/tests/test_mockmodel.py
> @@ -25,10 +25,8 @@ import os
>   import time
>   import unittest
>   
> -
>   import cherrypy
>   
> -
>   import kimchi.mockmodel
>   from kimchi.control.base import Collection, Resource
>   from utils import get_free_port, patch_auth, request, run_server
> diff --git a/tests/test_model.py b/tests/test_model.py
> index 0620501..e06507b 100644
> --- a/tests/test_model.py
> +++ b/tests/test_model.py
> @@ -30,7 +30,6 @@ import time
>   import unittest
>   import uuid
>   
> -
>   import iso_gen
>   import kimchi.model
>   import kimchi.objectstore
> diff --git a/tests/test_networkxml.py b/tests/test_networkxml.py
> index 445c36d..d58a31a 100644
> --- a/tests/test_networkxml.py
> +++ b/tests/test_networkxml.py
> @@ -23,7 +23,6 @@
>   import ipaddr
>   import unittest
>   
> -
>   import kimchi.networkxml
>   import utils
>   from kimchi.xmlutils import xpath_get_text
> diff --git a/tests/test_osinfo.py b/tests/test_osinfo.py
> index 0f88a35..79062cb 100644
> --- a/tests/test_osinfo.py
> +++ b/tests/test_osinfo.py
> @@ -22,7 +22,6 @@
>   
>   import unittest
>   
> -
>   from kimchi.osinfo import lookup, modern_version_bases
>   
>   
> diff --git a/tests/test_plugin.py b/tests/test_plugin.py
> index 1afec63..0421e1d 100644
> --- a/tests/test_plugin.py
> +++ b/tests/test_plugin.py
> @@ -26,7 +26,6 @@ import sys
>   import unittest
>   from functools import partial
>   
> -
>   import kimchi.mockmodel
>   import utils
>   from kimchi import config
> diff --git a/tests/test_rest.py b/tests/test_rest.py
> index 50542e4..bb242c8 100644
> --- a/tests/test_rest.py
> +++ b/tests/test_rest.py
> @@ -27,7 +27,6 @@ import time
>   import unittest
>   from functools import partial
>   
> -
>   import kimchi.mockmodel
>   from kimchi.rollbackcontext import RollbackContext
>   from utils import fake_user, get_free_port, https_request, patch_auth, request
> diff --git a/tests/test_server.py b/tests/test_server.py
> index 0050f6a..561325c 100644
> --- a/tests/test_server.py
> +++ b/tests/test_server.py
> @@ -23,7 +23,6 @@
>   import os
>   import unittest
>   
> -
>   import kimchi.mockmodel
>   import utils
>   
> diff --git a/tests/test_storagepool.py b/tests/test_storagepool.py
> index 8341537..415ed28 100644
> --- a/tests/test_storagepool.py
> +++ b/tests/test_storagepool.py
> @@ -23,7 +23,6 @@
>   import libxml2
>   import unittest
>   
> -
>   import kimchi.model
>   from kimchi.rollbackcontext import RollbackContext
>   
> diff --git a/tests/test_vmtemplate.py b/tests/test_vmtemplate.py
> index dc9c0ef..f883edd 100644
> --- a/tests/test_vmtemplate.py
> +++ b/tests/test_vmtemplate.py
> @@ -23,7 +23,6 @@
>   import unittest
>   import uuid
>   
> -
>   from kimchi.vmtemplate import VMTemplate
>   from kimchi.xmlutils import xpath_get_text
>   
> diff --git a/tests/utils.py b/tests/utils.py
> index 452a001..d72f282 100644
> --- a/tests/utils.py
> +++ b/tests/utils.py
> @@ -31,17 +31,18 @@ import unittest
>   from contextlib import closing
>   from lxml import etree
>   
> -
>   import cherrypy
>   
> -
>   import kimchi.server
>   import kimchi.model

>   
> +
>   _ports = {}
>   
> +
>   fake_user = {'admin': 'letmein!'}
>   
> +

Can't we have one single block for all constants?

>   # provide missing unittest decorators and API for python 2.6; these decorators
>   # do not actually work, just avoid the syntax failure
>   if sys.version_info[:2] == (2, 6):




More information about the Kimchi-devel mailing list