• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python base.find_object函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中weboob.capabilities.base.find_object函数的典型用法代码示例。如果您正苦于以下问题:Python find_object函数的具体用法?Python find_object怎么用?Python find_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了find_object函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_cards

    def get_cards(self, accounts_list=None):
        # accounts_list is only used by get_list
        self.location(self.accounts_url.format(self.sag))

        for idelco, parent_id in self.page.iter_idelcos():
            if not self.accounts.is_here():
                self.location(self.accounts_url.format(self.sag))

            obj = self.page.get_idelco(idelco)
            if isinstance(obj, basestring):
                self.location(obj)
            else:
                self.page.submit_card(obj)

            assert self.cards.is_here() or self.cards2.is_here()
            if self.page.several_cards():
                for account in self.page.iter_cards():
                    if accounts_list:
                        account.parent = find_object(accounts_list, id=account._parent_id)
                    yield account
            else:
                for account in self.page.iter_card():
                    if accounts_list:
                        account._parent_id = parent_id
                        account.parent = find_object(accounts_list, id=account._parent_id)
                    yield account
开发者ID:laurentb,项目名称:weboob,代码行数:26,代码来源:browser.py


示例2: init_transfer

    def init_transfer(self, transfer, **params):
        self.logger.info('Going to do a new transfer')
        transfer.label = ' '.join(w for w in re.sub('[^0-9a-zA-Z/\-\?:\(\)\.,\'\+ ]+', '', transfer.label).split()).upper()
        if transfer.account_iban:
            account = find_object(self.iter_accounts(), iban=transfer.account_iban, error=AccountNotFound)
        else:
            account = find_object(self.iter_accounts(), id=transfer.account_id, error=AccountNotFound)

        if transfer.recipient_iban:
            recipient = find_object(self.iter_transfer_recipients(account.id), iban=transfer.recipient_iban, error=RecipientNotFound)
        else:
            recipient = find_object(self.iter_transfer_recipients(account.id), id=transfer.recipient_id, error=RecipientNotFound)

        return self.browser.init_transfer(account, recipient, transfer)
开发者ID:P4ncake,项目名称:weboob,代码行数:14,代码来源:module.py


示例3: iter_history

    def iter_history(self, account):
        if account._history_url.startswith('javascript:') or account._history_url == '#':
            raise NotImplementedError()

        account = find_object(self.iter_accounts(), id=account.id)

        # this url (reached with a GET) return some transactions, but not in same format than POST method
        # and some transactions are duplicated and other are missing, don't take them from GET
        # because we don't want to manage both way in iter_history
        self.location(account._history_url)
        date_range_list = self.page.get_date_range_list()

        # a date_range is a couple of date like '01/03/201831/03/2018' but current month is often missing and we have to rebuild it
        # from first one to get very recent transaction without scrap them from 1st page (reached with GET url)
        if len(date_range_list):
            date_range_list = [self._build_next_date_range(date_range_list[0])] + date_range_list


        for date_range in date_range_list:
            date_guesser = LinearDateGuesser(datetime.datetime.strptime(date_range[10:], "%d/%m/%Y"))
            try:
                self.location(account._history_url, data={'date': date_range})
            except ServerError as error:
                if error.response.status_code == 500:
                    if 'RELEVE NON DISPONIBLE A CETTE PERIODE' in error.response.text:
                        continue
                        # just skip because it's still possible to have transactions next months
                        # Yes, they really did that heresy...
                    else:
                        raise
            for tr in sorted_transactions(self.page.iter_history(date_guesser=date_guesser)):
                yield tr
开发者ID:P4ncake,项目名称:weboob,代码行数:32,代码来源:browser.py


示例4: init_transfer

    def init_transfer(self, transfer, **params):
        if not transfer.label:
            raise TransferInvalidLabel()

        self.logger.info('Going to do a new transfer')
        if transfer.account_iban:
            account = find_object(self.iter_accounts(), iban=transfer.account_iban, error=AccountNotFound)
        else:
            account = find_object(self.iter_accounts(), id=transfer.account_id, error=AccountNotFound)

        if transfer.recipient_iban:
            recipient = find_object(self.iter_transfer_recipients(account.id), iban=transfer.recipient_iban, error=RecipientNotFound)
        else:
            recipient = find_object(self.iter_transfer_recipients(account.id), id=transfer.recipient_id, error=RecipientNotFound)

        return self.browser.init_transfer(account, recipient, transfer.amount, transfer.label, transfer.exec_date)
开发者ID:laurentb,项目名称:weboob,代码行数:16,代码来源:module.py


示例5: get_price

    def get_price(self, id, price=None):
        product = Product(id.split('.')[0])
        product.backend = self.name

        price = find_object(self.iter_prices([product]), id=id, error=PriceNotFound)
        price.shop.info = self.browser.get_shop_info(price.id.split('.', 2)[-1])
        return price
开发者ID:P4ncake,项目名称:weboob,代码行数:7,代码来源:module.py


示例6: get_life_insurance_list

    def get_life_insurance_list(self, accounts):

        self.life_insurances.go()

        for ins in self.page.iter_lifeinsurances(univers=self.current_univers):
            ins.parent = find_object(accounts, _number=ins._parent_number, type=Account.TYPE_CHECKING)
            yield ins
开发者ID:laurentb,项目名称:weboob,代码行数:7,代码来源:browser.py


示例7: get_list

    def get_list(self):
        accounts = []
        previous_account = None

        noaccounts = self.get_from_js('_js_noMvts =', ';')
        if noaccounts is not None:
            assert 'avez aucun compte' in noaccounts
            return []

        txt = self.get_from_js('_data = new Array(', ');', is_list=True)

        if txt is None:
            raise BrowserUnavailable('Unable to find accounts list in scripts')

        data = json.loads('[%s]' % txt.replace("'", '"'))

        for line in data:
            a = Account()
            a.id = line[self.COL_ID].replace(' ', '')

            if re.match(r'Classement=(.*?):::Banque=(.*?):::Agence=(.*?):::SScompte=(.*?):::Serie=(.*)', a.id):
                a.id = str(CleanDecimal().filter(a.id))

            a._acc_nb = a.id.split('_')[0] if len(a.id.split('_')) > 1 else None
            a.label = MyStrip(line[self.COL_LABEL], xpath='.//div[@class="libelleCompteTDB"]')
            # This account can be multiple life insurance accounts
            if a.label == 'ASSURANCE VIE-BON CAPI-SCPI-DIVERS *':
                continue

            a.balance = Decimal(FrenchTransaction.clean_amount(line[self.COL_BALANCE]))
            a.currency = a.get_currency(line[self.COL_BALANCE])
            a.type = self.get_account_type(a.label)

            # The parent account must be created right before
            if a.type == Account.TYPE_CARD:
                # duplicate
                if find_object(accounts, id=a.id):
                    self.logger.warning('Ignoring duplicate card %r', a.id)
                    continue
                a.parent = previous_account

            if line[self.COL_HISTORY] == 'true':
                a._inv = False
                a._link = self.get_history_link()
                a._args = self.make__args_dict(line)
            else:
                a._inv = True
                a._args = {'_ipc_eventValue':  line[self.COL_ID],
                           '_ipc_fireEvent':   line[self.COL_FIRE_EVENT],
                          }
                a._link = self.doc.xpath('//form[@name="changePageForm"]')[0].attrib['action']

            if a.type is Account.TYPE_CARD:
                a.coming = a.balance
                a.balance = Decimal('0.0')

            accounts.append(a)
            previous_account = a

        return accounts
开发者ID:laurentb,项目名称:weboob,代码行数:60,代码来源:pages.py


示例8: parse

            def parse(self, el):
                if any(s in CleanText('.')(el) for s in ['Avoir disponible', 'Solde']) or self.page.is_inner(CleanText('.')(el)):
                    self.env['category'] = u'Interne'
                else:
                    self.env['category'] = u'Externe'
                if self.env['category'] == u'Interne':
                    _id = Regexp(CleanText('.'), '- (.*?) -')(el)
                    if _id == self.env['account_id']:
                        raise SkipItem()
                    try:
                        account = find_object(self.page.browser.get_accounts_list(), id=_id, error=AccountNotFound)
                        self.env['id'] = _id
                        self.env['label'] = account.label
                        self.env['iban'] = account.iban
                    except AccountNotFound:
                        self.env['id'] = Regexp(CleanText('.'), '- (.*?) -')(el).replace(' ', '')
                        self.env['iban'] = NotAvailable
                        label = CleanText('.')(el).split('-')
                        holder = label[-1] if not any(string in label[-1] for string in ['Avoir disponible', 'Solde']) else label[-2]
                        self.env['label'] = '%s %s' % (label[0].strip(), holder.strip())
                    self.env['bank_name'] = u'La Banque Postale'

                else:
                    self.env['id'] = self.env['iban'] = Regexp(CleanText('.'), '- (.*?) -')(el).replace(' ', '')
                    self.env['label'] = Regexp(CleanText('.'), '- (.*?) - (.*)', template='\\2')(el).strip()
                    first_part = CleanText('.')(el).split('-')[0].strip()
                    self.env['bank_name'] = u'La Banque Postale' if first_part in ['CCP', 'PEL'] else NotAvailable

                if self.env['id'] in self.parent.objects: # user add two recipients with same iban...
                    raise SkipItem()
开发者ID:P4ncake,项目名称:weboob,代码行数:30,代码来源:transfer.py


示例9: iter_transfer_recipients

    def iter_transfer_recipients(self, origin_account):
        if not self.browser.is_new_website:
            raise NotImplementedError()

        if not isinstance(origin_account, Account):
            origin_account = find_object(self.iter_accounts(), id=origin_account, error=AccountNotFound)
        return self.browser.iter_recipients(origin_account)
开发者ID:P4ncake,项目名称:weboob,代码行数:7,代码来源:module.py


示例10: get_history

    def get_history(self, account):
        if account.type == Account.TYPE_LOAN:
            return []
        headers = {
            'Content-Type': 'application/json; charset=UTF-8',
            'Accept': 'application/json, text/javascript, */*; q=0.01'
        }

        data = {
            'contexte': '',
            'dateEntree': None,
            'filtreEntree': None,
            'donneesEntree': json.dumps(account._formated),
        }

        items = []
        self.cenet_account_history.go(data=json.dumps(data), headers=headers)
        # there might be some duplicate transactions regarding the card type ones
        # because some requests lead to the same transaction list
        # even with different parameters/data in the request
        card_tr_list = []
        while True:
            data_out = self.page.doc['DonneesSortie']
            for tr in self.page.get_history():
                items.append(tr)

                if tr.type is FrenchTransaction.TYPE_CARD_SUMMARY:
                    if find_object(card_tr_list, label=tr.label, amount=tr.amount, raw=tr.raw, date=tr.date, rdate=tr.rdate):
                        self.logger.warning('Duplicated transaction: %s', tr)
                        items.pop()
                        continue

                    card_tr_list.append(tr)
                    tr.deleted = True
                    tr_dict = [tr_dict for tr_dict in data_out if tr_dict['Libelle'] == tr.label]
                    donneesEntree = {}
                    donneesEntree['Compte'] = account._formated
                    donneesEntree['ListeOperations'] = [tr_dict[0]]
                    deferred_data = {
                        'contexte': '',
                        'dateEntree': None,
                        'donneesEntree': json.dumps(donneesEntree).replace('/', '\\/'),
                        'filtreEntree': json.dumps(tr_dict[0]).replace('/', '\\/')
                    }
                    tr_detail_page = self.cenet_tr_detail.open(data=json.dumps(deferred_data), headers=headers)
                    for tr in tr_detail_page.get_history():
                        items.append(tr)

            offset = self.page.next_offset()
            if not offset:
                break

            data['filtreEntree'] = json.dumps({
                'Offset': offset,
            })
            self.cenet_account_history.go(data=json.dumps(data), headers=headers)

        return sorted_transactions(items)
开发者ID:laurentb,项目名称:weboob,代码行数:58,代码来源:browser.py


示例11: iter_account_owners

    def iter_account_owners(self):
        """
        Some connections have a "Compte de Tiers" section with several
        people each having their own accounts. We must fetch the account
        for each person and store the owner of each account.
        """
        if self.unique_accounts_list:
            for account in self.unique_accounts_list.values():
                yield account
        else:
            self.go_post(self.js_url, data={'debr': 'OPTIONS_TIE'})
            if self.owners_list.is_here():
                self.owners = self.page.get_owners_urls()

                # self.accounts_list will be a dictionary of owners each
                # containing a dictionary of the owner's accounts.
                for owner in range(len(self.owners)):
                    self.accounts_list[owner] = {}
                    self.update_accounts_list(owner, True)

                    # We must set an "_owner" attribute to each account.
                    for a in self.accounts_list[owner].values():
                        a._owner = owner

                    # go on cards page if there are cards accounts
                    for a in self.accounts_list[owner].values():
                        if a.type == Account.TYPE_CARD:
                            self.location(a.url)
                            break

                    # get all couples (card, parent) on cards page
                    all_card_and_parent = []
                    if self.cbPage.is_here():
                        all_card_and_parent = self.page.get_all_parent_id()
                        self.go_post(self.js_url, data={'debr': 'COMPTES_PAN'})

                    # update cards parent and currency
                    for a in self.accounts_list[owner].values():
                        if a.type == Account.TYPE_CARD:
                            for card in all_card_and_parent:
                                if a.id in card[0].replace(' ', ''):
                                    a.parent = find_object(self.accounts_list[owner].values(), id=card[1])
                                if a.parent and not a.currency:
                                    a.currency = a.parent.currency

                    # We must get back to the owners list before moving to the next owner:
                    self.go_post(self.js_url, data={'debr': 'OPTIONS_TIE'})

                # Fill a dictionary will all accounts without duplicating common accounts:
                for owner in self.accounts_list.values():
                    for account in owner.values():
                        if account.id not in self.unique_accounts_list.keys():
                            self.unique_accounts_list[account.id] = account

                for account in self.unique_accounts_list.values():
                    yield account
开发者ID:laurentb,项目名称:weboob,代码行数:56,代码来源:browser.py


示例12: get_history

    def get_history(self, account):
        if account.type in (Account.TYPE_MARKET, Account.TYPE_PEA, Account.TYPE_LIFE_INSURANCE, Account.TYPE_PERP):
            self.logger.warning('This account is not supported')
            raise NotImplementedError()

        # some accounts may exist without a link to any history page
        if not account._form and (not account.url or 'CATITRES' in account.url):
            return

        if account._perimeter != self.current_perimeter:
            self.go_perimeter(account._perimeter)

        if account.type not in (Account.TYPE_LOAN, Account.TYPE_CARD) and account._form:
            # the account needs a form submission to go to the history
            # but we need to get the latest form data
            self.location(self.accounts_url.format(self.sag))
            accounts = self.page.iter_accounts()
            new_account = find_object(accounts, AccountNotFound, id=account.id)
            self.location(new_account._form.request)

        # card accounts need to get an updated link
        if account.type == Account.TYPE_CARD:
            account = self.get_card(account.id)

        if account.url and (account.type != Account.TYPE_CARD or not self.page.is_on_right_detail(account)):
            self.location(account.url.format(self.sag))

        if self.cards.is_here():
            date_guesser = ChaoticDateGuesser(date.today()-timedelta(weeks=42))
            url = self.page.url
            state = None
            notfirst = False
            while url:
                if notfirst:
                    self.location(url)
                else:
                    notfirst = True
                assert self.cards.is_here()
                for state, tr in self.page.get_history(date_guesser, state):
                    yield tr

                url = self.page.get_next_url()

        elif self.page and not self.no_fixed_deposit_page.is_here():
            date_guesser = LinearDateGuesser()
            self.page.order_transactions()
            while True:
                assert self.transactions.is_here()

                for tr in self.page.get_history(date_guesser):
                    yield tr

                url = self.page.get_next_url()
                if url is None:
                    break
                self.location(url)
开发者ID:P4ncake,项目名称:weboob,代码行数:56,代码来源:browser.py


示例13: iter_accounts

    def iter_accounts(self, accnum, current_univers):
        seen = set()

        accounts_list = []

        for content in  self.get_content():
            if accnum != '00000000000' and content['numero'] != accnum:
                continue
            for poste in content['postes']:
                a = Account()
                a._number = content['numeroLong']
                a._nature = poste['codeNature']
                a._codeSousPoste = poste['codeSousPoste'] if 'codeSousPoste' in poste else None
                a._consultable = poste['consultable']
                a._univers = current_univers
                a.id = '%s.%s' % (a._number, a._nature)

                if a.id in seen:
                    # some accounts like "compte à terme fidélis" have the same _number and _nature
                    # but in fact are kind of closed, so worthless...
                    self.logger.warning('ignored account id %r (%r) because it is already used', a.id, poste.get('numeroDossier'))
                    continue

                seen.add(a.id)

                a.type = self.ACCOUNT_TYPES.get(poste['codeNature'], Account.TYPE_UNKNOWN)
                if a.type == Account.TYPE_UNKNOWN:
                    self.logger.warning("unknown type %s" % poste['codeNature'])

                if a.type == Account.TYPE_CARD:
                    a.parent = find_object(accounts_list, _number=a._number, type=Account.TYPE_CHECKING)

                if 'numeroDossier' in poste and poste['numeroDossier']:
                    a._file_number = poste['numeroDossier']
                    a.id += '.%s' % a._file_number

                if poste['postePortefeuille']:
                    a.label = u'Portefeuille Titres'
                    a.balance = Decimal(str(poste['montantTitres']['valeur']))
                    a.currency = poste['montantTitres']['monnaie']['code'].strip()
                    if not a.balance and not a.currency and 'dateTitres' not in poste:
                        continue
                    accounts_list.append(a)

                if 'libelle' not in poste:
                    continue

                a.label = ' '.join([content['intitule'].strip(), poste['libelle'].strip()])
                a.balance = Decimal(str(poste['solde']['valeur']))
                a.currency = poste['solde']['monnaie']['code'].strip()
                # Some accounts may have balance currency
                if 'Solde en devises' in a.label and a.currency != u'EUR':
                    a.id += str(poste['monnaie']['codeSwift'])
                accounts_list.append(a)

        return accounts_list
开发者ID:laurentb,项目名称:weboob,代码行数:56,代码来源:pages.py


示例14: parse

 def parse(self, el):
     if bool(CleanText('./div[@id="soldeEurosCompte"]')(self)):
         self.env['category'] = u'Interne'
         account = find_object(self.page.browser.get_accounts_list(), id=self.obj_id(self))
         self.env['iban'] = account.iban if account else NotAvailable
         self.env['bank_name'] = u'LCL'
     else:
         self.env['category'] = u'Externe'
         self.env['iban'] = self.obj_id(self)
         self.env['bank_name'] = NotAvailable
开发者ID:P4ncake,项目名称:weboob,代码行数:10,代码来源:pages.py


示例15: get_accounts_list

 def get_accounts_list(self):
     if not self.accounts_list:
         self.update_accounts_list()
     for a in self.accounts_list.values():
         # Get parent of card account
         if a.type == Account.TYPE_CARD:
             card_page = self.open(a.url).page
             parent_id = card_page.get_parent_id()
             a.parent = find_object(self.accounts_list.values(), id=parent_id)
         yield a
开发者ID:P4ncake,项目名称:weboob,代码行数:10,代码来源:browser.py


示例16: get_account

    def get_account(self, id):
        """
        Get an account from its ID.

        :param id: ID of the account
        :type id: :class:`str`
        :rtype: :class:`Account`
        :raises: :class:`AccountNotFound`
        """
        return find_object(self.iter_accounts(), id=id, error=AccountNotFound)
开发者ID:laurentb,项目名称:weboob,代码行数:10,代码来源:module.py


示例17: get_city

    def get_city(self, _id):
        cities = list(self.iter_city_search(_id))

        if len(cities) == 0:
            raise CityNotFound()

        try:
            return find_object(cities, id=_id, error=CityNotFound)
        except CityNotFound:
            return cities[0]
开发者ID:dasimon,项目名称:weboob,代码行数:10,代码来源:module.py


示例18: iter_sensors

 def iter_sensors(self, gauge, pattern=None):
     if not isinstance(gauge, Gauge):
         gauge = find_object(self.browser.get_rivers_list(), id=gauge, error=SensorNotFound)
     if pattern is None:
         for sensor in gauge.sensors:
             yield sensor
     else:
         lowpattern = pattern.lower()
         for sensor in gauge.sensors:
             if lowpattern in sensor.name.lower():
                 yield sensor
开发者ID:Boussadia,项目名称:weboob,代码行数:11,代码来源:backend.py


示例19: iter_subscription

    def iter_subscription(self):
        subscriber = self.get_profile()

        self.subscription.go()

        for sub in self.page.iter_subscription():
            sub.subscriber = subscriber.name
            account = find_object(self.get_accounts_list(), id=sub.id, error=AccountNotFound)
            sub.label = account.label

            yield sub
开发者ID:laurentb,项目名称:weboob,代码行数:11,代码来源:browser.py


示例20: get_document

    def get_document(self, id):
        """
        Get a document.

        :param id: ID of document
        :rtype: :class:`Document`
        :raises: :class:`DocumentNotFound`
        """
        return find_object(self.iter_documents(id.split("#")[0]),
                           id=id,
                           error=DocumentNotFound)
开发者ID:laurentb,项目名称:weboob,代码行数:11,代码来源:module.py



注:本文中的weboob.capabilities.base.find_object函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python bill.Detail类代码示例发布时间:2022-05-26
下一篇:
Python base.empty函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap