Changeset - bdb79ef2c879
[Not reviewed]
default
0 7 0
Mads Kiilerich - 6 years ago 2019-12-26 05:17:09
mads@kiilerich.com
Grafted from: ca11709d4a95
py3: drop .keys when we don't need them

In python 3 they will be iterators and mostly useless ... but they are already
mostly redundant in py2.
7 files changed with 10 insertions and 10 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/changelog.py
Show inline comments
 
@@ -125,29 +125,29 @@ class ChangelogController(BaseRepoContro
 
            c.cs_comments = c.db_repo.get_comments(page_revisions)
 
            c.cs_statuses = c.db_repo.statuses(page_revisions)
 
        except EmptyRepositoryError as e:
 
            h.flash(e, category='warning')
 
            raise HTTPFound(location=url('summary_home', repo_name=c.repo_name))
 
        except (RepositoryError, ChangesetDoesNotExistError, Exception) as e:
 
            log.error(traceback.format_exc())
 
            h.flash(e, category='error')
 
            raise HTTPFound(location=url('changelog_home', repo_name=c.repo_name))
 

	
 
        c.branch_name = branch_name
 
        c.branch_filters = [('', _('None'))] + \
 
            [(k, k) for k in c.db_repo_scm_instance.branches.keys()]
 
            [(k, k) for k in c.db_repo_scm_instance.branches]
 
        if c.db_repo_scm_instance.closed_branches:
 
            prefix = _('(closed)') + ' '
 
            c.branch_filters += [('-', '-')] + \
 
                [(k, prefix + k) for k in c.db_repo_scm_instance.closed_branches.keys()]
 
                [(k, prefix + k) for k in c.db_repo_scm_instance.closed_branches]
 
        revs = []
 
        if not f_path:
 
            revs = [x.revision for x in c.cs_pagination]
 
        c.jsdata = graph_data(c.db_repo_scm_instance, revs)
 

	
 
        c.revision = revision # requested revision ref
 
        c.first_revision = c.cs_pagination[0] # pagination is never empty here!
 
        return render('changelog/changelog.html')
 

	
 
    @LoginRequired(allow_default_user=True)
 
    @HasRepoPermissionLevelDecorator('read')
 
    def changelog_details(self, cs):
kallithea/lib/indexers/daemon.py
Show inline comments
 
@@ -322,26 +322,26 @@ class WhooshIndexingDaemon(object):
 
                log.debug('indexed %s changesets for repo %s',
 
                          indexed_total, repo_name
 
                )
 
            finally:
 
                if writer_is_dirty:
 
                    log.debug('>> COMMITING CHANGES TO CHANGESET INDEX<<')
 
                    writer.commit(merge=True)
 
                    log.debug('>>> FINISHED REBUILDING CHANGESET INDEX <<<')
 
                else:
 
                    log.debug('>> NOTHING TO COMMIT TO CHANGESET INDEX<<')
 

	
 
    def update_file_index(self):
 
        log.debug((u'STARTING INCREMENTAL INDEXING UPDATE FOR EXTENSIONS %s '
 
                   'AND REPOS %s') % (INDEX_EXTENSIONS, self.repo_paths.keys()))
 
        log.debug(u'STARTING INCREMENTAL INDEXING UPDATE FOR EXTENSIONS %s '
 
                  'AND REPOS %s', INDEX_EXTENSIONS, ' and '.join(self.repo_paths))
 

	
 
        idx = open_dir(self.index_location, indexname=self.indexname)
 
        # The set of all paths in the index
 
        indexed_paths = set()
 
        # The set of all paths we need to re-index
 
        to_index = set()
 

	
 
        writer = idx.writer()
 
        writer_is_dirty = False
 
        try:
 
            with idx.reader() as reader:
 

	
 
@@ -423,25 +423,25 @@ class WhooshIndexingDaemon(object):
 
            rmtree(self.index_location)
 

	
 
        if not os.path.exists(self.index_location):
 
            os.mkdir(self.index_location)
 

	
 
        chgset_idx = create_in(self.index_location, CHGSETS_SCHEMA,
 
                               indexname=CHGSET_IDX_NAME)
 
        chgset_idx_writer = chgset_idx.writer()
 

	
 
        file_idx = create_in(self.index_location, SCHEMA, indexname=IDX_NAME)
 
        file_idx_writer = file_idx.writer()
 
        log.debug('BUILDING INDEX FOR EXTENSIONS %s '
 
                  'AND REPOS %s' % (INDEX_EXTENSIONS, self.repo_paths.keys()))
 
                  'AND REPOS %s', INDEX_EXTENSIONS, ' and '.join(self.repo_paths))
 

	
 
        for repo_name, repo in sorted(self.repo_paths.items()):
 
            log.debug('Updating indices for repo %s', repo_name)
 
            # skip indexing if there aren't any revisions
 
            if len(repo) < 1:
 
                continue
 

	
 
            self.index_files(file_idx_writer, repo_name, repo)
 
            self.index_changesets(chgset_idx_writer, repo_name, repo)
 

	
 
        log.debug('>> COMMITING CHANGES <<')
 
        file_idx_writer.commit(merge=True)
kallithea/lib/vcs/backends/__init__.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
"""
 
    vcs.backends
 
    ~~~~~~~~~~~~
 

	
 
    Main package for scm backends
 

	
 
    :created_on: Apr 8, 2010
 
    :copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
 
"""
 
import os
 
from pprint import pformat
 

	
 
from kallithea.lib.vcs.conf import settings
 
from kallithea.lib.vcs.exceptions import VCSError
 
from kallithea.lib.vcs.utils.helpers import get_scm
 
from kallithea.lib.vcs.utils.imports import import_class
 
from kallithea.lib.vcs.utils.paths import abspath
 

	
 

	
 
def get_repo(path=None, alias=None, create=False):
 
    """
 
    Returns ``Repository`` object of type linked with given ``alias`` at
 
    the specified ``path``. If ``alias`` is not given it will try to guess it
 
@@ -42,23 +41,23 @@ def get_repo(path=None, alias=None, crea
 
    backend = get_backend(alias)
 
    repo = backend(path, create=create)
 
    return repo
 

	
 

	
 
def get_backend(alias):
 
    """
 
    Returns ``Repository`` class identified by the given alias or raises
 
    VCSError if alias is not recognized or backend class cannot be imported.
 
    """
 
    if alias not in settings.BACKENDS:
 
        raise VCSError("Given alias '%s' is not recognized! Allowed aliases:\n"
 
            "%s" % (alias, pformat(settings.BACKENDS.keys())))
 
            "%s" % (alias, '", "'.join(settings.BACKENDS)))
 
    backend_path = settings.BACKENDS[alias]
 
    klass = import_class(backend_path)
 
    return klass
 

	
 

	
 
def get_supported_backends():
 
    """
 
    Returns list of aliases of supported backends.
 
    """
 
    return settings.BACKENDS.keys()
kallithea/lib/vcs/utils/termcolors.py
Show inline comments
 
@@ -179,25 +179,25 @@ def parse_color_setting(config_string):
 

	
 
            # The first instruction can contain a slash
 
            # to break apart fg/bg.
 
            colors = styles.pop().split('/')
 
            colors.reverse()
 
            fg = colors.pop()
 
            if fg in color_names:
 
                definition['fg'] = fg
 
            if colors and colors[-1] in color_names:
 
                definition['bg'] = colors[-1]
 

	
 
            # All remaining instructions are options
 
            opts = tuple(s for s in styles if s in opt_dict.keys())
 
            opts = tuple(s for s in styles if s in opt_dict)
 
            if opts:
 
                definition['opts'] = opts
 

	
 
            # The nocolor palette has all available roles.
 
            # Use that palette as the basis for determining
 
            # if the role is valid.
 
            if role in PALETTES[NOCOLOR_PALETTE] and definition:
 
                palette[role] = definition
 

	
 
    # If there are no colors specified, return the empty palette.
 
    if palette == PALETTES[NOCOLOR_PALETTE]:
 
        return None
kallithea/model/db.py
Show inline comments
 
@@ -65,24 +65,25 @@ log = logging.getLogger(__name__)
 

	
 
_hash_key = lambda k: hashlib.md5(safe_str(k)).hexdigest()
 

	
 

	
 
class BaseDbModel(object):
 
    """
 
    Base Model for all classes
 
    """
 

	
 
    @classmethod
 
    def _get_keys(cls):
 
        """return column names for this model """
 
        # Note: not a normal dict - iterator gives "users.firstname", but keys gives "firstname"
 
        return class_mapper(cls).c.keys()
 

	
 
    def get_dict(self):
 
        """
 
        return dict with keys and values corresponding
 
        to this model data """
 

	
 
        d = {}
 
        for k in self._get_keys():
 
            d[k] = getattr(self, k)
 

	
 
        # also use __json__() if present to get additional fields
kallithea/model/notification.py
Show inline comments
 
@@ -168,25 +168,25 @@ class EmailNotificationModel(object):
 
            self.TYPE_PULL_REQUEST: _('[Review] %(repo_name)s PR %(pr_nice_id)s "%(pr_title_short)s" from %(pr_source_branch)s by %(pr_owner_username)s'),
 
            self.TYPE_PULL_REQUEST_COMMENT: _('[Comment] %(repo_name)s PR %(pr_nice_id)s "%(pr_title_short)s" from %(pr_source_branch)s by %(pr_owner_username)s'),
 
        }
 

	
 
    def get_email_description(self, type_, **kwargs):
 
        """
 
        return subject for email based on given type
 
        """
 
        tmpl = self._subj_map[type_]
 
        try:
 
            subj = tmpl % kwargs
 
        except KeyError as e:
 
            log.error('error generating email subject for %r from %s: %s', type_, ','.join(self._subj_map.keys()), e)
 
            log.error('error generating email subject for %r from %s: %s', type_, ', '.join(self._subj_map), e)
 
            raise
 
        # gmail doesn't do proper threading but will ignore leading square
 
        # bracket content ... so that is where we put status info
 
        bracket_tags = []
 
        status_change = kwargs.get('status_change')
 
        if status_change:
 
            bracket_tags.append(unicode(status_change))  # apply unicode to evaluate LazyString before .join
 
        if kwargs.get('closing_pr'):
 
            bracket_tags.append(_('Closing'))
 
        if bracket_tags:
 
            if subj.startswith('['):
 
                subj = '[' + ', '.join(bracket_tags) + ': ' + subj[1:]
kallithea/templates/base/perms_summary.html
Show inline comments
 
## snippet for displaying permissions overview for users
 
## usage:
 
##    <%namespace name="p" file="/base/perms_summary.html"/>
 
##    ${p.perms_summary(c.perm_user.permissions)}
 

	
 
<%def name="perms_summary(permissions, show_all=False, actions=True)">
 
<div id="perms">
 
     %for section in sorted(permissions.keys()):
 
     %for section in sorted(permissions):
 
        <div class="perms_section_head">
 
            <h4>${section.replace("_"," ").capitalize()}</h4>
 
            %if section != 'global':
 
              <div class="pull-right checkbox">
 
                ${_('Show')}:
 
                <label>${h.checkbox('perms_filter_none_%s' % section, 'none', 'checked', class_='perm_filter filter_%s' % section, **{'data-section':section, 'data-perm_type':'none'})}<span class="label label-none">${_('None')}</span></label>
 
                <label>${h.checkbox('perms_filter_read_%s' % section, 'read', 'checked', class_='perm_filter filter_%s' % section, **{'data-section':section, 'data-perm_type':'read'})}<span class="label label-read">${_('Read')}</span></label>
 
                <label>${h.checkbox('perms_filter_write_%s' % section, 'write', 'checked', class_='perm_filter filter_%s' % section, **{'data-section':section, 'data-perm_type':'write'})}<span class="label label-write">${_('Write')}</span></label>
 
                <label>${h.checkbox('perms_filter_admin_%s' % section, 'admin', 'checked', class_='perm_filter filter_%s' % section, **{'data-section':section, 'data-perm_type':'admin'})}<span class="label label-admin">${_('Admin')}</span></label>
 
              </div>
 
            %endif
 
        </div>
0 comments (0 inline, 0 general)