1
1
from office365 .runtime .client_value import ClientValue
2
+ from office365 .runtime .odata .odata_type import ODataType
2
3
from office365 .runtime .odata .v3 .json_light_format import JsonLightFormat
3
4
4
5
@@ -37,16 +38,14 @@ def to_json(self, json_format=None):
37
38
"""
38
39
:type json_format: office365.runtime.odata.odata_json_format.ODataJsonFormat or None
39
40
"""
40
- json_items = [item for item in self ._data ]
41
- for i , v in enumerate (json_items ):
41
+ json = [item for item in self ._data ]
42
+ for i , v in enumerate (json ):
42
43
if isinstance (v , ClientValue ):
43
- json_items [i ] = v .to_json (json_format )
44
+ json [i ] = v .to_json (json_format )
44
45
if isinstance (json_format , JsonLightFormat ) and json_format .include_control_information ():
45
- json = {json_format .collection_tag_name : json_items ,
46
+ json = {json_format .collection_tag_name : json ,
46
47
json_format .metadata_type_tag_name : {'type' : self .entity_type_name }}
47
-
48
- return json
49
- return json_items
48
+ return json
50
49
51
50
def set_property (self , index , value , persist_changes = False ):
52
51
child_value = self ._item_type ()
@@ -56,23 +55,15 @@ def set_property(self, index, value, persist_changes=False):
56
55
else :
57
56
child_value = value
58
57
self .add (child_value )
58
+ return self
59
59
60
60
@property
61
61
def entity_type_name (self ):
62
- """
63
- Gets server type name
64
- """
65
- primitive_types = {
66
- bool : "Edm.Boolean" ,
67
- int : "Edm.Int32" ,
68
- str : "Edm.String" ,
69
- }
70
-
71
62
item_type_name = None
72
63
73
- is_primitive = primitive_types .get (self ._item_type , None ) is not None
64
+ is_primitive = ODataType . primitive_types .get (self ._item_type , None ) is not None
74
65
if is_primitive :
75
- item_type_name = primitive_types [self ._item_type ]
66
+ item_type_name = ODataType . primitive_types [self ._item_type ]
76
67
elif issubclass (self ._item_type , ClientValue ):
77
68
item_type_name = self ._item_type .entity_type_name .fget (self )
78
69
0 commit comments