本文整理匯總了Python中amazonproduct.API._parse方法的典型用法代碼示例。如果您正苦於以下問題:Python API._parse方法的具體用法?Python API._parse怎麽用?Python API._parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類amazonproduct.API
的用法示例。
在下文中一共展示了API._parse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getattr
# 需要導入模塊: from amazonproduct import API [as 別名]
# 或者: from amazonproduct.API import _parse [as 別名]
'xml.etree.cElementTree': etree.Processor(module='xml.etree.cElementTree'),
'xml.etree.ElementTree': etree.Processor(module='xml.etree.ElementTree'),
'cElementTree': etree.Processor(module='cElementTree'),
'elementtree.ElementTree': etree.Processor(module='elementtree.ElementTree'),
'minidom': minidom.Processor(),
}
print "Collecting test files..."
xml_files = [os.path.join(root, file)
for root, dirs, files in os.walk('.')
for file in files
if os.path.splitext(file)[1].lower() == '.xml']
print "Parsing %i XML files..." % (len(xml_files)*RUNS, )
for label, parser in custom_parsers.items():
print label,
if getattr(parser, 'etree', '') is None:
print 'not installed!'
continue
start = time.clock()
api = API(locale='de', processor=parser)
for i in range(RUNS):
for path in xml_files:
try:
api._parse(open(path))
except Exception, e:
pass
stop = time.clock()
print stop - start