regardscitoyens / the-law-factory-parser

Data generator for the-law-factory project
https://www.lafabriquedelaloi.fr
GNU General Public License v3.0
45 stars 9 forks source link

Catch and fix new AN text urls #120

Open boogheta opened 5 years ago

boogheta commented 5 years ago
pjl18-084
 -= DOSLEG URL: http://www.senat.fr/dossier-legislatif/pjl18-084.html =-
  [] download SENAT version
  [] parse SENAT version
  [] download AN version
  [] parse AN version
[warning] [merge] more anomalies in the steps after the merge: https://www.senat.fr/dossier-legislatif/pjl18-084.html
INCORRECT CMP • CMP • commission -> promulgation • gouvernement
https://www.senat.fr/dossier-legislatif/pjl18-084.html | http://www.assemblee-nationale.fr/dyn/15/dossiers/convention_luxembourg_doubles_impositions

1 anomalies ( 1 doslegs)
        title: projet de loi autorisant l'approbation de la convention entre le Gouvernement de la République française et le Gouvernement du Grand-Duché de Luxembourg en vue d'éviter les doubles impositions et 
de prévenir l'évasion et la fraude fiscales en matière d'impôts
  [] parse the texts
** parsing texts
    ^ text:  https://www.senat.fr/leg/pjl18-084.html
    ^ text:  https://www.senat.fr/leg/pjl18-191.html
    ^ text:  https://www.senat.fr/leg/tas18-040.html
    ^ text:  http://www2.assemblee-nationale.fr/documents/notice/15/projets/pl1507/(index)/depots
     * ignore missing intermediary depot http://www2.assemblee-nationale.fr/documents/notice/15/projets/pl1507/(index)/depots

which then makes tlfp/tools/common crash on identifying legislature and number among other things

mdamien commented 4 years ago

La fabrique va avoir du mal à se mettre à jour car l'AN a enlevé l'ancien accés aux textes.

Par exemple ce lien, qui fonctionnait avant: http://www.assemblee-nationale.fr/15/projets/pl2623.asp

Renvoi vers ce nouveau lien: http://www.assemblee-nationale.fr/dyn/15/textes/l15b2623_projet-loi

Le texte n'étant pas réellement sur cette page mais dans une iframe dont l'URL est facile à deviner: http://www.assemblee-nationale.fr/dyn/docs/PRJLANR5L15B2623.raw

Cela à l'air d'être vrai pour tout les textes de cette legislature.

Bonne nouvelle cependant, le HTML de ces nouvelles urls en .raw est bien annoté (titre section, titre article)

boogheta commented 4 years ago

Oui on a commencé à constater ça avec @paulineleon sur ND, en soit c un progrès pour les textes à venir, par contre c'est un gros travail de refonte à faire :( https://github.com/regardscitoyens/nosdeputes.fr/pull/132

mdamien commented 4 years ago

C'est parti pour essayer de reposer l'accés sur le dépôt assemblee-textes : https://git.en-root.org/tricoteuses/data/assemblee-textes/issues/1

mdamien commented 4 years ago

Petit point d'étape: la PR est acceptée et les textes récents passent mais en faisant le reparse_all, j'ai encore une centaine de regressions, maintenant le boulot c'est de reduire ces regressions

Liste des regressions et le pourquoi:

pjl13-792 : raise Exception('[parse_texts] Empty parsing %s' % url)
pjl15-822 : raise Exception('[parse_texts] Empty parsing %s' % url)
pjl16-164 : link = soup.select_one('.docOpaqueLink').select('a')[-1]
pjl16-525 : raise Exception('[parse_texts] Empty parsing %s' % url)
pjl16-529 : raise Exception('[parse_texts] Empty parsing %s' % url)
pjl16-576 : link = soup.select_one('.docOpaqueLink').select('a')[-1]
pjl16-582 : assert are_same_doslegs(senat_dos, an_dos)
pjl16-643 : raise Exception('[parse_texts] Empty parsing %s' % url)
pjl17-036 : raise Exception('[parse_texts] Empty parsing %s' % url)
pjl17-067 : raise Exception('[complete_articles] Fatal error')
pjl17-155 : self.parlementaires[urlapi][slug] = requests.get(parl_link(slug, urlapi)+"/json").json()[typeparl]
pjl17-296 : raise Exception('[complete_articles] Fatal error')
pjl17-360 : raise Exception('[parse_texts] Empty parsing %s' % url)
pjl17-463 : self.parlementaires[urlapi][slug] = requests.get(parl_link(slug, urlapi)+"/json").json()[typeparl]
pjl17-464 : self.parlementaires[urlapi][slug] = requests.get(parl_link(slug, urlapi)+"/json").json()[typeparl]
pjl17-487 : raise Exception('[complete_articles] Fatal error')
pjl17-525 : self.parlementaires[urlapi][slug] = requests.get(parl_link(slug, urlapi)+"/json").json()[typeparl]
pjl17-567 : self.parlementaires[urlapi][slug] = requests.get(parl_link(slug, urlapi)+"/json").json()[typeparl]
pjl17-583 : raise Exception('[complete_articles] Fatal error')
pjl17-595 : raise TextParsingFailedException('Duplicate article title found: %s' % article.get('titre'))
pjl17-704 : raise Exception('[parse_texts] Empty parsing %s' % url)
pjl18-028 : print("ERROR: Problem while renumbering sections: ", line['titre'], " is not ", cursec, '\n', file=sys.stderr)
pjl18-157 : raise Exception("ERROR: amendements JSON at %s is badly formatted, it should probably be hardcached on ND/NS" % amdt_url)
pjl18-198 : raise Exception('[complete_articles] Fatal error')
pjl18-274 : assert are_same_doslegs(senat_dos, an_dos)
pjl18-594 : raise Exception('[parse_texts] Invalid response %s' % url)
pjl18-660 : raise Exception("ERROR: amendements JSON at %s is badly formatted, it should probably be hardcached on ND/NS" % amdt_url)
pjl18-677 : raise Exception("ERROR: amendements JSON at %s is badly formatted, it should probably be hardcached on ND/NS" % amdt_url)
pjlf2014 : raise Exception("ERROR: amendements JSON at %s is badly formatted, it should probably be hardcached on ND/NS" % amdt_url)
pjlf2015 : raise Exception("ERROR: amendements JSON at %s is badly formatted, it should probably be hardcached on ND/NS" % amdt_url)
pjlf2016 : raise Exception("ERROR: amendements JSON at %s is badly formatted, it should probably be hardcached on ND/NS" % amdt_url)
pjlf2017 : raise Exception("ERROR: amendements JSON at %s is badly formatted, it should probably be hardcached on ND/NS" % amdt_url)
pjlf2018 : raise Exception('[complete_articles] Fatal error')
pjlf2019 : self.parlementaires[urlapi][slug] = requests.get(parl_link(slug, urlapi)+"/json").json()[typeparl]
plfss2019 : self.parlementaires[urlapi][slug] = requests.get(parl_link(slug, urlapi)+"/json").json()[typeparl]
ppl11-026 : raise Exception('[parse_texts] Empty parsing %s' % url)
ppl17-565 : raise TextParsingFailedException('Duplicate article title found: %s' % article.get('titre'))
ppl19-319 : raise TextParsingFailedException('Duplicate article title found: %s' % article.get('titre'))

Fait avec ce script:

doslegs = """<liste des doslegs en regression>""".split("\n")

for dosleg in doslegs:
    try:
        log = open("data.20200525/logs/" + dosleg).read()
    except:
        log = open("data.20200525/logs-encours/" + dosleg).read()
    last_line = log.split('\n')[-3].strip()
    print(dosleg, ':', last_line)

EDIT: Avec https://github.com/regardscitoyens/the-law-factory-parser/commit/c9d16d02cdfd79c8be3909a24811838702340cd2 , on est descendu à 70 regressions

EDIT (29 mai): Et avec https://github.com/regardscitoyens/the-law-factory-parser/commit/d35194680ad2cda7beb450ebf8357f1369461311 , on est descendu à 57 regressions

EDIT (1 juin): Hop, plus que 38 !