本文整理匯總了Python中weboob.tools.ordereddict.OrderedDict.popitem方法的典型用法代碼示例。如果您正苦於以下問題:Python OrderedDict.popitem方法的具體用法?Python OrderedDict.popitem怎麽用?Python OrderedDict.popitem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類weboob.tools.ordereddict.OrderedDict
的用法示例。
在下文中一共展示了OrderedDict.popitem方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: on_loaded
# 需要導入模塊: from weboob.tools.ordereddict import OrderedDict [as 別名]
# 或者: from weboob.tools.ordereddict.OrderedDict import popitem [as 別名]
def on_loaded(self):
for script in self.document.xpath('//script'):
text = script.text
if text is None:
continue
m = re.search("window.location.replace\('([^']+)'\);", text)
if m:
self.browser.location(m.group(1))
try:
self.browser.select_form(name='banque')
except FormNotFoundError:
pass
else:
self.browser.set_all_readonly(False)
accounts = OrderedDict()
for tr in self.document.getroot().cssselect('table.compteTable > tbody > tr'):
if len(tr.findall('td')) == 0:
continue
attr = tr.xpath('.//a')[0].attrib.get('onclick', '')
m = re.search("value = '(\w+)';(checkAndSubmit\('\w+','(\w+)','(\w+)'\))?", attr)
if m:
typeCompte = m.group(1)
tagName = m.group(3)
if tagName is not None:
value = self.document.xpath('//input[@name="%s"]' % m.group(3))[int(m.group(4))].attrib['value']
else:
value = typeCompte
accounts[value] = (typeCompte, tagName)
try:
typeCompte, tagName = accounts[self.browser.accnum]
value = self.browser.accnum
except KeyError:
accnums = ', '.join(accounts.keys())
if self.browser.accnum != '00000000000':
self.logger.warning(u'Unable to find account "%s". Available ones: %s' % (self.browser.accnum, accnums))
elif len(accounts) > 1:
self.logger.warning('There are several accounts, please use "accnum" backend parameter to force the one to use (%s)' % accnums)
value, (typeCompte, tagName) = accounts.popitem(last=False)
self.browser['typeCompte'] = typeCompte
if tagName is not None:
self.browser[tagName] = [value]
self.browser.submit()