[PATCH 14 of 52 Narval cube] [py3] Replace unicode by str

Nsukami Patrick ptrck at nskm.xyz
Wed Apr 1 11:34:14 CEST 2020


# HG changeset patch
# User Nsukami Patrick <ptrck at nskm dot xyz>
# Date 1585419220 0
#      Sat Mar 28 18:13:40 2020 +0000
# Node ID 403f8d3effb2d27673fe6eef131bbf1f5e8da588
# Parent  3910cd4c3190b568f43c7bc2ea403485eb729c05
[py3] Replace unicode by str

diff --git a/cubicweb_narval/narvalbot/server.py b/cubicweb_narval/narvalbot/server.py
--- a/cubicweb_narval/narvalbot/server.py
+++ b/cubicweb_narval/narvalbot/server.py
@@ -236,11 +236,11 @@
         # add output to Plan entity and change it's state if necessary
         log = u''
         if os.fstat(errfile.fileno())[stat.ST_SIZE]:
-            log += unicode(errfile.read(), 'utf-8', 'replace')
+            log += str(errfile.read(), 'utf-8', 'replace')
             self.info('***** %s error output', ' '.join(command))
             self.info(log)
         if os.fstat(outfile.fileno())[stat.ST_SIZE]:
-            out = unicode(outfile.read(), 'utf-8', 'replace')
+            out = str(outfile.read(), 'utf-8', 'replace')
             self.info('***** %s standard output', ' '.join(command))
             self.info(out)
             log += out
diff --git a/cubicweb_narval/testutils.py b/cubicweb_narval/testutils.py
--- a/cubicweb_narval/testutils.py
+++ b/cubicweb_narval/testutils.py
@@ -87,7 +87,7 @@
                 for fname, fval in form.pop('files').items():
                     if not isinstance(fval, tuple):
                         fval = (fname, fval)
-                    if isinstance(fval[1], unicode):
+                    if isinstance(fval[1], str):
                         fval = (fval[0], fval[1].encode('utf-8'))
                     if isinstance(fval[1], basestring):
                         fval = (fval[0], BytesIO(fval[1]))
diff --git a/cubicweb_narval/views/__init__.py b/cubicweb_narval/views/__init__.py
--- a/cubicweb_narval/views/__init__.py
+++ b/cubicweb_narval/views/__init__.py
@@ -16,7 +16,7 @@
         entity = self.cw_rset.get_entity(row, col)
 
         if entity.data:
-            log_to_html(self._cw, unicode(entity.eid),
+            log_to_html(self._cw, str(entity.eid),
                         entity.data.read().decode(entity.data_encoding),
                         self.w, defaultlevel=loglevel)
         else:
diff --git a/cubicweb_narval/views/recipe.py b/cubicweb_narval/views/recipe.py
--- a/cubicweb_narval/views/recipe.py
+++ b/cubicweb_narval/views/recipe.py
@@ -89,7 +89,7 @@
     columns = ['execution', 'starttime', 'duration']
     column_renderers = {'execution': tableview.MainEntityColRenderer(),
                         'starttime': tableview.EntityTableColRenderer(lambda w, p: w(p._cw.format_date(p.starttime, time=True))),
-                        'duration': tableview.EntityTableColRenderer(lambda w, p: w(unicode(p.duration)))}
+                        'duration': tableview.EntityTableColRenderer(lambda w, p: w(str(p.duration)))}
     html_headers = no_robot_index
 
     def call(self):
diff --git a/cubicweb_narval/views/startplan.py b/cubicweb_narval/views/startplan.py
--- a/cubicweb_narval/views/startplan.py
+++ b/cubicweb_narval/views/startplan.py
@@ -41,8 +41,8 @@
     def action(self):
         return self.edited_entity.absolute_url(vid='narval.startplan')
 
-    priority = ff.IntField(choices=[(l, unicode(v)) for l, v in PRIORITY.iteritems()],
-                           value=unicode(MEDIUM),
+    priority = ff.IntField(choices=[(l, str(v)) for l, v in PRIORITY.iteritems()],
+                           value=str(MEDIUM),
                            label=_('execution priority'),
                            sort=False, internationalizable=True)
 
@@ -89,7 +89,7 @@
             except ValidationError:
                 raise
             except Exception as ex:
-                raise Redirect(self.msg_url(unicode(ex)))
+                raise Redirect(self.msg_url(str(ex)))
         raise Redirect(self.msg_url(self._cw._('plan(s) queued')))
 
     def cell_call(self, row, col, priority=MEDIUM):
diff --git a/cubicweb_narval/views/startup.py b/cubicweb_narval/views/startup.py
--- a/cubicweb_narval/views/startup.py
+++ b/cubicweb_narval/views/startup.py
@@ -34,7 +34,7 @@
     columns = ['execution', 'recipe', 'starttime', 'duration']
     column_renderers = {'execution': tableview.MainEntityColRenderer(vid='narval.plan.statuscell'),
                         'starttime': tableview.EntityTableColRenderer(lambda w, p: w(p._cw.format_date(p.starttime))),
-                        'duration': tableview.EntityTableColRenderer(lambda w, p: w(unicode(p.duration))),
+                        'duration': tableview.EntityTableColRenderer(lambda w, p: w(str(p.duration))),
                         'recipe': tableview.RelatedEntityColRenderer(lambda p: p.recipe),
                         }
     html_headers = no_robot_index




More information about the cubicweb-devel mailing list