Improve sequence handling
This commit is contained in:
parent
aa55d75547
commit
78b7494271
@ -48,22 +48,24 @@ class FontTreeStoreBuilder:
|
|||||||
return
|
return
|
||||||
if not isinstance(value, basestring):
|
if not isinstance(value, basestring):
|
||||||
# Sequences
|
# Sequences
|
||||||
|
is_sequence = True
|
||||||
try:
|
try:
|
||||||
len(value)
|
len(value)
|
||||||
iter(value)
|
iter(value)
|
||||||
# It's hard to differentiate list-type sequences
|
# It's hard to differentiate list-type sequences
|
||||||
# from dict-type ones. Try fetching item 0.
|
# from dict-type ones. Try fetching item 0.
|
||||||
value[0]
|
value[0]
|
||||||
|
except TypeError:
|
||||||
|
is_sequence = False
|
||||||
|
except AttributeError:
|
||||||
|
is_sequence = False
|
||||||
|
except KeyError:
|
||||||
|
is_sequence = False
|
||||||
|
except IndexError:
|
||||||
|
is_sequence = False
|
||||||
|
if is_sequence:
|
||||||
self.add_list(parent, key, value)
|
self.add_list(parent, key, value)
|
||||||
return
|
return
|
||||||
except TypeError:
|
|
||||||
pass
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
except IndexError:
|
|
||||||
pass
|
|
||||||
if hasattr(value, '__dict__'):
|
if hasattr(value, '__dict__'):
|
||||||
self.add_object(parent, key, value)
|
self.add_object(parent, key, value)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user