Skip to content
Extraits de code Groupes Projets

Comparer les révisions

Les modifications sont affichées comme si la révision source était fusionnée avec la révision cible. En savoir plus sur la comparaison des révisions.

Source

Sélectionner le projet cible
No results found

Cible

Sélectionner le projet cible
  • la-quadrature-du-net/Attrap
  • foggyfrog/Attrap
  • skhwiz/Attrap
  • precambrien/Attrap
  • ketsapiwiq/Attrap
  • Joseki/Attrap
  • kr1p/attrap-pref-12
  • kr1p/attrap-pref-46
  • kr1p/attrap-pi
  • Guinness/Attrap
  • astroidgritty/attrap-pref-84
  • davinov/Attrap
  • maettellite/attrap-pref-01
  • m242/Attrap
  • multi/Attrap
  • mverdeil/Attrap
  • olpo/Attrap
17 résultats
Afficher les modifications
Validations sur la source (4)
......@@ -229,6 +229,11 @@ test_pref54:
PREF: "pref54"
extends: .default_pref
test_pref55:
variables:
PREF: "pref55"
extends: .default_pref
test_pref59:
variables:
PREF: "pref59"
......
......@@ -726,7 +726,7 @@ class Attrap:
"""
try:
search = re.search(regex, string, re.IGNORECASE)
guessed_date = dateparser.parse(search.group(1), languages=['fr'])
guessed_date = dateparser.parse(search.group(1), languages=['fr'], settings={'PREFER_DAY_OF_MONTH': 'last', 'PREFER_MONTH_OF_YEAR': 'last'})
if guessed_date is None:
raise Exception('La date est un objet None')
else:
......
......@@ -19,6 +19,7 @@ class Attrap_pref35(Attrap_prefdpt):
Attrap_prefdpt.DptSelectWidget(
'menu_deroulant',
regex=year_regex,
css_path='div.fr-select-group select#Archives-des-RAA-liste-docs.fr-select'
css_path='div.fr-select-group select#Archives-des-RAA-liste-docs.fr-select',
type='year'
)
)
......@@ -20,7 +20,8 @@ class Attrap_pref38(Attrap_prefdpt):
Attrap_prefdpt.select_widgets.append(
Attrap_prefdpt.DptSelectWidget(
'menu_deroulant',
regex='.*([0-9]*(?:er|ER)? [A-Za-zéÉûÛ]* [0-9]*)',
css_path='select#-liste-docs'
regex='([0-9]{1,2}[er]{0,1} [a-zéû]* [0-9]{4})',
css_path='select#-liste-docs',
type='year-month-day'
)
)
......@@ -18,6 +18,7 @@ class Attrap_pref54(Attrap_prefdpt):
Attrap_prefdpt.DptSelectWidget(
'menu_deroulant',
regex='.* du ([0-9]*(?:er|ER)? [A-Za-zéÉûÛ]* [0-9]*)',
css_path='select#Liste-liste-docs'
css_path='select#Liste-liste-docs',
type='year-month-day'
)
)
from Attrap_prefdpt import Attrap_prefdpt
class Attrap_pref55(Attrap_prefdpt):
# Configuration de la préfecture
hostname = 'https://www.meuse.gouv.fr'
raa_page = f'{hostname}/Publications/Recueil-des-Actes-Administratifs-RAA'
full_name = 'Préfecture de la Meuse'
short_code = 'pref55'
timezone = 'Europe/Paris'
# On configure le widget de menu déroulant
Attrap_prefdpt.select_widgets.append(
Attrap_prefdpt.DptSelectWidget(
'menu_deroulant',
regex='RAA année ([0-9]{4})',
css_path='select#Liste-des-recueils-liste-docs',
type='year'
)
)
......@@ -18,6 +18,7 @@ class Attrap_pref77(Attrap_prefdpt):
Attrap_prefdpt.DptSelectWidget(
'menu_deroulant',
regex='D77-([0-9]{2}-[0-9]{2}-[0-9]{4})',
css_path='select#Liste-liste-docs'
css_path='select#Liste-liste-docs',
type='year-month-day'
)
)
......@@ -90,12 +90,13 @@ class Attrap_prefdpt(Attrap):
class DptSelectWidget:
"""Une classe représentant un menu déroulant sur le site d'une préfecture de département."""
def __init__(self, name, regex=None, css_path=None, follow_link_on_unrecognised_date=True, exclude=[]):
def __init__(self, name, regex=None, css_path=None, follow_link_on_unrecognised_date=True, exclude=[], type='year-month-day'):
self.name = name
self.regex = regex
self.css_path = css_path
self.follow_link_on_unrecognised_date = follow_link_on_unrecognised_date
self.exclude = exclude
self.type = type
def add_url(self, url, date=None):
if date and date.year == 9999:
......@@ -243,10 +244,17 @@ class Attrap_prefdpt(Attrap):
if not option['value'] == "" and option['title'].strip() not in select_widget.exclude:
# On estime la date à partir du nom de fichier
date = Attrap.guess_date(option['title'].strip(), select_widget.regex)
match select_widget.type:
case 'year':
date = date.replace(day=1, month=1)
not_before = self.not_before.replace(day=1, month=1)
case 'year-month':
date = date.replace(day=1)
not_before = self.not_before.replace(day=1)
# Si la date estimée correspond à la plage d'analyse ou si follow_link_on_unrecognised_date est à True,
# on demande au serveur les détails du RAA
if (date.year < 9999 and date >= self.not_before) or (date.year == 9999 and select_widget.follow_link_on_unrecognised_date):
if (date.year < 9999 and date >= not_before) or (date.year == 9999 and select_widget.follow_link_on_unrecognised_date):
page_content = self.get_page(
page_url[0],
'post',
......
make: ppparis pref01 pref02 pref03 pref04 pref05 pref06 pref09 pref10 pref11 pref13 pref2a pref2b pref25 pref29 pref30 pref31 pref33 pref34 pref35 pref38 pref39 pref42 pref44 pref49 pref50 pref54 pref59 pref62 pref63 pref64 pref65 pref66 pref69 pref73 pref75 pref77 pref80 pref81 pref83 pref87 pref91 pref92 pref93 pref94 pref976 prefidf prefpaca
make: ppparis pref01 pref02 pref03 pref04 pref05 pref06 pref09 pref10 pref11 pref13 pref2a pref2b pref25 pref29 pref30 pref31 pref33 pref34 pref35 pref38 pref39 pref42 pref44 pref49 pref50 pref54 pref55 pref59 pref62 pref63 pref64 pref65 pref66 pref69 pref73 pref75 pref77 pref80 pref81 pref83 pref87 pref91 pref92 pref93 pref94 pref976 prefidf prefpaca
ppparis:
bin/python3 cli.py ppparis
pref01:
......@@ -53,6 +53,8 @@ pref50:
bin/python3 cli.py pref50
pref54:
bin/python3 cli.py pref54
pref55:
bin/python3 cli.py pref55
pref59:
bin/python3 cli.py pref59
pref62:
......
......@@ -83,6 +83,7 @@ Vous pouvez également activer le safe mode en spécifiant la variable d'environ
- Préfecture de Maine-et-Loire (identifiant : `pref49`)
- Préfecture de la Manche (identifiant : `pref50`)
- Préfecture de Meurthe-et-Moselle (identifiant : `pref54`)
- Préfecture de la Meuse (identifiant : `pref55`)
- Préfecture du Nord (identifiant : `pref59`)
- Préfecture du Pas-de-Calais (identifiant : `pref62`)
- Préfecture du Puy-de-Dôme (identifiant : `pref63`)
......
......@@ -71,6 +71,7 @@ available_administrations = [
'pref49',
'pref50',
'pref54',
'pref55',
'pref59',
'pref62',
'pref63',
......