changeset 8076:bdb79ef2c879

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.
author Mads Kiilerich <mads@kiilerich.com>
date Thu, 26 Dec 2019 05:17:09 +0100
parents c7d1efd3ca3f
children effd091203ae
files kallithea/controllers/changelog.py kallithea/lib/indexers/daemon.py kallithea/lib/vcs/backends/__init__.py kallithea/lib/vcs/utils/termcolors.py kallithea/model/db.py kallithea/model/notification.py kallithea/templates/base/perms_summary.html
diffstat 7 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/changelog.py	Thu Dec 26 04:02:48 2019 +0100
+++ b/kallithea/controllers/changelog.py	Thu Dec 26 05:17:09 2019 +0100
@@ -134,11 +134,11 @@
 
         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]
--- a/kallithea/lib/indexers/daemon.py	Thu Dec 26 04:02:48 2019 +0100
+++ b/kallithea/lib/indexers/daemon.py	Thu Dec 26 05:17:09 2019 +0100
@@ -331,8 +331,8 @@
                     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
@@ -432,7 +432,7 @@
         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)
--- a/kallithea/lib/vcs/backends/__init__.py	Thu Dec 26 04:02:48 2019 +0100
+++ b/kallithea/lib/vcs/backends/__init__.py	Thu Dec 26 05:17:09 2019 +0100
@@ -9,7 +9,6 @@
     :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
@@ -51,7 +50,7 @@
     """
     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
--- a/kallithea/lib/vcs/utils/termcolors.py	Thu Dec 26 04:02:48 2019 +0100
+++ b/kallithea/lib/vcs/utils/termcolors.py	Thu Dec 26 05:17:09 2019 +0100
@@ -188,7 +188,7 @@
                 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
 
--- a/kallithea/model/db.py	Thu Dec 26 04:02:48 2019 +0100
+++ b/kallithea/model/db.py	Thu Dec 26 05:17:09 2019 +0100
@@ -74,6 +74,7 @@
     @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):
--- a/kallithea/model/notification.py	Thu Dec 26 04:02:48 2019 +0100
+++ b/kallithea/model/notification.py	Thu Dec 26 05:17:09 2019 +0100
@@ -177,7 +177,7 @@
         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
--- a/kallithea/templates/base/perms_summary.html	Thu Dec 26 04:02:48 2019 +0100
+++ b/kallithea/templates/base/perms_summary.html	Thu Dec 26 05:17:09 2019 +0100
@@ -5,7 +5,7 @@
 
 <%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':