本文整理汇总了Python中entities.CListItem.CListItem.infos_names方法的典型用法代码示例。如果您正苦于以下问题:Python CListItem.infos_names方法的具体用法?Python CListItem.infos_names怎么用?Python CListItem.infos_names使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entities.CListItem.CListItem
的用法示例。
在下文中一共展示了CListItem.infos_names方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __parseHtml
# 需要导入模块: from entities.CListItem import CListItem [as 别名]
# 或者: from entities.CListItem.CListItem import infos_names [as 别名]
def __parseHtml(self, url, data, rules, definedIn, lItem):
items = []
for item_rule in rules:
revid = re.compile(item_rule.infos, re.IGNORECASE + re.DOTALL + re.MULTILINE)
for reinfos in revid.findall(data):
tmp = CListItem()
if item_rule.order.find('|') != -1:
tmp.infos_names = item_rule.order.split('|')
tmp.infos_values = list(reinfos)
else:
tmp[item_rule.order] = reinfos
for info in item_rule.info_list:
info_value = tmp[info.name]
if info_value:
if info.build.find('%s') != -1:
tmpVal = enc.smart_unicode(info.build % enc.smart_unicode(info_value))
tmp[info.name] = tmpVal
continue
if info.build.find('%s') != -1:
if info.src.__contains__('+'):
tmpArr = info.src.split('+')
src = ''
for t in tmpArr:
t = t.strip()
if t.find('\'') != -1:
src = src + t.strip('\'')
else:
src = src + enc.smart_unicode(tmp[t])
elif info.src.__contains__('||'):
variables = info.src.split('||')
src = firstNonEmpty(tmp, variables)
else:
src = tmp[info.src]
if src and info.convert != []:
src = self.__parseCommands(tmp, src, info.convert)
if isinstance(src, dict):
for dKey in src:
tmp[dKey] = src[dKey]
src = src.values()[0]
info_value = info.build % (enc.smart_unicode(src))
else:
info_value = info.build
tmp[info.name] = info_value
tmp['url'] = enc.smart_unicode(item_rule.url_build % (enc.smart_unicode(tmp['url'])))
tmp.merge(lItem)
if item_rule.skill.find('append') != -1:
tmp['url'] = url + tmp['url']
if item_rule.skill.find('space') != -1:
tmp['title'] = ' %s ' % tmp['title'].strip()
tmp['definedIn'] = definedIn
items.append(tmp)
return items