QCElemental icon indicating copy to clipboard operation
QCElemental copied to clipboard

ProtoModel.parse_raw should try everything if encoding==None

Open mattwelborn opened this issue 5 years ago • 0 comments

Currently, when encoding==None, the encoding is determined to be JSON if the datatype is str and MsgPack if the datatype is bytes. This issue proposes to just try all of the parsers for datatypes supported by QCElemental, e.g.:

data = None
for parser in [yaml_parser, msgpack_parser, json_parser]:
    try:
        data = parser(blob)
        break
    except ParserError:
        pass
else:
    raise TypeError("Cannot parse blob")

Additionally, if parse_file cannot determine datatype, it should call parse_raw with encoding=None rather than raising.

This issue blocks MolSSI/QCEngine#136.

mattwelborn avatar Aug 15 '19 14:08 mattwelborn