Refactor - module names don't match class names · RDFLib/rdflib@91015c1 (original) (raw)
`@@ -3,14 +3,14 @@
`
3
3
`from rdflib.plugins.serializers.xmlwriter import XMLWriter
`
4
4
``
5
5
`from rdflib.namespace import Namespace, RDF, RDFS # , split_uri
`
``
6
`+
from rdflib.plugins.parsers.RDFVOC import RDFVOC
`
6
7
``
7
8
`from rdflib.term import URIRef, Literal, BNode
`
8
9
`from rdflib.util import first, more_than
`
9
10
`from rdflib.collection import Collection
`
10
11
`from rdflib.serializer import Serializer
`
11
12
``
12
13
`from xml.sax.saxutils import quoteattr, escape
`
13
``
`-
import xml.dom.minidom
`
14
14
``
15
15
`from .xmlwriter import ESCAPE_ENTITIES
`
16
16
``
`@@ -182,7 +182,7 @@ def serialize(self, stream, base=None, encoding=None, **args):
`
182
182
``
183
183
`namespaces["rdf"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
`
184
184
``
185
``
`-
writer.push(RDF.RDF)
`
``
185
`+
writer.push(RDFVOC.RDF)
`
186
186
``
187
187
`if "xml_base" in args:
`
188
188
`writer.attribute(XMLBASE, args["xml_base"])
`
`@@ -214,7 +214,7 @@ def serialize(self, stream, base=None, encoding=None, **args):
`
214
214
`if bnode not in self.__serialized:
`
215
215
`self.subject(subject, 1)
`
216
216
``
217
``
`-
writer.pop(RDF.RDF)
`
``
217
`+
writer.pop(RDFVOC.RDF)
`
218
218
`stream.write("\n".encode("latin-1"))
`
219
219
``
220
220
`# Set to None so that the memory can get garbage collected.
`
`@@ -225,9 +225,9 @@ def subject(self, subject, depth=1):
`
225
225
`writer = self.writer
`
226
226
``
227
227
`if subject in self.forceRDFAbout:
`
228
``
`-
writer.push(RDF.Description)
`
229
``
`-
writer.attribute(RDF.about, self.relativize(subject))
`
230
``
`-
writer.pop(RDF.Description)
`
``
228
`+
writer.push(RDFVOC.Description)
`
``
229
`+
writer.attribute(RDFVOC.about, self.relativize(subject))
`
``
230
`+
writer.pop(RDFVOC.Description)
`
231
231
`self.forceRDFAbout.remove(subject)
`
232
232
``
233
233
`elif subject not in self.__serialized:
`
`@@ -239,7 +239,7 @@ def subject(self, subject, depth=1):
`
239
239
`except:
`
240
240
`type = None
`
241
241
``
242
``
`-
element = type or RDF.Description
`
``
242
`+
element = type or RDFVOC.Description
`
243
243
`writer.push(element)
`
244
244
``
245
245
`if isinstance(subject, BNode):
`
`@@ -252,10 +252,10 @@ def subj_as_obj_more_than(ceil):
`
252
252
`# more than once (this reduces the use of redundant BNode
`
253
253
`# identifiers)
`
254
254
`if subj_as_obj_more_than(1):
`
255
``
`-
writer.attribute(RDF.nodeID, fix(subject))
`
``
255
`+
writer.attribute(RDFVOC.nodeID, fix(subject))
`
256
256
``
257
257
`else:
`
258
``
`-
writer.attribute(RDF.about, self.relativize(subject))
`
``
258
`+
writer.attribute(RDFVOC.about, self.relativize(subject))
`
259
259
``
260
260
`if (subject, None, None) in store:
`
261
261
`for predicate, object in store.predicate_objects(subject):
`
`@@ -265,9 +265,9 @@ def subj_as_obj_more_than(ceil):
`
265
265
`writer.pop(element)
`
266
266
``
267
267
`elif subject in self.forceRDFAbout:
`
268
``
`-
writer.push(RDF.Description)
`
269
``
`-
writer.attribute(RDF.about, self.relativize(subject))
`
270
``
`-
writer.pop(RDF.Description)
`
``
268
`+
writer.push(RDFVOC.Description)
`
``
269
`+
writer.attribute(RDFVOC.about, self.relativize(subject))
`
``
270
`+
writer.pop(RDFVOC.Description)
`
271
271
`self.forceRDFAbout.remove(subject)
`
272
272
``
273
273
`def predicate(self, predicate, object, depth=1):
`
`@@ -282,21 +282,21 @@ def predicate(self, predicate, object, depth=1):
`
282
282
`if object.datatype == RDF.XMLLiteral and isinstance(
`
283
283
`object.value, xml.dom.minidom.Document
`
284
284
` ):
`
285
``
`-
writer.attribute(RDF.parseType, "Literal")
`
``
285
`+
writer.attribute(RDFVOC.parseType, "Literal")
`
286
286
`writer.text(u"")
`
287
287
`writer.stream.write(object)
`
288
288
`else:
`
289
289
`if object.datatype:
`
290
``
`-
writer.attribute(RDF.datatype, object.datatype)
`
``
290
`+
writer.attribute(RDFVOC.datatype, object.datatype)
`
291
291
`writer.text(object)
`
292
292
``
293
293
`elif object in self.__serialized or not (object, None, None) in store:
`
294
294
``
295
295
`if isinstance(object, BNode):
`
296
296
`if more_than(store.triples((None, None, object)), 0):
`
297
``
`-
writer.attribute(RDF.nodeID, fix(object))
`
``
297
`+
writer.attribute(RDFVOC.nodeID, fix(object))
`
298
298
`else:
`
299
``
`-
writer.attribute(RDF.resource, self.relativize(object))
`
``
299
`+
writer.attribute(RDFVOC.resource, self.relativize(object))
`
300
300
``
301
301
`else:
`
302
302
`if first(store.objects(object, RDF.first)): # may not have type
`
`@@ -314,7 +314,7 @@ def predicate(self, predicate, object, depth=1):
`
314
314
`UserWarning,
`
315
315
`stacklevel=2,
`
316
316
` )
`
317
``
`-
writer.attribute(RDF.parseType, "Collection")
`
``
317
`+
writer.attribute(RDFVOC.parseType, "Collection")
`
318
318
``
319
319
`col = Collection(store, object)
`
320
320
``
`@@ -332,7 +332,7 @@ def predicate(self, predicate, object, depth=1):
`
332
332
` (object, RDF.type, [OWL_NS.Class, RDFS.Class])
`
333
333
` )
`
334
334
` ) and isinstance(object, URIRef):
`
335
``
`-
writer.attribute(RDF.resource, self.relativize(object))
`
``
335
`+
writer.attribute(RDFVOC.resource, self.relativize(object))
`
336
336
``
337
337
`elif depth <= self.max_depth:
`
338
338
`self.subject(object, depth + 1)
`
`@@ -348,9 +348,9 @@ def predicate(self, predicate, object, depth=1):
`
348
348
`# and are only referenced once (regardless of depth)
`
349
349
`self.subject(object, depth + 1)
`
350
350
`else:
`
351
``
`-
writer.attribute(RDF.nodeID, fix(object))
`
``
351
`+
writer.attribute(RDFVOC.nodeID, fix(object))
`
352
352
``
353
353
`else:
`
354
``
`-
writer.attribute(RDF.resource, self.relativize(object))
`
``
354
`+
writer.attribute(RDFVOC.resource, self.relativize(object))
`
355
355
``
356
356
`writer.pop(predicate)
`