Merge lp:~chsn/parcel-tracker/parcel-tracker-gls into lp:parcel-tracker

Proposed by Erik Christiansson
Status: Superseded
Proposed branch: lp:~chsn/parcel-tracker/parcel-tracker-gls
Merge into: lp:parcel-tracker
Diff against target: 42 lines (+38/-0)
1 file modified
parcel_tracker_lib/postservices/gls.py (+38/-0)
To merge this branch: bzr merge lp:~chsn/parcel-tracker/parcel-tracker-gls
Reviewer Review Type Date Requested Status
Vsevolod Velichko Needs Fixing
Review via email: mp+170143@code.launchpad.net

This proposal has been superseded by a proposal from 2013-06-19.

Description of the change

Added service for GLS Group (www.gls-group.eu)

To post a comment you must log in.
162. By Erik Christiansson

Mixed up the order of location and action in the return values.

Revision history for this message
Vsevolod Velichko (torkvemada) wrote :

There's a definite bug in your patch — end of file has been lost somewhere so the file is actually broken.

review: Needs Fixing
163. By Erik Christiansson

Broken file

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'parcel_tracker_lib/postservices/gls.py'
2--- parcel_tracker_lib/postservices/gls.py 1970-01-01 00:00:00 +0000
3+++ parcel_tracker_lib/postservices/gls.py 2013-06-19 08:57:32 +0000
4@@ -0,0 +1,38 @@
5+#!/usr/bin/env python
6+# -*- coding: utf-8 -*-
7+
8+### BEGIN LICENSE
9+# Copyright © 2012 Vsevolod Velichko <torkvema@gmail.com>
10+# Copyright © 2012 Carlos da Costa <c.costa@outlook.com>
11+# Copyright © 2013 Erik Christiansson <erik@christiansson.net>
12+# This program is free software: you can redistribute it and/or modify it
13+# under the terms of the GNU General Public License version 3, as published
14+# by the Free Software Foundation.
15+#
16+# This program is distributed in the hope that it will be useful, but
17+# WITHOUT ANY WARRANTY; without even the implied warranties of
18+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
19+# PURPOSE. See the GNU General Public License for more details.
20+#
21+# You should have received a copy of the GNU General Public License along
22+# with this program. If not, see <http://www.gnu.org/licenses/>.
23+### END LICENSE
24+
25+from . import TrackingService
26+
27+import re
28+from dateutil.parser import parse as parsedate
29+
30+class GlsService(TrackingService):
31+ """GLS Group service"""
32+
33+ name = 'GLS Group'
34+ url = 'http://www.gls-group.eu/276-I-PORTAL-WEB/content/GLS/PL01/EN/5004.htm?txtRefNo=%(number)s&txtAction=71000'
35+
36+ def _parse_page(self, html):
37+ html = html.decode('utf-8')
38+ res = re.search(r'<table class="resultlist">(.*?)</table>', html, re.DOTALL)
39+ if res is None:
40+ return []
41+ html = res.group(1)
42+ return [(oper, parsedate(date), loc) for date, loc, oper in re.findall(r'<tr class="details">\s*<td>\s*(.*?)\s*</td>\s*<td>\s*(.*?)\s*</td>.*?</td>\s*<td>\s*(.*?)\s*</td>.*?</tr>', html, re.DOTALL)]

Subscribers

People subscribed via source and target branches