pax_global_header 0000666 0000000 0000000 00000000064 14575653726 0014536 g ustar 00root root 0000000 0000000 52 comment=5f3d558793b537a74480241ac6981479f5938cd3
woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-colissimo/ 0000775 0000000 0000000 00000000000 14575653726 0024043 5 ustar 00root root 0000000 0000000 woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-colissimo/modules/ 0000775 0000000 0000000 00000000000 14575653726 0025513 5 ustar 00root root 0000000 0000000 woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-colissimo/modules/colissimo/ 0000775 0000000 0000000 00000000000 14575653726 0027514 5 ustar 00root root 0000000 0000000 woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-colissimo/modules/colissimo/__init__.py0000664 0000000 0000000 00000001507 14575653726 0031630 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013 Florent Fourcot
#
# This file is part of a woob module.
#
# This woob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This woob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this woob module. If not, see .
from .module import ColissimoModule
__all__ = ['ColissimoModule']
woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-colissimo/modules/colissimo/browser.py 0000664 0000000 0000000 00000006221 14575653726 0031552 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013-2014 Florent Fourcot
#
# This file is part of a woob module.
#
# This woob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This woob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this woob module. If not, see .
import re
from woob.capabilities.parcel import Event, ParcelNotFound, Parcel
from woob.browser import PagesBrowser, URL
from woob.browser.pages import HTMLPage, JsonPage
from woob.browser.profiles import Firefox
from dateutil.parser import parse as parse_date
__all__ = ['ColissimoBrowser']
class MainPage(HTMLPage):
pass
class TrackingPage(JsonPage):
def build_event(self, idx, item):
event = Event(idx)
event.date = parse_date(item["date"], ignoretz=True)
event.activity = item["label"]
return event
STATUSES = {
re.compile(
r"remis au gardien ou"
+ r"|Votre colis est livré"
+ r"|Votre courrier a été distribué à l'adresse"
): Parcel.STATUS_ARRIVED,
re.compile(
r"pas encore pris en charge par La Poste"
+ r"|a été déposé dans un point postal"
+ r"|en cours de préparation"
): Parcel.STATUS_PLANNED,
}
def get_info(self, _id):
if self.doc.get("shipment", {}).get("idShip", None) != _id:
raise ParcelNotFound(f"Parcel ID {_id} not found.")
p = Parcel(_id)
events = [self.build_event(i, item) for i, item in enumerate(self.doc['shipment']['event'])]
p.history = events
first = events[0]
p.info = first.activity
context_data = self.doc["shipment"].get("contextData", {})
delivery_mode = context_data.get("deliveryMode", None)
if delivery_mode:
p.info += " " + delivery_mode
partner_reference = context_data.get("partner", {}).get("reference", None)
if partner_reference:
p.info += f" Partner reference: {partner_reference}"
for pattern, status in self.STATUSES.items():
if pattern.search(p.info):
p.status = status
break
else:
p.status = p.STATUS_IN_TRANSIT
return p
class ColissimoBrowser(PagesBrowser):
BASEURL = 'https://www.laposte.fr'
PROFILE = Firefox()
main_url = URL('/outils/suivre-vos-envois\?code=(?P<_id>.*)', MainPage)
tracking_url = URL('https://api.laposte.fr/ssu/v1/suivi-unifie/idship/(?P<_id>.*)', TrackingPage)
def get_tracking_info(self, _id):
self.main_url.stay_or_go(_id=_id)
self.tracking_url.stay_or_go(_id=_id, headers={"Accept": "application/json"})
return self.page.get_info(_id)
woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-colissimo/modules/colissimo/favicon.png0000664 0000000 0000000 00000001657 14575653726 0031660 0 ustar 00root root 0000000 0000000 PNG
IHDR @ @ iq bKGD C pHYs tIME% tEXtComment Created with GIMPW IDATxMSUu)0c,$ !] ĄH"ΐ@\1b
Yąʅ'WP1*c3tE_fھyc4}==1c1c1cy2O3FF/%)_y.Э+0|T붸PDDd8v ;: @ݻ]
AfWgwkĹ;5x'RvǍ+s|k|#qgD oE)rP~T֎(P=l
"C AHm7Ԛ9fmo%;sy+\ȃa!AS.BzX_`rwyB`DLjeߙ|ns x?} rm:"8ɉsWBǚ[][e9[cr:6Ey
/}W7.ZwFj *a[JՓ!)TFKiGJuyuft1iDҜ^~oYk2fzpde}2H7 n5@.ks:komDq
AЂLvL@/}&__bUeyzs8Z+[i֎,9\TMDX-ԃKTr=ȱk oΣ,r=xnZ~ec1c1c1<):ȉq IENDB` woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-colissimo/modules/colissimo/module.py 0000664 0000000 0000000 00000002676 14575653726 0031366 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013 Florent Fourcot
#
# This file is part of a woob module.
#
# This woob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This woob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this woob module. If not, see .
from woob.capabilities.parcel import CapParcel, ParcelNotFound
from woob.tools.backend import Module
from .browser import ColissimoBrowser
__all__ = ['ColissimoModule']
class ColissimoModule(Module, CapParcel):
NAME = 'colissimo'
DESCRIPTION = u'Colissimo parcel tracking website'
MAINTAINER = u'Florent Fourcot'
EMAIL = 'weboob@flo.fourcot.fr'
VERSION = '3.6'
LICENSE = 'AGPLv3+'
BROWSER = ColissimoBrowser
def get_parcel_tracking(self, _id):
# 13 is the magic length of colissimo tracking ids
if len(_id) != 13:
raise ParcelNotFound(u"Colissimo ID's must have 13 print character")
return self.browser.get_tracking_info(_id)
requirements.txt 0000664 0000000 0000000 00000000014 14575653726 0032714 0 ustar 00root root 0000000 0000000 woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-colissimo/modules/colissimo woob ~= 3.2