PEP8 cleanup (openstack-common)
Fixes bug #930625 Remove backslash continuations in openstack-common. Fix type checking taboos. Change-Id: I49ddb9ff5fa5af760dcfccb52cb4793b71e02f19
This commit is contained in:
@@ -62,8 +62,8 @@ def add_common_options(parser):
|
||||
|
||||
:param parser: optparse.OptionParser
|
||||
"""
|
||||
help_text = "The following configuration options are common to "\
|
||||
"this app's programs."
|
||||
help_text = ("The following configuration options are common to "
|
||||
"this app's programs.")
|
||||
|
||||
group = optparse.OptionGroup(parser, "Common Options", help_text)
|
||||
group.add_option('-v', '--verbose', default=False, dest="verbose",
|
||||
@@ -88,8 +88,8 @@ def add_log_options(parser):
|
||||
|
||||
:param parser: optparse.OptionParser
|
||||
"""
|
||||
help_text = "The following configuration options are specific to logging "\
|
||||
"functionality for this program."
|
||||
help_text = ("The following configuration options are specific to "
|
||||
"logging functionality for this program.")
|
||||
|
||||
group = optparse.OptionGroup(parser, "Logging Options", help_text)
|
||||
group.add_option('--log-config', default=None, metavar="PATH",
|
||||
@@ -133,10 +133,10 @@ def setup_logging(options, conf):
|
||||
|
||||
# If either the CLI option or the conf value
|
||||
# is True, we set to True
|
||||
debug = options.get('debug') or \
|
||||
get_option(conf, 'debug', type='bool', default=False)
|
||||
verbose = options.get('verbose') or \
|
||||
get_option(conf, 'verbose', type='bool', default=False)
|
||||
debug = (options.get('debug') or
|
||||
get_option(conf, 'debug', type='bool', default=False))
|
||||
verbose = (options.get('verbose') or
|
||||
get_option(conf, 'verbose', type='bool', default=False))
|
||||
root_logger = logging.root
|
||||
if debug:
|
||||
root_logger.setLevel(logging.DEBUG)
|
||||
@@ -157,8 +157,8 @@ def setup_logging(options, conf):
|
||||
if not logfile:
|
||||
logfile = conf.get('log_file')
|
||||
|
||||
use_syslog = options.get('use_syslog') or \
|
||||
get_option(conf, 'use_syslog', type='bool', default=False)
|
||||
use_syslog = (options.get('use_syslog') or
|
||||
get_option(conf, 'use_syslog', type='bool', default=False))
|
||||
|
||||
if use_syslog:
|
||||
handler = logging.handlers.SysLogHandler(address='/dev/log')
|
||||
@@ -289,10 +289,10 @@ def load_paste_app(app_name, options, args, config_dir=None):
|
||||
|
||||
# We only update the conf dict for the verbose and debug
|
||||
# flags. Everything else must be set up in the conf file...
|
||||
debug = options.get('debug') or \
|
||||
get_option(conf, 'debug', type='bool', default=False)
|
||||
verbose = options.get('verbose') or \
|
||||
get_option(conf, 'verbose', type='bool', default=False)
|
||||
debug = (options.get('debug') or
|
||||
get_option(conf, 'debug', type='bool', default=False))
|
||||
verbose = (options.get('verbose') or
|
||||
get_option(conf, 'verbose', type='bool', default=False))
|
||||
conf['debug'] = debug
|
||||
conf['verbose'] = verbose
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import os
|
||||
import random
|
||||
import shlex
|
||||
import sys
|
||||
import types
|
||||
|
||||
from eventlet import greenthread
|
||||
from eventlet.green import subprocess
|
||||
@@ -60,9 +59,9 @@ def bool_from_string(subject):
|
||||
|
||||
Useful for JSON-decoded stuff and config file parsing
|
||||
"""
|
||||
if isinstance(subject, types.BooleanType):
|
||||
if isinstance(subject, bool):
|
||||
return subject
|
||||
if isinstance(subject, types.StringTypes):
|
||||
if isinstance(subject, basestring):
|
||||
if subject.strip().lower() in ('true', 'on', '1'):
|
||||
return True
|
||||
return False
|
||||
@@ -120,8 +119,9 @@ def execute(*cmd, **kwargs):
|
||||
_returncode = obj.returncode # pylint: disable=E1101
|
||||
if _returncode:
|
||||
LOG.debug(_('Result was %s') % _returncode)
|
||||
if type(check_exit_code) == types.IntType \
|
||||
and _returncode != check_exit_code:
|
||||
if (isinstance(check_exit_code, int) and
|
||||
not isinstance(check_exit_code, bool) and
|
||||
_returncode != check_exit_code):
|
||||
(stdout, stderr) = result
|
||||
raise exception.ProcessExecutionError(
|
||||
exit_code=_returncode,
|
||||
|
||||
@@ -495,8 +495,8 @@ class ResponseSerializer(object):
|
||||
}
|
||||
self.body_serializers.update(body_serializers or {})
|
||||
|
||||
self.headers_serializer = headers_serializer or \
|
||||
ResponseHeadersSerializer()
|
||||
self.headers_serializer = (headers_serializer or
|
||||
ResponseHeadersSerializer())
|
||||
|
||||
def serialize(self, response_data, content_type, action='default'):
|
||||
"""Serialize a dict into a string and wrap in a wsgi.Request object.
|
||||
@@ -550,8 +550,8 @@ class RequestDeserializer(object):
|
||||
}
|
||||
self.body_deserializers.update(body_deserializers or {})
|
||||
|
||||
self.headers_deserializer = headers_deserializer or \
|
||||
RequestHeadersDeserializer()
|
||||
self.headers_deserializer = (headers_deserializer or
|
||||
RequestHeadersDeserializer())
|
||||
|
||||
def deserialize(self, request):
|
||||
"""Extract necessary pieces of the request.
|
||||
|
||||
5
setup.py
5
setup.py
@@ -16,9 +16,8 @@ write_requirements()
|
||||
setup(name='openstack.common',
|
||||
version=version,
|
||||
description="Common components for Openstack",
|
||||
long_description="""\
|
||||
Common components for Openstack including paster templates.
|
||||
""",
|
||||
long_description="Common components for Openstack "
|
||||
"including paster templates.",
|
||||
classifiers=[
|
||||
'Development Status :: 4 - Beta',
|
||||
'License :: OSI Approved :: Apache Software License',
|
||||
|
||||
@@ -115,8 +115,8 @@ class LeftoversTestCase(BaseTestCase):
|
||||
class FindConfigFilesTestCase(BaseTestCase):
|
||||
|
||||
def test_find_config_files(self):
|
||||
config_files = \
|
||||
[os.path.expanduser('~/.blaa/blaa.conf'), '/etc/foo.conf']
|
||||
config_files = [os.path.expanduser('~/.blaa/blaa.conf'),
|
||||
'/etc/foo.conf']
|
||||
|
||||
self.stubs.Set(sys, 'argv', ['foo'])
|
||||
self.stubs.Set(os.path, 'exists', lambda p: p in config_files)
|
||||
|
||||
@@ -68,8 +68,8 @@ class RequestTest(unittest.TestCase):
|
||||
self.assertEqual(result, "application/json")
|
||||
|
||||
request = wsgi.Request.blank('/tests/123')
|
||||
request.headers["Accept"] = \
|
||||
"application/json; q=0.3, application/xml; q=0.9"
|
||||
request.headers["Accept"] = ("application/json; q=0.3, "
|
||||
"application/xml; q=0.9")
|
||||
result = request.best_match_content_type()
|
||||
self.assertEqual(result, "application/xml")
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ Or:
|
||||
Where ../myproj is a project directory which contains a differently named
|
||||
configuration file, or:
|
||||
|
||||
$> python update.py --config-file ../myproj/myproj/openstack/common.conf \
|
||||
$> python update.py --config-file ../myproj/myproj/openstack/common.conf
|
||||
--dest-dir ../myproj
|
||||
|
||||
Where ../myproject is a project directory, but the configuration file is
|
||||
@@ -136,8 +136,8 @@ def _copy_file(path, base, dest_dir):
|
||||
|
||||
|
||||
def _copy_module(mod, base, dest_dir):
|
||||
print "Copying openstack.common.%s under the %s module in %s" % \
|
||||
(mod, base, dest_dir)
|
||||
print ("Copying openstack.common.%s under the %s module in %s" %
|
||||
(mod, base, dest_dir))
|
||||
|
||||
if '.' in mod:
|
||||
path = _mod_to_path('openstack.common')
|
||||
|
||||
Reference in New Issue
Block a user