From 4d56a9700666a14aee772ed59ae771fe0ec7c341 Mon Sep 17 00:00:00 2001 From: Atsushi Odagiri Date: Sat, 4 Feb 2012 00:17:29 -0800 Subject: [PATCH] cleaning code --- colander/__init__.py | 39 --------------------------------------- colander/tests.py | 5 ----- 2 files changed, 44 deletions(-) diff --git a/colander/__init__.py b/colander/__init__.py index 16672da..170e3ed 100644 --- a/colander/__init__.py +++ b/colander/__init__.py @@ -89,9 +89,6 @@ class Invalid(Exception): ``msg`` attribute is iterable, it is returned. If it is not iterable, a single-element list containing the ``msg`` value is returned.""" - #if hasattr(self.msg, '__iter__'): - # return self.msg - #return [self.msg] if isinstance(self.msg, basestring): return [self.msg] return self.msg @@ -1501,7 +1498,6 @@ class SchemaNode(object): def __new__(cls, *arg, **kw): inst = object.__new__(cls) - #inst._order = cls._counter.next() inst._order = next(cls._counter) return inst @@ -1721,26 +1717,9 @@ class _SchemaMeta(type): extended.sort() 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): 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) @@ -1755,28 +1734,10 @@ Schema = _SchemaMeta('Schema', (object,), 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): 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) diff --git a/colander/tests.py b/colander/tests.py index 31565ab..0faaaee 100644 --- a/colander/tests.py +++ b/colander/tests.py @@ -960,7 +960,6 @@ class TestString(unittest.TestCase): self.assertTrue(e.msg) def test_deserialize_unicode_from_None(self): - #uni = unicode(b'\xf8') uni = unicode(b'\xe3\x81\x82', encoding='utf-8') node = DummySchemaNode(None) typ = self._makeOne() @@ -975,7 +974,6 @@ class TestString(unittest.TestCase): self.assertEqual(result, unicode(value)) def test_deserialize_from_utf8(self): - #uni = unicode(b'\xf8') uni = unicode(b'\xe3\x81\x82', encoding='utf-8') utf8 = uni.encode('utf-8') node = DummySchemaNode(None) @@ -984,7 +982,6 @@ class TestString(unittest.TestCase): self.assertEqual(result, uni) def test_deserialize_from_utf16(self): - #uni = unicode(b'\xf8') uni = unicode(b'\xe3\x81\x82', encoding='utf-8') utf16 = uni.encode('utf-16') node = DummySchemaNode(None) @@ -1021,7 +1018,6 @@ class TestString(unittest.TestCase): self.assertEqual(result, value) def test_serialize_to_utf8(self): - #uni = unicode(b'\xf8') uni = unicode(b'\xe3\x81\x82', encoding='utf-8') utf8 = uni.encode('utf-8') node = DummySchemaNode(None) @@ -1030,7 +1026,6 @@ class TestString(unittest.TestCase): self.assertEqual(result, utf8) def test_serialize_to_utf16(self): - #uni = unicode(b'\xf8') uni = unicode(b'\xe3\x81\x82', encoding='utf-8') utf16 = uni.encode('utf-16') node = DummySchemaNode(None)