cleaning code
This commit is contained in:
@@ -89,9 +89,6 @@ class Invalid(Exception):
|
|||||||
``msg`` attribute is iterable, it is returned. If it is not
|
``msg`` attribute is iterable, it is returned. If it is not
|
||||||
iterable, a single-element list containing the ``msg`` value
|
iterable, a single-element list containing the ``msg`` value
|
||||||
is returned."""
|
is returned."""
|
||||||
#if hasattr(self.msg, '__iter__'):
|
|
||||||
# return self.msg
|
|
||||||
#return [self.msg]
|
|
||||||
if isinstance(self.msg, basestring):
|
if isinstance(self.msg, basestring):
|
||||||
return [self.msg]
|
return [self.msg]
|
||||||
return self.msg
|
return self.msg
|
||||||
@@ -1501,7 +1498,6 @@ class SchemaNode(object):
|
|||||||
|
|
||||||
def __new__(cls, *arg, **kw):
|
def __new__(cls, *arg, **kw):
|
||||||
inst = object.__new__(cls)
|
inst = object.__new__(cls)
|
||||||
#inst._order = cls._counter.next()
|
|
||||||
inst._order = next(cls._counter)
|
inst._order = next(cls._counter)
|
||||||
return inst
|
return inst
|
||||||
|
|
||||||
@@ -1721,26 +1717,9 @@ class _SchemaMeta(type):
|
|||||||
extended.sort()
|
extended.sort()
|
||||||
cls.nodes = [x[1] for x in extended]
|
cls.nodes = [x[1] for x in extended]
|
||||||
|
|
||||||
# class Schema(object):
|
|
||||||
# schema_type = Mapping
|
|
||||||
# node_type = SchemaNode
|
|
||||||
# __metaclass__ = _SchemaMeta
|
|
||||||
#
|
|
||||||
# def __new__(cls, *args, **kw):
|
|
||||||
# node = object.__new__(cls.node_type)
|
|
||||||
# node.name = None
|
|
||||||
# #node._order = SchemaNode._counter.next()
|
|
||||||
# node._order = next(SchemaNode._counter)
|
|
||||||
# typ = cls.schema_type()
|
|
||||||
# node.__init__(typ, *args, **kw)
|
|
||||||
# for n in cls.nodes:
|
|
||||||
# node.add(n)
|
|
||||||
# return node
|
|
||||||
|
|
||||||
def _Schema__new__(cls, *args, **kw):
|
def _Schema__new__(cls, *args, **kw):
|
||||||
node = object.__new__(cls.node_type)
|
node = object.__new__(cls.node_type)
|
||||||
node.name = None
|
node.name = None
|
||||||
#node._order = SchemaNode._counter.next()
|
|
||||||
node._order = next(SchemaNode._counter)
|
node._order = next(SchemaNode._counter)
|
||||||
typ = cls.schema_type()
|
typ = cls.schema_type()
|
||||||
node.__init__(typ, *args, **kw)
|
node.__init__(typ, *args, **kw)
|
||||||
@@ -1755,28 +1734,10 @@ Schema = _SchemaMeta('Schema', (object,),
|
|||||||
|
|
||||||
MappingSchema = Schema
|
MappingSchema = Schema
|
||||||
|
|
||||||
# class SequenceSchema(object):
|
|
||||||
# schema_type = Sequence
|
|
||||||
# node_type = SchemaNode
|
|
||||||
# __metaclass__ = _SchemaMeta
|
|
||||||
#
|
|
||||||
# def __new__(cls, *args, **kw):
|
|
||||||
# node = object.__new__(cls.node_type)
|
|
||||||
# node.name = None
|
|
||||||
# node._order = SchemaNode._counter.next()
|
|
||||||
# typ = cls.schema_type()
|
|
||||||
# node.__init__(typ, *args, **kw)
|
|
||||||
# if not len(cls.nodes) == 1:
|
|
||||||
# raise Invalid(node,
|
|
||||||
# 'Sequence schemas must have exactly one child node')
|
|
||||||
# for n in cls.nodes:
|
|
||||||
# node.add(n)
|
|
||||||
# return node
|
|
||||||
|
|
||||||
def _SequanceSchema__new__(cls, *args, **kw):
|
def _SequanceSchema__new__(cls, *args, **kw):
|
||||||
node = object.__new__(cls.node_type)
|
node = object.__new__(cls.node_type)
|
||||||
node.name = None
|
node.name = None
|
||||||
#node._order = SchemaNode._counter.next()
|
|
||||||
node._order = next(SchemaNode._counter)
|
node._order = next(SchemaNode._counter)
|
||||||
typ = cls.schema_type()
|
typ = cls.schema_type()
|
||||||
node.__init__(typ, *args, **kw)
|
node.__init__(typ, *args, **kw)
|
||||||
|
@@ -960,7 +960,6 @@ class TestString(unittest.TestCase):
|
|||||||
self.assertTrue(e.msg)
|
self.assertTrue(e.msg)
|
||||||
|
|
||||||
def test_deserialize_unicode_from_None(self):
|
def test_deserialize_unicode_from_None(self):
|
||||||
#uni = unicode(b'\xf8')
|
|
||||||
uni = unicode(b'\xe3\x81\x82', encoding='utf-8')
|
uni = unicode(b'\xe3\x81\x82', encoding='utf-8')
|
||||||
node = DummySchemaNode(None)
|
node = DummySchemaNode(None)
|
||||||
typ = self._makeOne()
|
typ = self._makeOne()
|
||||||
@@ -975,7 +974,6 @@ class TestString(unittest.TestCase):
|
|||||||
self.assertEqual(result, unicode(value))
|
self.assertEqual(result, unicode(value))
|
||||||
|
|
||||||
def test_deserialize_from_utf8(self):
|
def test_deserialize_from_utf8(self):
|
||||||
#uni = unicode(b'\xf8')
|
|
||||||
uni = unicode(b'\xe3\x81\x82', encoding='utf-8')
|
uni = unicode(b'\xe3\x81\x82', encoding='utf-8')
|
||||||
utf8 = uni.encode('utf-8')
|
utf8 = uni.encode('utf-8')
|
||||||
node = DummySchemaNode(None)
|
node = DummySchemaNode(None)
|
||||||
@@ -984,7 +982,6 @@ class TestString(unittest.TestCase):
|
|||||||
self.assertEqual(result, uni)
|
self.assertEqual(result, uni)
|
||||||
|
|
||||||
def test_deserialize_from_utf16(self):
|
def test_deserialize_from_utf16(self):
|
||||||
#uni = unicode(b'\xf8')
|
|
||||||
uni = unicode(b'\xe3\x81\x82', encoding='utf-8')
|
uni = unicode(b'\xe3\x81\x82', encoding='utf-8')
|
||||||
utf16 = uni.encode('utf-16')
|
utf16 = uni.encode('utf-16')
|
||||||
node = DummySchemaNode(None)
|
node = DummySchemaNode(None)
|
||||||
@@ -1021,7 +1018,6 @@ class TestString(unittest.TestCase):
|
|||||||
self.assertEqual(result, value)
|
self.assertEqual(result, value)
|
||||||
|
|
||||||
def test_serialize_to_utf8(self):
|
def test_serialize_to_utf8(self):
|
||||||
#uni = unicode(b'\xf8')
|
|
||||||
uni = unicode(b'\xe3\x81\x82', encoding='utf-8')
|
uni = unicode(b'\xe3\x81\x82', encoding='utf-8')
|
||||||
utf8 = uni.encode('utf-8')
|
utf8 = uni.encode('utf-8')
|
||||||
node = DummySchemaNode(None)
|
node = DummySchemaNode(None)
|
||||||
@@ -1030,7 +1026,6 @@ class TestString(unittest.TestCase):
|
|||||||
self.assertEqual(result, utf8)
|
self.assertEqual(result, utf8)
|
||||||
|
|
||||||
def test_serialize_to_utf16(self):
|
def test_serialize_to_utf16(self):
|
||||||
#uni = unicode(b'\xf8')
|
|
||||||
uni = unicode(b'\xe3\x81\x82', encoding='utf-8')
|
uni = unicode(b'\xe3\x81\x82', encoding='utf-8')
|
||||||
utf16 = uni.encode('utf-16')
|
utf16 = uni.encode('utf-16')
|
||||||
node = DummySchemaNode(None)
|
node = DummySchemaNode(None)
|
||||||
|
Reference in New Issue
Block a user