当前位置: 首页>>代码示例>>Python>>正文


Python compat.read_json方法代码示例

本文整理汇总了Python中compat.read_json方法的典型用法代码示例。如果您正苦于以下问题:Python compat.read_json方法的具体用法?Python compat.read_json怎么用?Python compat.read_json使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在compat的用法示例。


在下文中一共展示了compat.read_json方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import compat [as 别名]
# 或者: from compat import read_json [as 别名]
def main():
    if len(sys.argv) < 3:
        sys.exit("Needs args: hook_name, control_dir")
    hook_name = sys.argv[1]
    control_dir = sys.argv[2]
    if hook_name not in HOOK_NAMES:
        sys.exit("Unknown hook: %s" % hook_name)
    hook = globals()[hook_name]

    hook_input = compat.read_json(pjoin(control_dir, 'input.json'))

    json_out = {'unsupported': False, 'return_val': None}
    try:
        json_out['return_val'] = hook(**hook_input['kwargs'])
    except BackendUnavailable:
        json_out['no_backend'] = True
    except GotUnsupportedOperation:
        json_out['unsupported'] = True

    compat.write_json(json_out, pjoin(control_dir, 'output.json'), indent=2) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:22,代码来源:_in_process.py

示例2: main

# 需要导入模块: import compat [as 别名]
# 或者: from compat import read_json [as 别名]
def main():
    if len(sys.argv) < 3:
        sys.exit("Needs args: hook_name, control_dir")
    hook_name = sys.argv[1]
    control_dir = sys.argv[2]
    if hook_name not in HOOK_NAMES:
        sys.exit("Unknown hook: %s" % hook_name)
    hook = globals()[hook_name]

    hook_input = compat.read_json(pjoin(control_dir, 'input.json'))

    json_out = {'unsupported': False, 'return_val': None}
    try:
        json_out['return_val'] = hook(**hook_input['kwargs'])
    except GotUnsupportedOperation:
        json_out['unsupported'] = True
    
    compat.write_json(json_out, pjoin(control_dir, 'output.json'), indent=2) 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:20,代码来源:_in_process.py

示例3: main

# 需要导入模块: import compat [as 别名]
# 或者: from compat import read_json [as 别名]
def main():
    if len(sys.argv) < 3:
        sys.exit("Needs args: hook_name, control_dir")
    hook_name = sys.argv[1]
    control_dir = sys.argv[2]
    if hook_name not in HOOK_NAMES:
        sys.exit("Unknown hook: %s" % hook_name)
    hook = globals()[hook_name]

    hook_input = compat.read_json(pjoin(control_dir, 'input.json'))

    json_out = {'unsupported': False, 'return_val': None}
    try:
        json_out['return_val'] = hook(**hook_input['kwargs'])
    except BackendUnavailable as e:
        json_out['no_backend'] = True
        json_out['traceback'] = e.traceback
    except BackendInvalid as e:
        json_out['backend_invalid'] = True
        json_out['backend_error'] = e.message
    except GotUnsupportedOperation as e:
        json_out['unsupported'] = True
        json_out['traceback'] = e.traceback
    except HookMissing:
        json_out['hook_missing'] = True

    compat.write_json(json_out, pjoin(control_dir, 'output.json'), indent=2) 
开发者ID:pantsbuild,项目名称:pex,代码行数:29,代码来源:_in_process.py


注:本文中的compat.read_json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。