diff options
Diffstat (limited to 'archaeological_operations/import_from_dbf.py')
-rw-r--r-- | archaeological_operations/import_from_dbf.py | 77 |
1 files changed, 2 insertions, 75 deletions
diff --git a/archaeological_operations/import_from_dbf.py b/archaeological_operations/import_from_dbf.py index 6b20f6e10..1e3d6a0ea 100644 --- a/archaeological_operations/import_from_dbf.py +++ b/archaeological_operations/import_from_dbf.py @@ -31,7 +31,8 @@ from django.contrib.auth.models import User from django.db import transaction from archaeological_operations.import_from_csv import parse_operationtype, \ - parse_multivalue, parse_person as _parse_person, parse_date + parse_multivalue, parse_person as _parse_person, parse_date,\ + Column, parse_patriarche_operationtype, parse_ope_name from archaeological_operations.models import Operation, OperationType, Period, \ AdministrativeAct, ActType @@ -100,80 +101,6 @@ def parse_period(value): value = '' return _CACHED_PERIOD_TYPES[value] -ope_types = { - 'AET':('other_study', - 'Autre étude', True), - 'APP':('assistance_preparation_help', - 'Aide à la préparation de publication', True), - 'DOC':('documents_study', - 'Étude documentaire', True), - 'EV':('evaluation', - "Fouille d'évaluation", True), - 'FOU':('ancient_excavation', - "Fouille ancienne", True), - 'FP':('prog_excavation', - "Fouille programmée", False), - 'MH':('building_study', "Fouille avant MH", True), - 'OPD':('arch_diagnostic', - "Diagnostic archéologique", True), - 'PAN':('analysis_program', - "Programme d'analyses", False), - 'PCR':('collective_research_project', - "Projet collectif de recherche", False), - 'PMS':('specialized_eqp_prospection', - "Prospection avec matériel spécialisé", False), - 'PRD':('diachronic_prospection', - "Prospection diachronique", False), - 'PI':('diachronic_prospection', - "Prospection diachronique", False), - 'PRM':('metal_detector_prospection', - "Prospection détecteur de métaux", False), - 'PRT':('thematic_prospection', - "Prospection thématique", False), - 'PT':('thematic_prospection', - "Prospection thématique", False), - 'RAR':('cave_art_record', - "Relevé d'art rupestre", False), - 'SD':('sampling_research', - "Sondage", False), - 'SP':('prev_excavation', - "Fouille préventive", True), - 'SU':('emergency_excavation', - "Fouille préventive d'urgence", True), -} - -_CACHED_OPE_TYPES = {} - -def _prepare_ope_types(): - for k in ope_types.keys(): - txt_idx, label, preventive = ope_types[k] - ot, created = OperationType.objects.get_or_create(txt_idx=txt_idx, - defaults={'label':label, 'preventive':preventive}) - if k not in _CACHED_OPE_TYPES.keys(): - _CACHED_OPE_TYPES[k] = ot - -def parse_patriarche_operationtype(value): - if value not in _CACHED_OPE_TYPES.keys(): - return None - return _CACHED_OPE_TYPES[value] - -_dpt_re_filter = re.compile('^\([0-9]*\) ') - -def parse_ope_name(value): - if not value: - return '' - value = value.strip() - if value.lower() == 'null': - return '' - value = _dpt_re_filter.sub('', value) - return value - -class Column: - def __init__(self, col_models, format, associated_cols=None, multi=False): - self.col_models, self.format = col_models, format - self.associated_cols, self.multi = associated_cols, multi - - PATRIARCHE_DBF_OPE_COLS = [ Column(('operation_type',), 'parse_patriarche_operationtype'), Column(('common_name',), 'parse_ope_name'), |