• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.load_json函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.load_json函数的典型用法代码示例。如果您正苦于以下问题:Python load_json函数的具体用法?Python load_json怎么用?Python load_json使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: main

def main():
    parser = get_arg_parser()
    args = parser.parse_args()

    endpoint = utils.format_endpoint(args.endpoint[0])
    options = None

    if args.datafile is not None:
        if os.path.exists(args.datafile):
            options = utils.load_json(args.datafile)
    else:
        fkjson_path = os.path.dirname(os.path.abspath(__file__)) + '/fkdata.json'
        if os.path.exists(fkjson_path):
            options = utils.load_json(fkjson_path)

    if options is None:
        print '''
        fkdata.json file needed...
        '''
    else:
        fk_checker = fkchecker.FkChecker(endpoint, options)
        fk_checker.execute()

        print 'Total Frames Received: ' + str(fk_checker.get_recv_frames)
        print 'Total Asserts: ' + str(fk_checker.get_asserts)
        print 'Total of validation executed: ' + str(fk_checker.get_validations_runned)
        print 'Assert frame rate: ' + str(fk_checker.get_assert_rate) + ' %'
开发者ID:Gabriellpweb,项目名称:fk-websocket-checker,代码行数:27,代码来源:check.py


示例2: test_tree_root

    def test_tree_root(self):
        path = get_path(['tree', utils.EXPECTED_BRANCH])
        rv = self.app.get(path)
        assert json.loads(rv.data) == utils.load_json('tree.json')

        rv = self.app.get('{0}?limit={1}'.format(path, utils.EXPECTED_LIMIT))
        assert json.loads(rv.data) == utils.load_json('tree_limit.json')
开发者ID:HAYASAKA-Ryosuke,项目名称:koshinuke.py,代码行数:7,代码来源:koshinuke_test.py


示例3: test_blob

    def test_blob(self):
        rv = self.app.get(get_path(['blob',
                                    utils.EXPECTED_BRANCH,
                                    utils.EXPECTED_RESOURCE]))
        assert json.loads(rv.data) == utils.load_json('blob.json')

        rv = self.app.get(get_path(['blob',
                                    utils.EXPECTED_REV,
                                    utils.EXPECTED_RESOURCE]))
        assert json.loads(rv.data) == utils.load_json('blob_rev.json')
开发者ID:HAYASAKA-Ryosuke,项目名称:koshinuke.py,代码行数:10,代码来源:koshinuke_test.py


示例4: test_commits_root

    def test_commits_root(self):
        path = get_path(['commits', utils.EXPECTED_BRANCH])
        rv = self.app.get(path)
        assert json.loads(rv.data) == utils.load_json('commits.json')

        rv = self.app.get('{0}?limit={1}'.format(path, utils.EXPECTED_LIMIT))
        assert json.loads(rv.data) == utils.load_json('commits_limit.json')

        rv = self.app.get(get_path(['commits', utils.EXPECTED_REV]))
        assert json.loads(rv.data) == utils.load_json('commits_rev.json')
开发者ID:HAYASAKA-Ryosuke,项目名称:koshinuke.py,代码行数:10,代码来源:koshinuke_test.py


示例5: test_get_resource

    def test_get_resource(self):
        resource = core.get_resource(utils.EXPECTED_PROJECT,
                                     utils.EXPECTED_REPOSITORY,
                                     utils.EXPECTED_BRANCH,
                                     utils.EXPECTED_RESOURCE)
        assert resource == utils.load_json('blob.json')

        resource = core.get_resource(utils.EXPECTED_PROJECT,
                                     utils.EXPECTED_REPOSITORY,
                                     utils.EXPECTED_REV,
                                     utils.EXPECTED_RESOURCE)
        assert resource == utils.load_json('blob_rev.json')
开发者ID:HAYASAKA-Ryosuke,项目名称:koshinuke.py,代码行数:12,代码来源:core_test.py


示例6: load_train_result

def load_train_result(args):
    settings = parse_settings(args.setting)
    try:
        chn_trained_file = os.path.join(ENV.data_dir, "%s.json" % settings['chn'])
        eng_trained_file = os.path.join(ENV.data_dir, "%s.json" % settings['eng'])
    except Exception as e:
        print e
    if os.path.isfile(chn_trained_file) and os.path.isfile(eng_trained_file):
        chn_freq = utils.load_json(chn_trained_file)
        eng_freq = utils.load_json(eng_trained_file)
    else:
        chn_freq, eng_freq = train(args)
    return chn_freq, eng_freq
开发者ID:toxu,项目名称:NLP,代码行数:13,代码来源:__init__.py


示例7: read_project_config

def read_project_config(project_path):
	config_path = project_path + "/project-config.luna2d"

	if os.path.exists(config_path):
		return utils.load_json(config_path)
	else:
		return {}
开发者ID:dreamsxin,项目名称:luna2d,代码行数:7,代码来源:updateproject.py


示例8: __init__

    def __init__(self, input_movies, file_path, count=5):
        # Call parent constructor function
        super(Recommendation, self).__init__()

        self.movies_data = load_json(file_path)
        self.input_movies = input_movies
        self.show_count = count
开发者ID:mohammad-ahsan,项目名称:python-recommendation,代码行数:7,代码来源:recommendation.py


示例9: on_query_completions

	def on_query_completions(self, view, prefix, locations):
		if utils.get_language() != "java":return
		ultimo=utils.get_last_character()
		if ultimo=="." and utils.get_language()=="java":
			window=sublime.active_window()
			view=window.active_view()
			word=utils.get_word(-1)
			variables=Java().get_variables()
			tipo=word
			static=True
			if variables.get(word):
				tipo=variables[word]
				static=False

			package=re.findall("import ([\w.]+\.%s);"%tipo, utils.get_text())
			
			if not package:
				posibleRuta=os.path.join(PATH_JSON, "java", "lang", tipo+".json")
				if os.path.exists(posibleRuta):
					package=["java.lang."+tipo]

			if package:
				package=package[0]
				clase=self.get_project_class(package)
				if clase:
					return utils.get_completion_list(clase["members"])
				ruta=package.replace(".", os.sep)+".json"
				ruta=os.path.join(PATH_JSON, ruta)
				print("ya se determino")
				objeto=utils.load_json(ruta)
				miembros="clase" if static else "object"
				return utils.get_completion_list(objeto[miembros])
开发者ID:programadorsito,项目名称:Packages,代码行数:32,代码来源:java.py


示例10: run

	def run(self, edit):
		print("va a importar")
		window=sublime.active_window()
		view=window.active_view()
		self.window=sublime.active_window()
		self.view=self.window.active_view()
		java=Java()
		tipos=java.get_tipos()
		self.packages=utils.load_json(PATH_INDEX_PACKAGES)
		projectFiles=utils.get_files({"ext":"java"})
		projectFiles=[x.replace("/", ".").replace("\\", ".") for x in projectFiles]
		projectFiles=[x[x.rfind(".java.")+6:x.rfind(".")] for x in projectFiles]
		
		##print(projectFiles)
		viewPackage=view.substr(view.find(utils.REG_JAVA_PACKAGE, 0))
		viewPackage=viewPackage.replace("package ", "").replace(";", "")

		for projectFile in projectFiles:
			className=projectFile[projectFile.rfind(".")+1:]
			packageClass=projectFile[:projectFile.rfind(".")]
			if packageClass==viewPackage:continue
			if self.packages.get(className)==None:
				self.packages[className]=[]
			self.packages[className].append(packageClass)
		
		self.clases=list(set(tipos))
		##print(self.clases)
		self.i=0
		self.importar(None)
开发者ID:programadorsito,项目名称:Packages,代码行数:29,代码来源:java.py


示例11: _request

    def _request(self, url, data=None, method=None):
        """Send an HTTP request to the remote server.

        Args:
          method - A string for the HTTP method to send the request with.
          url - The URL to send the request to.
          body - The message body to send.

        Returns:
          A dictionary with the server's parsed JSON response.
        """
        logging.debug('%s %s %s' % (method, url, data))

        request = Request(url, data=data, method=method)
        request.add_header('Accept', 'application/json')

        opener = urllib2.build_opener(urllib2.HTTPRedirectHandler(),
                                      HttpErrorHandler())
        response = opener.open(request)
        try:
            if response.code > 399 and response.code < 500:
                return {'status': response.code, 'value': response.read()}
            body = response.read().replace('\x00', '').strip()
            if body:
                data = utils.load_json(body.strip())
                assert type(data) is dict, (
                    'Invalid server response body: %s' % body)
                assert 'status' in data, (
                    'Invalid server response; no status: %s' % body)
                assert 'value' in data, (
                    'Invalid server response; no value: %s' % body)
                return data
        finally:
            response.close()
开发者ID:Angeleena,项目名称:selenium,代码行数:34,代码来源:remote_connection.py


示例12: test_get_resources

    def test_get_resources(self):
        resources = core.get_resources(utils.EXPECTED_PROJECT,
                                       utils.EXPECTED_REPOSITORY,
                                       utils.EXPECTED_BRANCH)
        assert resources == utils.load_json('tree.json')

        resources = core.get_resources(utils.EXPECTED_PROJECT,
                                       utils.EXPECTED_REPOSITORY,
                                       utils.EXPECTED_REV)
        assert resources == utils.load_json('tree_rev.json')

        resources = core.get_resources(utils.EXPECTED_PROJECT,
                                       utils.EXPECTED_REPOSITORY,
                                       utils.EXPECTED_BRANCH,
                                       limit=utils.EXPECTED_LIMIT)
        assert resources == utils.load_json('tree_limit.json')
开发者ID:HAYASAKA-Ryosuke,项目名称:koshinuke.py,代码行数:16,代码来源:core_test.py


示例13: run

def run(args):
    settings = parse_settings(args.setting)
    try:
        chn_trained_file = os.path.join(ENV.data_dir, "%s.json" % settings['chn'])
        eng_trained_file = os.path.join(ENV.data_dir, "%s.json" % settings['eng'])
        test_data = os.path.join(ENV.data_dir, settings['input'])
    except Exception as e:
        print e
    if os.path.isfile(chn_trained_file) and os.path.isfile(eng_trained_file):
        chn_freq = utils.load_json(chn_trained_file)
        eng_freq = utils.load_json(eng_trained_file)
    else:
        chn_freq, eng_freq = train(args)
    
    classifier = naive_baysian_classifier.NaiveBaysianClassifier(chn_freq, eng_freq)
    worker.start_classify(test_data, classifier)
开发者ID:toxu,项目名称:NLP,代码行数:16,代码来源:__init__.py


示例14: cambiar_version

def cambiar_version(cambio=1, mostrar=False):
    diff=utils.load_json(DIFF_JSON)
    window=sublime.active_window()
    view=window.active_view()
    filename=view.file_name()
    folder=get_folder(filename)
    actual=diff[view.file_name()]
    viejo=actual
    lista=os.listdir(folder)
    lista=sorted(lista)
    i=lista.index(actual)
    i+=cambio
    if i<0 or i==len(lista):return
    actual=lista[i]
    diff[filename]=actual
    utils.save_json(DIFF_JSON, diff)
    lines=view.lines(sublime.Region(0, view.size()))
    folder=get_folder(filename)
#    self.view.add_regions("diferentes", self.lista, "comment", "bookmark", sublime.DRAW_OUTLINED)
    if not mostrar:utils.set_text(open(get_folder(filename)+os.sep+actual).read())

    print("\n")
    with open(folder+os.sep+actual, 'r') as one:
        with open(folder+os.sep+viejo, 'r') as two:
            diff = difflib.unified_diff(one.readlines(),two.readlines())
            for line in diff:
                line=line.strip()
                if line.startswith("@@ -"):
#                    line=line[4, line.find(",")]
#                    print(line)
                    utils.go_line(int(line[4:line.find(",")])+3)
                if line.startswith("-") or line.startswith("+") or line.startswith("@@"):
                    print(line.strip()+":")
    print("\n")
开发者ID:programadorsito,项目名称:Packages,代码行数:34,代码来源:diff.py


示例15: update_libs

def update_libs(args, luna2d_path, config):
	libs_source_dir = luna2d_path + "/lib/" + args.platform + "/release/"
	libs_dest_dir = args.project_path + "/.luna2d/libs"

	# Copy luna2d libs
	shutil.rmtree(libs_dest_dir, ignore_errors=True)
	shutil.copytree(libs_source_dir, libs_dest_dir)

	# Copy sdkmodules libs
	if "sdkmodules" in config:
		for module_name in config["sdkmodules"]:
			module_path = find_sdk_module(module_name, args, luna2d_path)

			if module_path is None:
				print("SDK module \"" + module_name + "\" not found")
				continue

			module_config_path = module_path + "sdkmodule.luna2d"
			if not os.path.exists(module_config_path):
				print("Config for SDK module \"" + module_name + "\" not found")
				continue

			module_config = utils.load_json(module_config_path)

			for module_file in module_config["files"]:
				src_path = module_path + "/" + module_file
				dest_path = libs_dest_dir + "/" + module_name + "-" + module_file
				shutil.copyfile(src_path, dest_path)

			if args.platform == "android":
				update_android.apply_sdk_module(args, module_name, config, module_config)
开发者ID:dreamsxin,项目名称:luna2d,代码行数:31,代码来源:updateproject.py


示例16: make_Xy

def make_Xy():
    orders = pd.read_pickle(ORDERS_LOCAL_PATH)
    print('%s: %s' % (ORDERS_NAME, list(orders.shape)))

    Xcols = [col for col in orders.columns if orders[col].dtype == np.int32]
    print(len(Xcols))
    orders = orders[Xcols]
    print('%s: %s' % (ORDERS_NAME, list(orders.shape)))

    converted_quotes = load_json('converted_quotes.json')
    converted = {q for q, s in converted_quotes if s}

    quotes = orders[orders['isQuote'] == 1]

    _, key_to_idx = load_enumerations()
    CHANGE = key_to_idx['type']['CHANGE']
    quotes = quotes[quotes['type'] == CHANGE]

    print('%s: %s' % ('quotes', dim(quotes)))
    quotes = quotes[[col for col in quotes.columns if col not in
                     {'endCustomerId', 'originalEndCustomerId'}]]
    print('%s: %s' % ('quotes', dim(quotes)))

    y = pd.DataFrame(index=quotes.index)
    y_values = [i in converted for i in quotes['id'].values]
    y['converted'] = pd.Series(y_values, index=quotes.index, dtype=np.int32)
    print('y', y.shape, y['converted'].dtype)

    X = quotes[[col for col in quotes.columns if col != 'isQuote']]
    X = X[[col for col in X.columns if col != 'id']]
    X = X[[col for col in X.columns if col != 'customerId']]
    print('X', X.shape)
    # print(X.describe())
    return X, y
开发者ID:peterwilliams97,项目名称:Butt-Head-Astronomer,代码行数:34,代码来源:feature_select.py


示例17: salt_ssh

 def salt_ssh(self, target, cmd):
     roster = self['container']['config']['salt_config']['roster']
     target_id = target['config']['name']
     SSH = "salt-ssh -l quiet -i --out json --key-deploy --passwd {0} {1} {{0}}".format(
         target['ssh_config']['password'], target_id)
     data = self['container'].run(SSH.format(cmd))
     return load_json(data)[target_id]
开发者ID:dincamihai,项目名称:pytest-salt-containers,代码行数:7,代码来源:models.py


示例18: find_all_chars

def find_all_chars(verbose=False):

    char_count = load_json(CHAR_COUNT, {})
    if not char_count:
        train, test, _ = load_data()
        char_count = defaultdict(int)
        S = 0
        for df in (test, train):
            for sentence in df_to_sentences(df):
                S += 1
                for c in sentence:
                    assert len(c) == 1, (c, sentence)
                    char_count[c] += 1
        char_count = {c: n for c, n in char_count.items()}
        save_json(CHAR_COUNT, char_count)
        print('S=%d' % S)

    chars = sorted(char_count, key=lambda c: (-char_count[c], c))
    N = sum(char_count.values())
    print('find_all_chars: %d %r' % (len(chars), ''.join(chars[:100])))
    print('N=%d=%.3fM' % (N, N * 1e-6))

    if verbose:
        tot = 0.0
        for i, c in enumerate(chars[:200]):
            n = char_count[c]
            r = n / N
            tot += r
            print('%4d: %8d %.4f %.3f %4d=%2r' % (i, n, r, tot, ord(c), c))

    return char_count
开发者ID:peterwilliams97,项目名称:Butt-Head-Astronomer,代码行数:31,代码来源:framework.py


示例19: run

 def run(self):
     while True:
         comando=None
         if os.path.exists(ARCHIVO_COMANDO) and existe_archivo_bloqueo(ORDEN):
             archivito=open(ARCHIVO_COMANDO)
             comando=archivito.read()
             archivito.close()
             os.remove(ARCHIVO_COMANDO)
             if comando:
                 comando=comando.strip()
                 print(comando)
                 window=sublime.active_window()
                 view=window.active_view()
                 if comando.find("side_bar")!=-1:
                     window.run_command(comando)
                 elif comando.startswith("code_"):
                     rutaJson=sublime.packages_path()+os.sep+"snippets"+os.sep+utils.get_language()+".json"
                     if os.path.exists(rutaJson):
                         comando=comando.replace("code_", "")
                         d=utils.load_json(rutaJson)
                         if d.get(comando) :view.run_command('insert_snippet', {"contents":utils.agregarCursores(d[comando])})
                 elif comando.startswith("make_"):
                     window=sublime.active_window()
                     view=window.active_view()
                     comando=comando.replace("make_", "")   
                     view.run_command("load_template", {"nombre":comando})
                 else:
                     view.run_command(comando)
         time.sleep(1)
开发者ID:programadorsito,项目名称:Packages,代码行数:29,代码来源:comando.py


示例20: on_query_completions

 def on_query_completions(self, view, prefix, locations):
     lang=utils.get_language()
     if lang != "go":return
     ultimo=utils.get_last_character()
     if ultimo != ".":return
     d=utils.load_json(GO_MAIN_MODULE)
     word=utils.get_word(-1)
     if d.get(word):
         return utils.get_completion_list(d[word])
开发者ID:programadorsito,项目名称:Packages,代码行数:9,代码来源:go_completion.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.load_pkl函数代码示例发布时间:2022-05-26
下一篇:
Python utils.load_image函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap