changeset 8179:756e46bd926b

py3: trivial renaming of .iteritems() to .items() A bit like "2to3 -f dict", but we don't want list().
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 25 Nov 2019 04:15:17 +0100
parents 1886705c4a8c
children c4c2df844424
files kallithea/bin/kallithea_cli_repo.py kallithea/controllers/admin/defaults.py kallithea/controllers/admin/settings.py kallithea/controllers/api/__init__.py kallithea/controllers/pullrequests.py kallithea/lib/auth.py kallithea/lib/diffs.py kallithea/lib/markup_renderer.py kallithea/lib/vcs/backends/git/changeset.py kallithea/lib/vcs/backends/git/inmemory.py kallithea/lib/vcs/backends/git/repository.py kallithea/lib/vcs/backends/hg/changeset.py kallithea/lib/vcs/utils/progressbar.py kallithea/lib/vcs/utils/termcolors.py kallithea/model/db.py kallithea/model/scm.py kallithea/model/validators.py kallithea/templates/changeset/changeset_file_comment.html kallithea/tests/functional/test_admin.py kallithea/tests/vcs/test_changesets.py kallithea/tests/vcs/test_git.py
diffstat 21 files changed, 45 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/bin/kallithea_cli_repo.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/bin/kallithea_cli_repo.py	Mon Nov 25 04:15:17 2019 +0100
@@ -110,7 +110,7 @@
             return
         parts = parts.groupdict()
         time_params = {}
-        for (name, param) in parts.iteritems():
+        for name, param in parts.items():
             if param:
                 time_params[name] = int(param)
         return datetime.timedelta(**time_params)
--- a/kallithea/controllers/admin/defaults.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/controllers/admin/defaults.py	Mon Nov 25 04:15:17 2019 +0100
@@ -68,7 +68,7 @@
 
         try:
             form_result = _form.to_python(dict(request.POST))
-            for k, v in form_result.iteritems():
+            for k, v in form_result.items():
                 setting = Setting.create_or_update(k, v)
             Session().commit()
             h.flash(_('Default settings updated successfully'),
--- a/kallithea/controllers/admin/settings.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/controllers/admin/settings.py	Mon Nov 25 04:15:17 2019 +0100
@@ -423,7 +423,7 @@
         import kallithea
         c.ini = kallithea.CONFIG
         server_info = Setting.get_server_info()
-        for key, val in server_info.iteritems():
+        for key, val in server_info.items():
             setattr(c, key, val)
 
         return htmlfill.render(
--- a/kallithea/controllers/api/__init__.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/controllers/api/__init__.py	Mon Nov 25 04:15:17 2019 +0100
@@ -180,7 +180,7 @@
         USER_SESSION_ATTR = 'apiuser'
 
         # get our arglist and check if we provided them as args
-        for arg, default in func_kwargs.iteritems():
+        for arg, default in func_kwargs.items():
             if arg == USER_SESSION_ATTR:
                 # USER_SESSION_ATTR is something translated from API key and
                 # this is checked before so we don't need validate it
--- a/kallithea/controllers/pullrequests.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/controllers/pullrequests.py	Mon Nov 25 04:15:17 2019 +0100
@@ -109,7 +109,7 @@
         tipbranch = None
 
         branches = []
-        for abranch, branchrev in repo.branches.iteritems():
+        for abranch, branchrev in repo.branches.items():
             n = 'branch:%s:%s' % (abranch, branchrev)
             desc = abranch
             if branchrev == tiprev:
@@ -133,14 +133,14 @@
                 log.debug('branch %r not found in %s', branch, repo)
 
         bookmarks = []
-        for bookmark, bookmarkrev in repo.bookmarks.iteritems():
+        for bookmark, bookmarkrev in repo.bookmarks.items():
             n = 'book:%s:%s' % (bookmark, bookmarkrev)
             bookmarks.append((n, bookmark))
             if rev == bookmarkrev:
                 selected = n
 
         tags = []
-        for tag, tagrev in repo.tags.iteritems():
+        for tag, tagrev in repo.tags.items():
             if tag == 'tip':
                 continue
             n = 'tag:%s:%s' % (tag, tagrev)
--- a/kallithea/lib/auth.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/lib/auth.py	Mon Nov 25 04:15:17 2019 +0100
@@ -442,7 +442,7 @@
             self.is_default_user = False
         else:
             # copy non-confidential database fields from a `db.User` to this `AuthUser`.
-            for k, v in dbuser.get_dict().iteritems():
+            for k, v in dbuser.get_dict().items():
                 assert k not in ['api_keys', 'permissions']
                 setattr(self, k, v)
             self.is_default_user = dbuser.is_default_user
@@ -525,7 +525,7 @@
         """
         Returns list of repositories you're an admin of
         """
-        return [x[0] for x in self.permissions['repositories'].iteritems()
+        return [x[0] for x in self.permissions['repositories'].items()
                 if x[1] == 'repository.admin']
 
     @property
@@ -533,7 +533,7 @@
         """
         Returns list of repository groups you're an admin of
         """
-        return [x[0] for x in self.permissions['repositories_groups'].iteritems()
+        return [x[0] for x in self.permissions['repositories_groups'].items()
                 if x[1] == 'group.admin']
 
     @property
@@ -541,7 +541,7 @@
         """
         Returns list of user groups you're an admin of
         """
-        return [x[0] for x in self.permissions['user_groups'].iteritems()
+        return [x[0] for x in self.permissions['user_groups'].items()
                 if x[1] == 'usergroup.admin']
 
     def __repr__(self):
--- a/kallithea/lib/diffs.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/lib/diffs.py	Mon Nov 25 04:15:17 2019 +0100
@@ -397,7 +397,7 @@
                 'new_lineno': '',
                 'action':     'context',
                 'line':       msg,
-                } for _op, msg in stats['ops'].iteritems()
+                } for _op, msg in stats['ops'].items()
                   if _op not in [MOD_FILENODE]])
 
             _files.append({
--- a/kallithea/lib/markup_renderer.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/lib/markup_renderer.py	Mon Nov 25 04:15:17 2019 +0100
@@ -219,7 +219,7 @@
             docutils_settings.update({'input_encoding': 'unicode',
                                       'report_level': 4})
 
-            for k, v in docutils_settings.iteritems():
+            for k, v in docutils_settings.items():
                 directives.register_directive(k, v)
 
             parts = publish_parts(source=source,
--- a/kallithea/lib/vcs/backends/git/changeset.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/lib/vcs/backends/git/changeset.py	Mon Nov 25 04:15:17 2019 +0100
@@ -79,7 +79,7 @@
     @LazyProperty
     def tags(self):
         _tags = []
-        for tname, tsha in self.repository.tags.iteritems():
+        for tname, tsha in self.repository.tags.items():
             if tsha == self.raw_id:
                 _tags.append(tname)
         return _tags
@@ -123,7 +123,7 @@
             curdir = ''
 
             # initially extract things from root dir
-            for item, stat, id in tree.iteritems():
+            for item, stat, id in tree.items():
                 if curdir:
                     name = '/'.join((curdir, item))
                 else:
@@ -137,7 +137,7 @@
                 else:
                     curdir = dir
                 dir_id = None
-                for item, stat, id in tree.iteritems():
+                for item, stat, id in tree.items():
                     if dir == item:
                         dir_id = id
                 if dir_id:
@@ -149,7 +149,7 @@
                     raise ChangesetError('%s have not been found' % curdir)
 
                 # cache all items from the given traversed tree
-                for item, stat, id in tree.iteritems():
+                for item, stat, id in tree.items():
                     if curdir:
                         name = '/'.join((curdir, item))
                     else:
@@ -407,7 +407,7 @@
         dirnodes = []
         filenodes = []
         als = self.repository.alias
-        for name, stat, id in tree.iteritems():
+        for name, stat, id in tree.items():
             if path != '':
                 obj_path = '/'.join((path, name))
             else:
--- a/kallithea/lib/vcs/backends/git/inmemory.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/lib/vcs/backends/git/inmemory.py	Mon Nov 25 04:15:17 2019 +0100
@@ -172,7 +172,7 @@
             return []
 
         def get_tree_for_dir(tree, dirname):
-            for name, mode, id in tree.iteritems():
+            for name, mode, id in tree.items():
                 if name == dirname:
                     obj = self.repository._repo[id]
                     if isinstance(obj, objects.Tree):
--- a/kallithea/lib/vcs/backends/git/repository.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/lib/vcs/backends/git/repository.py	Mon Nov 25 04:15:17 2019 +0100
@@ -252,7 +252,7 @@
 
     def _get_all_revisions2(self):
         # alternate implementation using dulwich
-        includes = [ascii_str(sha) for key, (sha, type_) in self._parsed_refs.iteritems()
+        includes = [ascii_str(sha) for key, (sha, type_) in self._parsed_refs.items()
                     if type_ != b'T']
         return [c.commit.id for c in self._repo.get_walker(include=includes)]
 
@@ -360,7 +360,7 @@
             return {}
         sortkey = lambda ctx: ctx[0]
         _branches = [(key, ascii_str(sha))
-                     for key, (sha, type_) in self._parsed_refs.iteritems() if type_ == b'H']
+                     for key, (sha, type_) in self._parsed_refs.items() if type_ == b'H']
         return OrderedDict(sorted(_branches, key=sortkey, reverse=False))
 
     @LazyProperty
@@ -377,7 +377,7 @@
 
         sortkey = lambda ctx: ctx[0]
         _tags = [(key, ascii_str(sha))
-                 for key, (sha, type_) in self._parsed_refs.iteritems() if type_ == b'T']
+                 for key, (sha, type_) in self._parsed_refs.items() if type_ == b'T']
         return OrderedDict(sorted(_tags, key=sortkey, reverse=True))
 
     def tag(self, name, user, revision=None, message=None, date=None,
@@ -447,7 +447,7 @@
                 (b'refs/remotes/origin/', b'RH'),
                 (b'refs/tags/', b'T')]
         _refs = {}
-        for ref, sha in refs.iteritems():
+        for ref, sha in refs.items():
             for k, type_ in keys:
                 if ref.startswith(k):
                     _key = ref[len(k):]
@@ -470,7 +470,7 @@
                     if n not in [b'HEAD']:
                         heads[n] = val
 
-        return heads if reverse else dict((y, x) for x, y in heads.iteritems())
+        return heads if reverse else dict((y, x) for x, y in heads.items())
 
     def get_changeset(self, revision=None):
         """
--- a/kallithea/lib/vcs/backends/hg/changeset.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/lib/vcs/backends/hg/changeset.py	Mon Nov 25 04:15:17 2019 +0100
@@ -340,7 +340,7 @@
             if os.path.dirname(d) == path]
 
         als = self.repository.alias
-        for k, vals in self._extract_submodules().iteritems():
+        for k, vals in self._extract_submodules().items():
             #vals = url,rev,type
             loc = vals[0]
             cs = vals[1]
--- a/kallithea/lib/vcs/utils/progressbar.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/lib/vcs/utils/progressbar.py	Mon Nov 25 04:15:17 2019 +0100
@@ -215,7 +215,7 @@
     code_list = []
     if text == '' and len(opts) == 1 and opts[0] == 'reset':
         return '\x1b[%sm' % RESET
-    for k, v in kwargs.iteritems():
+    for k, v in kwargs.items():
         if k == 'fg':
             code_list.append(foreground[v])
         elif k == 'bg':
--- a/kallithea/lib/vcs/utils/termcolors.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/lib/vcs/utils/termcolors.py	Mon Nov 25 04:15:17 2019 +0100
@@ -44,7 +44,7 @@
     code_list = []
     if text == '' and len(opts) == 1 and opts[0] == 'reset':
         return '\x1b[%sm' % RESET
-    for k, v in kwargs.iteritems():
+    for k, v in kwargs.items():
         if k == 'fg':
             code_list.append(foreground[v])
         elif k == 'bg':
--- a/kallithea/model/db.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/model/db.py	Mon Nov 25 04:15:17 2019 +0100
@@ -94,7 +94,7 @@
             # update with attributes from __json__
             if callable(_json_attr):
                 _json_attr = _json_attr()
-            for k, val in _json_attr.iteritems():
+            for k, val in _json_attr.items():
                 d[k] = val
         return d
 
--- a/kallithea/model/scm.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/model/scm.py	Mon Nov 25 04:15:17 2019 +0100
@@ -671,18 +671,18 @@
         repo = repo.scm_instance
 
         branches_group = ([(u'branch:%s' % k, k) for k, v in
-                           repo.branches.iteritems()], _("Branches"))
+                           repo.branches.items()], _("Branches"))
         hist_l.append(branches_group)
         choices.extend([x[0] for x in branches_group[0]])
 
         if repo.alias == 'hg':
             bookmarks_group = ([(u'book:%s' % k, k) for k, v in
-                                repo.bookmarks.iteritems()], _("Bookmarks"))
+                                repo.bookmarks.items()], _("Bookmarks"))
             hist_l.append(bookmarks_group)
             choices.extend([x[0] for x in bookmarks_group[0]])
 
         tags_group = ([(u'tag:%s' % k, k) for k, v in
-                       repo.tags.iteritems()], _("Tags"))
+                       repo.tags.items()], _("Tags"))
         hist_l.append(tags_group)
         choices.extend([x[0] for x in tags_group[0]])
 
--- a/kallithea/model/validators.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/model/validators.py	Mon Nov 25 04:15:17 2019 +0100
@@ -544,7 +544,7 @@
 
             # CLEAN OUT ORG VALUE FROM NEW MEMBERS, and group them using
             new_perms_group = defaultdict(dict)
-            for k, v in value.copy().iteritems():
+            for k, v in value.copy().items():
                 if k.startswith('perm_new_member'):
                     del value[k]
                     _type, part = k.split('perm_new_member_')
@@ -564,7 +564,7 @@
                 if new_member and new_perm and new_type:
                     perms_new.add((new_member, new_perm, new_type))
 
-            for k, v in value.iteritems():
+            for k, v in value.items():
                 if k.startswith('u_perm_') or k.startswith('g_perm_'):
                     member = k[7:]
                     t = {'u': 'user',
--- a/kallithea/templates/changeset/changeset_file_comment.html	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/templates/changeset/changeset_file_comment.html	Mon Nov 25 04:15:17 2019 +0100
@@ -163,7 +163,7 @@
 ## original location of comments ... but the ones outside diff context remains here
 <div class="comments inline-comments">
   %for f_path, lines in c.inline_comments:
-    %for line_no, comments in lines.iteritems():
+    %for line_no, comments in lines.items():
       <div class="comments-list-chunk" data-f_path="${f_path}" data-line_no="${line_no}" data-target-id="${h.safeid(h.safe_unicode(f_path))}_${line_no}">
         %for co in comments:
             ${comment_block(co)}
--- a/kallithea/tests/functional/test_admin.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/tests/functional/test_admin.py	Mon Nov 25 04:15:17 2019 +0100
@@ -34,7 +34,7 @@
         with open(os.path.join(FIXTURES, 'journal_dump.csv')) as f:
             for row in csv.DictReader(f):
                 ul = UserLog()
-                for k, v in row.iteritems():
+                for k, v in row.items():
                     v = safe_unicode(v)
                     if k == 'action_date':
                         v = strptime(v)
--- a/kallithea/tests/vcs/test_changesets.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/tests/vcs/test_changesets.py	Mon Nov 25 04:15:17 2019 +0100
@@ -119,11 +119,11 @@
         assert doc_changeset not in default_branch_changesets
 
     def test_get_changeset_by_branch(self):
-        for branch, sha in self.repo.branches.iteritems():
+        for branch, sha in self.repo.branches.items():
             assert sha == self.repo.get_changeset(branch).raw_id
 
     def test_get_changeset_by_tag(self):
-        for tag, sha in self.repo.tags.iteritems():
+        for tag, sha in self.repo.tags.items():
             assert sha == self.repo.get_changeset(tag).raw_id
 
     def test_get_changeset_parents(self):
--- a/kallithea/tests/vcs/test_git.py	Mon Nov 25 01:48:22 2019 +0100
+++ b/kallithea/tests/vcs/test_git.py	Mon Nov 25 04:15:17 2019 +0100
@@ -791,13 +791,13 @@
         Tests if hooks are installed in repository if they are missing.
         """
 
-        for hook, hook_path in self.kallithea_hooks.iteritems():
+        for hook, hook_path in self.kallithea_hooks.items():
             if os.path.exists(hook_path):
                 os.remove(hook_path)
 
         ScmModel().install_git_hooks(repo=self.repo)
 
-        for hook, hook_path in self.kallithea_hooks.iteritems():
+        for hook, hook_path in self.kallithea_hooks.items():
             assert os.path.exists(hook_path)
 
     def test_kallithea_hooks_updated(self):
@@ -805,13 +805,13 @@
         Tests if hooks are updated if they are Kallithea hooks already.
         """
 
-        for hook, hook_path in self.kallithea_hooks.iteritems():
+        for hook, hook_path in self.kallithea_hooks.items():
             with open(hook_path, "w") as f:
                 f.write("KALLITHEA_HOOK_VER=0.0.0\nJUST_BOGUS")
 
         ScmModel().install_git_hooks(repo=self.repo)
 
-        for hook, hook_path in self.kallithea_hooks.iteritems():
+        for hook, hook_path in self.kallithea_hooks.items():
             with open(hook_path) as f:
                 assert "JUST_BOGUS" not in f.read()
 
@@ -820,13 +820,13 @@
         Tests if hooks are left untouched if they are not Kallithea hooks.
         """
 
-        for hook, hook_path in self.kallithea_hooks.iteritems():
+        for hook, hook_path in self.kallithea_hooks.items():
             with open(hook_path, "w") as f:
                 f.write("#!/bin/bash\n#CUSTOM_HOOK")
 
         ScmModel().install_git_hooks(repo=self.repo)
 
-        for hook, hook_path in self.kallithea_hooks.iteritems():
+        for hook, hook_path in self.kallithea_hooks.items():
             with open(hook_path) as f:
                 assert "CUSTOM_HOOK" in f.read()
 
@@ -835,12 +835,12 @@
         Tests if hooks are forcefully updated even though they are custom hooks.
         """
 
-        for hook, hook_path in self.kallithea_hooks.iteritems():
+        for hook, hook_path in self.kallithea_hooks.items():
             with open(hook_path, "w") as f:
                 f.write("#!/bin/bash\n#CUSTOM_HOOK")
 
         ScmModel().install_git_hooks(repo=self.repo, force_create=True)
 
-        for hook, hook_path in self.kallithea_hooks.iteritems():
+        for hook, hook_path in self.kallithea_hooks.items():
             with open(hook_path) as f:
                 assert "KALLITHEA_HOOK_VER" in f.read()