Skip to content

Commit

Permalink
better serializer structure
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Mar 29, 2015
1 parent 348ea08 commit 5d50f4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion misc/src/formcode_c/serializer.py
Expand Up @@ -39,6 +39,7 @@

import re
import types
import itertools

import colony

Expand Down Expand Up @@ -69,7 +70,8 @@
SEQUENCE_TYPES = {
tuple : True,
list : True,
types.GeneratorType : True
types.GeneratorType : True,
itertools.chain : True
}
""" The map used to check sequence types """

Expand Down
8 changes: 5 additions & 3 deletions misc/src/json_c/serializer.py
Expand Up @@ -43,8 +43,9 @@
import re
import types
import decimal
import datetime
import calendar
import datetime
import itertools

import colony

Expand Down Expand Up @@ -90,7 +91,8 @@
SEQUENCE_TYPES = {
tuple : True,
list : True,
types.GeneratorType : True
types.GeneratorType : True,
itertools.chain : True
}
""" The map used to check sequence types """

Expand Down Expand Up @@ -178,7 +180,7 @@ def dumps(object, eager = None):
lazy evaluation may be performed for generation.
"""

if eager == None: eager = not type(object) == types.GeneratorType
if eager == None: eager = not colony.legacy.is_generator(object)
parts = dump_parts(object)
if not eager: return parts
return "".join([part for part in parts])
Expand Down

0 comments on commit 5d50f4e

Please sign in to comment.