本文整理汇总了Python中weboob.tools.date.parse_french_date函数的典型用法代码示例。如果您正苦于以下问题:Python parse_french_date函数的具体用法?Python parse_french_date怎么用?Python parse_french_date使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_french_date函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_response
def handle_response(self, transfer):
self.check_errors()
transfer_data = self.doc['data']['enregistrementVirement']
transfer.id = transfer_data['reference']
transfer.exec_date = parse_french_date(self.doc['data']['enregistrementVirement']['dateExecution']).date()
# Timestamp at which the bank registered the transfer
register_date = re.sub(' 24:', ' 00:', self.doc['data']['enregistrementVirement']['dateEnregistrement'])
transfer._register_date = parse_french_date(register_date)
return transfer
示例2: parse_transaction
def parse_transaction(self, transaction, account):
trans = []
if transaction['transactionStatus'] in [u'Créé', u'Annulé', u'Suspendu', u'Mis à jour', u'Actif', u'Payé', u'En attente', u'Rejeté', u'Expiré', \
u'Created']:
return []
if transaction['transactionDescription'].startswith(u'Offre de remboursement') or transaction['transactionDescription'].startswith(u'Commande à'):
return []
t = FrenchTransaction(transaction['transactionId'])
if not transaction['transactionAmount']['currencyCode'] == account.currency:
cc = self.browser.convert_amount(account, transaction, 'https://www.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id=' + transaction['transactionId'])
if not cc:
return []
t.original_amount = Decimal('%.2f' % transaction['transactionAmount']['currencyDoubleValue'])
t.original_currency = u'' + transaction['transactionAmount']['currencyCode']
t.amount = abs(cc) if not transaction['debit'] else -abs(cc)
else:
t.amount = Decimal('%.2f' % transaction['net']['currencyDoubleValue'])
date = parse_french_date(transaction['transactionTime'])
raw = transaction['transactionDescription']
if raw.startswith(u'Paiement \xe0') or raw.startswith('Achat de'):
payback_id, payback_raw, payback_amount, payback_currency = self.browser.check_for_payback(transaction, 'https://www.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id=' + transaction['transactionId'])
if payback_id and payback_raw and payback_amount and payback_currency:
t_payback = FrenchTransaction(payback_id)
t_payback.amount = payback_amount
t_payback.original_currency = payback_currency
t_payback.type = FrenchTransaction.TYPE_TRANSFER
t_payback.parse(date=date, raw=u'Prélèvement pour %s' % raw)
trans.append(t_payback)
t.commission = Decimal('%.2f' % transaction['fee']['currencyDoubleValue'])
t.parse(date=date, raw=raw)
trans.append(t)
return trans
示例3: iter_coming
def iter_coming(self):
for op in self.path('data.listerOperations.compte.operationAvenir.*.operation.*'):
codeOperation = cast(op.get('codeOperation'), int, 0)
# Coming transactions don't have real id
tr = Transaction.from_dict({
'type': self.COMING_TYPE_TO_TYPE.get(codeOperation) or Transaction.TYPE_UNKNOWN,
'amount': op.get('montant'),
'card': op.get('numeroPorteurCarte'),
})
tr.parse(date=parse_french_date(op.get('dateOperation')),
vdate=parse_french_date(op.get('valueDate')),
raw=op.get('libelle'))
if tr.type == Transaction.TYPE_CARD:
tr.type = self.browser.card_to_transaction_type.get(op.get('keyCarte'),
Transaction.TYPE_DEFERRED_CARD)
yield tr
示例4: parse_datetime
def parse_datetime(self, text):
m = re.match('(\d+)/(\d+)/(\d+) (\d+):(\d+) (\w+)', text)
if m:
date = datetime.datetime(int(m.group(3)),
int(m.group(1)),
int(m.group(2)),
int(m.group(4)),
int(m.group(5)))
if m.group(6) == 'pm':
date += datetime.timedelta(0,12*3600)
return date
m = re.match('(\d+)-(\d+)-(\d+) (\d+):(\d+)', text)
if m:
return datetime.datetime(int(m.group(1)),
int(m.group(2)),
int(m.group(3)),
int(m.group(4)),
int(m.group(5)))
m = re.match('(\d+) (\w+) (\d+) (\d+):(\d+)', text)
if m:
return parse_french_date(text)
self.logger.warning('Unable to parse "%s"' % text)
return text
示例5: parse_transaction
def parse_transaction(self, transaction, account):
t = FrenchTransaction(transaction['id'])
if not transaction['isPrimaryCurrency']:
original_currency = unicode(transaction['amounts']['txnCurrency'])
if original_currency in self.browser.account_currencies:
return []
if 'conversionFrom' in transaction['amounts'] and account.currency == transaction['amounts']['conversionFrom']['currency']:
cc = self.format_amount(transaction['amounts']['conversionFrom']['value'], transaction['isCredit'])
else:
try:
cc = self.browser.convert_amount(account, transaction, transaction['detailsLink'])
except ServerError:
self.logger.warning('Unable to go on detail, transaction skipped.')
return []
if not cc:
return []
t.original_amount = self.format_amount(transaction['amounts']['net']['value'], transaction["isCredit"])
t.original_currency = original_currency
t.amount = self.format_amount(cc, transaction['isCredit'])
else:
t.amount = self.format_amount(transaction['amounts']['net']['value'], transaction['isCredit'])
date = parse_french_date(transaction['date']['formattedDate'] + ' ' + transaction['date']['year'])
raw = transaction.get('counterparty', transaction['displayType'])
t.parse(date=date, raw=raw)
return [t]
示例6: recap
def recap(self, origin, recipient, transfer):
error = CleanText(u'//div[@id="transfer_form:moveMoneyDetailsBody"]//span[@class="error"]', default=None)(self.doc) or \
CleanText(u'//p[contains(text(), "Nous sommes désolés. Le solde de votre compte ne doit pas être inférieur au montant de votre découvert autorisé. Veuillez saisir un montant inférieur.")]', default=None)(self.doc)
if error:
raise TransferInvalidAmount(message=error)
t = Transfer()
t.label = transfer.label
assert transfer.amount == CleanDecimal('//div[@id="transferSummary"]/div[@id="virementLabel"]\
//label[@class="digits positive"]', replace_dots=True)(self.doc)
t.amount = transfer.amount
t.currency = FrenchTransaction.Currency('//div[@id="transferSummary"]/div[@id="virementLabel"]\
//label[@class="digits positive"]')(self.doc)
assert origin.label == CleanText('//div[@id="transferSummary"]/div[has-class("debit")]//span[@class="title"]')(self.doc)
assert origin.balance == CleanDecimal('//div[@id="transferSummary"]/div[has-class("debit")]\
//label[@class="digits positive"]', replace_dots=True)(self.doc)
t.account_balance = origin.balance
t.account_label = origin.label
t.account_iban = origin.iban
t.account_id = origin.id
assert recipient.label == CleanText('//div[@id="transferSummary"]/div[has-class("credit")]//span[@class="title"]')(self.doc)
t.recipient_label = recipient.label
t.recipient_iban = recipient.iban
t.recipient_id = recipient.id
t.exec_date = parse_french_date(CleanText('//p[has-class("exec-date")]', children=False,
replace=[('le', ''), (u'exécuté', ''), ('demain', ''), ('(', ''), (')', ''),
("aujourd'hui", '')])(self.doc)).date()
return t
示例7: parse
def parse(self, el):
label = CleanText('//div[contains(@class, "lister")]//p[@class="c"]')(el)
if not label:
return
label = re.findall('(\d+ [^ ]+ \d+)', label)[-1]
# use the trick of relativedelta to get the last day of month.
self.env['debit_date'] = parse_french_date(label) + relativedelta(day=31)
示例8: get_history
def get_history(self, date_guesser):
seen = set()
lines = self.document.xpath('(//table[@class="ca-table"])[2]/tr')
for line in lines[1:]: # first line is balance
is_balance = line.xpath('./td/@class="cel-texte cel-neg"')
[date, label, _, amount] = [self.parser.tocleanstring(td)
for td in line.xpath('./td')]
t = Transaction(0)
t.set_amount(amount)
t.label = t.raw = label
if is_balance:
m = re.search('(\d+ [^ ]+ \d+)', label)
if not m:
raise BrokenPageError('Unable to read card balance in history: %r' % label)
t.date = parse_french_date(m.group(1))
t.amount = -t.amount
else:
day, month = map(int, date.split('/', 1))
t.date = date_guesser.guess_date(day, month)
t.type = t.TYPE_CARD
t.rdate = t.date
try:
t.id = t.unique_id(seen)
except UnicodeEncodeError:
print t
print t.label
raise
yield t
示例9: obj_rdate
def obj_rdate(self):
raw = self.obj_raw()
mtc = re.search(r'\bDU (\d{2})\.?(\d{2})\.?(\d{2})\b', raw)
if mtc:
date = '%s/%s/%s' % (mtc.group(1), mtc.group(2), mtc.group(3))
return parse_french_date(date)
return fromtimestamp(Dict('dateCreation')(self))
示例10: obj_date
def obj_date(self):
date = CleanText(
'./div/p[@class="item-date"]'
)(self).split(" / ")
if len(date) > 1:
return parse_french_date(date[1].strip())
else:
return NotLoaded
示例11: iter_history
def iter_history(self):
for op in self.get('data.listerOperations.compte.operationPassee') or []:
codeFamille = cast(self.one('operationType.codeFamille', op), int)
tr = Transaction.from_dict({
'id': op.get('idOperation'),
'type': self.CODE_TO_TYPE.get(codeFamille) or Transaction.TYPE_UNKNOWN,
'category': op.get('categorie'),
'amount': self.one('montant.montant', op),
})
tr.parse(raw=op.get('libelleOperation'),
date=parse_french_date(op.get('dateOperation')),
vdate=parse_french_date(self.one('montant.valueDate', op)))
raw_is_summary = re.match(r'FACTURE CARTE SELON RELEVE DU\b|FACTURE CARTE CARTE AFFAIRES \d{4}X{8}\d{4} SUIVANT\b', tr.raw)
if tr.type == Transaction.TYPE_CARD and raw_is_summary:
tr.type = Transaction.TYPE_CARD_SUMMARY
tr.deleted = True
yield tr
示例12: get_operations
def get_operations(self):
for tr in self._get_operations(self)():
tr.type = tr.TYPE_DEFERRED_CARD
deferred_date = Regexp(CleanText('//div[@class="date"][contains(text(), "Carte")]'), r'le ([^:]+)', default=None)(self.doc)
if deferred_date:
tr.date = parse_french_date(deferred_date).date()
# rdate > date doesn't make any sense but it seems that lcl website can do shitty things sometimes
if tr.date >= tr.rdate:
yield tr
else:
self.logger.error('skipping transaction with rdate > date')
示例13: get_contact
def get_contact(self):
profile_a = self.document.find("a", href=re.compile(r"profil_read.php\?.*"))
_id = re.search(r"\?(.*)", profile_a["href"]).group(1)
# not available in the 'boosted' version
contact = Contact(_id, _id, Contact.STATUS_OFFLINE)
contact.url = self.url
contact.profile = {}
thumbnail_url = "http://photos.onvasortir.com/%s/photos/%s_resize.png" % (self.browser.city, _id)
if self.document.find("img", attrs={"src": thumbnail_url}):
photo_url = thumbnail_url.replace("_resize", "")
contact.set_photo("main", thumbnail_url=thumbnail_url, url=photo_url, hidden=False)
location_a = self.document.find("a", href=re.compile(r"vue_profil_carte\.php\?"))
if location_a:
lat = float(re.search(r"Lat=([\d.]+)", location_a["href"]).group(1))
self._set_profile(contact, "latitude", lat)
lng = float(re.search(r"Lng=([\d.]+)", location_a["href"]).group(1))
self._set_profile(contact, "longitude", lng)
div = self.document.find("div", attrs={"class": "PADtitreBlanc_txt"}, text=re.compile("Personal Info"))
td = div.findParent("tr").findNextSibling("tr").td
infos_text = td.getText(separator="\n").strip()
it = iter(infos_text.split("\n"))
infos = dict(zip(it, it))
if infos["Sex :"] == "Man":
self._set_profile(contact, "sex", "M")
elif infos["Sex :"] == "Woman":
self._set_profile(contact, "sex", "F")
if infos["Birthday :"] != "Unknown":
self._set_profile(
contact, "birthday", parse_french_date(re.search(r"(\d+ \w+ \d+)", infos["Birthday :"]).group(1))
)
self._try_attr(contact, infos, "First Name :", "first_name")
self._try_attr(contact, infos, "Status :", "marriage")
self._try_attr(contact, infos, "Area :", "area")
div = self.document.find("div", attrs={"class": "PADtitreBlanc_txt"}, text=re.compile("A few words"))
td = div.findParent("tr").findNextSibling("tr").td
summary = td.getText(separator="\n").strip()
if summary == "Unknown":
contact.summary = u""
else:
contact.summary = summary
div = self.document.find("div", style=re.compile("dashed"))
if div:
# TODO handle html, links and smileys
contact.status_msg = div.getText()
else:
contact.status_msg = u""
return contact
示例14: get_profile
def get_profile(self):
profile = Person()
content = self.get_content()
profile.name = content['prenom'] + ' ' + content['nom']
profile.address = content['adresse'] + ' ' + content['codePostal'] + ' ' + content['ville']
profile.country = content['pays']
profile.birth_date = parse_french_date(content['dateNaissance']).date()
return profile
示例15: get_contact
def get_contact(self):
profile_a = self.document.find('a', href=re.compile(r'profil_read.php\?.*'))
_id = re.search(r'\?(.*)', profile_a['href']).group(1)
# not available in the 'boosted' version
contact = Contact(_id, _id, Contact.STATUS_OFFLINE)
contact.url = self.url
contact.profile = {}
thumbnail_url = 'http://photos.onvasortir.com/%s/photos/%s_resize.png' % (self.browser.city, _id)
if self.document.find('img', attrs={'src': thumbnail_url}):
photo_url = thumbnail_url.replace('_resize', '')
contact.set_photo('main', thumbnail_url=thumbnail_url, url=photo_url, hidden=False)
location_a = self.document.find('a', href=re.compile(r'vue_profil_carte\.php\?'))
if location_a:
lat = float(re.search(r'Lat=([\d.]+)', location_a['href']).group(1))
self._set_profile(contact, 'latitude', lat)
lng = float(re.search(r'Lng=([\d.]+)', location_a['href']).group(1))
self._set_profile(contact, 'longitude', lng)
div = self.document.find('div', attrs={'class': 'PADtitreBlanc_txt'}, text=re.compile('Personal Info'))
td = div.findParent('tr').findNextSibling('tr').td
infos_text = td.getText(separator='\n').strip()
it = iter(infos_text.split('\n'))
infos = dict(zip(it, it))
if infos['Sex :'] == 'Man':
self._set_profile(contact, 'sex', 'M')
elif infos['Sex :'] == 'Woman':
self._set_profile(contact, 'sex', 'F')
if infos['Birthday :'] != 'Unknown':
self._set_profile(contact, 'birthday', parse_french_date(re.search(r'(\d+ \w+ \d+)', infos['Birthday :']).group(1)))
self._try_attr(contact, infos, 'First Name :', 'first_name')
self._try_attr(contact, infos, 'Status :', 'marriage')
self._try_attr(contact, infos, 'Area :', 'area')
div = self.document.find('div', attrs={'class': 'PADtitreBlanc_txt'}, text=re.compile('A few words'))
td = div.findParent('tr').findNextSibling('tr').td
summary = td.getText(separator='\n').strip()
if summary == 'Unknown':
contact.summary = u''
else:
contact.summary = summary
div = self.document.find('div', style=re.compile('dashed'))
if div:
# TODO handle html, links and smileys
contact.status_msg = div.getText()
else:
contact.status_msg = u''
return contact