Commit 22eb8045 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[py3k] unicode -> text_type, basestring -> string_types

parent 7896a09a5f08
......@@ -15,6 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-seda adapter classes for generation of a profile generation as HTML"""
from six import string_types
from cubicweb import _
from cubes.seda.entities.profile_generation import SEDA2ExportAdapter, content_types
......@@ -190,7 +192,7 @@ class SEDA2HTMLExport(SEDA2ExportAdapter):
self.element('span', div, text=occ.target.local_name, attributes={'class': 'label'})
self.element('span', div, text=card, attributes={'class': 'card'})
fixed_value = self.serialize(target_value)
if isinstance(fixed_value, basestring):
if isinstance(fixed_value, string_types):
self.element('span', div, text=fixed_value, attributes={'class': 'value'})
else:
span = self.element('span', div, attributes={'class': 'value'})
......@@ -243,7 +245,7 @@ class SEDA2HTMLExport(SEDA2ExportAdapter):
value_div = self.element('div', div)
self.element('span', value_div, text=self._cw._('fixed value'),
attributes={'class': 'label'})
if isinstance(fixed_value, basestring):
if isinstance(fixed_value, string_types):
self.element('span', value_div, text=fixed_value, attributes={'class': 'value'})
else:
span = self.element('span', value_div, attributes={'class': 'value'})
......@@ -289,5 +291,5 @@ class SEDA2HTMLExport(SEDA2ExportAdapter):
else:
if isinstance(value, bool):
value = 'true' if value else 'false'
assert isinstance(value, basestring), repr(value)
assert isinstance(value, string_types), repr(value)
return value
......@@ -17,6 +17,8 @@
from collections import defaultdict
from six import text_type, string_types
from lxml import etree
from pyxst.xml_struct import graph_nodes
......@@ -84,8 +86,8 @@ def serialize(value):
return None # intermediary entity
if isinstance(value, bool):
return 'true' if value else 'false'
assert isinstance(value, basestring), repr(value)
return unicode(value)
assert isinstance(value, string_types), repr(value)
return text_type(value)
def element_minmax_cardinality(occ, card_entity):
......
......@@ -15,6 +15,8 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-saem_ref unit tests for entities.container"""
from six import text_type
from cubicweb.devtools.testlib import CubicWebTC
from cubes.seda.entities import seda_profile_container_def, simplified_profile, full_seda2_profile
......@@ -92,7 +94,7 @@ class PredicatesTC(CubicWebTC):
self.assertEqual(simplified_profile_pred(None, req, entity=being_created), 0)
self.assertEqual(full_seda2_profile_pred(None, req, entity=being_created), 1)
del req.form['__linkto']
req.form['arg'] = [unicode(transfer.eid)]
req.form['arg'] = [text_type(transfer.eid)]
self.assertEqual(simplified_profile_pred(None, req, entity=being_created), 0)
self.assertEqual(full_seda2_profile_pred(None, req, entity=being_created), 1)
transfer.cw_set(simplified_profile=True)
......
......@@ -17,6 +17,8 @@
import unittest
from six import text_type
from cubicweb.devtools.testlib import CubicWebTC
from cubicweb.web import INTERNAL_FIELD_VALUE
......@@ -55,9 +57,9 @@ class ManagementRulesTC(CubicWebTC):
cnx.commit()
self.assertEqual(_rule_ref_vocabulary(rule_base, transfer),
[(access_concept.label(), unicode(access_concept.eid))])
[(access_concept.label(), text_type(access_concept.eid))])
self.assertEqual(_rule_ref_vocabulary(rule_alt, transfer),
[(access_concept.label(), unicode(access_concept.eid))])
[(access_concept.label(), text_type(access_concept.eid))])
class PermissionsTC(CubicWebTC):
......@@ -108,7 +110,7 @@ class RelationWidgetTC(CubicWebTC):
with self.admin_access.web_request() as req:
compressed = req.entity_from_eid(compressed.eid)
req.form = {'relation': 'seda_algorithm:Concept:subject',
'container': unicode(transfer.eid)}
'container': text_type(transfer.eid)}
view = self.vreg['views'].select('search_related_entities', req,
rset=compressed.as_rset())
self.failIf(view.linkable_rset())
......@@ -122,7 +124,7 @@ class RelationWidgetTC(CubicWebTC):
with self.admin_access.web_request() as req:
compressed = req.entity_from_eid(compressed.eid)
req.form = {'relation': 'seda_algorithm:Concept:subject',
'container': unicode(transfer.eid)}
'container': text_type(transfer.eid)}
view = self.vreg['views'].select('search_related_entities', req,
rset=compressed.as_rset())
self.assertEqual(len(view.linkable_rset()), 1)
......
......@@ -15,6 +15,8 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-seda views for ArchiveUnit"""
from six import text_type
from logilab.common.registry import objectify_predicate, yes
from cubicweb import tags, _
......@@ -413,7 +415,7 @@ class SimplifiedArchiveUnitDataObjectReferencesTab(ArchiveUnitDataObjectReferenc
def display_add_button(self, entity):
rtype_roles = [(rtype, role) for rtype, role, _ in self.rtype_role_targets]
params = self.url_params(entity)
params['referenced_by'] = unicode(entity.eid)
params['referenced_by'] = text_type(entity.eid)
transfer = entity.container[0]
button = add_subobjects_button(transfer, rtype_roles, params)
if button:
......
......@@ -17,6 +17,8 @@
import json
from six import text_type
from logilab.mtconverter import xml_escape
from cubicweb import tags, view, _
......@@ -76,7 +78,7 @@ class ContainedRelationFacetWidget(rwdg.RelationFacetWidget):
_, container = parent_and_container(entity)
# and put it as an extra url param
if container is not None:
url_params['container'] = unicode(container.eid)
url_params['container'] = text_type(container.eid)
return super(ContainedRelationFacetWidget, self).trigger_search_url(entity, url_params)
......
......@@ -15,6 +15,8 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-seda views for management rules"""
from six import text_type
from logilab.mtconverter import xml_escape
from cubicweb.predicates import is_instance
......@@ -50,7 +52,7 @@ def _rule_ref_vocabulary(parent, container):
'CACLV seda_{0}_rule_code_list_version_to CS'.format(rule_type))
rset = req.execute(rql, {'at': container.eid})
if rset:
return [(concept.label(), unicode(concept.eid))
return [(concept.label(), text_type(concept.eid))
for concept in rset.entities()]
else:
scheme_relation = 'seda_{0}_rule_code_list_version_from_object'.format(rule_type)
......
......@@ -15,6 +15,8 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-seda custom fields/widgets"""
from six import text_type
from logilab.common.decorators import monkeypatch
from cubicweb import tags, utils
......@@ -138,7 +140,7 @@ class ConceptAutoCompleteWidget(fw.TextInput):
eid = u''
else:
value = concept.label()
eid = unicode(concept.eid)
eid = text_type(concept.eid)
# we need an hidden input to handle the value while the text input display the label
inputs = [
tags.input(name=field.input_name(form, 'Label'), id=slave_id + 'Label',
......@@ -206,7 +208,7 @@ class SEDAMetaField(ff.StringField):
else:
hidden = ' hidden'
icon = 'icon-list-add'
wdgs.append(tags.a(u'', onclick=unicode(js.seda.toggleFormMetaVisibility(divid)),
wdgs.append(tags.a(u'', onclick=text_type(js.seda.toggleFormMetaVisibility(divid)),
href='javascript:$.noop()', title=form._cw._('show/hide meta fields'),
# take care, related js relies on the icon class position
klass=icon + ' metaFieldSwitch'))
......
......@@ -19,6 +19,8 @@ XSD parsing is done using generateDS, which has been copied into the `gends` dir
used bits).
"""
from six import text_type
from cubicweb import neg_role
from xsd import XSDM_MAPPING
......@@ -193,9 +195,9 @@ class UICFGGenerator(CodeGenerator):
yield mapping.etype, attributes
class Code(unicode):
"""Special unicode subclass whose repr() doesn't add quotes, for insertion of python code in a data
structure
class Code(text_type):
"""Special string subclass whose repr() doesn't add quotes, for insertion of python code in a
data structure
"""
def __repr__(self):
return str(self)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment