Ejemplo n.º 1
0
def main(package_name, resource_re, output_file_name):
    """Download a resource from Emploi Store as a CSV.

    Args:
        - package_name: "bmo", "imt" or another package name.
        - resource_re: a regular expression to match the resource's name within
          the package, e.g. ".*2014.*"
        - output_file_name: path to the CSV file to write.

    To use this script you first have to create a `client_id` and a `client_secret` for
    an [Emploi Store app](https://www.emploi-store-dev.fr). When you have these access
    credentials, set the environment variables EMPLOI_STORE_CLIENT_ID and
    EMPLOI_STORE_CLIENT_SECRET with them.

    For Bayes internal use visit http://go/pe:api-credentials
    """

    # The client ID and Secret have been created by Pascal
    # ([email protected]) for an app called MyGamePlan on the Emploi Store
    # Dev website. Don't spread those identifiers.
    client = emploi_store.Client(
        client_id=os.getenv('EMPLOI_STORE_CLIENT_ID'),
        client_secret=os.getenv('EMPLOI_STORE_CLIENT_SECRET'))
    package = client.get_package(package_name)
    resource = package.get_resource(name_re=re.compile(resource_re))
    resource.to_csv(output_file_name, iterator=tqdm.tqdm)
 def setUp(self):
     super(ResourceTest, self).setUp()
     _client = emploi_store.Client('my-ID', 'my-Secret')
     self.res = emploi_store.Resource(_client,
                                      name='BMO 2016',
                                      id='1234-abc')
     self.tmpdir = tempfile.mkdtemp()
Ejemplo n.º 3
0
def get_lbb_companies(
    project: project_pb2.Project,
    distance_km: float = 10,
    contract: Optional[str] = None,
) -> Iterator[Dict[str, str]]:
    """Retrieve a list of companies from LaBonneBoite API."""

    if not _EMPLOI_STORE_DEV_CLIENT_ID or not _EMPLOI_STORE_DEV_SECRET:
        logging.warning('Missing Emploi Store Dev identifiers.')
        return

    client = emploi_store.Client(client_id=_EMPLOI_STORE_DEV_CLIENT_ID,
                                 client_secret=_EMPLOI_STORE_DEV_SECRET)
    try:
        companies = client.get_lbb_companies(
            city_id=project.city.city_id,
            rome_codes=[project.target_job.job_group.rome_id],
            distance=distance_km,
            contract=contract)
        yield from companies
    except (IOError, ValueError) as error:
        logging.error(
            'Error while calling LBB API: %s\nCity: %s\nJob group: %s', error,
            project.city.city_id, project.target_job.job_group)
        return
Ejemplo n.º 4
0
def main(output: TextIO, rome: str = DEFAULT_ROME_OPTIONS) -> None:
    """Retrieve a list of skills from MatchviaSoftSkills API.
    https://www.emploi-store-dev.fr/portail-developpeur-cms/home/catalogue-des-api/documentation-des-api/api-matchviasoftskills-v1.html
    """

    if not _EMPLOI_STORE_DEV_CLIENT_ID or not _EMPLOI_STORE_DEV_SECRET:
        logging.warning('Missing Emploi Store Dev identifiers.')
        return

    client = emploi_store.Client(client_id=_EMPLOI_STORE_DEV_CLIENT_ID,
                                 client_secret=_EMPLOI_STORE_DEV_SECRET)

    if rome == 'all':
        romes = list(cleaned_data.rome_job_groups().index)
    else:
        romes = [rome]

    if not romes:
        logging.warning('Missing job group identifiers.')
        return

    writer = csv.DictWriter(output, fieldnames=_SoftSkill._fields)
    writer.writeheader()

    for rome in romes:
        try:
            skills = client.get_match_via_soft_skills(rome=rome)

            for fields in _create_skill_csv_lines(rome, skills):
                writer.writerow(fields._asdict())
        except (IOError) as error:
            logging.error(
                'Error while calling MatchviaSoftSkills API: %s\nJob group: %s',
                error, rome)
            return
Ejemplo n.º 5
0
def main():
    """Download the "Référentiel des familles de métier" from the API."""
    client = emploi_store.Client()
    bmo_package = client.get_package('bmo')
    fap_ref = bmo_package.get_resource(
        name=u'Référentiel des familles de métier')
    fap_ref.to_csv('ref_fap.csv')
def _iterate_job_offers():
    client = emploi_store.Client(
        client_id=os.getenv('EMPLOI_STORE_CLIENT_ID'),
        client_secret=os.getenv('EMPLOI_STORE_CLIENT_SECRET'))
    package = client.get_package('offres')
    resource = package.get_resource(name="Offres d'emploi")
    return resource.records(fields=[
        'DEPARTEMENT_CODE', 'ROME_PROFESSION_CARD_CODE'])
Ejemplo n.º 7
0
def get_lbb_companies(project):
    """Retrieve a list of companies from LaBonneBoite API."""
    if not _EMPLOI_STORE_DEV_CLIENT_ID or not _EMPLOI_STORE_DEV_SECRET:
        logging.warning('Missing Emploi Store Dev identifiers.')
        return

    client = emploi_store.Client(client_id=_EMPLOI_STORE_DEV_CLIENT_ID,
                                 client_secret=_EMPLOI_STORE_DEV_SECRET)
    try:
        companies = client.get_lbb_companies(
            city_id=project.mobility.city.city_id,
            rome_codes=[project.target_job.job_group.rome_id])
        for company in companies:
            yield company
    except IOError as error:
        logging.error(
            'Error while calling LBB API: %s\nCity: %s\nJob group: %s', error,
            project.mobility.city.city_id, project.target_job.job_group)
        return
Ejemplo n.º 8
0
def main(json_file_name: str) -> None:
    """Download all online events from Emploi Store as a JSON.

    To use this script you first have to create a `client_id` and a `client_secret` for
    an [Emploi Store app](https://www.emploi-store-dev.fr). When you have these access
    credentials, set the environment variables EMPLOI_STORE_CLIENT_ID and
    EMPLOI_STORE_CLIENT_SECRET with them.

    For Bayes internal use visit http://go/pe:api-credentials
    """

    # The client ID and Secret have been created by Pascal
    # ([email protected]) for an app called MyGamePlan on the Emploi Store
    # Dev website. Don't spread those identifiers.
    client = emploi_store.Client(
        client_id=os.getenv('EMPLOI_STORE_CLIENT_ID'),
        client_secret=os.getenv('EMPLOI_STORE_CLIENT_SECRET'))
    salons = client.list_online_events()
    with open(json_file_name, 'w', encoding='utf-8') as outfile:
        json.dump(salons, outfile)
 def setUp(self):
     super(PackageTest, self).setUp()
     self._client = emploi_store.Client('my-ID', 'my-Secret')
 def setUp(self):
     super(ClientTestCase, self).setUp()
     self.client = emploi_store.Client('my-ID', 'my-Secret')
Ejemplo n.º 11
0
There are few environment variables that allow you to specify how to run the
server:
 - DEBUG: set it to 1 to turn on debug mode.
 - PORT: set it to the port you want the server to listen on.
 - BIND_HOST: set it to 0.0.0.0 to listen on all interfaces.
"""
import os
import re

import emploi_store
import flask

app = flask.Flask(__name__)  # pylint: disable=invalid-name

# Access to the ROME appellations resource on Emploi Store Dev.
_ROME_APPELLATIONS = (emploi_store.Client().get_package('rome').get_resource(
    name_re=re.compile(r'.*appellations.*')))


@app.route("/")
def main():
    """Homepage."""
    page = ('<form action=".">'
            '<input name="rome" placeholder="ROME code, e.g. F1402"/>'
            '</form>')
    rome = flask.request.args.get('rome', '')
    if rome:
        page += '<ul>'
        filters = {'ROME_PROFESSION_CARD_CODE': rome}
        for appellation in _ROME_APPELLATIONS.records(filters=filters):
            page += '<li>%s</li>' % appellation['ROME_PROFESSION_NAME']
        page += '</ul>'