示例#1
0
 def loads(s, *args, **kwargs):
     try:
         return _json.loads(s,
                            cls=WAJSONDecoder,
                            object_pairs_hook=OrderedDict,
                            *args,
                            **kwargs)
     except ValueError as e:
         raise SerializerSyntaxError(e.args[0])
示例#2
0
 def load(fh, *args, **kwargs):
     try:
         return _yaml.load(fh, *args, Loader=_WaYamlLoader, **kwargs)
     except _yaml.YAMLError as e:
         lineno = None
         if hasattr(e, 'problem_mark'):
             lineno = e.problem_mark.line  # pylint: disable=no-member
         message = e.args[0] if (e.args and e.args[0]) else str(e)
         raise SerializerSyntaxError(message, lineno)
示例#3
0
 def load(fh, *args, **kwargs):
     try:
         return _yaml.load(fh, *args, **kwargs)
     except _yaml.YAMLError as e:
         lineno = None
         if hasattr(e, 'problem_mark'):
             lineno = e.problem_mark.line  # pylint: disable=no-member
         raise SerializerSyntaxError(e.args[0] if e.args else str(e),
                                     lineno)
示例#4
0
 def loads(s, *args, **kwargs):
     pod = {}
     try:
         exec(s, pod)  # pylint: disable=exec-used
     except SyntaxError as e:
         raise SerializerSyntaxError(e.message, e.lineno)
     for k in list(pod.keys()):  # pylint: disable=consider-iterating-dictionary
         if k.startswith('__'):
             del pod[k]
     return pod