MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / _grid_out_property

Function _grid_out_property

gridfs/grid_file_shared.py:143–162  ·  view source on GitHub ↗

Create a GridOut property.

(field_name: str, docstring: str)

Source from the content-addressed store, hash-verified

141
142
143def _grid_out_property(field_name: str, docstring: str) -> Any:
144 """Create a GridOut property."""
145 warn_str = ""
146 if docstring.startswith("DEPRECATED,"):
147 warn_str = (
148 f"GridOut property '{field_name}' is deprecated and will be removed in PyMongo 5.0"
149 )
150
151 def getter(self: Any) -> Any:
152 if warn_str:
153 warnings.warn(warn_str, stacklevel=2, category=DeprecationWarning)
154 self.open()
155
156 # Protect against PHP-237
157 if field_name == "length":
158 return self._file.get(field_name, 0)
159 return self._file.get(field_name, None)
160
161 docstring += "\n\nThis attribute is read-only."
162 return property(getter, doc=docstring)
163
164
165def _clear_entity_type_registry(entity: Any, **kwargs: Any) -> Any:

Callers 1

GridOutClass · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected