module.py 8.37 KB
Newer Older
1 2 3 4
# -*- coding: utf-8 -*-

# Copyright(C) 2013      Bezleputh
#
5
# This file is part of a weboob module.
6
#
7
# This weboob module is free software: you can redistribute it and/or modify
8 9 10 11
# 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.
#
12
# This weboob module is distributed in the hope that it will be useful,
13 14 15 16 17
# 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
18
# along with this weboob module. If not, see <http://www.gnu.org/licenses/>.
19

20
from collections import OrderedDict
21

22
from weboob.tools.backend import Module, BackendConfig
23
from weboob.tools.value import Value
24
from weboob.capabilities.job import CapJob, BaseJobAdvert
25 26
from .browser import AdeccoBrowser

Florent Fourcot's avatar
Florent Fourcot committed
27
__all__ = ['AdeccoModule']
28 29


30
class AdeccoModule(Module, CapJob):
31 32 33 34
    NAME = 'adecco'
    DESCRIPTION = u'adecco website'
    MAINTAINER = u'Bezleputh'
    EMAIL = 'carton_ben@yahoo.fr'
Romain Bignon's avatar
Romain Bignon committed
35
    VERSION = '1.5'
36 37 38

    BROWSER = AdeccoBrowser

39
    publicationDate_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({
40 41 42 43
        '000000': u'-- Indifferent --',
        '2': u'Moins de 48 heures',
        '7': u'Moins de 1 semaine',
        '14': u'Moins de 2 semaines',
44
    }.items())])
45

46
    type_contract_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({
47 48 49 50 51 52
        '': u'-- Indifferent --',
        'ADCFREMP005': u'CDD',
        'ADCFREMP004': u'CDI',
        'ADCFREMP003': u'Intérim',
        'ADCFREMP009': u'Autres',
        'ADCFREMP010': u'Libéral',
53
    }.items())])
54

55
    places_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
        '': u'-- Indifferent --',
        'AIN': u'Ain',
        'AISNE': u'Aisne',
        'ALLIER': u'Allier',
        'ALPES-DE-HAUTE-PROVENCE': u'Alpes-De-Haute-Provence',
        'ALPES-MARITIMES': u'Alpes-Maritimes',
        'ARDECHE': u'Ardeche',
        'ARDENNES': u'Ardennes',
        'ARIEGE': u'Ariege',
        'AUBE': u'Aube',
        'AUDE': u'Aude',
        'AVEYRON': u'Aveyron',
        'BAS-RHIN': u'Bas-Rhin',
        'BOUCHES-DU-RHONE': u'Bouches-Du-Rhone',
        'CALVADOS': u'Calvados',
        'CANTAL': u'Cantal',
        'CHARENTE': u'Charente',
        'CHARENTE-MARITIME': u'Charente-Maritime',
        'CHER': u'Cher',
        'CORREZE': u'Correze',
        'CORSE-DU-SUD': u'Corse du Sud',
        'COTE-D%27OR': u'Cote D\'Or',
        'COTES-D%27ARMOR': u'Cotes D\'Armor',
        'CREUSE': u'Creuse',
        'DEUX-SEVRES': u'Deux-Sevres',
        'DORDOGNE': u'Dordogne',
        'DOUBS': u'Doubs',
        'DROME': u'Drome',
        'ESSONNE': u'Essonne',
        'EURE': u'Eure',
        'EURE-ET-LOIR': u'Eure-Et-Loir',
        'FINISTERE': u'Finistere',
        'GARD': u'Gard',
        'GERS': u'Gers',
        'GIRONDE': u'Gironde',
        'GUADELOUPE': u'Guadeloupe',
        'GUYANE': u'Guyane',
        'HAUT-RHIN': u'Haut-Rhin',
        'HAUTE-CORSE': u'Haute-Corse',
        'HAUTE-GARONNE': u'Haute-Garonne',
        'HAUTE-LOIRE': u'Haute-Loire',
        'HAUTE-MARNE': u'Haute-Marne',
        'HAUTE-SAONE': u'Haute-Saone',
        'HAUTE-SAVOIE': u'Haute-Savoie',
        'HAUTE-VIENNE': u'Haute-Vienne',
        'HAUTES-ALPES': u'Hautes-Alpes',
        'HAUTES-PYRENEES': u'Hautes-Pyrenees',
        'HAUTS-DE-SEINE': u'Hauts-De-Seine',
        'HERAULT': u'Herault',
        'ILLE-ET-VILAINE': u'Ille-Et-Vilaine',
        'INDRE': u'Indre',
        'INDRE-ET-LOIRE': u'Indre-Et-Loire',
        'ISERE': u'Isere',
        'JURA': u'Jura',
        'LA+REUNION': u'La Reunion',
        'LANDES': u'Landes',
        'LOIR-ET-CHER': u'Loir-Et-Cher',
        'LOIRE': u'Loire',
        'LOIRE-ATLANTIQUE': u'Loire-Atlantique',
        'LOIRET': u'Loiret',
        'LOT': u'Lot',
        'LOT-ET-GARONNE': u'Lot-Et-Garonne',
        'LOZERE': u'Lozere',
        'MAINE-ET-LOIRE': u'Maine-Et-Loire',
        'MANCHE': u'Manche',
        'MARNE': u'Marne',
        'MARTINIQUE': u'Martinique',
        'MAYENNE': u'Mayenne',
        'MAYOTTE': u'Mayotte',
        'MEURTHE-ET-MOSELLE': u'Meurthe et Moselle',
        'MEUSE': u'Meuse',
        'MONACO': u'Monaco',
        'MORBIHAN': u'Morbihan',
        'MOSELLE': u'Moselle',
        'NIEVRE': u'Nievre',
        'NORD': u'Nord',
        'OISE': u'Oise',
        'ORNE': u'Orne',
        'PARIS': u'Paris',
        'PAS-DE-CALAIS': u'Pas-de-Calais',
        'PUY-DE-DOME': u'Puy-de-Dome',
        'PYRENEES-ATLANTIQUES': u'Pyrenees-Atlantiques',
        'PYRENEES-ORIENTALES': u'Pyrenees-Orientales',
        'RHONE': u'Rhone',
        'SAONE-ET-LOIRE': u'Saone-et-Loire',
        'SARTHE': u'Sarthe',
        'SAVOIE': u'Savoie',
        'SEINE-ET-MARNE': u'Seine-et-Marne',
        'SEINE-MARITIME': u'Seine-Maritime',
        'SEINE-SAINT-DENIS': u'Seine-Saint-Denis',
        'SOMME': u'Somme',
        'ST+PIERRE+ET+MIQUELON': u'St Pierre et Miquelon',
        'SUISSE': u'Suisse',
        'TARN': u'Tarn',
        'TARN-ET-GARONNE': u'Tarn-et-Garonne',
        'TERRITOIRE+DE+BELFORT': u'Territoire de Belfort',
        'VAL-D%27OISE': u'Val-D\'Oise',
        'VAL-DE-MARNE': u'Val-De-Marne',
        'VAR': u'Var',
        'VAUCLUSE': u'Vaucluse',
        'VENDEE': u'Vendee',
        'VIENNE': u'Vienne',
        'VOSGES': u'Vosges',
        'YONNE': u'Yonne',
        'YVELINES': u'Yvelines',
161
    }.items())])
162 163

    activityDomain_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
        'Z': '-- Indifferent --',
        'A': u'Accueil - Secrétariat - Fonctions Administratives',
        'B': u'Achats - Juridique - Qualité - RH - Direction',
        'C': u'Agriculture - Viticulture - Pêche - Espaces Verts',
        'D': u'Automobile',
        'E': u'Banque - Finance - Gestion Comptabilité - Assurance',
        'F': u'Bâtiment - Travaux Publics - Architecture - Immobilier',
        'G': u'Bureaux d\'Etudes - Méthodes',
        'H': u'Commerce - Vente - Grande Distribution',
        'I': u'Environnement - Nettoyage - Sécurité',
        'J': u'Hôtellerie - Restauration - Métiers de Bouche',
        'K': u'Industrie',
        'L': u'Informatique - Technologie de l\'Information',
        'M': u'Logistique - Manutention - Transport',
        'N': u'Marketing - Communication - Imprimerie - Edition',
        'O': u'Médical - Paramédical - Esthétique',
        'P': u'Pharmacie (Industrie, Officine) - Recherche clinique',
        'Q': u'Télémarketing - Téléservices',
        'R': u'Tourisme - Loisirs - Spectacle - Audiovisuel',
183
    }.items())])
184

185 186 187 188
    CONFIG = BackendConfig(Value('job', label='Job name', masked=False, default=''),
                           Value('town', label='Town name', masked=False, default=''),
                           Value('place', label=u'County', choices=places_choices),
                           Value('publication_date', label=u'Publication Date', choices=publicationDate_choices),
189
                           Value('contract', labe=u'Contract type', choices=type_contract_choices),
190 191
                           Value('activity_domain', label=u'Activity Domain', choices=activityDomain_choices,
                                 default=''),
Bezleputh's avatar
Bezleputh committed
192
                           )
193

194
    def search_job(self, pattern=None):
195 196
        for advert in self.browser.search_job(pattern):
            yield advert
197

198
    def advanced_search_job(self):
199 200
        activity_domain = self.config['activity_domain'].get() if self.config['activity_domain'].get() != u'Z' else None

201
        for advert in self.browser.advanced_search_job(publication_date=int(self.config['publication_date'].get()),
202 203 204 205 206
                                                       contract_type=self.config['contract'].get(),
                                                       conty=self.config['place'].get(),
                                                       activity_domain=activity_domain,
                                                       job=self.config['job'].get(),
                                                       town=self.config['town'].get()
207 208
                                                       ):
            yield advert
Bezleputh's avatar
Bezleputh committed
209

210
    def get_job_advert(self, _id, advert=None):
211
        return self.browser.get_job_advert(_id, advert)
212 213

    def fill_obj(self, advert, fields):
214
        return self.get_job_advert(advert.id, advert)
215

216
    OBJECTS = {BaseJobAdvert: fill_obj}