Example #1
0
        print(circuit_blo['info'])
        if cree > 0:
            found_circuit.creation_date = cree
        if renove > 0:
            found_circuit.renovation_date = renove
        if descriptif:
            found_circuit.note = descriptif

####################################################################################################

with open('html-data/blo/json/blo.json', encoding='utf8') as f:
    secteurs = json.load(f)

for secteur in secteurs:
    for massif in secteur['items']:
        for circuit_blo in massif['items']:
            if 'items' in circuit_blo:
                boulders = circuit_blo['items']
                number_of_boulders = len(boulders)
                if number_of_boulders > 1:
                    merge_circuit(circuit_blo)

if args.rewrite is not None:
    bleau_database.to_json(args.rewrite)

####################################################################################################
#
# End
#
####################################################################################################
####################################################################################################

bleau_database = BleauDataBase()

parser = MyHTMLParser(MassifExporter())
html_file = os.path.join('html-data', 'massif.html')
with open(html_file) as f:
    source = f.read()
    parser.feed(source)
for massif in parser.items:
    bleau_database.add_massif(massif)

parser = MyHTMLParser(CircuitExporter(bleau_database))
for i in range(1, 5):
    html_file = os.path.join('html-data', 'circuit{}.html'.format(i))
    with open(html_file) as f:
        source = f.read()
        parser.feed(source)
for circuit in parser.items:
    bleau_database.add_circuit(circuit)

json_file = 'bleau-raw.json'
bleau_database.to_json(json_file)

####################################################################################################
#
# End
#
####################################################################################################