Changeset - e8e9f33e9ff6
[Not reviewed]
default
0 8 0
Mads Kiilerich - 6 years ago 2019-11-23 22:47:35
mads@kiilerich.com
Grafted from: 16227defffea
py3: use comprehensions and generators instead of filters - it is more explicit, and sometimes shorter

From 2to3 -f filter.
8 files changed with 12 insertions and 18 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/admin/repo_groups.py
Show inline comments
 
@@ -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
kallithea/controllers/changeset.py
Show inline comments
 
@@ -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]
kallithea/lib/caching_query.py
Show inline comments
 
@@ -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)
 

	
kallithea/lib/diffs.py
Show inline comments
 
@@ -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 ''
 

	
kallithea/lib/helpers.py
Show inline comments
 
@@ -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)
kallithea/lib/utils2.py
Show inline comments
 
@@ -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):
kallithea/model/repo.py
Show inline comments
 
@@ -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:
kallithea/model/validators.py
Show inline comments
 
@@ -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
0 comments (0 inline, 0 general)