(field_name, docstring, read_only=False,
                      closed_only=False)
return property(getter, doc=docstring)
Create a GridIn property.
Create a GridIn property.
Create a GridIn property .
def _grid_in_property(field_name, docstring, read_only=False,
                      closed_only=False):
    """Create a GridIn property."""
    def getter(self):
        if closed_only and not self._closed:
            raise AttributeError("can only get %r on a closed file" %
                                 field_name)
        # Protect against PHP-237
        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 ) # Protect against PHP-237 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 )