improve ls command in handjoob
This commit is contained in:
parent
86f5444cab
commit
b4c93587b4
10 changed files with 54 additions and 71 deletions
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
|
|
||||||
from weboob.tools.backend import BaseBackend, BackendConfig
|
from weboob.tools.backend import BaseBackend, BackendConfig
|
||||||
from weboob.capabilities.collection import ICapCollection, CollectionNotFound
|
|
||||||
from weboob.tools.ordereddict import OrderedDict
|
from weboob.tools.ordereddict import OrderedDict
|
||||||
from weboob.tools.value import Value
|
from weboob.tools.value import Value
|
||||||
from weboob.capabilities.job import ICapJob
|
from weboob.capabilities.job import ICapJob
|
||||||
|
|
@ -29,7 +28,7 @@ from .job import AdeccoJobAdvert
|
||||||
__all__ = ['AdeccoBackend']
|
__all__ = ['AdeccoBackend']
|
||||||
|
|
||||||
|
|
||||||
class AdeccoBackend(BaseBackend, ICapJob, ICapCollection):
|
class AdeccoBackend(BaseBackend, ICapJob):
|
||||||
NAME = 'adecco'
|
NAME = 'adecco'
|
||||||
DESCRIPTION = u'adecco website'
|
DESCRIPTION = u'adecco website'
|
||||||
MAINTAINER = u'Bezleputh'
|
MAINTAINER = u'Bezleputh'
|
||||||
|
|
@ -284,22 +283,14 @@ class AdeccoBackend(BaseBackend, ICapJob, ICapCollection):
|
||||||
for advert in self.browser.search_job(pattern):
|
for advert in self.browser.search_job(pattern):
|
||||||
yield advert
|
yield advert
|
||||||
|
|
||||||
def iter_resources(self, objs, split_path):
|
def advanced_search_job(self):
|
||||||
with self.browser:
|
for advert in self.browser.advanced_search_job(publication_date=int(self.config['publication_date'].get()),
|
||||||
collection = self.get_collection(objs, split_path)
|
conty=int(self.config['conty'].get()),
|
||||||
if collection.path_level == 0:
|
region=int(self.config['region'].get()),
|
||||||
for advert in self.browser.advanced_search_job(publication_date=int(self.config['publication_date'].get()),
|
job_category=int(self.config['job_category'].get()),
|
||||||
conty=int(self.config['conty'].get()),
|
activity_domain=int(self.config['activity_domain'].get())
|
||||||
region=int(self.config['region'].get()),
|
):
|
||||||
job_category=int(self.config['job_category'].get()),
|
yield advert
|
||||||
activity_domain=int(self.config['activity_domain'].get())
|
|
||||||
):
|
|
||||||
yield advert
|
|
||||||
|
|
||||||
def validate_collection(self, objs, collection):
|
|
||||||
if collection.path_level == 0:
|
|
||||||
return
|
|
||||||
raise CollectionNotFound(collection.split_path)
|
|
||||||
|
|
||||||
def get_job_advert(self, _id, advert=None):
|
def get_job_advert(self, _id, advert=None):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class AdeccoTest(BackendTest):
|
||||||
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
||||||
|
|
||||||
def test_adecco_advanced_search(self):
|
def test_adecco_advanced_search(self):
|
||||||
l = list(self.backend.iter_resources([], []))
|
l = list(self.backend.advanced_search_job())
|
||||||
assert len(l)
|
assert len(l)
|
||||||
advert = self.backend.get_job_advert(l[0].id, None)
|
advert = self.backend.get_job_advert(l[0].id, None)
|
||||||
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
|
|
||||||
from weboob.tools.backend import BaseBackend, BackendConfig
|
from weboob.tools.backend import BaseBackend, BackendConfig
|
||||||
from weboob.capabilities.collection import ICapCollection, CollectionNotFound
|
|
||||||
from weboob.capabilities.job import ICapJob
|
from weboob.capabilities.job import ICapJob
|
||||||
from weboob.tools.ordereddict import OrderedDict
|
from weboob.tools.ordereddict import OrderedDict
|
||||||
from weboob.tools.value import Value
|
from weboob.tools.value import Value
|
||||||
|
|
@ -29,7 +28,7 @@ from .job import ApecJobAdvert
|
||||||
__all__ = ['ApecBackend']
|
__all__ = ['ApecBackend']
|
||||||
|
|
||||||
|
|
||||||
class ApecBackend(BaseBackend, ICapJob, ICapCollection):
|
class ApecBackend(BaseBackend, ICapJob):
|
||||||
NAME = 'apec'
|
NAME = 'apec'
|
||||||
DESCRIPTION = u'apec website'
|
DESCRIPTION = u'apec website'
|
||||||
MAINTAINER = u'Bezleputh'
|
MAINTAINER = u'Bezleputh'
|
||||||
|
|
@ -233,23 +232,15 @@ class ApecBackend(BaseBackend, ICapJob, ICapCollection):
|
||||||
for job_advert in self.browser.search_job(pattern=pattern):
|
for job_advert in self.browser.search_job(pattern=pattern):
|
||||||
yield job_advert
|
yield job_advert
|
||||||
|
|
||||||
def iter_resources(self, objs, split_path):
|
def advanced_search_job(self):
|
||||||
with self.browser:
|
for job_advert in self.browser.advanced_search_job(region=self.config['place'].get(),
|
||||||
collection = self.get_collection(objs, split_path)
|
fonction=self.config['fonction'].get(),
|
||||||
if collection.path_level == 0:
|
secteur=self.config['secteur'].get(),
|
||||||
for job_advert in self.browser.advanced_search_job(region=self.config['place'].get(),
|
salaire=self.config['salaire'].get(),
|
||||||
fonction=self.config['fonction'].get(),
|
contrat=self.config['contrat'].get(),
|
||||||
secteur=self.config['secteur'].get(),
|
limit_date=self.config['limit_date'].get(),
|
||||||
salaire=self.config['salaire'].get(),
|
level=self.config['level'].get()):
|
||||||
contrat=self.config['contrat'].get(),
|
yield job_advert
|
||||||
limit_date=self.config['limit_date'].get(),
|
|
||||||
level=self.config['level'].get()):
|
|
||||||
yield job_advert
|
|
||||||
|
|
||||||
def validate_collection(self, objs, collection):
|
|
||||||
if collection.path_level == 0:
|
|
||||||
return
|
|
||||||
raise CollectionNotFound(collection.split_path)
|
|
||||||
|
|
||||||
def get_job_advert(self, _id, advert=None):
|
def get_job_advert(self, _id, advert=None):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class ApecTest(BackendTest):
|
||||||
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
||||||
|
|
||||||
def test_apec_advanced_search(self):
|
def test_apec_advanced_search(self):
|
||||||
l = list(self.backend.iter_resources([], []))
|
l = list(self.backend.advanced_search_job())
|
||||||
assert len(l)
|
assert len(l)
|
||||||
advert = self.backend.get_job_advert(l[0].id, None)
|
advert = self.backend.get_job_advert(l[0].id, None)
|
||||||
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from weboob.tools.backend import BaseBackend, BackendConfig
|
from weboob.tools.backend import BaseBackend, BackendConfig
|
||||||
from weboob.capabilities.collection import ICapCollection, CollectionNotFound
|
|
||||||
from weboob.tools.ordereddict import OrderedDict
|
from weboob.tools.ordereddict import OrderedDict
|
||||||
from weboob.tools.value import Value
|
from weboob.tools.value import Value
|
||||||
from weboob.capabilities.job import ICapJob
|
from weboob.capabilities.job import ICapJob
|
||||||
|
|
@ -29,7 +28,7 @@ from .job import LolixJobAdvert
|
||||||
__all__ = ['LolixBackend']
|
__all__ = ['LolixBackend']
|
||||||
|
|
||||||
|
|
||||||
class LolixBackend(BaseBackend, ICapJob, ICapCollection):
|
class LolixBackend(BaseBackend, ICapJob):
|
||||||
NAME = 'lolix'
|
NAME = 'lolix'
|
||||||
DESCRIPTION = u'Lolix French free software employment website'
|
DESCRIPTION = u'Lolix French free software employment website'
|
||||||
MAINTAINER = u'Bezleputh'
|
MAINTAINER = u'Bezleputh'
|
||||||
|
|
@ -138,20 +137,12 @@ class LolixBackend(BaseBackend, ICapJob, ICapCollection):
|
||||||
Value('contrat', label=u'Contrat', choices=contrat_choices),
|
Value('contrat', label=u'Contrat', choices=contrat_choices),
|
||||||
Value('limit_date', label=u'Date limite', choices=limit_date_choices))
|
Value('limit_date', label=u'Date limite', choices=limit_date_choices))
|
||||||
|
|
||||||
def iter_resources(self, objs, split_path):
|
def advanced_search_job(self):
|
||||||
with self.browser:
|
for advert in self.browser.advanced_search_job(region=self.config['region'].get(),
|
||||||
collection = self.get_collection(objs, split_path)
|
poste=self.config['poste'].get(),
|
||||||
if collection.path_level == 0:
|
contrat=int(self.config['contrat'].get()),
|
||||||
for advert in self.browser.advanced_search_job(region=self.config['region'].get(),
|
limit_date=self.config['limit_date'].get()):
|
||||||
poste=self.config['poste'].get(),
|
yield advert
|
||||||
contrat=int(self.config['contrat'].get()),
|
|
||||||
limit_date=self.config['limit_date'].get()):
|
|
||||||
yield advert
|
|
||||||
|
|
||||||
def validate_collection(self, objs, collection):
|
|
||||||
if collection.path_level == 0:
|
|
||||||
return
|
|
||||||
raise CollectionNotFound(collection.split_path)
|
|
||||||
|
|
||||||
def get_job_advert(self, _id, advert=None):
|
def get_job_advert(self, _id, advert=None):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class LolixTest(BackendTest):
|
||||||
BACKEND = 'lolix'
|
BACKEND = 'lolix'
|
||||||
|
|
||||||
def test_lolix_advanced_search(self):
|
def test_lolix_advanced_search(self):
|
||||||
l = list(self.backend.iter_resources([], []))
|
l = list(self.backend.advanced_search_job())
|
||||||
assert len(l)
|
assert len(l)
|
||||||
advert = self.backend.get_job_advert(l[0].id, l[0])
|
advert = self.backend.get_job_advert(l[0].id, l[0])
|
||||||
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
|
|
||||||
from weboob.tools.backend import BaseBackend, BackendConfig
|
from weboob.tools.backend import BaseBackend, BackendConfig
|
||||||
from weboob.capabilities.collection import ICapCollection, CollectionNotFound
|
|
||||||
from weboob.capabilities.job import ICapJob
|
from weboob.capabilities.job import ICapJob
|
||||||
from weboob.tools.value import Value
|
from weboob.tools.value import Value
|
||||||
from weboob.tools.ordereddict import OrderedDict
|
from weboob.tools.ordereddict import OrderedDict
|
||||||
|
|
@ -30,7 +29,7 @@ from .job import PopolemploiJobAdvert
|
||||||
__all__ = ['PopolemploiBackend']
|
__all__ = ['PopolemploiBackend']
|
||||||
|
|
||||||
|
|
||||||
class PopolemploiBackend(BaseBackend, ICapJob, ICapCollection):
|
class PopolemploiBackend(BaseBackend, ICapJob):
|
||||||
NAME = 'popolemploi'
|
NAME = 'popolemploi'
|
||||||
DESCRIPTION = u'Pole Emploi website'
|
DESCRIPTION = u'Pole Emploi website'
|
||||||
MAINTAINER = u'Bezleputh'
|
MAINTAINER = u'Bezleputh'
|
||||||
|
|
@ -205,18 +204,10 @@ class PopolemploiBackend(BaseBackend, ICapJob, ICapCollection):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.search_job(pattern=pattern)
|
return self.browser.search_job(pattern=pattern)
|
||||||
|
|
||||||
def iter_resources(self, objs, split_path):
|
def advanced_search_job(self):
|
||||||
with self.browser:
|
return self.browser.advanced_search_job(metier=self.config['metier'].get(),
|
||||||
collection = self.get_collection(objs, split_path)
|
place=self.config['place'].get(),
|
||||||
if collection.path_level == 0:
|
contrat=self.config['contrat'].get())
|
||||||
return self.browser.advanced_search_job(metier=self.config['metier'].get(),
|
|
||||||
place=self.config['place'].get(),
|
|
||||||
contrat=self.config['contrat'].get())
|
|
||||||
|
|
||||||
def validate_collection(self, objs, collection):
|
|
||||||
if collection.path_level == 0:
|
|
||||||
return
|
|
||||||
raise CollectionNotFound(collection.split_path)
|
|
||||||
|
|
||||||
def get_job_advert(self, _id, advert=None):
|
def get_job_advert(self, _id, advert=None):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class PopolemploiTest(BackendTest):
|
||||||
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
||||||
|
|
||||||
def test_popolemploi_advanced_search(self):
|
def test_popolemploi_advanced_search(self):
|
||||||
l = list(self.backend.iter_resources([], []))
|
l = list(self.backend.advanced_search_job())
|
||||||
assert len(l)
|
assert len(l)
|
||||||
advert = self.backend.get_job_advert(l[0].id, l[0])
|
advert = self.backend.get_job_advert(l[0].id, l[0])
|
||||||
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ class Handjoob(ReplApplication):
|
||||||
'job_advert': JobAdvertFormatter,
|
'job_advert': JobAdvertFormatter,
|
||||||
}
|
}
|
||||||
COMMANDS_FORMATTERS = {'search': 'job_advert_list',
|
COMMANDS_FORMATTERS = {'search': 'job_advert_list',
|
||||||
|
'ls': 'job_advert_list',
|
||||||
'info': 'job_advert',
|
'info': 'job_advert',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -99,6 +100,17 @@ class Handjoob(ReplApplication):
|
||||||
for backend, job_advert in self.do('search_job', pattern):
|
for backend, job_advert in self.do('search_job', pattern):
|
||||||
self.cached_format(job_advert)
|
self.cached_format(job_advert)
|
||||||
|
|
||||||
|
@defaultcount(10)
|
||||||
|
def do_ls(self, line):
|
||||||
|
"""
|
||||||
|
advanced search
|
||||||
|
|
||||||
|
Search for an advert matching to advanced filters.
|
||||||
|
"""
|
||||||
|
self.change_path([u'advanced'])
|
||||||
|
for backend, job_advert in self.do('advanced_search_job'):
|
||||||
|
self.cached_format(job_advert)
|
||||||
|
|
||||||
def complete_info(self, text, line, *ignored):
|
def complete_info(self, text, line, *ignored):
|
||||||
args = line.split(' ')
|
args = line.split(' ')
|
||||||
if len(args) == 2:
|
if len(args) == 2:
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,13 @@ class ICapJob(IBaseCap):
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
def advanced_search_job(self):
|
||||||
|
"""
|
||||||
|
Iter results of an advanced search
|
||||||
|
|
||||||
|
:rtype: iter[:class:`BaseJobAdvert`]
|
||||||
|
"""
|
||||||
|
|
||||||
def get_job_advert(self, _id, advert=None):
|
def get_job_advert(self, _id, advert=None):
|
||||||
"""
|
"""
|
||||||
Get an announce from an ID.
|
Get an announce from an ID.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue