text
stringlengths
0
828
continue
else:
os.unlink(hook_path)
source = os.path.join(sys.prefix, ""bin"", ""kwalitee-"" + hook)
os.symlink(os.path.normpath(source), hook_path)
return True"
1184,"def uninstall():
""""""Uninstall git hooks.""""""
ret, git_dir, _ = run(""git rev-parse --show-toplevel"")
if ret != 0:
click.echo(
""ERROR: Please run from within a GIT repository."",
file=sys.stderr)
raise click.Abort
git_dir = git_dir[0]
hooks_dir = os.path.join(git_dir, HOOK_PATH)
for hook in HOOKS:
hook_path = os.path.join(hooks_dir, hook)
if os.path.exists(hook_path):
os.remove(hook_path)
return True"
1185,"def find_promulgation_date(line):
""""""
>>> find_promulgation_date(""Loi nº 2010-383 du 16 avril 2010 autorisant l'approbation de l'accord entre..."")
'2010-04-16'
""""""
line = line.split(' du ')[1]
return format_date(re.search(r""(\d\d? \w\w\w+ \d\d\d\d)"", line).group(1))"
1186,"def historic_doslegs_parse(html, url_an=None, logfile=sys.stderr, nth_dos_in_page=0, parse_previous_works=True, parse_next_works=True):
""""""
Parse an AN dosleg like http://www.assemblee-nationale.fr/13/dossiers/accord_Montenegro_mobilite_jeunes.asp
nth_dos_in_page, parse_previous_works and parse_next_works are for internal logic
""""""
data = {
'url_dossier_assemblee': clean_url(url_an),
'urgence': False,
}
def log_error(*error):
print('## ERROR ###', *error, file=logfile)
def log_warning(*error):
print('## WARNING ###', *error, file=logfile)
soup = BeautifulSoup(html, 'lxml')
legislature, slug = parse_national_assembly_url(data['url_dossier_assemblee'])
data['assemblee_slug'] = slug
if legislature:
data['assemblee_legislature'] = legislature
else: # strange link (old dosleg)
log_error('NO LEGISLATURE IN AN LINK: ' + data['url_dossier_assemblee'])
data['assemblee_id'] = '%s-%s' % (data.get('assemblee_legislature', ''), data['assemblee_slug'])
data['steps'] = []
curr_institution = 'assemblee'
curr_stage = '1ère lecture'
last_section = None # Travaux des commissions/Discussion en séance publique
last_step_index = 0
travaux_prep_already = False
another_dosleg_inside = None
predicted_next_step = None # For unfinished projects, we try to catch the next step
previous_works = None
url_jo = None
html_lines = html.split('\n')
for i, line in enumerate(html_lines):
def parse_line():
return BeautifulSoup(line, 'lxml')
def line_text():
return parse_line().text.strip()
def get_last_step():
if len(data['steps']) > 0:
return data['steps'][-1]
return {}
if '<COMMENTAIRE>' in line or '<table border=""1""' in line:
continue
if '<font face=""ARIAL"" size=""3"" color=""#000080"">' in line:
data['long_title'] = line_text()
if '<br><b><font color=""#000099"">Travaux des commissions</font></b><br>' in line:
last_section = line_text()
if '<p align=""center""><b><font color=""#000080"">Travaux préparatoires</font></b><br>' in line:
if travaux_prep_already:
if parse_next_works and not nth_dos_in_page:
log_warning('FOUND ANOTHER DOSLEG INSIDE THE DOSLEG')
another_dosleg_inside = '\n'.join(html.split('\n')[last_step_index + 1:])
if not nth_dos_in_page:
break
travaux_prep_already = False
else:
travaux_prep_already = True