本文整理汇总了Python中util.Logutil.log方法的典型用法代码示例。如果您正苦于以下问题:Python Logutil.log方法的具体用法?Python Logutil.log怎么用?Python Logutil.log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Logutil
的用法示例。
在下文中一共展示了Logutil.log方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scanDescription
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import log [as 别名]
def scanDescription(self, descFile, descParseInstruction, encoding):
Logutil.log('scanDescription: %s' % descFile, util.LOG_LEVEL_INFO)
if(descFile.startswith('http://')):
req = urllib2.Request(descFile)
req.add_unredirected_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31')
descFile = urllib2.urlopen(req).read()
else:
fh = open(str(descFile), 'r')
descFile = fh.read()
#load xmlDoc as elementtree to check with xpaths
tree = fromstring(descFile)
#single result as dictionary
result = {}
rootElement = self.grammarNode.attrib.get('root')
for node in tree.findall(rootElement):
result = self.parseElement(node)
result = self.replaceResultTokens(result)
yield result
示例2: parseDescription
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import log [as 别名]
def parseDescription(self, descFile, encoding):
Logutil.log('parseDescription: %s' % descFile, util.LOG_LEVEL_INFO)
results = None
if(descFile.startswith('http://')):
req = urllib2.Request(descFile)
req.add_unredirected_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31')
descFile = urllib2.urlopen(req).read()
del req
else:
fh = open(str(descFile), 'r')
descFile = fh.read()
del fh
#load xmlDoc as elementtree to check with xpaths
# force utf-8
parser = XMLParser(encoding='utf-8')
tree = fromstring(descFile, parser)
del descFile
if(tree == None):
return None
rootElementXPath = self.grammarNode.attrib.get('root')
if(not rootElementXPath):
rootElementXPath = "."
rootElements = tree.findall(rootElementXPath)
del tree, rootElementXPath
if(rootElements == None):
return None
resultList = []
for rootElement in rootElements:
tempResults = self.parseElement(rootElement)
if tempResults != None:
results = tempResults
del tempResults
results = self.replaceResultTokens(results)
resultList.append(results)
return resultList
示例3: scanDescription
# 需要导入模块: from util import Logutil [as 别名]
# 或者: from util.Logutil import log [as 别名]
def scanDescription(self, descFile, descParseInstruction, encoding):
Logutil.log('scanDescription: %s' % descFile, util.LOG_LEVEL_INFO)
if(descFile.startswith('http://')):
descFile = urllib.urlopen(descFile).read()
else:
fh = open(str(descFile), 'r')
descFile = fh.read()
#load xmlDoc as elementtree to check with xpaths
tree = fromstring(descFile)
#single result as dictionary
result = {}
rootElement = self.grammarNode.attrib.get('root')
for node in tree.findall(rootElement):
result = self.parseElement(node)
result = self.replaceResultTokens(result)
yield result