Example #1
0
 def get_ref(self, ref, string_decode, file_decode):
     runtime_response = self.ciel_runtime.synchronous_request(
         "open_ref", {"ref": ref})
     if "error" in runtime_response:
         raise ReferenceUnavailableException(ref)
     elif "strdata" in runtime_response:
         return string_decode(
             decode_datavalue_string(runtime_response["strdata"]))
     elif "filename" in runtime_response:
         with open(runtime_response["filename"], "r") as fp:
             return file_decode(fp)
Example #2
0
 def from_safe_dict(in_dict):
     try:
         in_dict["strdata"] = decode_datavalue_string(in_dict["strdata"])
     except KeyError:
         pass
     return FileOrString(**in_dict)
Example #3
0
def ref_from_safe_string(string, id):
    if len(string) < 1024:
        return SWDataValue(id, value=string)
    else:
        return ref_from_string(decode_datavalue_string(string), id)
Example #4
0
def ref_from_safe_string(string, id):
    if len(string) < 1024:
        return SWDataValue(id, value=string)
    else:
        return ref_from_string(decode_datavalue_string(string), id)
Example #5
0
 def from_safe_dict(in_dict):
     try:
         in_dict["strdata"] = decode_datavalue_string(in_dict["strdata"])
     except KeyError:
         pass
     return FileOrString(**in_dict)