Mercurial > code > home > repos > rdfdb
changeset 26:95c57a5cb18e
run 2to3
Ignore-this: e8419af046fb5f0b5158c0d237d8d7fb
author | drewp@bigasterisk.com |
---|---|
date | Fri, 24 May 2019 00:06:34 +0000 |
parents | ab17449e5a8c |
children | 53783e475df0 |
files | rdfdb/autodepgraphapi.py rdfdb/file_vs_uri.py rdfdb/grapheditapi.py rdfdb/graphfile.py rdfdb/patch.py rdfdb/patchreceiver.py rdfdb/patchsender.py rdfdb/rdflibpatch.py rdfdb/rdflibpatch_literal.py rdfdb/service.py |
diffstat | 10 files changed, 27 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/rdfdb/autodepgraphapi.py Thu May 23 17:30:48 2019 +0000 +++ b/rdfdb/autodepgraphapi.py Fri May 24 00:06:34 2019 +0000 @@ -182,28 +182,28 @@ ret = set() affectedSubjPreds = set([(s, p) for s, p, o, c in patch.addQuads]+ [(s, p) for s, p, o, c in patch.delQuads]) - for (s, p), funcs in self._handlersSp.iteritems(): + for (s, p), funcs in self._handlersSp.items(): if (s, p) in affectedSubjPreds: ret.update(funcs) funcs.clear() affectedPredObjs = set([(p, o) for s, p, o, c in patch.addQuads]+ [(p, o) for s, p, o, c in patch.delQuads]) - for (p, o), funcs in self._handlersPo.iteritems(): + for (p, o), funcs in self._handlersPo.items(): if (p, o) in affectedPredObjs: ret.update(funcs) funcs.clear() affectedTriples = set([(s, p, o) for s, p, o, c in patch.addQuads]+ [(s, p, o) for s, p, o, c in patch.delQuads]) - for triple, funcs in self._handlersSpo.iteritems(): + for triple, funcs in self._handlersSpo.items(): if triple in affectedTriples: ret.update(funcs) funcs.clear() affectedSubjs = set([s for s, p, o, c in patch.addQuads]+ [s for s, p, o, c in patch.delQuads]) - for subj, funcs in self._handlersS.iteritems(): + for subj, funcs in self._handlersS.items(): if subj in affectedSubjs: ret.update(funcs) funcs.clear()
--- a/rdfdb/file_vs_uri.py Thu May 23 17:30:48 2019 +0000 +++ b/rdfdb/file_vs_uri.py Fri May 24 00:06:34 2019 +0000 @@ -7,15 +7,15 @@ def uriFromFile(dirUriMap, filename): assert filename.endswith('.n3'), filename - for d, prefix in dirUriMap.items(): + for d, prefix in list(dirUriMap.items()): if filename.startswith(d): return URIRef(prefix + filename[len(d):-len('.n3')]) raise ValueError("filename %s doesn't start with any of %s" % - (filename, dirUriMap.keys())) + (filename, list(dirUriMap.keys()))) def fileForUri(dirUriMap, ctx): assert isinstance(ctx, URIRef), ctx - for d, prefix in dirUriMap.items(): + for d, prefix in list(dirUriMap.items()): if ctx.startswith(prefix): return d + ctx[len(prefix):] + '.n3' raise ValueError("don't know what filename to use for %s" % ctx) @@ -29,5 +29,5 @@ break else: raise ValueError("can't correct %s to start with one of %s" % - (inFile, dirUriMap.keys())) + (inFile, list(dirUriMap.keys()))) return inFile
--- a/rdfdb/grapheditapi.py Thu May 23 17:30:48 2019 +0000 +++ b/rdfdb/grapheditapi.py Fri May 24 00:06:34 2019 +0000 @@ -113,5 +113,5 @@ obj.patchSubgraph(URIRef('g'), [stmt1]) self.assertEqual(len(appliedPatches), 1) p = appliedPatches[0] - self.assert_(p.isNoop()) + self.assertTrue(p.isNoop()) self.assertEqual(p.jsonRepr, '{"patch": {"adds": "", "deletes": ""}}')
--- a/rdfdb/graphfile.py Thu May 23 17:30:48 2019 +0000 +++ b/rdfdb/graphfile.py Fri May 24 00:06:34 2019 +0000 @@ -184,7 +184,7 @@ new.parse(location=self.path, format='n3') self.readPrefixes = dict(new.namespaces()) except SyntaxError as e: - print e + print(e) traceback.print_exc() log.error("%s syntax error", self.path) # todo: likely bug- if a file has this error upon first @@ -234,9 +234,9 @@ tmpOut = self.path + ".rdfdb-temp" f = open(tmpOut, 'w') t1 = time.time() - for p, n in (self.globalPrefixes.items() + - self.readPrefixes.items() + - self.ctxPrefixes.items()): + for p, n in (list(self.globalPrefixes.items()) + + list(self.readPrefixes.items()) + + list(self.ctxPrefixes.items())): self.graphToWrite.bind(p, n) self.graphToWrite.serialize(destination=f, format='n3') serializeTime = time.time() - t1
--- a/rdfdb/patch.py Thu May 23 17:30:48 2019 +0000 +++ b/rdfdb/patch.py Fri May 24 00:06:34 2019 +0000 @@ -70,7 +70,7 @@ new = set(quadsWithContextUris(newGraph)) return cls(addQuads=list(new - old), delQuads=list(old - new)) - def __nonzero__(self): + def __bool__(self): """ does this patch do anything to a graph? """ @@ -181,13 +181,13 @@ def testEmpty(self): g = ConjunctiveGraph() p = Patch.fromDiff(g, g) - self.assert_(not p) + self.assertTrue(not p) def testNonEmpty(self): g1 = ConjunctiveGraph() g2 = graphFromQuads([stmt1]) p = Patch.fromDiff(g1, g2) - self.assert_(p) + self.assertTrue(p) def testNoticesAdds(self): g1 = ConjunctiveGraph()
--- a/rdfdb/patchreceiver.py Thu May 23 17:30:48 2019 +0000 +++ b/rdfdb/patchreceiver.py Fri May 24 00:06:34 2019 +0000 @@ -1,4 +1,4 @@ -import logging, cyclone.httpclient, traceback, urllib +import logging, cyclone.httpclient, traceback, urllib.request, urllib.parse, urllib.error from twisted.internet import reactor from rdfdb.patch import Patch log = logging.getLogger('syncedgraph') @@ -27,7 +27,7 @@ def _register(self, label): url = self.rdfdbRoot + 'graphClients' - body = urllib.urlencode([('clientUpdate', self.updateResource), + body = urllib.parse.urlencode([('clientUpdate', self.updateResource), ('label', label)]) cyclone.httpclient.fetch( url=url,
--- a/rdfdb/patchsender.py Thu May 23 17:30:48 2019 +0000 +++ b/rdfdb/patchsender.py Fri May 24 00:06:34 2019 +0000 @@ -1,4 +1,4 @@ -from __future__ import print_function + import logging, time import cyclone.httpclient from twisted.internet import defer
--- a/rdfdb/rdflibpatch.py Thu May 23 17:30:48 2019 +0000 +++ b/rdfdb/rdflibpatch.py Fri May 24 00:06:34 2019 +0000 @@ -100,7 +100,7 @@ if '[' in c.n3(): import ipdb;ipdb.set_trace() ntObject = _quoteLiteral(o) if isinstance(o, Literal) else o.n3() - out.append(u"%s %s %s %s .\n" % (s.n3(), + out.append("%s %s %s %s .\n" % (s.n3(), p.n3(), ntObject, c.n3())) @@ -140,7 +140,7 @@ class TestInGraph(unittest.TestCase): def testSimpleMatch(self): g = graphFromQuads([(A,A,A,A)]) - self.assert_(inGraph((A,A,A,A), g)) + self.assertTrue(inGraph((A,A,A,A), g)) def testDontMatchDifferentStatement(self): g = graphFromQuads([(A,A,A,A)]) @@ -176,7 +176,7 @@ def testAddsToNewContext(self): g = ConjunctiveGraph() patchQuads(g, [], [stmt1]) - self.assert_(len(g), 1) + self.assertTrue(len(g), 1) quads = list(g.quads((None,None,None))) self.assertEqual(quads, [(A, B, C, Graph(identifier=CTX1))])
--- a/rdfdb/rdflibpatch_literal.py Thu May 23 17:30:48 2019 +0000 +++ b/rdfdb/rdflibpatch_literal.py Fri May 24 00:06:34 2019 +0000 @@ -15,11 +15,11 @@ # we try to produce "pretty" output if self.datatype == _XSD_DOUBLE: # this is the drewp fix - return sub(r"\.?0*e","e", u'%e' % float(self)) + return sub(r"\.?0*e","e", '%e' % float(self)) elif self.datatype == _XSD_DECIMAL: - return sub("0*$","0",u'%f' % float(self)) + return sub("0*$","0",'%f' % float(self)) else: - return u'%s' % self + return '%s' % self except ValueError: pass # if it's in, we let it out? @@ -53,4 +53,4 @@ vv = Literal("0.88", datatype=_XSD_DOUBLE) out = _literal_n3(vv, use_plain=True) print(out) - self.assert_(out in ["8.8e-01", "0.88"], out) + self.assertTrue(out in ["8.8e-01", "0.88"], out)
--- a/rdfdb/service.py Thu May 23 17:30:48 2019 +0000 +++ b/rdfdb/service.py Fri May 24 00:06:34 2019 +0000 @@ -284,7 +284,7 @@ format = 'nquads' elif accept == 'pickle': # don't use this; it's just for speed comparison - import cPickle as pickle + import pickle as pickle pickle.dump(self.settings.db.graph, self, protocol=2) return elif accept == 'msgpack':