diff --git a/kallithea/controllers/admin/repo_groups.py b/kallithea/controllers/admin/repo_groups.py --- a/kallithea/controllers/admin/repo_groups.py +++ b/kallithea/controllers/admin/repo_groups.py @@ -92,10 +92,8 @@ class RepoGroupsController(BaseControlle return data def _revoke_perms_on_yourself(self, form_result): - _up = filter(lambda u: request.authuser.username == u[0], - form_result['perms_updates']) - _new = filter(lambda u: request.authuser.username == u[0], - form_result['perms_new']) + _up = [u for u in form_result['perms_updates'] if request.authuser.username == u[0]] + _new = [u for u in form_result['perms_new'] if request.authuser.username == u[0]] if _new and _new[0][1] != 'group.admin' or _up and _up[0][1] != 'group.admin': return True return False diff --git a/kallithea/controllers/changeset.py b/kallithea/controllers/changeset.py --- a/kallithea/controllers/changeset.py +++ b/kallithea/controllers/changeset.py @@ -66,7 +66,7 @@ def anchor_url(revision, path, GET): def get_ignore_ws(fid, GET): ig_ws_global = GET.get('ignorews') - ig_ws = filter(lambda k: k.startswith('WS'), GET.getall(fid)) + ig_ws = [k for k in GET.getall(fid) if k.startswith('WS')] if ig_ws: try: return int(ig_ws[0].split(':')[-1]) @@ -109,9 +109,9 @@ def _ignorews_url(GET, fileid=None): def get_line_ctx(fid, GET): ln_ctx_global = GET.get('context') if fid: - ln_ctx = filter(lambda k: k.startswith('C'), GET.getall(fid)) + ln_ctx = [k for k in GET.getall(fid) if k.startswith('C')] else: - _ln_ctx = filter(lambda k: k.startswith('C'), GET) + _ln_ctx = [k for k in GET if k.startswith('C')] ln_ctx = GET.get(_ln_ctx[0]) if _ln_ctx else ln_ctx_global if ln_ctx: ln_ctx = [ln_ctx] diff --git a/kallithea/lib/caching_query.py b/kallithea/lib/caching_query.py --- a/kallithea/lib/caching_query.py +++ b/kallithea/lib/caching_query.py @@ -139,8 +139,7 @@ def _get_cache_parameters(query): if cache_key is None: # cache key - the value arguments from this query's parameters. args = [safe_str(x) for x in _params_from_query(query)] - args.extend(filter(lambda k: k not in ['None', None, u'None'], - [str(query._limit), str(query._offset)])) + args.extend([k for k in [str(query._limit), str(query._offset)] if k not in ['None', None, u'None']]) cache_key = " ".join(args) diff --git a/kallithea/lib/diffs.py b/kallithea/lib/diffs.py --- a/kallithea/lib/diffs.py +++ b/kallithea/lib/diffs.py @@ -216,8 +216,7 @@ def wrapped_diff(filenode_old, filenode_ stats = (0, 0) if not html_diff: - submodules = filter(lambda o: isinstance(o, SubModuleNode), - [filenode_new, filenode_old]) + submodules = [o for o in [filenode_new, filenode_old] if isinstance(o, SubModuleNode)] if submodules: html_diff = wrap_to_table(h.escape('Submodule %r' % submodules[0])) else: @@ -235,8 +234,7 @@ def get_gitdiff(filenode_old, filenode_n """ # make sure we pass in default context context = context or 3 - submodules = filter(lambda o: isinstance(o, SubModuleNode), - [filenode_new, filenode_old]) + submodules = [o for o in [filenode_new, filenode_old] if isinstance(o, SubModuleNode)] if submodules: return '' diff --git a/kallithea/lib/helpers.py b/kallithea/lib/helpers.py --- a/kallithea/lib/helpers.py +++ b/kallithea/lib/helpers.py @@ -676,7 +676,7 @@ def action_parser(user_log, feed=False, return _op, _name revs = [] - if len(filter(lambda v: v != '', revs_ids)) > 0: + if len([v for v in revs_ids if v != '']) > 0: repo = None for rev in revs_ids[:revs_top_limit]: _op, _name = _get_op(rev) diff --git a/kallithea/lib/utils2.py b/kallithea/lib/utils2.py --- a/kallithea/lib/utils2.py +++ b/kallithea/lib/utils2.py @@ -394,7 +394,7 @@ def uri_filter(uri): else: host, port = uri[:cred_pos], uri[cred_pos + 1:] - return filter(None, [proto, host, port]) + return [_f for _f in [proto, host, port] if _f] def credentials_filter(uri): diff --git a/kallithea/model/repo.py b/kallithea/model/repo.py --- a/kallithea/model/repo.py +++ b/kallithea/model/repo.py @@ -306,8 +306,7 @@ class RepoModel(object): repo=cur_repo, user='default', perm=EMPTY_PERM ) # handle extra fields - for field in filter(lambda k: k.startswith(RepositoryField.PREFIX), - kwargs): + for field in [k for k in kwargs if k.startswith(RepositoryField.PREFIX)]: k = RepositoryField.un_prefix_key(field) ex_field = RepositoryField.get_by_key_name(key=k, repo=cur_repo) if ex_field: diff --git a/kallithea/model/validators.py b/kallithea/model/validators.py --- a/kallithea/model/validators.py +++ b/kallithea/model/validators.py @@ -782,7 +782,7 @@ def ValidAuthPlugins(): def _convert_to_python(self, value, state): # filter empty values - return filter(lambda s: s not in [None, ''], value) + return [s for s in value if s not in [None, '']] def _validate_python(self, value, state): from kallithea.lib import auth_modules