[PATCH inlinedit] [py3] Get rid of python3 syntax/import errors

Denis Laxalde denis.laxalde at logilab.fr
Mon Jun 4 14:41:42 CEST 2018


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1528115943 -7200
#      Mon Jun 04 14:39:03 2018 +0200
# Branch stable
# Node ID 7061c032182c9d0c898475b89f925fee5e94af2f
# Parent  3365fb93319d19ecbd7b8fba561eb48509de3c09
# Available At http://hg.logilab.org/review/cubes/inlinedit
#              hg pull http://hg.logilab.org/review/cubes/inlinedit -r 7061c032182c
# EXP-Topic py3
[py3] Get rid of python3 syntax/import errors

Add a dependency on six and bump cubicweb's version so that we surely
get cubicweb._.

According to "python3 -m flake8 --select=F", the code base is "okay".

diff --git a/__pkginfo__.py b/__pkginfo__.py
--- a/__pkginfo__.py
+++ b/__pkginfo__.py
@@ -18,8 +18,11 @@ author_email = 'contact at logilab.fr'
 description = 'Extension of the `reledit` builtin feature'
 web = 'http://www.cubicweb.org/project/%s' % distname
 
-__depends__ =  {'cubicweb': '>= 3.19.0',
-                'cwtags': None}
+__depends__ =  {
+    'cubicweb': '>= 3.23.0',
+    'cwtags': None,
+    'six': None,
+}
 __recommends__ = {}
 
 classifiers = [
diff --git a/cubicweb-inlinedit.spec b/cubicweb-inlinedit.spec
--- a/cubicweb-inlinedit.spec
+++ b/cubicweb-inlinedit.spec
@@ -20,8 +20,9 @@ BuildArch:      noarch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-buildroot
 
 BuildRequires:  %{python} %{python}-setuptools
-Requires:       cubicweb >= 3.19.0
+Requires:       cubicweb >= 3.23.0
 Requires:       %{python}-cwtags
+Requires:       %{python}-six
 
 %description
 Extension of the `reledit` builtin feature
diff --git a/debian/control b/debian/control
--- a/debian/control
+++ b/debian/control
@@ -11,8 +11,9 @@ Standards-Version: 3.9.8
 Package: cubicweb-inlinedit
 Architecture: all
 Depends:
- cubicweb-common (>= 3.19.0),
+ cubicweb-common (>= 3.23.0),
  python-cwtags,
+ python-six,
  ${python:Depends},
  ${misc:Depends},
 Description: Extension of the `reledit` builtin feature
diff --git a/views/reledit.py b/views/reledit.py
--- a/views/reledit.py
+++ b/views/reledit.py
@@ -20,17 +20,14 @@
 import copy
 
 import cwtags.tag as t
+from six.moves import range
 
 from logilab.mtconverter import xml_escape
 from logilab.common.registry import yes
 
 from threading import Lock
 
-try:
-    from cubicweb import _
-except ImportError:
-    _ = unicode
-
+from cubicweb import _
 from cubicweb import neg_role, appobject
 from cubicweb.schema import display_name
 from cubicweb.utils import json_dumps
@@ -96,7 +93,7 @@ class RelatedEntityEdit(EntityView):
     def display_entitites(self, action, reload, evid, extradata, **kwargs):
         w = self.w; rset = self.cw_rset
         with t.div(w, Class=self.__regid__):
-            for i in xrange(len(rset)):
+            for i in range(len(rset)):
                 with t.div(w, Class='%s-item' % self.__regid__):
                     self.wview(self.__regid__, rset, row=i, action=action, evid=evid,
                                extradata=extradata, reload=reload, **kwargs)


More information about the cubicweb-devel mailing list