@@ -63,49 +63,6 @@ def add_dict(self, dict_, base64=False):
6363 for f in dict_ :
6464 self .add (f , dict_ [f ])
6565
66- @contract
67- def add_unstruct (self , dict_ , encode_base64 ,
68- type_when_encoded , type_when_not_encoded ):
69- """
70- Add an encoded or unencoded JSON to the payload after verifying
71- the contents of the dict
72-
73- :param dict_: Dictionary of the payload to be generated
74- :type dict_: dict(str:*)
75- :param encode_base64: If the payload is base64 encoded
76- :type encode_base64: bool
77- :param type_when_encoded: Name of the field when encode_base64 is set
78- :type type_when_encoded: str
79- :param type_when_not_encoded: Name of the field when encode_base64 is not set
80- :type type_when_not_encoded: str
81- """
82- def raise_error (f , type_ ):
83- raise RuntimeError ("" .join ([f , " in dict is not a " , type_ ]))
84-
85- types = ["int" , "flt" , "geo" , "dt" , "ts" , "tms" ]
86-
87- for f in dict_ :
88- parts = f .split ("$" )
89- if parts [- 1 ] in types :
90- type_ = parts [- 1 ]
91- if ((type_ == "int" and not isinstance (dict_ [f ], int )) or
92- (type_ == "flt" and not isinstance (dict_ [f ], float )) or
93- (type_ == "geo" and not isinstance (dict_ [f ], tuple )) or
94- (type_ == "dt" and not isinstance (dict_ [f ], int )) or
95- (type_ == "ts" and not isinstance (dict_ [f ], int )) or
96- (type_ == "tms" and not isinstance (dict_ [f ], int ))):
97- raise_error (f , type_ )
98- json_dict = json .dumps (dict_ )
99-
100- if encode_base64 :
101- encoded_dict = base64 .urlsafe_b64encode (json_dict .encode ("ascii" ))
102- if not isinstance (encoded_dict , str ):
103- encoded_dict = encoded_dict .decode ("utf-8" )
104- self .add (type_when_encoded , encoded_dict )
105-
106- else :
107- self .add (type_when_not_encoded , json_dict )
108-
10966 @contract
11067 def add_json (self , dict_ , encode_base64 , type_when_encoded , type_when_not_encoded ):
11168 """
0 commit comments