From 8666b398cd9ec7affb2dbcf9dc08f17434133c61 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 7 Mar 2013 17:53:24 +0100 Subject: Operations import: filter name --- archaeological_operations/import_from_dbf.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'archaeological_operations') diff --git a/archaeological_operations/import_from_dbf.py b/archaeological_operations/import_from_dbf.py index 5c3d942d7..b539d3a51 100644 --- a/archaeological_operations/import_from_dbf.py +++ b/archaeological_operations/import_from_dbf.py @@ -25,6 +25,7 @@ from __future__ import unicode_literals import datetime import dbf +import re from django.contrib.auth.models import User from django.db import transaction @@ -102,9 +103,20 @@ def parse_patriarche_operationtype(value): 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 + PATRIARCHE_DBF_OPE_COLS = [ (('operation_type',), 'parse_patriarche_operationtype', []), - (('common_name',), unicode, []), + (('common_name',), 'parse_ope_name', []), [], (('in_charge',), 'parse_person', [2]), [], #'etat', -- cgit v1.2.3