Fix missing quotes and make spacing more standard

This commit is contained in:
Éric Araujo
2016-06-29 16:48:40 -04:00
committed by GitHub
parent 263698173f
commit 70c3cd369a

View File

@@ -23,7 +23,7 @@ serialization might look something like this:
'age': '20', 'age': '20',
'friends': [('1', 'jim'), ('2', 'bob'), ('3', 'joe'), ('4', 'fred')], 'friends': [('1', 'jim'), ('2', 'bob'), ('3', 'joe'), ('4', 'fred')],
'phones': [{'location': 'home', 'number': '555-1212'}, 'phones': [{'location': 'home', 'number': '555-1212'},
{'location':'work', 'number':'555-8989'},], {'location': 'work', 'number': '555-8989'}],
} }
Let's further imagine you'd like to make sure, on demand, that a Let's further imagine you'd like to make sure, on demand, that a
@@ -416,7 +416,7 @@ Deserializing A Valid Serialization
'age': '20', 'age': '20',
'friends': [('1', 'jim'), ('2', 'bob'), ('3', 'joe'), ('4', 'fred')], 'friends': [('1', 'jim'), ('2', 'bob'), ('3', 'joe'), ('4', 'fred')],
'phones': [{'location': 'home', 'number': '555-1212'}, 'phones': [{'location': 'home', 'number': '555-1212'},
{'location':'work', 'number':'555-8989'},], {'location': 'work', 'number': '555-8989'}],
} }
schema = Person() schema = Person()
deserialized = schema.deserialize(cstruct) deserialized = schema.deserialize(cstruct)
@@ -433,7 +433,7 @@ conforms to the schema, ``deserialized`` will be the following:
'age': 20, 'age': 20,
'friends': [(1, 'jim'), (2, 'bob'), (3, 'joe'), (4, 'fred')], 'friends': [(1, 'jim'), (2, 'bob'), (3, 'joe'), (4, 'fred')],
'phones': [{'location': 'home', 'number': '555-1212'}, 'phones': [{'location': 'home', 'number': '555-1212'},
{'location':'work', 'number':'555-8989'},], {'location': 'work', 'number': '555-8989'}],
} }
Note that all the friend rankings have been converted to integers, Note that all the friend rankings have been converted to integers,
@@ -459,7 +459,7 @@ validation error?
'age': '-1', 'age': '-1',
'friends': [('1', 'jim'), ('t', 'bob'), ('3', 'joe'), ('4', 'fred')], 'friends': [('1', 'jim'), ('t', 'bob'), ('3', 'joe'), ('4', 'fred')],
'phones': [{'location': 'bar', 'number': '555-1212'}, 'phones': [{'location': 'bar', 'number': '555-1212'},
{'location':'work', 'number':'555-8989'},], {'location': 'work', 'number': '555-8989'}],
} }
schema = Person() schema = Person()
schema.deserialize(cstruct) schema.deserialize(cstruct)
@@ -473,7 +473,7 @@ It will print something like:
Invalid: {'age': '-1 is less than minimum value 0', Invalid: {'age': '-1 is less than minimum value 0',
'friends.1.0': '"t" is not a number', 'friends.1.0': '"t" is not a number',
'phones.0.location:'"bar" is not one of "home", "work"'} 'phones.0.location': '"bar" is not one of "home", "work"'}
The above error is telling us that: The above error is telling us that:
@@ -498,7 +498,7 @@ dictionary:
'age': '-1', 'age': '-1',
'friends': [('1', 'jim'), ('t', 'bob'), ('3', 'joe'), ('4', 'fred')], 'friends': [('1', 'jim'), ('t', 'bob'), ('3', 'joe'), ('4', 'fred')],
'phones': [{'location': 'bar', 'number': '555-1212'}, 'phones': [{'location': 'bar', 'number': '555-1212'},
{'location':'work', 'number':'555-8989'},], {'location': 'work', 'number': '555-8989'}],
} }
schema = Person() schema = Person()
try: try:
@@ -514,7 +514,7 @@ This will print something like:
{'age': '-1 is less than minimum value 0', {'age': '-1 is less than minimum value 0',
'friends.1.0': '"t" is not a number', 'friends.1.0': '"t" is not a number',
'phones.0.location:'"bar" is not one of "home", "work"'} 'phones.0.location': '"bar" is not one of "home", "work"'}
:exc:`colander.Invalid` Exceptions :exc:`colander.Invalid` Exceptions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1053,7 +1053,7 @@ a schema created declaratively:
'age': '20', 'age': '20',
'friends': [('1', 'jim'), ('2', 'bob'), ('3', 'joe'), ('4', 'fred')], 'friends': [('1', 'jim'), ('2', 'bob'), ('3', 'joe'), ('4', 'fred')],
'phones': [{'location': 'home', 'number': '555-1212'}, 'phones': [{'location': 'home', 'number': '555-1212'},
{'location':'work', 'number':'555-8989'},], {'location': 'work', 'number': '555-8989'}],
} }
deserialized = schema.deserialize(data) deserialized = schema.deserialize(data)
@@ -1102,4 +1102,3 @@ module scope before mutating any of its subnodes:
:meth:`colander.SchemaNode.clone` clones all the nodes in the schema, :meth:`colander.SchemaNode.clone` clones all the nodes in the schema,
so you can work with a "deep copy" of the schema without disturbing the so you can work with a "deep copy" of the schema without disturbing the
"template" schema nodes defined at a higher scope. "template" schema nodes defined at a higher scope.