Example #1
0
def open_api(json_path):
    path = get_header(json_path)
    try:
        apispec = json.read_file(path)
    except OSError as error:
        raise Error(("[Errno %d]: %s\n" % (error.errno, path)).decode('utf-8'))
    api = Api(apispec.getitem(String(u"constants")),
              apispec.getitem(String(u"types")),
              apispec.getitem(String(u"variables")))
    return api
Example #2
0
def open_api(json_path, dependencies, decorator):
    path = get_header(json_path)
    try:
        apispec = json.read_file([path])
    except OSError as error:
        raise OldError(u"[Errno %d]: %s\n" %
                       (error.errno, pathobj.stringify(path)))
    api = Api(apispec.getitem(String(u"constants")),
              apispec.getitem(String(u"types")),
              apispec.getitem(String(u"variables")), dependencies, decorator)
    return api
Example #3
0
def open_api(json_path):
    path = get_header(json_path)
    try:
        apispec = json.read_file(path)
    except OSError as error:
        raise Error(("[Errno %d]: %s\n" % (error.errno, path)).decode('utf-8'))
    api = Api(
        apispec.getitem(String(u"constants")),
        apispec.getitem(String(u"types")),
        apispec.getitem(String(u"variables")))
    return api
Example #4
0
def open_api(json_path, dependencies, decorator):
    path = get_header(json_path)
    try:
        apispec = json.read_file([path])
    except OSError as error:
        raise OldError(u"[Errno %d]: %s\n" % (error.errno, pathobj.stringify(path)))
    api = Api(
        apispec.getitem(String(u"constants")),
        apispec.getitem(String(u"types")),
        apispec.getitem(String(u"variables")),
        dependencies,
        decorator)
    return api
Example #5
0
def read_file(path, dependencies, decorator):
    basename = path.getattr(u"basename")
    if isinstance(basename, String):
        if not basename.string.endswith(u".json"):
            dirname = path.getattr(u"dirname")
            path = pathobj.concat(dirname,
                pathobj.parse(basename.string + u".json"))
    path = pathobj.concat(conf.headers_dir, path)
    try:
        apispec = json.read_file(path)
    except OSError as error:
        raise OldError(u"[Errno %d]: %s\n" % (error.errno, pathobj.stringify(path)))
    return read_object(apispec, dependencies, decorator)
Example #6
0
File: api.py Project: cheery/lever
def read_file(path, dependencies, decorator):
    basename = path.getattr(u"basename")
    if isinstance(basename, String):
        if not basename.string.endswith(u".json"):
            path.setattr(
                u"basename",
                String(basename.string + u".json"))
    path = pathobj.concat(conf.headers_dir, path)
    try:
        apispec = json.read_file(path)
    except OSError as error:
        raise OldError(u"[Errno %d]: %s\n" % (error.errno, pathobj.stringify(path)))
    return read_object(apispec, dependencies, decorator)