def load(fn, parent_pymod, yang_module, path_helper=None, extmethods=None, overwrite=False):
    try:
        with open(fn, "r") as fp:
            f = json.load(fp, object_pairs_hook=OrderedDict)
    except IOError as m:
        raise pybindJSONIOError("could not open file to read: %s" % m)
    return loads(f, parent_pymod, yang_module, path_helper=path_helper, extmethods=extmethods, overwrite=overwrite)
def dump(obj, fn, indent=4, filter=True, skip_subtrees=[], mode="default"):
    try:
        fh = open(fn, "w")
    except IOError as m:
        raise pybindJSONIOError("could not open file for writing: %s" % m)
    fh.write(dumps(obj, indent=indent, filter=filter, skip_subtrees=skip_subtrees, mode=mode))
    fh.close()
Exemple #3
0
def load(fn,
         parent_pymod,
         yang_module,
         path_helper=None,
         extmethods=None,
         overwrite=False):
    try:
        f = json.load(open(fn, 'r'))
    except IOError as m:
        raise pybindJSONIOError("could not open file to read: %s" % m)
    return loads(f,
                 parent_pymod,
                 yang_module,
                 path_helper=path_helper,
                 extmethods=extmethods,
                 overwrite=overwrite)