21
21
from sqlalchemy .engine import reflection
22
22
from sqlalchemy .sql import select , expression
23
23
24
- from rdflib_sqlalchemy import __version__
25
24
from rdflib_sqlalchemy .tables import (
26
25
TABLE_NAME_TEMPLATES ,
27
26
create_asserted_statements_table ,
@@ -131,7 +130,6 @@ def union_select(selectComponents, distinct=False, select_type=TRIPLE_SELECT):
131
130
elif tableType in FULL_TRIPLE_PARTITIONS :
132
131
selectClause = table .select (whereClause )
133
132
elif tableType == ASSERTED_TYPE_PARTITION :
134
- offset_idx = 1 if __version__ <= "0.2" else 0
135
133
selectClause = expression .select (
136
134
[table .c .id .label ("id" ),
137
135
table .c .member .label ("subject" ),
@@ -140,7 +138,7 @@ def union_select(selectComponents, distinct=False, select_type=TRIPLE_SELECT):
140
138
table .c .context .label ("context" ),
141
139
table .c .termComb .label ("termcomb" ),
142
140
expression .literal_column ("NULL" ).label ("objlanguage" ),
143
- expression .literal_column ("NULL" ).label ("objdatatype" )][ offset_idx :] ,
141
+ expression .literal_column ("NULL" ).label ("objdatatype" )],
144
142
whereClause )
145
143
elif tableType == ASSERTED_NON_TYPE_PARTITION :
146
144
selectClause = expression .select (
@@ -173,24 +171,14 @@ def extractTriple(tupleRt, store, hardCodedContext=None):
173
171
converts it to a tuple of terms using the termComb integer
174
172
to interpret how to instantiate each term
175
173
"""
176
- if __version__ <= "0.2" :
177
- try :
178
- subject , predicate , obj , rtContext , termComb , \
179
- objLanguage , objDatatype = tupleRt
180
- termCombString = REVERSE_TERM_COMBINATIONS [termComb ]
181
- subjTerm , predTerm , objTerm , ctxTerm = termCombString
182
- except ValueError :
183
- subject , subjTerm , predicate , predTerm , obj , objTerm , \
184
- rtContext , ctxTerm , objLanguage , objDatatype = tupleRt
185
- else :
186
- try :
187
- id , subject , predicate , obj , rtContext , termComb , \
188
- objLanguage , objDatatype = tupleRt
189
- termCombString = REVERSE_TERM_COMBINATIONS [termComb ]
190
- subjTerm , predTerm , objTerm , ctxTerm = termCombString
191
- except ValueError :
192
- id , subject , subjTerm , predicate , predTerm , obj , objTerm , \
193
- rtContext , ctxTerm , objLanguage , objDatatype = tupleRt
174
+ try :
175
+ id , subject , predicate , obj , rtContext , termComb , \
176
+ objLanguage , objDatatype = tupleRt
177
+ termCombString = REVERSE_TERM_COMBINATIONS [termComb ]
178
+ subjTerm , predTerm , objTerm , ctxTerm = termCombString
179
+ except ValueError :
180
+ id , subject , subjTerm , predicate , predTerm , obj , objTerm , \
181
+ rtContext , ctxTerm , objLanguage , objDatatype = tupleRt
194
182
195
183
context = rtContext is not None \
196
184
and rtContext \
@@ -200,10 +188,8 @@ def extractTriple(tupleRt, store, hardCodedContext=None):
200
188
o = createTerm (obj , objTerm , store , objLanguage , objDatatype )
201
189
202
190
graphKlass , idKlass = construct_graph (ctxTerm )
203
- if __version__ <= "0.2" :
204
- return s , p , o , (graphKlass , idKlass , context )
205
- else :
206
- return id , s , p , o , (graphKlass , idKlass , context )
191
+
192
+ return id , s , p , o , (graphKlass , idKlass , context )
207
193
208
194
209
195
def createTerm (
@@ -902,12 +888,7 @@ class membership columns: member,klass,context termComb
902
888
result = res .fetchall ()
903
889
tripleCoverage = {}
904
890
for rt in result :
905
- if __version__ <= "0.2" :
906
- s , p , o , (graphKlass , idKlass , graphId ) = \
907
- extractTriple (rt , self , context )
908
- else :
909
- id , s , p , o , (graphKlass , idKlass , graphId ) = \
910
- extractTriple (rt , self , context )
891
+ id , s , p , o , (graphKlass , idKlass , graphId ) = extractTriple (rt , self , context )
911
892
contexts = tripleCoverage .get ((s , p , o ), [])
912
893
contexts .append (graphKlass (self , idKlass (graphId )))
913
894
tripleCoverage [(s , p , o )] = contexts
0 commit comments