MCPcopy Create free account
hub / github.com/libgit2/pygit2 / __getitem__

Method __getitem__

pygit2/submodules.py:190–200  ·  view source on GitHub ↗

Look up submodule information by name or path. Raises KeyError if there is no such submodule.

(self, name: str | Path)

Source from the content-addressed store, hash-verified

188 self._repository = repository
189
190 def __getitem__(self, name: str | Path) -> Submodule:
191 """
192 Look up submodule information by name or path.
193 Raises KeyError if there is no such submodule.
194 """
195 csub = ffi.new('git_submodule **')
196 cpath = ffi.new('char[]', to_bytes(name))
197
198 err = C.git_submodule_lookup(csub, self._repository._repo, cpath)
199 check_error(err)
200 return Submodule._from_c(self._repository, csub[0])
201
202 def __contains__(self, name: str) -> bool:
203 return self.get(name) is not None

Callers

nothing calls this directly

Calls 3

to_bytesFunction · 0.85
check_errorFunction · 0.85
_from_cMethod · 0.45

Tested by

no test coverage detected