def _grid_in_property(field_name, docstring, read_only=False, closed_only=False):
 def getter(self):
  if (closed_only and (not self._closed)):
   raise AttributeError(('can only get %r on a closed file' % field_name))
  if (field_name == 'length'):
   return self._file.get(field_name, 0)
  return self._file.get(field_name, None)
 def setter(self, value):
  if self._closed:
   self._coll.files.update_one({'_id': self._file['_id']}, {'$set': {field_name: value}})
  self._file[field_name] = value
 if read_only:
  docstring += '\n\nThis attribute is read-only.'
 elif closed_only:
  docstring = ('%s\n\n%s' % (docstring, 'This attribute is read-only and can only be read after :meth:`close` has been called.'))
 if ((not read_only) and (not closed_only)):
  return property(getter, setter, doc=docstring)
 return property(getter, doc=docstring)

def _grid_in_property ( field_name , docstring , read_only = False , closed_only = False ) : def getter ( self ) : if ( closed_only and ( not self . _closed ) ) : raise AttributeError ( ( 'can only get %r on a closed file' % field_name ) ) if ( field_name == 'length' ) : return self . _file . get ( field_name , 0 ) return self . _file . get ( field_name , None ) def setter ( self , value ) : if self . _closed : self . _coll . files . update_one ( { '_id' : self . _file [ '_id' ] } , { '$set' : { field_name : value } } ) self . _file [ field_name ] = value if read_only : docstring += '\n\nThis attribute is read-only.' elif closed_only : docstring = ( '%s\n\n%s' % ( docstring , 'This attribute is read-only and can only be read after :meth:`close` has been called.' ) ) if ( ( not read_only ) and ( not closed_only ) ) : return property ( getter , setter , doc = docstring ) return property ( getter , doc = docstring )
create a gridin property .