MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / crate_for_bin

Method crate_for_bin

misc/python/materialize/cargo.py:178–199  ·  view source on GitHub ↗

Find the crate containing the named binary. Args: bin: The name of the binary to find. Raises: ValueError: The named binary did not exist in exactly one crate in the Cargo workspace.

(self, bin: str)

Source from the content-addressed store, hash-verified

176 pass
177
178 def crate_for_bin(self, bin: str) -> Crate:
179 """Find the crate containing the named binary.
180
181 Args:
182 bin: The name of the binary to find.
183
184 Raises:
185 ValueError: The named binary did not exist in exactly one crate in
186 the Cargo workspace.
187 """
188 out = None
189 for crate in self.crates.values():
190 for b in crate.bins:
191 if b == bin:
192 if out is not None:
193 raise ValueError(
194 f"bin {bin} appears more than once in cargo workspace"
195 )
196 out = crate
197 if out is None:
198 raise ValueError(f"bin {bin} does not exist in cargo workspace")
199 return out
200
201 def crate_for_example(self, example: str) -> Crate:
202 """Find the crate containing the named example.

Callers 2

inputsMethod · 0.80

Calls 2

ValueErrorClass · 0.85
valuesMethod · 0.45

Tested by

no test coverage detected