[schema] deal with py3k's string types

Related to #267910.

authorJulien Cristau <julien.cristau@logilab.fr>
changesetcfc4e2fb9167
branchdefault
phasepublic
hiddenno
parent revision#a54af46409ce [reader] use six.moves to get at __builtin__ or builtins module
child revision#299b110e1916 [schema] implement __eq__ and __lt__ instead of __cmp__ for ERSchema
files modified by this revision
schema.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1413462762 -7200
# Thu Oct 16 14:32:42 2014 +0200
# Node ID cfc4e2fb9167d6cb9a0a3ac81a4a876e5fc8fa3d
# Parent a54af46409ce25813261cf51b842cf4d8b6640c4
[schema] deal with py3k's string types

Related to #267910.

diff --git a/schema.py b/schema.py
@@ -16,17 +16,18 @@
1  # You should have received a copy of the GNU Lesser General Public License along
2  # with yams. If not, see <http://www.gnu.org/licenses/>.
3  """Classes to define generic Entities/Relations schemas."""
4 
5  __docformat__ = "restructuredtext en"
6 -_ = unicode
7 
8  import warnings
9  from copy import deepcopy
10  from decimal import Decimal
11  from itertools import chain
12 
13 +from six import text_type
14 +
15  from logilab.common import attrdict
16  from logilab.common.decorators import cached, clear_cache
17  from logilab.common.interface import implements
18 
19  import yams
@@ -35,10 +36,12 @@
20                    DEFAULT_COMPUTED_RELPERMS)
21  from yams.interfaces import (ISchema, IRelationSchema, IEntitySchema,
22                               IVocabularyConstraint)
23  from yams.constraints import BASE_CHECKERS, BASE_CONVERTERS, UniqueConstraint
24 
25 +_ = text_type
26 +
27  def role_name(rtype, role):
28      """function to use for qualifying attribute / relation in ValidationError
29      errors'dictionnary
30      """
31      return '%s-%s' % (rtype, role)
@@ -492,11 +495,11 @@
32          contains some invalid fields (ie some constraints failed)
33          """
34          if _ is not None:
35              warnings.warn('[yams 0.36] _ argument is deprecated, remove it',
36                            DeprecationWarning, stacklevel=2)
37 -        _ = unicode
38 +        _ = text_type
39          errors = {}
40          msgargs = {}
41          i18nvalues = []
42          relations = relations or self.subject_relations()
43          for rschema in relations: