@@ -191,34 +191,10 @@ impl LookupKey {
191
191
}
192
192
}
193
193
194
- pub fn py_get_attr < ' py , ' s > (
195
- & ' s self ,
196
- obj : & Bound < ' py , PyAny > ,
197
- kwargs : Option < & Bound < ' py , PyDict > > ,
198
- ) -> ValResult < Option < ( & ' s LookupPath , Bound < ' py , PyAny > ) > > {
199
- match self . _py_get_attr ( obj, kwargs) {
200
- Ok ( v) => Ok ( v) ,
201
- Err ( err) => {
202
- let error = py_err_string ( obj. py ( ) , err) ;
203
- Err ( ValError :: new (
204
- ErrorType :: GetAttributeError { error, context : None } ,
205
- obj,
206
- ) )
207
- }
208
- }
209
- }
210
-
211
- pub fn _py_get_attr < ' py , ' s > (
194
+ pub fn simple_py_get_attr < ' py , ' s > (
212
195
& ' s self ,
213
196
obj : & Bound < ' py , PyAny > ,
214
- kwargs : Option < & Bound < ' py , PyDict > > ,
215
197
) -> PyResult < Option < ( & ' s LookupPath , Bound < ' py , PyAny > ) > > {
216
- if let Some ( dict) = kwargs {
217
- if let Ok ( Some ( item) ) = self . py_get_dict_item ( dict) {
218
- return Ok ( Some ( item) ) ;
219
- }
220
- }
221
-
222
198
match self {
223
199
Self :: Simple { py_key, path, .. } => match py_get_attrs ( obj, py_key) ? {
224
200
Some ( value) => Ok ( Some ( ( path, value) ) ) ,
@@ -260,6 +236,37 @@ impl LookupKey {
260
236
}
261
237
}
262
238
239
+ pub fn py_get_attr < ' py , ' s > (
240
+ & ' s self ,
241
+ obj : & Bound < ' py , PyAny > ,
242
+ kwargs : Option < & Bound < ' py , PyDict > > ,
243
+ ) -> ValResult < Option < ( & ' s LookupPath , Bound < ' py , PyAny > ) > > {
244
+ match self . _py_get_attr ( obj, kwargs) {
245
+ Ok ( v) => Ok ( v) ,
246
+ Err ( err) => {
247
+ let error = py_err_string ( obj. py ( ) , err) ;
248
+ Err ( ValError :: new (
249
+ ErrorType :: GetAttributeError { error, context : None } ,
250
+ obj,
251
+ ) )
252
+ }
253
+ }
254
+ }
255
+
256
+ pub fn _py_get_attr < ' py , ' s > (
257
+ & ' s self ,
258
+ obj : & Bound < ' py , PyAny > ,
259
+ kwargs : Option < & Bound < ' py , PyDict > > ,
260
+ ) -> PyResult < Option < ( & ' s LookupPath , Bound < ' py , PyAny > ) > > {
261
+ if let Some ( dict) = kwargs {
262
+ if let Ok ( Some ( item) ) = self . py_get_dict_item ( dict) {
263
+ return Ok ( Some ( item) ) ;
264
+ }
265
+ }
266
+
267
+ self . simple_py_get_attr ( obj)
268
+ }
269
+
263
270
pub fn json_get < ' a , ' data , ' s > (
264
271
& ' s self ,
265
272
dict : & ' a JsonObject < ' data > ,
0 commit comments