#NEWLINE# def __init__( self , layer_ptr , ds ) : #NEWLINE# #INDENT# '\n        Initializes on an OGR C pointer to the Layer and the `DataSource` object\n        that owns this layer.  The `DataSource` object is required so that a \n        reference to it is kept with this Layer.  This prevents garbage \n        collection of the `DataSource` while this Layer is still active.\n        ' #NEWLINE# self . _ptr = None #NEWLINE# if ( not layer_ptr ) : #NEWLINE# #INDENT# raise OGRException ( 'Cannot create Layer, invalid pointer given' ) #NEWLINE# #UNINDENT# self . _ptr = layer_ptr #NEWLINE# self . _ds = layer_ptr #NEWLINE# self . _ldefn = get_layer_defn ( self . _ptr ) #NEWLINE# self . _random_read = self . test_capability ( 'RandomRead' )