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


Python Analyzer.Analyzer类代码示例

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


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

示例1: runAnAnalyzer

def runAnAnalyzer(channels, baseCuts, infile, outdir,
                  maxEvents, intLumi, cleanRows, cutModifiers):
    '''
    Run an Analyzer.
    Intended for use in threads, such that several processes all do this once.
    '''
    outfile = outdir+'/'+(infile.split('/')[-1])
    try:
        analyzer = Analyzer(channels, baseCuts, infile, outfile,
                            maxEvents, intLumi,
                            cleanRows, cutModifiers=cutModifiers)
    # Exceptions won't print from threads without help
    except Exception as e:
        print "**********************************************************************"
        print "EXCEPTION"
        print "Caught exception:"
        print e
        print "While initializing analyzer for {} with base cuts {} and modifiers [{}]".format(infile, baseCuts, ', '.join(m for m in cutModifiers))
        print "Killing task"
        print "**********************************************************************"
        return

    try:
        analyzer.analyze()
    except Exception as e:
        print "**********************************************************************"
        print "EXCEPTION"
        print "Caught exception:"
        print e
        print "While running analyzer for {} with base cuts {} and modifiers [{}]".format(infile, baseCuts, ', '.join(m for m in cutModifiers))
        print "Killing task"
        print "**********************************************************************"
        return
开发者ID:nwoods,项目名称:ZZAnalyzer,代码行数:33,代码来源:AnalysisManager.py

示例2: test_endgame_heuristics

def test_endgame_heuristics():
    a = Analyzer()
    b = Board()
    b.board = [[0, 5, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 999, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0],
               [5, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, -999]]

    res = a.minimax(b, 200)
    print_move_chain(a, b, res)

    b = Board()
    b.turn = -1
    b.board = [[0, -5, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, -999, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0],
               [-5, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 999]]

    res = a.minimax(b, 200)
    print_move_chain(a, b, res)
开发者ID:flatline,项目名称:Lopez,代码行数:28,代码来源:AnalyzerTests.py

示例3: main

def main():
    analyzer = Analyzer(isTest,train_filename,test_filename,
                        test_answers,smoothing,cv_validation_percentage)
    (predicted, actual, tokens) = analyzer.run()
    accuracy, ten_mistakes = get_score(predicted,actual, tokens)
    print "Accuracy: " + str(accuracy)
    print "Ten Misclassifications: %s"%str(ten_mistakes)
开发者ID:amm385,项目名称:POS,代码行数:7,代码来源:run.py

示例4: test_capture

def test_capture():
    print("testing simple capture and advance")
    print("\tsimple choice white")
    b = Board()
    b.board = [[0, 0, 0, 0, 0, 0, 0, -999],
               [0, 0, 0, 0, 0, 0, 0, 0],
               [0, 1, 0, 0, 0, 0, 0, 0],
               [-1, 0, -3, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 999]]
    
    a = Analyzer()
    a.sd_limit = 2
    res = a.minimax(b, 20)
    assert(res.move == ((2, 1), (3, 2)))

    print("\tsimple choice black")
    b = Board()
    b.turn = -1
    b.board = [[0, 0, 0, 0, 0, 0, 0, 999],
               [0, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0],
               [1, 0, 3, 0, 0, 0, 0, 0],
               [0, -1, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, 0, 0, 0, -999]]
    
    # a = Analyzer(20)
    a.sd_limit = 2
    res = a.minimax(b, 20)
    assert(res.move == ((4, 1), (3, 2)))
开发者ID:flatline,项目名称:Lopez,代码行数:34,代码来源:AnalyzerTests.py

示例5: __init__

 def __init__(self):
     self.ToCrawl = set([])
     self.Crawled = set([])
     self.Crawling = ""
     self.PageAnalyzer = Analyzer()  # used to extract useful info
     self.PageSniffer = Analyzer()  # used to find new pages to crawl
     self.initBrowser()
开发者ID:Lynxiayel,项目名称:LynCrawler,代码行数:7,代码来源:LynCrawler.py

示例6: __init__

class Builder:

	def __init__(self):
		self.grabber = Grabber()
		self.analyzer = Analyzer()
		self.manipulator = Manipulator()

	def convertColor(self, hex_color):
		value = hex_color.lstrip('#')
		lv = len(value)
		return tuple(int(value[i:i+lv/3], 16) for i in range(0, lv, lv/3))

	def getCellColors(self, cells, progress_bar=False):
	    cell_colors = [x[:] for x in [[0]*len(cells[0])]*len(cells)]
	    if not progress_bar:
			for i in range(0, len(cells)):
				for j in range(0, len(cells[0])):
					cell_colors[i][j] = self.convertColor(self.analyzer.colorz(cells[i][j], 1)[0])
	    else:
			for i in tqdm(range(0, len(cells)), ncols=50):
				for j in range(0, len(cells[0])):
					cell_colors[i][j] = self.convertColor(self.analyzer.colorz(cells[i][j], 1)[0])
	    return cell_colors

	def calculateContrast(self, color1, color2):
	    term1 = (color1[0] - color2[0])**2
	    term2 = (color1[1] - color2[1])**2
	    term3 = (color1[2] - color2[2])**2
	    return math.sqrt(term1 + term2 + term3)

	def processImage(self, cell_file):
	    cell_image = self.manipulator.crop_and_resize(Image.open(cell_file), subimage_width, subimage_height)
	    subcells = self.manipulator.split_image(cell_image, 2, 2)
	    cell_image_data = {'pixels':cell_image.tostring(), 'size':cell_image.size, 'mode':cell_image.mode}
	    return(cell_image_data, self.getCellColors(subcells))
开发者ID:renbeynolds,项目名称:photoMosaic,代码行数:35,代码来源:Builder.py

示例7: handle_request

 def handle_request(self, flow):
     if flow.request.path.find("?vulnerable_javascript_injection") != -1:
         visited_url_index = flow.request.path.find("&url=")
         self.add_to_report(self.get_filter_id(),
                            "Dynamically verified that malicious Javascript can be injected via HTTP via url %s" % base64.b64decode(
                                flow.request.path[visited_url_index + 5:]))
     Analyzer.handle_request(self,flow)
开发者ID:bigfool,项目名称:Marvin-dynamic-Analyzer,代码行数:7,代码来源:PhonegapAnalyzerJSInjection.py

示例8: get

	def get(self):
		user = users.get_current_user()
		
		if user:
			analyzer = Analyzer()
			analyzer.get(self)
		else:
			self.redirect(users.create_login_url(self.request.uri))
开发者ID:anawas,项目名称:wasserblog,代码行数:8,代码来源:main.py

示例9: test_file_parsing

 def test_file_parsing(self):
     an = Analyzer('data/trash.py', Node)
     res = an.process_file()
     self.assertEqual(len(res), 10)
     first = res[0]
     self.assertEqual(first.what, "os")
     self.assertIsNone(first.alias)
     self.assertEqual(first.who, "data.trash")
     self.assertEqual(first._extra, "os")
开发者ID:vwvolodya,项目名称:project,代码行数:9,代码来源:tests.py

示例10: handle_request

 def handle_request(self, flow):
     if flow.request.path.find("?vulnerable_file_scheme") != -1:
         activity_index = flow.request.path.find("&activity=")
         self.add_to_report(self.get_filter_id(),
                            "Dynamically verified that Javascript can be inyected running as file:// scheme via an Intent to " + base64.b64decode(
                                flow.request.path[
                                activity_index + len(
                                    "&activity="):]))
     Analyzer.handle_request(self,flow)
开发者ID:bigfool,项目名称:Marvin-dynamic-Analyzer,代码行数:9,代码来源:FileSchemeAnalyzer.py

示例11: __init__

    def __init__(self, query, query_evidences, sf_object):
        Analyzer.__init__(self, query, query_evidences, sf_object)
        self.query_answer = sf_object.final_answers[query.id]

        # load coutry province dict
        self.world_coutry_province = OrderedDict()
        f = io.open('data/dict/china_province_dict', 'r', -1, 'utf-8')
        province_dict = f.read().splitlines()
        self.world_coutry_province[u'中国'] = province_dict
开发者ID:zblol,项目名称:Chinese_SF,代码行数:9,代码来源:InferenceAnalyzer.py

示例12: handle_request

 def handle_request(self, flow):
     if flow.request.path.find("?vulnerable_javascript_injection") != -1:
         visited_url_index = flow.request.path.find("&url=")
         interface_url_index = flow.request.path.find("&interface=")
         self.add_to_report(self.get_filter_id(),
                            "Dynamically verified that malicious Javascript can be injected via HTTP via url %s and can run arbitrary code via the Javascript Interface %s" % (
                                base64.b64decode(
                                    flow.request.path[visited_url_index + len("&url="):]),
                                flow.request.path[interface_url_index + len("&interface="):visited_url_index]))
     Analyzer.handle_request(self,flow)
开发者ID:bigfool,项目名称:Marvin-dynamic-Analyzer,代码行数:10,代码来源:JavascriptInterfaceAnalyzer.py

示例13: test_scenarios

def test_scenarios():
    # some puzzles from Reinfeld's Chess Tactics for Beginners
    print("testing move pruning")
    a = Analyzer()
    a.sd_limit = 4
    print("\tPuzzle #21")
    b = Board()
    b.board = [[0,  0, 0, 0, 0,     0, 0, 0],
               [0,  0, 0, 0, 0,     0, 0, 0],
               [0, -1, 9, 0, 0,     0, 0, 0],
               [0,  0, 0, 0, -999, -1, 0, 0],
               [0,  0, 0, 0, 0,     0, 0, 999],
               [0,  0, 0, 0, 0,     0, 0, -1],
               [0,  0, 0, 0, 0,     0, 0, 0],
               [-9, 0, 0, 0, 3,     0, 0, 0]]

    res = a.minimax(b, 100)
    print_move_chain(a, b, res)
    assert(res.move == ((7,4),(5,3)))

    # todo - pawn promotion is required for this one!
    # print("\tPuzzle #23")
    # b = Board()
    # b.turn = -1
    # b.board = [[0, 0, 0, 0, 0, 0, 0, 0],
    #            [0, 0, 999, 0, 0, 0, 0, -1],
    #            [-5, 0, 0, 0, 0, 0, 0, 0],
    #            [0, 0, 0, 0, 0, 0, 0, 0],
    #            [0, 0, 0, 0, 0, 0, 0, 0],
    #            [0, 0, 0, 0, 0, 0, 0, 0],
    #            [0, 0, 0, 0, 0, -999, 0, 0],
    #            [0, 0, 0, 0, 0, 0, 0, 5]]   

    # res = a.minimax(b)
    # print_move_chain(b, res)

    print("\tPuzzle 52")
    b = Board()
    b.turn = -1
    b.board = [[0, 0,  5, 0, 0, 0, 999, 0],
               [0, 0,  0, 0, 0, 1, 1, 1],
               [1, 0,  0, -9, 0, 0, 0, 0],
               [0, 1,  0, 0, 0, 0, 0, 0],
               [0, 0,  0, 0, 0, 0, 0, 0],
               [-1, -1, 0, 0, 0, 0, 0, -1],
               [0, 0,  9, 0, 0, -1, -1, 0],
               [0, 0,  0, -5, 0, 0, -999, 0]]    
    
    res = a.minimax(b, 100)
    print_move_chain(a, b, res)
开发者ID:flatline,项目名称:Lopez,代码行数:50,代码来源:AnalyzerTests.py

示例14: analyze

    def analyze(self, resource):
        analysis = Analyzer.analyze(self, resource)
        analysis.add_messages(self._lib_message_list)
        if self._js_lint_proc_args is None:
            analysis.mark_as_bad()
            analysis.add_error('No suitable JSLint runner (cscript.exe, node.js or rhino) could be found.')
            return analysis

        try:
            js_lint_proc = subprocess.Popen(self._js_lint_proc_args, -1, None, subprocess.PIPE,
                subprocess.PIPE, subprocess.PIPE)
            js_lint_proc_outputs = js_lint_proc.communicate(resource.content)
        except Exception as e:
            analysis.add_error("An exception what thrown while running JsLint: %s\n%s" %
                (str(e), traceback.format_exc))
            return analysis

        # The JSLint process returns 1 if it finds lint
        if js_lint_proc.returncode != 0 and js_lint_proc.returncode != 1:
            analysis.add_error('The JSLint process exited with return code %d\nArguments: %s\n Output: %s'
                % (js_lint_proc.returncode, self._js_lint_proc_args, js_lint_proc_outputs))
            return analysis

        analysis.mark_as_good()  # Assume that JSLint produced no complaints until parsing one from the process output

        for js_lint_proc_output in js_lint_proc_outputs:
            js_lint_complaints = js_lint_proc_output.split("Lint at ")
            for complaint in js_lint_complaints:
                if len(complaint.strip()):
                    analysis.mark_as_bad()
                    js_lint_complaint = JsLintComplaint(complaint)
                    analysis.add_error(str(js_lint_complaint))

        return analysis
开发者ID:jwalgran,项目名称:blend,代码行数:34,代码来源:JSLintAnalyzer.py

示例15: find_matches

def find_matches( workflow_dir,keywords ):
	workflows = Workflow.workflows_for_filestrings( Seeker.file_strings( workflow_dir ) )
	keyword_set = KeywordSet( keywords )
	if keyword_set.is_valid() == False:
		print("   > Invalid keywords")
		sys.exit()
	return Analyzer.workflows_for_keywords( keyword_set,workflows )
开发者ID:alexjamesa,项目名称:Workflows,代码行数:7,代码来源:Workflows.py


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