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


Python baseObjects.PreParser类代码示例

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


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

示例1: __init__

 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,代码行数:7,代码来源:preParser.py

示例2: __init__

    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,代码行数:54,代码来源:multivalent.py

示例3: __init__

 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,代码行数:12,代码来源:preParser.py

示例4: __init__

 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,代码行数:6,代码来源:preParser.py


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