# Path: tlfp/tools/parse_texte.py
# class TextParsingFailedException(Exception):
# def word_to_number(word):
# def non_recursive_find_all(node, should_be_parsed, should_be_ignored):
# def clean_extra_expose_des_motifs(html):
# def clean_extra_expose_des_motifs_v2(html):
# def romans(n):
# def lower_but_first(text):
# def clean_full_upcase(text):
# def clean_html(t):
# def check_section_is_not_a_duplicate(section_id, articles):
# def add_to_articles(dic, all_articles):
# def normalize_1(name, one):
# def normalize_section_title(line, line_soup, has_multiple_expose):
# def clean_article_name(text):
# def parse(url, resp=None, DEBUG=False, include_annexes=False):
#     def pr_js(article):
#     def should_be_parsed(x):
#     def should_be_ignored(x):
#     NEW_LINE_MARKER = 'NEW_LINE_MARKER'
#     READ_DISABLED = -1 # the text is not detected yet
#     READ_TEXT = 0 # read the text
#     READ_TITLE = 1 # titles lecture
#     READ_ALINEAS = 2 # alineas lecture


import sys
from tlfp.tools import parse_texte
    from lawfactory_utils.urls import enable_requests_cache

if "--enable-cache" in sys.argv:

    enable_requests_cache()

print("> testing parse_texte without annexes (default)")
result = parse_texte.parse(
    "https://web.archive.org/web/20191104051233/http://www.assemblee-nationale.fr/15/ta-commission/r1056-a0.asp"
)
article = result[-1]
assert article["type"] == "article"
print("     > OK")

print("> testing parse_texte annexes from AN")
result = parse_texte.parse(
    "https://web.archive.org/web/20191104051233/http://www.assemblee-nationale.fr/15/ta-commission/r1056-a0.asp",
    include_annexes=True,
)
assert len(result) == 94, len(result)
annexe = result[-1]
assert annexe["type"] == "annexe", annexe["type"]
assert annexe["order"] == 82, annexe["order"]
assert annexe["statut"] == "none", annexe["statut"]
assert (
    annexe["titre"] == "Stratégie nationale d'orientation de l'action publique"
), annexe["titre"]
assert len(annexe["alineas"]) == 29, len(annexe["alineas"])
print("     > OK")

print("> testing parse_texte annexes from Senat")

# Path: tlfp/tools/parse_texte.py
# class TextParsingFailedException(Exception):
# def word_to_number(word):
# def non_recursive_find_all(node, should_be_parsed, should_be_ignored):
# def clean_extra_expose_des_motifs(html):
# def clean_extra_expose_des_motifs_v2(html):
# def romans(n):
# def lower_but_first(text):
# def clean_full_upcase(text):
# def clean_html(t):
# def check_section_is_not_a_duplicate(section_id, articles):
# def add_to_articles(dic, all_articles):
# def normalize_1(name, one):
# def normalize_section_title(line, line_soup, has_multiple_expose):
# def clean_article_name(text):
# def parse(url, resp=None, DEBUG=False, include_annexes=False):
#     def pr_js(article):
#     def should_be_parsed(x):
#     def should_be_ignored(x):
#     NEW_LINE_MARKER = 'NEW_LINE_MARKER'
#     READ_DISABLED = -1 # the text is not detected yet
#     READ_TEXT = 0 # read the text
#     READ_TITLE = 1 # titles lecture
#     READ_ALINEAS = 2 # alineas lecture


# Path: tests/test_parse_annexes.py
import sys
from tlfp.tools import parse_texte
    from lawfactory_utils.urls import enable_requests_cache


if "--enable-cache" in sys.argv:

    enable_requests_cache()

print("> testing parse_texte without annexes (default)")
result = parse_texte.parse(
    "https://web.archive.org/web/20191104051233/http://www.assemblee-nationale.fr/15/ta-commission/r1056-a0.asp"
)
article = result[-1]
assert article["type"] == "article"
print("     > OK")

print("> testing parse_texte annexes from AN")
result = parse_texte.parse(
    "https://web.archive.org/web/20191104051233/http://www.assemblee-nationale.fr/15/ta-commission/r1056-a0.asp",
    include_annexes=True,
)
assert len(result) == 94, len(result)
annexe = result[-1]
assert annexe["type"] == "annexe", annexe["type"]
assert annexe["order"] == 82, annexe["order"]
assert annexe["statut"] == "none", annexe["statut"]
assert (
    annexe["titre"] == "Stratégie nationale d'orientation de l'action publique"
), annexe["titre"]
assert len(annexe["alineas"]) == 29, len(annexe["alineas"])
print("     > OK")

print("> testing parse_texte annexes from Senat")

result = parse_texte.parse(