@@ -314,109 +314,6 @@ def _snake_to_camel_case(value):
314314 return words [0 ] + '' .join (map (str .capitalize , words [1 :]))
315315
316316
317- class _ApiResourceProperty (object ):
318- """Base property implementation.
319-
320- Values will be stored on a `_properties` helper attribute of the
321- property's job instance.
322-
323- :type name: str
324- :param name: name of the property
325-
326- :type resource_name: str
327- :param resource_name: name of the property in the resource dictionary
328- """
329-
330- def __init__ (self , name , resource_name ):
331- self .name = name
332- self .resource_name = resource_name
333-
334- def __get__ (self , instance , owner ):
335- """Descriptor protocol: accessor"""
336- if instance is None :
337- return self
338- return instance ._properties .get (self .resource_name )
339-
340- def _validate (self , value ):
341- """Subclasses override to impose validation policy."""
342- raise NotImplementedError ("Abstract" )
343-
344- def __set__ (self , instance , value ):
345- """Descriptor protocol: mutator"""
346- self ._validate (value )
347- instance ._properties [self .resource_name ] = value
348-
349- def __delete__ (self , instance ):
350- """Descriptor protocol: deleter"""
351- del instance ._properties [self .resource_name ]
352-
353-
354- class _TypedApiResourceProperty (_ApiResourceProperty ):
355- """Property implementation: validates based on value type.
356-
357- :type name: str
358- :param name: name of the property
359-
360- :type resource_name: str
361- :param resource_name: name of the property in the resource dictionary
362-
363- :type property_type: type or sequence of types
364- :param property_type: type to be validated
365- """
366- def __init__ (self , name , resource_name , property_type ):
367- super (_TypedApiResourceProperty , self ).__init__ (
368- name , resource_name )
369- self .property_type = property_type
370-
371- def _validate (self , value ):
372- """Ensure that 'value' is of the appropriate type.
373-
374- :raises: ValueError on a type mismatch.
375- """
376- if value is None :
377- return
378- if not isinstance (value , self .property_type ):
379- raise ValueError ('Required type: %s' % (self .property_type ,))
380-
381-
382- class _ListApiResourceProperty (_ApiResourceProperty ):
383- """Property implementation: validates based on value type.
384-
385- :type name: str
386- :param name: name of the property
387-
388- :type resource_name: str
389- :param resource_name: name of the property in the resource dictionary
390-
391- :type property_type: type or sequence of types
392- :param property_type: type to be validated
393- """
394- def __init__ (self , name , resource_name , property_type ):
395- super (_ListApiResourceProperty , self ).__init__ (
396- name , resource_name )
397- self .property_type = property_type
398-
399- def __get__ (self , instance , owner ):
400- """Descriptor protocol: accessor"""
401- if instance is None :
402- return self
403- return instance ._properties .get (self .resource_name , [])
404-
405- def _validate (self , value ):
406- """Ensure that 'value' is of the appropriate type.
407-
408- :raises: ValueError on a type mismatch.
409- """
410- if value is None :
411- raise ValueError ((
412- 'Required type: list of {}. '
413- 'To unset, use del or set to empty list' ).format (
414- self .property_type ,))
415- if not all (isinstance (item , self .property_type ) for item in value ):
416- raise ValueError (
417- 'Required type: list of %s' % (self .property_type ,))
418-
419-
420317def _item_to_row (iterator , resource ):
421318 """Convert a JSON row to the native object.
422319
0 commit comments