← Back to team overview

zeitgeist team mailing list archive

Re: [Merge] lp:~zeitgeist/zeitgeist/rdflib3 into lp:zeitgeist

 

Review: Disapprove
Seif,
I don't like the way this bug is fixed in your branch, sorry.
First of all you are using blank try:...except:... blocks, and you are putting too much code in this exception handlers, which makes the code unreadable.

I propose this diff:


=== modified file 'extra/PythonSerializer.py'
--- extra/PythonSerializer.py   2010-04-26 19:42:07 +0000
+++ extra/PythonSerializer.py   2010-09-01 06:47:31 +0000
@@ -17,9 +17,16 @@
 # You should have received a copy of the GNU Lesser General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-from rdflib.syntax.serializers.RecursiveSerializer import RecursiveSerializer
+try:
+       #rdflib2
+       from rdflib.syntax.serializers.RecursiveSerializer import RecursiveSerializer
+       from rdflib.Namespace import Namespace
+except ImportError:
+       #rdflib3 (LP: #626224)
+       from rdflib.plugins.serializers.turtle import RecursiveSerializer
+       from rdflib.namespace import Namespace
+
 from rdflib import RDF, RDFS
-from rdflib.Namespace import Namespace
 
 NIENS = Namespace("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#";)
 

=== modified file 'extra/rdfxml2py'
--- extra/rdfxml2py     2010-03-05 18:05:55 +0000
+++ extra/rdfxml2py     2010-09-01 06:47:36 +0000
@@ -9,16 +9,23 @@
 import rdflib
 
 from rdflib.plugin import register
-from rdflib.syntax import serializer, serializers
+try:
+       #rdflib2
+       from rdflib.syntax.serializers import Serializer
+       from rdflib import FileInputSource
+except ImportError:
+       #rdflib3 (LP: #626224)
+       from rdflib.serializer import Serializer
+       from rdflib.parser import FileInputSource
 
-register('python', serializers.Serializer,
+register('python', Serializer,
          'PythonSerializer', 'PythonSerializer')
 
 def parse(trig_stream):
        """
        Return a list of triples representing the ontology
        """
-       trig_in = rdflib.FileInputSource(trig_stream)
+       trig_in = FileInputSource(trig_stream)
        ontology = rdflib.ConjunctiveGraph()
        ontology.parse(trig_in)
        pycode = ontology.serialize(format="python")

-- 
https://code.launchpad.net/~zeitgeist/zeitgeist/rdflib3/+merge/34246
Your team Zeitgeist Framework Team is subscribed to branch lp:~zeitgeist/zeitgeist/rdflib3.



References