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


Python utils.Util类代码示例

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


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

示例1: _is_ip_internal

 def _is_ip_internal(self,ip, ranges):
     result = 0
     for row in ranges:
         if Util.ip_to_int(ip) >= row[0] and Util.ip_to_int(ip) <= row[1]: 
             result = 1
             break
     return result
开发者ID:cgiraldo,项目名称:incubator-spot,代码行数:7,代码来源:flow_oa.py

示例2: prepare

    def prepare(self, word_type):
        """
        Generates trie structure containing all words from clp
        :param word_type: part of speech of which kind read words from clp data
        :return: None
        """
        old = ""
        index = 0
        keys = []
        values = []
        for i in range(16777231, 18663982):
            if Util.is_word_unneeded(i):
                continue
            if Util.is_word_appropriate_type(self.plp.label(i)[0], word_type):
                continue
            form = self.plp.bform(i)

            if old != form:
                for s in self.plp.forms(i):
                    if len(s) > 0:
                        a = Util.substring(s, form)
                        to_remove = s[len(a): len(s)]
                        to_add = form[len(a): len(form)]
                        keys.append(Util.reverse(s))
                        a = unicode(to_remove).encode('utf-8')
                        b = unicode(to_add).encode('utf-8')
                        values.append((a, b))
                index += 1

            old = self.plp.bform(i)
        return zip(keys, values)
开发者ID:mslawin,项目名称:Magisterka,代码行数:31,代码来源:stemmer.py

示例3: _get_dns_results

    def _get_dns_results(self):

        self._logger.info("Getting {0} Machine Learning Results from HDFS".format(self._date))
        dns_results = "{0}/dns_results.csv".format(self._data_path)

        # get hdfs path from conf file.
        HUSER = self._oni_conf.get('conf','HUSER').replace("'","").replace('"','')   
        hdfs_path = "{0}/dns/scored_results/{1}/scores/dns_results.csv".format(HUSER,self._date)

        # get results file from hdfs.
        get_command = Util.get_ml_results_form_hdfs(hdfs_path,self._data_path)
        self._logger.info("{0}".format(get_command))

         # valdiate files exists
        if os.path.isfile(dns_results):

            # read number of results based in the limit specified.
            self._logger.info("Reading {0} dns results file: {1}".format(self._date,dns_results))
            self._dns_results = Util.read_results(dns_results,self._limit,self._results_delimiter)[:]
            if len(self._dns_results) == 0: self._logger.error("There are not flow results.");sys.exit(1)

        else:
            self._logger.error("There was an error getting ML results from HDFS")
            sys.exit(1)

        # add headers.        
        self._logger.info("Adding headers")
        self._dns_scores_headers = [  str(key) for (key,value) in self._conf['dns_score_fields'].items() ]

        # add dns content.
        self._dns_scores = [ conn[:]  for conn in self._dns_results][:]       
开发者ID:Open-Network-Insight,项目名称:oni-oa,代码行数:31,代码来源:dns_oa.py

示例4: _initialize_members

    def _initialize_members(self,date,limit,logger):
        
        # get logger if exists. if not, create new instance.
        self._logger = logging.getLogger('OA.Flow') if logger else Util.get_logger('OA.Flow',create_file=False)

        # initialize required parameters.
        self._scrtip_path = os.path.dirname(os.path.abspath(__file__))
        self._date = date
        self._table_name = "flow"
        self._flow_results = []
        self._limit = limit
        self._data_path = None
        self._ipynb_path = None
        self._ingest_summary_path = None
        self._flow_scores = []
        self._results_delimiter = '\t'

        # get app configuration.
        self._oni_conf = Util.get_oni_conf()  

        # get scores fields conf
        conf_file = "{0}/flow_conf.json".format(self._scrtip_path)
        self._conf = json.loads(open (conf_file).read(),object_pairs_hook=OrderedDict)     
 
        # initialize data engine
        self._db = self._oni_conf.get('conf','DBNAME').replace("'","").replace('"','') 
        self._engine = Data(self._db, self._table_name,self._logger)
开发者ID:Open-Network-Insight,项目名称:oni-oa,代码行数:27,代码来源:flow_oa.py

示例5: _get_flow_results

    def _get_flow_results(self):
               
        self._logger.info("Getting {0} Machine Learning Results from HDFS".format(self._date))
        flow_results = "{0}/flow_results.csv".format(self._data_path)

        # get hdfs path from conf file 
        HUSER = self._spot_conf.get('conf', 'HUSER').replace("'", "").replace('"', '')
        hdfs_path = "{0}/flow/scored_results/{1}/scores/flow_results.csv".format(HUSER,self._date)
        
         # get results file from hdfs
        get_command = Util.get_ml_results_form_hdfs(hdfs_path,self._data_path)
        self._logger.info("{0}".format(get_command))

        # valdiate files exists
        if os.path.isfile(flow_results):

            # read number of results based in the limit specified.
            self._logger.info("Reading {0} flow results file: {1}".format(self._date,flow_results))
            self._flow_results = Util.read_results(flow_results,self._limit,self._results_delimiter)
            if len(self._flow_results) == 0: self._logger.error("There are not flow results.");sys.exit(1)

        else:
            self._logger.error("There was an error getting ML results from HDFS")
            sys.exit(1)

        # filter results add rank.
        self._logger.info("Filtering required columns based on configuration")

        self._flow_scores.extend([ [ conn[i] for i in self._conf['column_indexes_filter'] ] + [n] for n, conn in enumerate(self._flow_results) ])
开发者ID:cgiraldo,项目名称:incubator-spot,代码行数:29,代码来源:flow_oa.py

示例6: _get_flow_results

    def _get_flow_results(self):
               
        self._logger.info("Getting {0} Machine Learning Results from HDFS".format(self._date))
        flow_results = "{0}/flow_results.csv".format(self._data_path)

        # get hdfs path from conf file 
        HUSER = self._oni_conf.get('conf','HUSER').replace("'","").replace('"','')   
        hdfs_path = "{0}/flow/scored_results/{1}/scores/flow_results.csv".format(HUSER,self._date)
               
        # get results file from hdfs
        get_command = Util.get_ml_results_form_hdfs(hdfs_path,self._data_path)
        self._logger.info("{0}".format(get_command))

        # valdiate files exists
        if os.path.isfile(flow_results):

            # read number of results based in the limit specified.
            self._logger.info("Reading {0} flow results file: {1}".format(self._date,flow_results))
            self._flow_results = Util.read_results(flow_results,self._limit,self._results_delimiter)
            if len(self._flow_results) == 0: self._logger.error("There are not flow results.");sys.exit(1)

        else:
            self._logger.error("There was an error getting ML results from HDFS")
            sys.exit(1)

        # add headers.        
        self._logger.info("Adding headers based on configuration file: score_fields.json")
        self._flow_scores = [ [ str(key) for (key,value) in self._conf['flow_score_fields'].items()] ]

        ldaab_index = self._conf["flow_results_fields"]["lda_score_ab"]
        ldaba_index = self._conf["flow_results_fields"]["lda_score_ba"]

        # filter results add sev and rank.
        self._logger.info("Filtering required columns based on configuration")
        self._flow_scores.extend([ [0] +  [ conn[i] for i in self._conf['column_indexes_filter'] ] + [(conn[ldaab_index] if (conn[ldaab_index]<= conn[ldaba_index]) else conn[ldaba_index])] + [n]  for n, conn in enumerate(self._flow_results) ])
开发者ID:Open-Network-Insight,项目名称:oni-oa,代码行数:35,代码来源:flow_oa.py

示例7: view

	def view(self):
		Util.setup3d()

		self.drawMap()
		self.drawModel()

		glFlush()
		glutSwapBuffers()
开发者ID:quintenpalmer,项目名称:squatgame,代码行数:8,代码来源:MainMenuView.py

示例8: _create_flow_scores_csv

    def _create_flow_scores_csv(self):

        flow_scores_csv = "{0}/flow_scores.csv".format(self._data_path)
        Util.create_csv_file(flow_scores_csv,self._flow_scores)

        # create bk file
        flow_scores_bu_csv = "{0}/flow_scores_bu.csv".format(self._data_path)
        Util.create_csv_file(flow_scores_bu_csv,self._flow_scores)  
开发者ID:Open-Network-Insight,项目名称:oni-oa,代码行数:8,代码来源:flow_oa.py

示例9: draw

def draw():
	Util.setup2D()

	glColor(.1,.1,.5)
	glRectf(0,Model.getWinfo().h/2,Model.getWinfo().w,Model.getWinfo().h)
	glColor(.1,.5,.1)
	glRectf(0,0,Model.getWinfo().w,Model.getWinfo().h/2)

	Util.finish2D()
开发者ID:quintenpalmer,项目名称:squatgame,代码行数:9,代码来源:Background.py

示例10: sign_for_jspay

 def sign_for_jspay(self, prepay_id):
     """jssdk调起支付时需要的sign"""
     timestamp = Util.timestamp()
     nonce_str = Util.generate_nonce(15)
     package = 'prepay_id=%s' % prepay_id
     sign_type = 'MD5'
     pay_sign = self._generate_sign(appId=self._appid, timeStamp=timestamp,
                             nonceStr=nonce_str, package=package, signType=sign_type)
     return {'timestamp':timestamp, 'nonceStr':nonce_str, 'package':package, 'signType':sign_type, 'paySign':pay_sign}
开发者ID:momingxu,项目名称:weixin-sdk,代码行数:9,代码来源:pay.py

示例11: motion

	def motion(self,x,y):
		turnh = -(x-Model.getMouseInfo().clickedx)/(Model.getWinfo().w*.31)
		turnv = (y-Model.getMouseInfo().clickedy)/(Model.getWinfo().w*.31)
		if Model.getMouseInfo().side == "left":
			Util.restoreCamera()
			Util.turnCamera(turnh,turnv)
		elif Model.getMouseInfo().side == "right":
			Util.restoreCamera()
			Util.turnCamera(turnh,turnv)
			Util.resetPlayer()
开发者ID:quintenpalmer,项目名称:squatgame,代码行数:10,代码来源:GameMotion.py

示例12: _create_dns_scores_csv

    def _create_dns_scores_csv(self):
        
        dns_scores_csv = "{0}/dns_scores.csv".format(self._data_path)
        dns_scores_final =  self._move_time_stamp(self._dns_scores)
        dns_scores_final.insert(0,self._dns_scores_headers)
        Util.create_csv_file(dns_scores_csv,dns_scores_final)   

        # create bk file
        dns_scores_bu_csv = "{0}/dns_scores_bu.csv".format(self._data_path)
        Util.create_csv_file(dns_scores_bu_csv,dns_scores_final)  
开发者ID:Open-Network-Insight,项目名称:oni-oa,代码行数:10,代码来源:dns_oa.py

示例13: change

 def change(self, name):
     if name == "maingame":
         self.horizontal = 0
         self.vertical = 0.25
         Util.resetCamera()
     elif name == "mainmenu":
         self.location = [30, 30, 0]
         self.lookAt = [-70, 10, 0]
         self.up = [0, 1, 0]
         self.horizon = 0
         self.vertical = -1.0
         self.distance = 50
开发者ID:quintenpalmer,项目名称:squatgame,代码行数:12,代码来源:Camera.py

示例14: draw

def draw():
	Util.setup2D()

	glColor(.15,.21,.41)
	barwidth = 400
	x1 = (Model.getWinfo().w/2)-(barwidth/2)
	x2 = (Model.getWinfo().w/2)+(barwidth/2)
	y1 = 20
	y2 = 50
	glRectf(x1,y1,x2,y2)

	Util.finish2D()
开发者ID:quintenpalmer,项目名称:squatgame,代码行数:12,代码来源:GameInterface.py

示例15: _generate_sign

 def _generate_sign(self, **kwargs):
     """
     签名算法,返回得到的签名字符串
     """
     valid_keys = [k for k in kwargs if kwargs[k] and k != 'sign']
     valid_keys.sort()
     kv_str = ''
     for k in valid_keys:
         kv_str += '%s=%s&' % (k, kwargs[k])
     kv_str += '%s=%s' % ('key', self._sign_key)
     kv_str = Util.encode_data(kv_str)
     sign = Util.md5(kv_str).upper()
     return sign
开发者ID:momingxu,项目名称:weixin-sdk,代码行数:13,代码来源:pay.py


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