| author | cavaliet |
| Tue, 03 Sep 2013 13:05:55 +0200 | |
| changeset 22 | 48ff361f96c8 |
| parent 14 | 52fa6990e0bb |
| child 97 | 12bbec897e48 |
| child 101 | 71532a54d1c4 |
| permissions | -rw-r--r-- |
| 0 | 1 |
# -*- coding: utf-8 -*- |
2 |
||
| 6 | 3 |
from django.core.management import BaseCommand |
4 |
from django.db import reset_queries, transaction |
|
5 |
from optparse import make_option |
|
6 |
from p4l.models import Record, Language |
|
|
13
6296aa12fd71
model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents:
7
diff
changeset
|
7 |
from p4l.utils import show_progress |
| 0 | 8 |
from rdflib import Graph, Namespace, BNode, URIRef |
9 |
from rdflib.plugins.sparql import prepareQuery |
|
| 6 | 10 |
import logging |
| 0 | 11 |
import xml.etree.cElementTree as ET |
12 |
||
13 |
logger = logging.getLogger(__name__) |
|
14 |
||
15 |
||
16 |
RDF = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#") |
|
17 |
RDFS = Namespace("http://www.w3.org/2000/01/rdf-schema#") |
|
18 |
DCT = Namespace("http://purl.org/dc/terms/") |
|
19 |
IIEP = Namespace("http://www.iiep.unesco.org/plan4learning/model.owl#") |
|
20 |
UNESCO = Namespace("http://www.iiep.unesco.org/Ontology/") |
|
21 |
||
22 |
DEFAULT_LANGUAGE_URI = "http://psi.oasis-open.org/iso/639/#eng" |
|
23 |
||
24 |
DEFAULT_LANGUAGE_QUERY = """SELECT ( COALESCE(?lang, ?other_lang) as ?main_lang) WHERE { |
|
25 |
OPTIONAL { ?s dct:language ?lang }. |
|
26 |
OPTIONAL { ?s iiep:otherLanguage ?other_lang }. |
|
27 |
}""" |
|
28 |
||
29 |
||
30 |
class Command(BaseCommand): |
|
31 |
||
32 |
args = "record_url ..." |
|
33 |
||
34 |
help = "Import p4l record rdf format" |
|
35 |
||
36 |
option_list = BaseCommand.option_list + ( |
|
37 |
make_option('-b', '--batch-size', |
|
38 |
dest= 'batch_size', |
|
39 |
type='int', |
|
40 |
default= 50, |
|
41 |
help= 'number of object to import in bulk operations' |
|
42 |
), |
|
43 |
) |
|
44 |
||
45 |
def __init__(self, *args, **kwargs): |
|
46 |
super(Command, self).__init__(*args, **kwargs) |
|
47 |
self.__query_cache = {} |
|
48 |
||
49 |
||
50 |
def __get_sparql_query(self, query, namespaces): |
|
51 |
||
52 |
return self.__query_cache[query] \ |
|
53 |
if query in self.__query_cache \ |
|
54 |
else self.__query_cache.setdefault(query, prepareQuery(query, initNs=namespaces)) |
|
55 |
||
56 |
def get_empty_graph(self): |
|
57 |
record_graph = Graph() |
|
58 |
record_graph.bind('iiep',"http://www.iiep.unesco.org/plan4learning/model.owl#") |
|
59 |
record_graph.bind('dct',"http://purl.org/dc/terms/") |
|
60 |
return record_graph |
|
61 |
||
62 |
def extract_single_value_form_graph(self, graph, q, bindings={}, index=0, convert=lambda v:unicode(v) if v is not None else None): |
|
63 |
return next(self.extract_multiple_values_from_graph(graph, q, bindings, index, convert), None) |
|
64 |
||
65 |
def extract_multiple_values_from_graph(self, graph, q, bindings={}, index=0, convert=lambda v:unicode(v) if v is not None else None): |
|
66 |
||
67 |
index_list = index |
|
68 |
if isinstance(index, int): |
|
69 |
index_list = range(index+1) |
|
70 |
||
71 |
if hasattr(convert, '__call__'): |
|
72 |
convert_dict = dict((k, convert) for k in index_list) |
|
73 |
else: |
|
74 |
convert_dict = convert |
|
75 |
||
76 |
convert_dict = dict((k, f if hasattr(f,'__call__') else lambda v:unicode(v) if v is not None else None) for k,f in convert_dict.iteritems()) |
|
77 |
||
78 |
for row in graph.query(self.__get_sparql_query(q, dict(graph.namespaces())), initBindings=bindings): |
|
79 |
if len(row) < len(index_list): |
|
80 |
break |
|
81 |
else: |
|
82 |
res = dict([ (k, convert_dict.get(k, lambda v:unicode(v) if v is not None else None)(v)) for k, v in zip(index_list, row)]) |
|
83 |
if isinstance(index, int): |
|
84 |
yield res[index] |
|
85 |
else: |
|
86 |
yield res |
|
87 |
||
88 |
||
89 |
def convert_bool(self, val): |
|
90 |
if val == True or val == False: |
|
91 |
return val |
|
92 |
if val is None: |
|
93 |
return False |
|
94 |
if isinstance(val, basestring): |
|
95 |
if len(val) == 0: |
|
96 |
return False |
|
97 |
if val[0].lower() in ['t','y','1','o']: |
|
98 |
return True |
|
99 |
else: |
|
100 |
return False |
|
101 |
return bool(val) |
|
102 |
||
103 |
||
104 |
def add_to_related_collection(self, coll, graph, fields, q, bindings={}, convert=lambda v: unicode(v) if v is not None else None, through_fields=None): |
|
105 |
||
106 |
for val in self.extract_multiple_values_from_graph(graph, q, bindings=bindings, index=fields, convert=convert): |
|
107 |
||
108 |
if through_fields: |
|
109 |
new_obj_val = dict([(k,v) for k,v in val.iteritems() if k not in through_fields]) |
|
110 |
else: |
|
111 |
new_obj_val = val |
|
112 |
||
113 |
if hasattr(coll, 'through'): |
|
114 |
new_obj_rel, _ = coll.model.objects.get_or_create(**new_obj_val) |
|
115 |
if through_fields: |
|
116 |
through_vals = {coll.source_field_name: coll.instance, coll.target_field_name: new_obj_rel} |
|
117 |
through_vals.update(dict([(k,v) for k,v in val.iteritems() if k in through_fields])) |
|
118 |
coll.through.objects.create(**through_vals) |
|
119 |
new_obj = None |
|
120 |
else: |
|
121 |
new_obj = new_obj_rel |
|
122 |
||
123 |
else: |
|
124 |
new_obj = coll.create(**new_obj_val) |
|
125 |
||
126 |
if new_obj: |
|
127 |
coll.add(new_obj) |
|
128 |
||
129 |
||
130 |
||
131 |
||
132 |
def build_record(self, graph): |
|
133 |
||
134 |
record_uri = self.extract_single_value_form_graph(graph,"SELECT DISTINCT ?s WHERE { ?s rdf:type iiep:Record .}") |
|
135 |
||
136 |
record = Record() |
|
137 |
record.uri = record_uri |
|
138 |
record.identifier = self.extract_single_value_form_graph(graph,"SELECT DISTINCT ?o WHERE { ?s dct:identifier ?o .}", bindings={'s':URIRef(record.uri)}) |
|
139 |
record.notes = self.extract_single_value_form_graph(graph,"SELECT DISTINCT ?o WHERE { ?s iiep:notes ?o .}", bindings={'s':URIRef(record.uri)}) |
|
140 |
record.recordType = self.extract_single_value_form_graph(graph,"SELECT DISTINCT ?o WHERE { ?s dct:type ?o .}", bindings={'s':URIRef(record.uri)}) |
|
141 |
record.isDocumentPart = self.extract_single_value_form_graph(graph,"SELECT DISTINCT ?o WHERE { ?s iiep:isDocumentPart ?o .}", bindings={'s':URIRef(record.uri)}, convert=self.convert_bool) |
|
|
14
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
142 |
record.isMultilingual = self.extract_single_value_form_graph(graph,"SELECT DISTINCT ?o WHERE { ?s iiep:isMultilingual ?o .}", bindings={'s':URIRef(record.uri)}, convert=self.convert_bool) |
| 0 | 143 |
record.editionStatement = self.extract_single_value_form_graph(graph,"SELECT DISTINCT ?o WHERE { ?s iiep:editionStatement ?o .}", bindings={'s':URIRef(record.uri)}) |
144 |
||
145 |
language = self.extract_single_value_form_graph(graph,"SELECT DISTINCT ?o WHERE { ?s dct:language ?o .}", bindings={'s':URIRef(record.uri)}) |
|
146 |
if language: |
|
|
14
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
147 |
record.language, _ = Language.objects.get_or_create(uri=language) |
| 0 | 148 |
|
149 |
record.save() |
|
150 |
||
|
14
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
151 |
self.add_to_related_collection(record.otherLanguages, graph, ['uri'], "SELECT ?o WHERE { ?s iiep:otherLanguage ?o .}", bindings={'s':URIRef(record.uri)}) |
|
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
152 |
self.add_to_related_collection(record.subjects, graph, ['uri'], "SELECT ?o WHERE { ?s dct:subject ?o .}", bindings={'s':URIRef(record.uri)}) |
|
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
153 |
self.add_to_related_collection(record.themes, graph, ['uri'], "SELECT ?o WHERE { ?s iiep:theme ?o .}", bindings={'s':URIRef(record.uri)}) |
|
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
154 |
self.add_to_related_collection(record.countries, graph, ['uri'], "SELECT ?o WHERE { ?s iiep:country ?o .}", bindings={'s':URIRef(record.uri)}) |
| 0 | 155 |
self.add_to_related_collection(record.authors, graph, ['name'], "SELECT ?o WHERE { ?s iiep:author ?o .}", bindings={'s':URIRef(record.uri)}) |
156 |
self.add_to_related_collection(record.subjectPersons, graph, ['name'], "SELECT ?o WHERE { ?s iiep:subjectPerson ?o .}", bindings={'s':URIRef(record.uri)}) |
|
|
14
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
157 |
self.add_to_related_collection(record.projectNames, graph, ['uri'], "SELECT ?o WHERE { ?s iiep:projectName ?o . }") |
| 0 | 158 |
|
159 |
self.add_to_related_collection( |
|
160 |
record.periodicals, |
|
161 |
graph, |
|
162 |
['label','lang'], |
|
163 |
"SELECT DISTINCT ?o ( lang(?o) as ?l) WHERE { ?s iiep:periodical ?o .}", |
|
| 22 | 164 |
bindings={'s':URIRef(record.uri)} |
| 0 | 165 |
) |
166 |
||
167 |
self.add_to_related_collection( |
|
168 |
record.meetings, |
|
169 |
graph, |
|
170 |
['label', 'meetingNumber', 'meetingPlace', 'meetingDate', 'meetingYear', 'lang'], |
|
171 |
"SELECT ?l ?mn ?mp ?md ?my (lang(COALESCE(?l,?nm, ?mp,?md,?my)) as ?lang) WHERE { [iiep:meeting ?bnode]. OPTIONAL { ?bnode rdfs:label ?l }. OPTIONAL { ?bnode iiep:meetingNumber ?mn }. OPTIONAL { ?bnode iiep:meetingPlace ?mp }. OPTIONAL { ?bnode iiep:meetingDate ?md }. OPTIONAL { ?bnode iiep:meetingYear ?my }}", |
|
| 22 | 172 |
convert={'meetingYear' : lambda y: int(y) if y is not None else None} |
| 0 | 173 |
) |
174 |
||
175 |
self.add_to_related_collection( |
|
176 |
record.series, |
|
177 |
graph, |
|
178 |
['title', 'volume', 'lang'], |
|
179 |
"SELECT ?t ?vol (lang(COALESCE(?t,?vol)) as ?lang) WHERE { [iiep:serie ?bnode]. OPTIONAL { ?bnode dct:title ?t }. OPTIONAL { ?bnode iiep:volume ?vol } }", |
|
180 |
) |
|
181 |
||
182 |
self.add_to_related_collection( |
|
183 |
record.subjectCorporateBodies, |
|
184 |
graph, |
|
|
14
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
185 |
['uri'], |
|
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
186 |
"SELECT ?o WHERE { ?s iiep:subjectCorporateBody ?o. }", |
|
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
187 |
bindings={'s':URIRef(record.uri)} |
| 0 | 188 |
) |
189 |
||
190 |
self.add_to_related_collection( |
|
191 |
record.subjectMeetings, |
|
192 |
graph, |
|
193 |
['label', 'meetingNumber', 'meetingPlace', 'meetingDate', 'meetingYear'], |
|
| 7 | 194 |
"SELECT ?l ?mn ?mp ?md ?my WHERE { [iiep:subjectMeeting ?bnode]. OPTIONAL { ?bnode rdfs:label ?l }. OPTIONAL { ?bnode iiep:meetingNumber ?mn }. OPTIONAL { ?bnode iiep:meetingPlace ?mp }. OPTIONAL { ?bnode iiep:meetingDate ?md }. OPTIONAL { ?bnode iiep:meetingYear ?my }}", |
| 0 | 195 |
convert={'meetingYear' : lambda y: int(y) if y is not None else None} |
196 |
) |
|
197 |
||
198 |
self.add_to_related_collection( |
|
199 |
record.corporateAuthors, |
|
200 |
graph, |
|
|
14
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
201 |
['uri'], |
|
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
202 |
"SELECT ?o WHERE { ?s iiep:corporateAuthor ?o.}", |
|
52fa6990e0bb
adapt model to new rdf serialization
ymh <ymh.work@gmail.com>
parents:
13
diff
changeset
|
203 |
bindings={'s':URIRef(record.uri)} |
| 0 | 204 |
) |
205 |
||
206 |
self.add_to_related_collection( |
|
207 |
record.issns, |
|
208 |
graph, |
|
209 |
['issn', 'lang'], |
|
210 |
"SELECT ?issn (lang(COALESCE(?issn)) as ?lang) WHERE { ?s iiep:issn ?issn . }", |
|
211 |
bindings={'s':URIRef(record.uri)}, |
|
212 |
) |
|
213 |
||
214 |
self.add_to_related_collection( |
|
215 |
record.isbns, |
|
216 |
graph, |
|
217 |
['isbn', 'lang'], |
|
218 |
"SELECT ?isbn (lang(COALESCE(?isbn)) as ?lang) WHERE { ?s iiep:isbn ?isbn . }", |
|
219 |
bindings={'s':URIRef(record.uri)}, |
|
220 |
) |
|
221 |
||
222 |
self.add_to_related_collection( |
|
223 |
record.documentCodes, |
|
224 |
graph, |
|
225 |
['documentCode', 'lang'], |
|
226 |
"SELECT ?c (lang(COALESCE(?c)) as ?lang) WHERE { ?s iiep:documentCode ?c . }", |
|
227 |
bindings={'s':URIRef(record.uri)}, |
|
228 |
) |
|
229 |
||
230 |
self.add_to_related_collection( |
|
231 |
record.titles, |
|
232 |
graph, |
|
233 |
['title', 'lang'], |
|
234 |
"SELECT ?t (lang(COALESCE(?t)) as ?lang) WHERE { ?s dct:title ?t . }", |
|
235 |
bindings={'s':URIRef(record.uri)}, |
|
|
13
6296aa12fd71
model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents:
7
diff
changeset
|
236 |
) |
|
6296aa12fd71
model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents:
7
diff
changeset
|
237 |
|
|
6296aa12fd71
model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents:
7
diff
changeset
|
238 |
self.add_to_related_collection( |
|
6296aa12fd71
model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents:
7
diff
changeset
|
239 |
record.abstracts, |
|
6296aa12fd71
model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents:
7
diff
changeset
|
240 |
graph, |
|
6296aa12fd71
model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents:
7
diff
changeset
|
241 |
['abstract', 'lang'], |
|
6296aa12fd71
model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents:
7
diff
changeset
|
242 |
"SELECT ?t (lang(COALESCE(?t)) as ?lang) WHERE { ?s dct:abstract ?t . }", |
|
6296aa12fd71
model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents:
7
diff
changeset
|
243 |
bindings={'s':URIRef(record.uri)}, |
| 0 | 244 |
) |
245 |
||
246 |
self.add_to_related_collection( |
|
247 |
record.addedTitles, |
|
248 |
graph, |
|
249 |
['title', 'lang'], |
|
250 |
"SELECT ?t (lang(COALESCE(?t)) as ?lang) WHERE { ?s iiep:addedTitle ?t . }", |
|
251 |
bindings={'s':URIRef(record.uri)}, |
|
252 |
) |
|
253 |
||
254 |
self.add_to_related_collection( |
|
255 |
record.titlesMainDocument, |
|
256 |
graph, |
|
257 |
['title', 'lang'], |
|
258 |
"SELECT ?t (lang(COALESCE(?t)) as ?lang) WHERE { ?s iiep:titleMainDocument ?t . }", |
|
259 |
bindings={'s':URIRef(record.uri)}, |
|
260 |
) |
|
261 |
||
262 |
self.add_to_related_collection( |
|
263 |
record.imprints, |
|
264 |
graph, |
|
265 |
['imprintCity', 'publisher', 'imprintDate', 'lang'], |
|
266 |
"SELECT ?c ?p ?d (lang(COALESCE(?c, ?p, ?d)) as ?lang) WHERE { [ iiep:imprint ?bnode ]. OPTIONAL { ?bnode iiep:imprintCity ?c }. OPTIONAL { ?bnode dct:publisher ?p }. OPTIONAL { ?bnode iiep:imprintDate ?d }}", |
|
267 |
) |
|
268 |
||
269 |
self.add_to_related_collection( |
|
270 |
record.collations, |
|
271 |
graph, |
|
272 |
['collation', 'lang'], |
|
273 |
"SELECT ?c (lang(COALESCE(?c)) as ?lang) WHERE { ?s iiep:collation ?c . }", |
|
274 |
bindings={'s':URIRef(record.uri)}, |
|
275 |
) |
|
276 |
||
277 |
self.add_to_related_collection( |
|
278 |
record.volumeIssues, |
|
279 |
graph, |
|
280 |
['volume', 'number', 'lang'], |
|
| 6 | 281 |
"SELECT ?v ?n (lang(COALESCE(?v, ?n)) as ?lang) WHERE { [ iiep:volumeIssue ?bnode ]. OPTIONAL { ?bnode iiep:volume ?v }. OPTIONAL { ?bnode iiep:number ?n }}", |
| 0 | 282 |
) |
283 |
||
284 |
self.add_to_related_collection( |
|
285 |
record.urls, |
|
286 |
graph, |
|
287 |
['address', 'display', 'accessLevel'], |
|
288 |
"SELECT ?a ?d ?al WHERE { [ iiep:url ?bnode ]. OPTIONAL { ?bnode iiep:address ?a }. OPTIONAL { ?bnode iiep:display ?d }. OPTIONAL { ?bnode iiep:accessLevel ?al }.}", |
|
289 |
) |
|
290 |
||
291 |
return record |
|
292 |
||
293 |
||
294 |
def filter_node(self, node, graph, res_graph): |
|
295 |
for p,o in graph[node]: |
|
296 |
res_graph.add((node,p,o)) |
|
297 |
if isinstance(o, BNode): |
|
298 |
self.filter_node(o, graph, res_graph) |
|
299 |
||
300 |
||
301 |
||
302 |
def calculate_records_nb(self, records_url): |
|
303 |
context = ET.iterparse(records_url, events=("end",)) |
|
304 |
i = 0 |
|
305 |
for _,elem in context: |
|
306 |
if elem.tag == "{%s}Record" % IIEP: |
|
307 |
i += 1 |
|
308 |
return i |
|
309 |
||
310 |
def process_url(self, records_url, options): |
|
311 |
||
312 |
total_records = self.calculate_records_nb(records_url) |
|
313 |
writer = None |
|
314 |
errors=[] |
|
315 |
||
316 |
context = ET.iterparse(records_url, events=("end",)) |
|
317 |
i = 0 |
|
| 6 | 318 |
for _,elem in context: |
| 0 | 319 |
if elem.tag == "{%s}Record" % IIEP: |
320 |
i += 1 |
|
321 |
writer = show_progress(i, total_records, "Processing record nb %d " % i, 50, writer=writer) |
|
322 |
try: |
|
323 |
record_graph = self.get_empty_graph() |
|
324 |
record_graph.parse(data=ET.tostring(elem, encoding='utf-8'), format='xml') |
|
325 |
# add transaction management |
|
326 |
self.build_record(record_graph) |
|
327 |
except Exception as e: |
|
328 |
transaction.rollback() |
|
329 |
msg = "Error processing resource %d in %s : %s" % (i, records_url, repr(e)) |
|
330 |
logger.exception(msg) |
|
331 |
errors.append((i, records_url, msg)) |
|
332 |
else: |
|
333 |
transaction.commit() |
|
334 |
||
335 |
if i%self.batch_size == 0: |
|
336 |
reset_queries() |
|
337 |
||
338 |
return errors |
|
339 |
||
340 |
||
341 |
# def process_url(self, records_url, options): |
|
342 |
# #open graph with rdflib |
|
|
13
6296aa12fd71
model simplification, correct import on language. We do not try to impose a language when none is found. add forgotten abstract field on import.
ymh <ymh.work@gmail.com>
parents:
7
diff
changeset
|
343 |
# |
| 0 | 344 |
# g = Graph() |
345 |
# print("Loading %s" % records_url) |
|
346 |
# g.parse(records_url) |
|
347 |
# print("Parsing %s done" % records_url) |
|
348 |
# for i,record_uri in enumerate(g[:RDF.type:IIEP.Record]): |
|
349 |
# print(i, repr(record_uri)) |
|
350 |
# record_graph = self.get_empty_graph() |
|
351 |
# self.filter_node(record_uri, g, record_graph) |
|
352 |
# self.build_record(record_graph) |
|
353 |
# if i > 3: |
|
354 |
# break |
|
355 |
||
356 |
||
357 |
||
358 |
||
359 |
def handle(self, *args, **options): |
|
360 |
||
361 |
self.batch_size = options.get('batch_size', 50) |
|
362 |
transaction.enter_transaction_management() |
|
363 |
transaction.managed(True) |
|
364 |
||
365 |
for records_url in args: |
|
366 |
print("Processing %s" % records_url) |
|
367 |
errors = self.process_url(records_url, options) |
|
368 |
print("Processing %s Done" % records_url) |
|
369 |
if errors: |
|
370 |
print("%d error(s) when processing %s, check your log file." % (len(errors), records_url)) |
|
371 |
||
372 |
transaction.leave_transaction_management() |
|
373 |