init depot renew
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
# SHELL COMMAND
|
||||
# source venv/bin/activate
|
||||
# flask shell
|
||||
|
||||
import os
|
||||
import logging
|
||||
from zipfile import ZipFile
|
||||
import importlib.resources
|
||||
|
||||
from apptax.taxonomie.commands.utils import truncate_bdc_statuts
|
||||
from apptax.database import db
|
||||
from apptax.taxonomie.commands.utils import (
|
||||
copy_from_csv,
|
||||
refresh_taxref_vm,
|
||||
populate_bdc_statut_cor_text_area,
|
||||
)
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
BASE_URL = "/home/geonatureadmin/tmp"
|
||||
zipfile = "BDC-Statuts-v17.zip"
|
||||
status_types_file = "BDC-Statuts-v17/BDC_STATUTS_TYPES_17.csv"
|
||||
status_file = "BDC-Statuts-v17/BDC_STATUTS_17.csv"
|
||||
|
||||
truncate_bdc_statuts()
|
||||
db.session.commit()
|
||||
|
||||
|
||||
archive = ZipFile(os.path.join(BASE_URL, zipfile), "r")
|
||||
with archive.open(status_file) as f:
|
||||
logger.info("Insert BDC statuts…")
|
||||
copy_from_csv(
|
||||
f,
|
||||
"bdc_statut",
|
||||
dest_cols=(
|
||||
"cd_nom",
|
||||
"cd_ref",
|
||||
"cd_sup",
|
||||
"cd_type_statut",
|
||||
"lb_type_statut",
|
||||
"regroupement_type",
|
||||
"code_statut",
|
||||
"label_statut",
|
||||
"rq_statut",
|
||||
"cd_sig",
|
||||
"cd_doc",
|
||||
"lb_nom",
|
||||
"lb_auteur",
|
||||
"nom_complet_html",
|
||||
"nom_valide_html",
|
||||
"regne",
|
||||
"phylum",
|
||||
"classe",
|
||||
"ordre",
|
||||
"famille",
|
||||
"group1_inpn",
|
||||
"group2_inpn",
|
||||
"lb_adm_tr",
|
||||
"niveau_admin",
|
||||
"cd_iso3166_1",
|
||||
"cd_iso3166_2",
|
||||
"full_citation",
|
||||
"doc_url",
|
||||
"thematique",
|
||||
"type_value",
|
||||
),
|
||||
)
|
||||
|
||||
logger.info("Populate BDC statuts…")
|
||||
db.session.execute(
|
||||
importlib.resources.read_text("apptax.migrations.data", "taxonomie_bdc_statuts.sql")
|
||||
)
|
||||
|
||||
populate_bdc_statut_cor_text_area(logger)
|
||||
refresh_taxref_vm()
|
||||
db.session.commit()
|
||||
|
||||
exit()
|
||||
|
||||
# flask taxref link-bdc-statut-to-areas
|
||||
# flask taxref enable-bdc-statut-text --clean -d 38
|
||||
Reference in New Issue
Block a user