本文整理汇总了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))
示例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)
示例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)
示例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)