summaryrefslogtreecommitdiff
path: root/archaeological_operations/import_from_dbf.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@peacefrogs.net>2013-03-03 17:39:27 +0100
committerÉtienne Loks <etienne.loks@peacefrogs.net>2013-03-03 17:39:27 +0100
commit20898182ec24b990b7311977b684512701a2b892 (patch)
treef95aea2cf8bcded52e1949484aeb585e355f4e05 /archaeological_operations/import_from_dbf.py
parent2d79b1c2692eb5d8dbeff8e2b8b6652d4c1ad99a (diff)
downloadIshtar-20898182ec24b990b7311977b684512701a2b892.tar.bz2
Ishtar-20898182ec24b990b7311977b684512701a2b892.zip
Operations import: complete operation types
Diffstat (limited to 'archaeological_operations/import_from_dbf.py')
-rw-r--r--archaeological_operations/import_from_dbf.py72
1 files changed, 45 insertions, 27 deletions
diff --git a/archaeological_operations/import_from_dbf.py b/archaeological_operations/import_from_dbf.py
index 982e6785f..a3e35c291 100644
--- a/archaeological_operations/import_from_dbf.py
+++ b/archaeological_operations/import_from_dbf.py
@@ -21,6 +21,7 @@
Utils: import archaelogical operation from a DBF file
"""
+from __future__ import unicode_literals
import datetime
import dbf
@@ -44,41 +45,58 @@ def parse_ha(value):
return val * 10000
ope_types = {
- 'AET':None,
- 'APP':None,
- 'DOC':(u'documents_study',
- u'Étude documentaire'),
- 'EV':(u'evaluation',
- u'Évaluation'),
- 'FOU':(u'prev_excavation',
- u"Fouille archéologique préventive"),
- 'FP':(u'prog_excavation',
- u"Fouille archéologique programmée"),
- 'MH':(u'building_study', u"Étude de bâti (préventif)"),
- 'OPD':None,
- 'PCR':None,
- 'PMS':None,
- 'PRD':None,
- 'PRT':None,
- 'PRM':None,
- 'RAR':None,
- 'SD':(u'sampling_research',
- u"Sondage (préventif)"),
- 'SP':(u'prev_excavation',
- u"Fouille archéologique préventive"),
- 'SU':(u'emergency_excavation',
- u"Sauvetage urgent"),
+ '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':('diag_prev_excavation',
+ "Opération préventive de diagnostic", True),
+ 'PAN':('analysis_program',
+ "Programme d'analyses", False)
+ 'PCR':('collective_research_project',
+ "Projet collectif de recherche", False),
+ 'PMS':('specialized_equipment_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),
}
def parse_patriarche_operationtype(value):
if value not in ope_types.keys():
- print value
return None
if not ope_types[value]:
return None
- return OperationType.objects.get(txt_idx=ope_types[value][0])
+ txt_idx, name, preventive = ope_types[value]
+ ot, created = OperationType.objects.get_or_create(txt_idx=txt_idx,
+ defaults={'name':name, 'preventive':preventive})
+ return ot
PATRIARCHE_DBF_OPE_COLS = [
(('operation_type',), 'parse_patriarche_operationtype', []),
@@ -119,7 +137,7 @@ def import_from_dbf(filename, update=False, col_defs=DBF_OPE_COLS,
try:
table = dbf.Table(filename)
except (dbf.DbfError, TypeError):
- return 0, [u"Incorrect DBF file."]
+ return 0, ["Incorrect DBF file."]
new_ops, errors = import_operations_dbf(table, col_defs=col_defs,
update=update, person=person, stdout=stdout)