當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。