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


Python utils.load_json函数代码示例

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


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


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