Changeset 987aaa1 for fedd/fedd_util.py
- Timestamp:
- Sep 9, 2008 2:07:18 PM (16 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
- Children:
- 45ebc4d
- Parents:
- 4fc2250
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd_util.py
r4fc2250 r987aaa1 7 7 from M2Crypto import SSL, X509, EVP 8 8 from pyasn1.codec.der import decoder 9 10 from xmlrpclib import Binary 9 11 10 12 … … 89 91 90 92 def pack_soap(self): 93 return self.buf 94 95 def pack_xmlrpc(self): 91 96 return self.buf 92 97 … … 227 232 else: 228 233 return element 234 235 def encapsulate_binaries(e, tags): 236 """Walk through a message and encapsulate any dictionary entries in 237 tags into a binary object.""" 238 dict_type = type(dict()) 239 list_type = type(list()) 240 str_type = type(str()) 241 242 if isinstance(e, dict_type): 243 for k in e.keys(): 244 if k in tags: 245 if isinstance(e[k], list_type): 246 bin_list = [] 247 for ee in e[k]: 248 if getattr(ee, 'pack_xmlrpc', None): 249 bin_list.append(Binary(ee.pack_xmlrpc())) 250 else: 251 bin_list.append(Binary(ee)) 252 e[k] = bin_list 253 elif getattr(e[k],'pack_xmlrpc', None): 254 e[k] = Binary(e[k].pack_xmlrpc()) 255 else: 256 e[k] = Binary(e[k]) 257 elif isinstance(e[k], dict_type): 258 encapsulate_binaries(e[k], tags) 259 elif isinstance(e[k], list_type): 260 for ee in e[k]: 261 encapsulate_binaries(ee, tags) 262 # Other types end the recursion - they should be leaves 263 return e 264 265 def decapsulate_binaries(e, tags): 266 """Walk through a message and encapsulate any dictionary entries in 267 tags into a binary object.""" 268 dict_type = type(dict()) 269 list_type = type(list()) 270 str_type = type(str()) 271 272 if isinstance(e, dict_type): 273 for k in e.keys(): 274 if k in tags: 275 if isinstance(e[k], list_type): 276 e[k] = [ b.data for b in e[k]] 277 else: 278 e[k] = e[k].data 279 elif isinstance(e[k], dict_type): 280 decapsulate_binaries(e[k], tags) 281 elif isinstance(e[k], list_type): 282 for ee in e[k]: 283 decapsulate_binaries(ee, tags) 284 # Other types end the recursion - they should be leaves 285 return e 286 229 287 230 288 def generate_fedid(subj, bits=2048, trace=None, dir=None):
Note: See TracChangeset
for help on using the changeset viewer.