@@ -21,7 +21,8 @@ def _build_type_sql_command(self, member, klass, context):
21
21
"member" : member ,
22
22
"klass" : klass ,
23
23
"context" : context .identifier ,
24
- "termComb" : int (type_to_term_combination (member , klass , context ))}
24
+ "termComb" : int (type_to_term_combination (member , klass , context ))
25
+ }
25
26
26
27
def _build_literal_triple_sql_command (self , subject , predicate , obj , context ):
27
28
"""
@@ -70,10 +71,8 @@ def _build_triple_sql_command(self, subject, predicate, obj, context, quoted):
70
71
"object" : obj ,
71
72
"context" : context .identifier ,
72
73
"termComb" : triple_pattern ,
73
- "objLanguage" : isinstance (
74
- obj , Literal ) and obj .language or None ,
75
- "objDatatype" : isinstance (
76
- obj , Literal ) and obj .datatype or None
74
+ "objLanguage" : isinstance (obj , Literal ) and obj .language or None ,
75
+ "objDatatype" : isinstance (obj , Literal ) and obj .datatype or None
77
76
}
78
77
else :
79
78
params = {
@@ -89,18 +88,18 @@ def build_clause(self, table, subject, predicate, obj, context=None, typeTable=F
89
88
"""Build WHERE clauses for the supplied terms and, context."""
90
89
if typeTable :
91
90
clauseList = [
92
- self .buildTypeMemberClause (subject , table ),
93
- self .buildTypeClassClause (obj , table ),
94
- self .buildContextClause (context , table )
91
+ self .build_type_member_clause (subject , table ),
92
+ self .build_type_class_clause (obj , table ),
93
+ self .build_context_clause (context , table )
95
94
]
96
95
else :
97
96
clauseList = [
98
- self .buildSubjClause (subject , table ),
99
- self .buildPredClause (predicate , table ),
100
- self .buildObjClause (obj , table ),
101
- self .buildContextClause (context , table ),
102
- self .buildLitDTypeClause (obj , table ),
103
- self .buildLitLanguageClause (obj , table )
97
+ self .build_subject_clause (subject , table ),
98
+ self .build_predicate_clause (predicate , table ),
99
+ self .build_object_clause (obj , table ),
100
+ self .build_context_clause (context , table ),
101
+ self .build_literal_datatype_clause (obj , table ),
102
+ self .build_literal_language_clause (obj , table )
104
103
]
105
104
106
105
clauseList = [clause for clause in clauseList if clause is not None ]
@@ -109,14 +108,14 @@ def build_clause(self, table, subject, predicate, obj, context=None, typeTable=F
109
108
else :
110
109
return None
111
110
112
- def buildLitDTypeClause (self , obj , table ):
111
+ def build_literal_datatype_clause (self , obj , table ):
113
112
"""Build Literal and datatype clause."""
114
113
if isinstance (obj , Literal ) and obj .datatype is not None :
115
114
return table .c .objDatatype == obj .datatype
116
115
else :
117
116
return None
118
117
119
- def buildLitLanguageClause (self , obj , table ):
118
+ def build_literal_language_clause (self , obj , table ):
120
119
"""Build Literal and language clause."""
121
120
if isinstance (obj , Literal ) and obj .language is not None :
122
121
return table .c .objLanguage == obj .language
@@ -126,25 +125,25 @@ def buildLitLanguageClause(self, obj, table):
126
125
# Where Clause utility Functions
127
126
# The predicate and object clause builders are modified in order
128
127
# to optimize subjects and objects utility functions which can
129
- # take lists as their last argument (object, predicate -
130
- # respectively)
131
- def buildSubjClause (self , subject , table ):
128
+ # take lists as their last argument (object, predicate - respectively)
129
+
130
+ def build_subject_clause (self , subject , table ):
132
131
"""Build Subject clause."""
133
132
if isinstance (subject , REGEXTerm ):
134
133
# TODO: this work only in mysql. Must adapt for postgres and sqlite
135
134
return table .c .subject .op ("REGEXP" )(subject )
136
135
elif isinstance (subject , list ):
137
136
# clauseStrings = [] --- unused
138
137
return expression .or_ (
139
- * [self .buildSubjClause (s , table ) for s in subject if s ])
138
+ * [self .build_subject_clause (s , table ) for s in subject if s ])
140
139
elif isinstance (subject , (QuotedGraph , Graph )):
141
140
return table .c .subject == subject .identifier
142
141
elif subject is not None :
143
142
return table .c .subject == subject
144
143
else :
145
144
return None
146
145
147
- def buildPredClause (self , predicate , table ):
146
+ def build_predicate_clause (self , predicate , table ):
148
147
"""
149
148
Build Predicate clause.
150
149
@@ -157,13 +156,13 @@ def buildPredClause(self, predicate, table):
157
156
return table .c .predicate .op ("REGEXP" )(predicate )
158
157
elif isinstance (predicate , list ):
159
158
return expression .or_ (
160
- * [self .buildPredClause (p , table ) for p in predicate if p ])
159
+ * [self .build_predicate_clause (p , table ) for p in predicate if p ])
161
160
elif predicate is not None :
162
161
return table .c .predicate == predicate
163
162
else :
164
163
return None
165
164
166
- def buildObjClause (self , obj , table ):
165
+ def build_object_clause (self , obj , table ):
167
166
"""
168
167
Build Object clause.
169
168
@@ -176,15 +175,15 @@ def buildObjClause(self, obj, table):
176
175
return table .c .object .op ("REGEXP" )(obj )
177
176
elif isinstance (obj , list ):
178
177
return expression .or_ (
179
- * [self .buildObjClause (o , table ) for o in obj if o ])
178
+ * [self .build_object_clause (o , table ) for o in obj if o ])
180
179
elif isinstance (obj , (QuotedGraph , Graph )):
181
180
return table .c .object == obj .identifier
182
181
elif obj is not None :
183
182
return table .c .object == obj
184
183
else :
185
184
return None
186
185
187
- def buildContextClause (self , context , table ):
186
+ def build_context_clause (self , context , table ):
188
187
"""Build Context clause."""
189
188
if isinstance (context , REGEXTerm ):
190
189
# TODO: this work only in mysql. Must adapt for postgres and sqlite
@@ -194,27 +193,27 @@ def buildContextClause(self, context, table):
194
193
else :
195
194
return None
196
195
197
- def buildTypeMemberClause (self , subject , table ):
196
+ def build_type_member_clause (self , subject , table ):
198
197
"""Build Type Member clause."""
199
198
if isinstance (subject , REGEXTerm ):
200
199
# TODO: this work only in mysql. Must adapt for postgres and sqlite
201
200
return table .c .member .op ("regexp" )(subject )
202
201
elif isinstance (subject , list ):
203
202
return expression .or_ (
204
- * [self .buildTypeMemberClause (s , table ) for s in subject if s ])
203
+ * [self .build_type_member_clause (s , table ) for s in subject if s ])
205
204
elif subject is not None :
206
205
return table .c .member == subject
207
206
else :
208
207
return None
209
208
210
- def buildTypeClassClause (self , obj , table ):
209
+ def build_type_class_clause (self , obj , table ):
211
210
"""Build Type Class clause."""
212
211
if isinstance (obj , REGEXTerm ):
213
212
# TODO: this work only in mysql. Must adapt for postgres and sqlite
214
213
return table .c .klass .op ("regexp" )(obj )
215
214
elif isinstance (obj , list ):
216
215
return expression .or_ (
217
- * [self .buildTypeClassClause (o , table ) for o in obj if o ])
216
+ * [self .build_type_class_clause (o , table ) for o in obj if o ])
218
217
elif obj is not None :
219
218
return obj and table .c .klass == obj
220
219
else :
0 commit comments