From 22bedc900d3d3e0fd367bdf05fd4324cfd339649 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Tue, 7 Mar 2017 14:42:57 +0100 Subject: [PATCH] whitespace formatting --- hub/kojihub.py | 112 +++++++++++++++++----------------- hub/kojixmlrpc.py | 12 ++-- koji/policy.py | 12 ++-- koji/server.py | 26 ++++---- plugins/builder/runroot.py | 8 +-- plugins/hub/runroot_hub.py | 2 +- tests/test_compatrequests.py | 6 +- tests/test_policy.py | 2 +- www/kojiweb/index.py | 16 ++--- www/kojiweb/wsgi_publisher.py | 2 +- 10 files changed, 99 insertions(+), 99 deletions(-) diff --git a/hub/kojihub.py b/hub/kojihub.py index 84a9d493..ca93dac7 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -5092,7 +5092,7 @@ class CG_Importer(object): 'package': self.buildinfo['name'], 'source': self.buildinfo.get('source'), 'metadata_only': self.metadata_only, - 'cg_list' : list(self.cgs), + 'cg_list': list(self.cgs), # TODO: provide more data } assert_policy('cg_import', policy_data) @@ -5212,20 +5212,20 @@ class CG_Importer(object): def prep_buildroot(self, brdata): ret = {} brinfo = { - 'cg_id' : brdata['cg_id'], - 'cg_version' : brdata['content_generator']['version'], - 'container_type' : brdata['container']['type'], - 'container_arch' : brdata['container']['arch'], - 'host_os' : brdata['host']['os'], - 'host_arch' : brdata['host']['arch'], - 'extra' : brdata.get('extra'), + 'cg_id': brdata['cg_id'], + 'cg_version': brdata['content_generator']['version'], + 'container_type': brdata['container']['type'], + 'container_arch': brdata['container']['arch'], + 'host_os': brdata['host']['os'], + 'host_arch': brdata['host']['arch'], + 'extra': brdata.get('extra'), } rpmlist, archives = self.match_components(brdata['components']) ret = { - 'brinfo' : brinfo, - 'rpmlist' : rpmlist, - 'archives' : archives, - 'tools' : brdata['tools'], + 'brinfo': brinfo, + 'rpmlist': rpmlist, + 'archives': archives, + 'tools': brdata['tools'], } return ret @@ -6410,11 +6410,11 @@ def query_history(tables=None, **kwargs): """ common_fields = { #fields:aliases common to all versioned tables - 'active' : 'active', - 'create_event' : 'create_event', - 'revoke_event' : 'revoke_event', - 'creator_id' : 'creator_id', - 'revoker_id' : 'revoker_id', + 'active': 'active', + 'create_event': 'create_event', + 'revoke_event': 'revoke_event', + 'creator_id': 'creator_id', + 'revoker_id': 'revoker_id', } common_joins = [ "events AS ev1 ON ev1.id = create_event", @@ -6423,45 +6423,45 @@ def query_history(tables=None, **kwargs): "LEFT OUTER JOIN users AS revoker ON revoker.id = revoker_id", ] common_joined_fields = { - 'creator.name' : 'creator_name', - 'revoker.name' : 'revoker_name', - 'EXTRACT(EPOCH FROM ev1.time) AS create_ts' : 'create_ts', - 'EXTRACT(EPOCH FROM ev2.time) AS revoke_ts' : 'revoke_ts', + 'creator.name': 'creator_name', + 'revoker.name': 'revoker_name', + 'EXTRACT(EPOCH FROM ev1.time) AS create_ts': 'create_ts', + 'EXTRACT(EPOCH FROM ev2.time) AS revoke_ts': 'revoke_ts', } table_fields = { - 'user_perms' : ['user_id', 'perm_id'], - 'user_groups' : ['user_id', 'group_id'], - 'cg_users' : ['user_id', 'cg_id'], - 'tag_inheritance' : ['tag_id', 'parent_id', 'priority', 'maxdepth', 'intransitive', 'noconfig', 'pkg_filter'], - 'tag_config' : ['tag_id', 'arches', 'perm_id', 'locked', 'maven_support', 'maven_include_all'], - 'tag_extra' : ['tag_id', 'key', 'value'], - 'build_target_config' : ['build_target_id', 'build_tag', 'dest_tag'], - 'external_repo_config' : ['external_repo_id', 'url'], - 'tag_external_repos' : ['tag_id', 'external_repo_id', 'priority'], - 'tag_listing' : ['build_id', 'tag_id'], - 'tag_packages' : ['package_id', 'tag_id', 'owner', 'blocked', 'extra_arches'], - 'group_config' : ['group_id', 'tag_id', 'blocked', 'exported', 'display_name', 'is_default', 'uservisible', + 'user_perms': ['user_id', 'perm_id'], + 'user_groups': ['user_id', 'group_id'], + 'cg_users': ['user_id', 'cg_id'], + 'tag_inheritance': ['tag_id', 'parent_id', 'priority', 'maxdepth', 'intransitive', 'noconfig', 'pkg_filter'], + 'tag_config': ['tag_id', 'arches', 'perm_id', 'locked', 'maven_support', 'maven_include_all'], + 'tag_extra': ['tag_id', 'key', 'value'], + 'build_target_config': ['build_target_id', 'build_tag', 'dest_tag'], + 'external_repo_config': ['external_repo_id', 'url'], + 'tag_external_repos': ['tag_id', 'external_repo_id', 'priority'], + 'tag_listing': ['build_id', 'tag_id'], + 'tag_packages': ['package_id', 'tag_id', 'owner', 'blocked', 'extra_arches'], + 'group_config': ['group_id', 'tag_id', 'blocked', 'exported', 'display_name', 'is_default', 'uservisible', 'description', 'langonly', 'biarchonly'], - 'group_req_listing' : ['group_id', 'tag_id', 'req_id', 'blocked', 'type', 'is_metapkg'], - 'group_package_listing' : ['group_id', 'tag_id', 'package', 'blocked', 'type', 'basearchonly', 'requires'], + 'group_req_listing': ['group_id', 'tag_id', 'req_id', 'blocked', 'type', 'is_metapkg'], + 'group_package_listing': ['group_id', 'tag_id', 'package', 'blocked', 'type', 'basearchonly', 'requires'], } name_joins = { #joins triggered by table fields for name lookup #field : [table, join-alias, alias] - 'user_id' : ['users', 'users', 'user'], - 'perm_id' : ['permissions', 'permission'], - 'cg_id' : ['content_generator'], + 'user_id': ['users', 'users', 'user'], + 'perm_id': ['permissions', 'permission'], + 'cg_id': ['content_generator'], #group_id is overloaded (special case below) - 'tag_id' : ['tag'], - 'parent_id' : ['tag', 'parent'], - 'build_target_id' : ['build_target'], - 'build_tag' : ['tag', 'build_tag'], - 'dest_tag' : ['tag', 'dest_tag'], - 'external_repo_id' : ['external_repo'], + 'tag_id': ['tag'], + 'parent_id': ['tag', 'parent'], + 'build_target_id': ['build_target'], + 'build_tag': ['tag', 'build_tag'], + 'dest_tag': ['tag', 'dest_tag'], + 'external_repo_id': ['external_repo'], # build_id is special cased - 'package_id' : ['package'], - 'owner' : ['users', 'owner'], - 'req_id' : ['groups', 'req'], + 'package_id': ['package'], + 'owner': ['users', 'owner'], + 'req_id': ['groups', 'req'], } if tables is None: tables = table_fields.keys() @@ -6501,11 +6501,11 @@ def query_history(tables=None, **kwargs): elif field == 'build_id': #special case fields.update({ - 'package.name' : 'name', #XXX? - 'build.version' : 'version', - 'build.release' : 'release', - 'build.epoch' : 'epoch', - 'build.state' : 'build.state', + 'package.name': 'name', #XXX? + 'build.version': 'version', + 'build.release': 'release', + 'build.epoch': 'epoch', + 'build.state': 'build.state', }) joins.extend([ 'build ON build_id = build.id', @@ -9916,7 +9916,7 @@ class RootExports(object): return query.execute() - def checkTagPackage(self,tag,pkg): + def checkTagPackage(self, tag, pkg): """Check that pkg is in the list for tag. Returns true/false""" tag_id = get_tag_id(tag, strict=False) pkg_id = get_package_id(pkg, strict=False) @@ -12339,9 +12339,9 @@ def handle_upload(environ): # this will also remove our lock os.close(fd) ret = { - 'size' : koji.encode_int(size), - 'fileverify' : verify, - 'offset' : koji.encode_int(offset), + 'size': koji.encode_int(size), + 'fileverify': verify, + 'offset': koji.encode_int(offset), } if verify: # unsigned 32bit - could be too big for xmlrpc diff --git a/hub/kojixmlrpc.py b/hub/kojixmlrpc.py index 6ea6dc08..53cd2291 100644 --- a/hub/kojixmlrpc.py +++ b/hub/kojixmlrpc.py @@ -539,28 +539,28 @@ def load_plugins(opts): return tracker _default_policies = { - 'build_from_srpm' : ''' + 'build_from_srpm': ''' has_perm admin :: allow all :: deny ''', - 'build_from_repo_id' : ''' + 'build_from_repo_id': ''' has_perm admin :: allow all :: deny ''', - 'package_list' : ''' + 'package_list': ''' has_perm admin :: allow all :: deny ''', - 'channel' : ''' + 'channel': ''' has req_channel :: req is_child_task :: parent all :: use default ''', - 'vm' : ''' + 'vm': ''' has_perm admin win-admin :: allow all :: deny ''', - 'cg_import' :''' + 'cg_import': ''' all :: allow ''', } diff --git a/koji/policy.py b/koji/policy.py index 4e1bd61b..a3f05d70 100644 --- a/koji/policy.py +++ b/koji/policy.py @@ -142,12 +142,12 @@ class CompareTest(BaseSimpleTest): allow_float = True operators = { - '<' : lambda a, b: a < b, - '>' : lambda a, b: a > b, - '<=' : lambda a, b: a <= b, - '>=' : lambda a, b: a >= b, - '=' : lambda a, b: a == b, - '!=' : lambda a, b: a != b, + '<': lambda a, b: a < b, + '>': lambda a, b: a > b, + '<=': lambda a, b: a <= b, + '>=': lambda a, b: a >= b, + '=': lambda a, b: a == b, + '!=': lambda a, b: a != b, } def __init__(self, str): diff --git a/koji/server.py b/koji/server.py index 9229bb60..6a6ae6a5 100644 --- a/koji/server.py +++ b/koji/server.py @@ -48,21 +48,21 @@ class WSGIWrapper(object): self._env = None host, port = req.connection.remote_addr environ = { - 'REMOTE_ADDR' : req.connection.remote_ip, + 'REMOTE_ADDR': req.connection.remote_ip, # or remote_addr[0]? # or req.get_remote_host(apache.REMOTE_NOLOOKUP)? - 'REMOTE_PORT' : str(req.connection.remote_addr[1]), - 'REMOTE_USER' : req.user, - 'REQUEST_METHOD' : req.method, - 'REQUEST_URI' : req.uri, - 'PATH_INFO' : req.path_info, - 'SCRIPT_FILENAME' : req.filename, - 'QUERY_STRING' : req.args or '', - 'SERVER_NAME' : req.hostname, - 'SERVER_PORT' : str(req.connection.local_addr[1]), - 'wsgi.version' : (1, 0), - 'wsgi.input' : InputWrapper(req), - 'wsgi.errors' : sys.stderr, + 'REMOTE_PORT': str(req.connection.remote_addr[1]), + 'REMOTE_USER': req.user, + 'REQUEST_METHOD': req.method, + 'REQUEST_URI': req.uri, + 'PATH_INFO': req.path_info, + 'SCRIPT_FILENAME': req.filename, + 'QUERY_STRING': req.args or '', + 'SERVER_NAME': req.hostname, + 'SERVER_PORT': str(req.connection.local_addr[1]), + 'wsgi.version': (1, 0), + 'wsgi.input': InputWrapper(req), + 'wsgi.errors': sys.stderr, #TODO - file_wrapper support } environ = LazyDict(environ) diff --git a/plugins/builder/runroot.py b/plugins/builder/runroot.py index 37fabbef..049f2558 100644 --- a/plugins/builder/runroot.py +++ b/plugins/builder/runroot.py @@ -125,7 +125,7 @@ class RunRootTask(tasks.BaseTaskHandler): if not tag_arches: raise koji.BuildError("No arch list for tag: %s" % root) #index canonical host arches - host_arches = dict([(koji.canonArch(a),1) for a in host_arches.split()]) + host_arches = dict([(koji.canonArch(a), 1) for a in host_arches.split()]) #pick the first suitable match from tag's archlist for br_arch in tag_arches.split(): br_arch = koji.canonArch(br_arch) @@ -250,10 +250,10 @@ class RunRootTask(tasks.BaseTaskHandler): logfile = "%s/do_mounts.log" % self.workdir uploadpath = self.getUploadDir() error = None - for dev,path,type,opts in mounts: + for dev, path, type, opts in mounts: if not path.startswith('/'): raise koji.GenericError("invalid mount point: %s" % path) - mpoint = "%s%s" % (rootdir,path) + mpoint = "%s%s" % (rootdir, path) if opts is None: opts = [] else: @@ -294,7 +294,7 @@ class RunRootTask(tasks.BaseTaskHandler): mounts = {} fn = '%s/tmp/runroot_mounts' % rootdir if os.path.exists(fn): - fslog = file(fn,'r') + fslog = file(fn, 'r') for line in fslog: mounts.setdefault(line.strip(), 1) fslog.close() diff --git a/plugins/hub/runroot_hub.py b/plugins/hub/runroot_hub.py index ab1ebbe9..e6ee0b35 100644 --- a/plugins/hub/runroot_hub.py +++ b/plugins/hub/runroot_hub.py @@ -57,6 +57,6 @@ def runroot(tagInfo, arch, command, channel=None, **opts): % (tagInfo, taskopts['channel'])) taskopts['arch'] = koji.canonArch(random.choice(choices)) - args = koji.encode_args(tagInfo, arch, command,**opts) + args = koji.encode_args(tagInfo, arch, command, **opts) return kojihub.make_task('runroot', args, **taskopts) diff --git a/tests/test_compatrequests.py b/tests/test_compatrequests.py index 4056fe7f..c67f5856 100644 --- a/tests/test_compatrequests.py +++ b/tests/test_compatrequests.py @@ -140,7 +140,7 @@ class TestSessionConnection(unittest.TestCase): ret = session.get_connection(uri, None, None, None) @mock.patch('httplib.HTTPConnection') - @mock.patch('sys.version_info', new=(2,7,12,'final', 0)) + @mock.patch('sys.version_info', new=(2, 7, 12, 'final', 0)) def test_timeout(self, HTTPConnection): # no cert, no verify session = koji.compatrequests.Session() @@ -199,7 +199,7 @@ class TestSessionConnection(unittest.TestCase): @mock.patch('ssl._create_unverified_context') @mock.patch('httplib.HTTPSConnection') - @mock.patch('sys.version_info', new=(2,7,12,'final', 0)) + @mock.patch('sys.version_info', new=(2, 7, 12, 'final', 0)) def test_unverified(self, HTTPSConnection, create_unverified_context): # no cert, verify=False, no timeout session = koji.compatrequests.Session() @@ -230,7 +230,7 @@ class TestSessionConnection(unittest.TestCase): @mock.patch('ssl._create_unverified_context') @mock.patch('ssl.SSLContext') @mock.patch('httplib.HTTPSConnection') - @mock.patch('sys.version_info', new=(2,7,12,'final', 0)) + @mock.patch('sys.version_info', new=(2, 7, 12, 'final', 0)) def test_verify(self, HTTPSConnection, SSLContext, create_unverified_context): # no cert, no timeout session = koji.compatrequests.Session() diff --git a/tests/test_policy.py b/tests/test_policy.py index cac991c1..2fbc0aaf 100644 --- a/tests/test_policy.py +++ b/tests/test_policy.py @@ -281,7 +281,7 @@ has DEPTH :: { lines = policy.splitlines() - for depth in ['1','2','3','4']: + for depth in ['1', '2', '3', '4']: data = {'DEPTH': depth} obj = koji.policy.SimpleRuleSet(lines, tests) action = obj.apply(data) diff --git a/www/kojiweb/index.py b/www/kojiweb/index.py index 7124bd42..2273a63d 100644 --- a/www/kojiweb/index.py +++ b/www/kojiweb/index.py @@ -76,7 +76,7 @@ def _clearUserCookie(environ): def _getUserCookie(environ): options = environ['koji.options'] - cookies = Cookie.SimpleCookie(environ.get('HTTP_COOKIE','')) + cookies = Cookie.SimpleCookie(environ.get('HTTP_COOKIE', '')) if 'user' not in cookies: return None value = cookies['user'].value @@ -2205,14 +2205,14 @@ _VALID_SEARCH_SYMS = r""" @.,_/\()%+-*?|[]^$""" _VALID_SEARCH_RE = re.compile('^[' + _VALID_SEARCH_CHARS + re.escape(_VALID_SEARCH_SYMS) + ']+$') _DEFAULT_SEARCH_ORDER = { # For searches against large tables, use '-id' to show most recent first - 'build' : '-id', - 'rpm' : '-id', - 'maven' : '-id', - 'win' : '-id', + 'build': '-id', + 'rpm': '-id', + 'maven': '-id', + 'win': '-id', # for other tables, ordering by name makes much more sense - 'tag' : 'name', - 'target' : 'name', - 'package' : 'name', + 'tag': 'name', + 'target': 'name', + 'package': 'name', # any type not listed will default to 'name' } diff --git a/www/kojiweb/wsgi_publisher.py b/www/kojiweb/wsgi_publisher.py index 76f78d5c..e2d427b7 100644 --- a/www/kojiweb/wsgi_publisher.py +++ b/www/kojiweb/wsgi_publisher.py @@ -411,7 +411,7 @@ class Dispatcher(object): start_response(status, headers) return result headers = { - 'allow' : ('Allow', 'GET, POST, HEAD'), + 'allow': ('Allow', 'GET, POST, HEAD'), } extra = [] for name, value in environ.get('koji.headers', []):