當前位置: 首頁>>代碼示例>>Python>>正文


Python PreParser.__init__方法代碼示例

本文整理匯總了Python中cheshire3.baseObjects.PreParser.__init__方法的典型用法代碼示例。如果您正苦於以下問題:Python PreParser.__init__方法的具體用法?Python PreParser.__init__怎麽用?Python PreParser.__init__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cheshire3.baseObjects.PreParser的用法示例。


在下文中一共展示了PreParser.__init__方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from cheshire3.baseObjects import PreParser [as 別名]
# 或者: from cheshire3.baseObjects.PreParser import __init__ [as 別名]
 def __init__(self, session, config, parent):
     PreParser.__init__(self, session, config, parent)
     self.sumType = self.get_setting(session, 'sumType', 'md5')
     try:
         hashlib.new(self.sumType)
     except ValueError as e:
         raise ConfigFileException(str(e))
開發者ID:Cheshire-Grampa,項目名稱:cheshire3,代碼行數:9,代碼來源:preParser.py

示例2: __init__

# 需要導入模塊: from cheshire3.baseObjects import PreParser [as 別名]
# 或者: from cheshire3.baseObjects.PreParser import __init__ [as 別名]
    def __init__(self, session, server, config):
        PreParser.__init__(self, session, server, config)
        self.source_re = re.compile("<open file '(.+?)', mode '.' at .*?>")
        
        # get settings from config
        # Az:  Check existence of settings and fail consistently rather than
        # die half way through execution
        self.mvServerPath = self.get_path(session, 'mvServerPath')
        if self.mvServerPath:
            # they've specified a local path to the server code
            # we should start a server locally with automatically generated port, in local-only mode
            if not os.path.exists(self.mvServerPath):
                raise ConfigFileException('Path type="mvServerPath" does not exist')

            host = '127.0.0.1'
            # find a random free port
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            err = True
            while (err):
                err = False
                port = random.randrange(10000)
                try: s.bind((host,port))
                except: err = True

            s.close()
            del s
            mvStdin, mvStdout = os.popen2('java -D64 -Djava.awt.headless=true -Xms40m -Xmx256m -jar %s %d -guess -out xml -link' % (self.mvServerPath, port), 't')
            
        else:
            # get settings for remote mv server
            host = self.get_setting(session, 'host')
            port  = self.get_setting(session, 'port')
            if not port.isdigit():
                raise ConfigFileException("'port' setting for Multivalent preParser must be an integer.")
            
        pack = self.get_setting(session, 'returnPacking')
        if not (host and port and pack):
            raise ConfigFileException("'host', 'port' and 'returnPacking' settings must be set for Multivalent preParser '%s'" % self.id)
            
        self.mvHost = host
        self.mvPort = int(port)
        self.returnPacking = pack.lower()        
        if (self.returnPacking == 'xml'):
            self.outMimeType = 'text/xml'
        else:
            self.outMimeType = 'text/plain'
        # initialise and connect to multivalent client
        self.mvClient = MultivalentClient()
        try:
            self.mvClient.connect(self.mvHost, self.mvPort)
        except:
            # (Try to connect at run time)
            pass
	atexit.register(self.close_mvServer)            
開發者ID:ReinSi,項目名稱:cheshire3,代碼行數:56,代碼來源:multivalent.py

示例3: __init__

# 需要導入模塊: from cheshire3.baseObjects import PreParser [as 別名]
# 或者: from cheshire3.baseObjects.PreParser import __init__ [as 別名]
 def __init__(self, session, config, parent):
     PreParser.__init__(self, session, config, parent)
     # Some settings that are needed at this stage
     self.offset = self.get_setting(session, 'termOffset', 0)
     filename = self.get_path(session, 'modelPath', None)
     if not filename:
         dfp = self.get_path(session, 'defaultPath')
         filename = os.path.join(dfp, self.id + "_ATTRHASH.pickle")
     self.modelPath = filename
     self.model = {}
     self.lastModTime = 0
     self.load_model(session)
開發者ID:ReinSi,項目名稱:cheshire3,代碼行數:14,代碼來源:preParser.py

示例4: __init__

# 需要導入模塊: from cheshire3.baseObjects import PreParser [as 別名]
# 或者: from cheshire3.baseObjects.PreParser import __init__ [as 別名]
 def __init__(self, session, config, parent):
     PreParser.__init__(self, session, config, parent)
     self.normalizer = self.get_path(session, 'normalizer', None)
     if self.normalizer is None:
         msg = "Normalizer for {0} does not exist.".format(self.id)
         raise ConfigFileException(msg)
開發者ID:ReinSi,項目名稱:cheshire3,代碼行數:8,代碼來源:preParser.py


注:本文中的cheshire3.baseObjects.PreParser.__init__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。