118 filepath += ".gz" |
124 filepath += ".gz" |
119 |
125 |
120 limit = options.get("limit", -1) |
126 limit = options.get("limit", -1) |
121 skip = options.get("skip", 0) |
127 skip = options.get("skip", 0) |
122 batch = options.get("batch", 100) |
128 batch = options.get("batch", 100) |
|
129 newline = options.get("newline", False) |
123 |
130 |
124 qs = Record.objects.all().select_related(*[field.name for field in Record._meta.fields if isinstance(field, ForeignKey)]).prefetch_related(*([field.name for field in Record._meta.many_to_many] + [obj.get_accessor_name() for obj in Record._meta.get_all_related_objects()])).order_by('identifier') # @UndefinedVariable |
131 qs = Record.objects.all().select_related(*[field.name for field in Record._meta.fields if isinstance(field, ForeignKey)]).prefetch_related(*([field.name for field in Record._meta.many_to_many] + [obj.get_accessor_name() for obj in Record._meta.get_all_related_objects()])).order_by('identifier') # @UndefinedVariable |
125 |
132 |
126 if limit>=0: |
133 if limit>=0: |
127 qs = qs[skip:skip+limit] |
134 qs = qs[skip:skip+limit] |
155 writer.startPrefixMapping(prefix, uri) |
162 writer.startPrefixMapping(prefix, uri) |
156 writer.startElementNS((RDF, 'RDF'), 'RDF', AttributesNSImpl({}, {})) |
163 writer.startElementNS((RDF, 'RDF'), 'RDF', AttributesNSImpl({}, {})) |
157 writer.characters("\n") |
164 writer.characters("\n") |
158 for n in range((total_records/batch)+1): |
165 for n in range((total_records/batch)+1): |
159 for i,r in enumerate(qs[n*batch:((n+1)*batch)]): |
166 for i,r in enumerate(qs[n*batch:((n+1)*batch)]): |
160 progress_writer = show_progress(i+(n*batch)+1, total_records, "Exporting record %s" % r.identifier, 50, progress_writer) |
167 progress_writer = show_progress(i+(n*batch)+1, total_records, "Exporting record %s" % r.identifier, 40, writer=progress_writer, newline=newline) |
161 graph = self.get_graph_from_object(r) |
168 graph = self.get_graph_from_object(r) |
162 do_write = False |
169 do_write = False |
163 for line in graph.serialize(format="pretty-xml", encoding="utf-8").splitlines(True): |
170 for line in graph.serialize(format="pretty-xml", encoding="utf-8").splitlines(True): |
164 if "<iiep:Record" in line: |
171 if "<iiep:Record" in line: |
165 do_write = True |
172 do_write = True |