From c024b8b3a0d43f93d2e917dc090a51a7aabb9d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 5 Dec 2011 16:40:19 +0100 Subject: [PATCH] add some debugging and safety measures --- themis/libellioimport/migration.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/themis/libellioimport/migration.py b/themis/libellioimport/migration.py index 52e5940..fe3dff8 100644 --- a/themis/libellioimport/migration.py +++ b/themis/libellioimport/migration.py @@ -3,6 +3,7 @@ import cPickle import os import datetime +import time import cStringIO import xml.etree.ElementTree as ET @@ -522,6 +523,7 @@ class UpdateToBlobs(BrowserView): class SplitDocNumbers(BrowserView): def __call__(self): catalog = getToolByName(self.context, 'portal_catalog') + fd = file('/tmp/archive-numeros.%d' % int(time.time()%10000000), 'w') for count, brain in enumerate(catalog.search({'portal_type': ['bqrD', 'biqD', 'cr_seanceD', 'ProjetD', 'proposition_decret_reglementD', 'proposition_resolution_modificationD', 'PropositionD', @@ -541,6 +543,7 @@ class SplitDocNumbers(BrowserView): try: new_number = re.findall(r'(\d+) \(', attr_value)[0] except IndexError: + print 'object:', object.id print 'failed to get doc number for', attr_value continue no_suite = None @@ -548,8 +551,10 @@ class SplitDocNumbers(BrowserView): try: no_suite = re.findall(r'°\s*(\d+)', attr_value)[0] except IndexError: + print 'object:', object.id print 'failed to get suite number for', attr_value continue + print >> fd, object.id, attr_value setattr(object, attr, new_number) if no_suite: object.numero_suite = no_suite @@ -557,3 +562,4 @@ class SplitDocNumbers(BrowserView): notify(ObjectModifiedEvent(object)) if count%100 == 0: transaction.commit() + fd.close()