MCPcopy
hub / github.com/explosion/spaCy / verify_cli_args

Function verify_cli_args

spacy/cli/convert.py:228–252  ·  view source on GitHub ↗
(
    msg: Printer,
    input_path: Path,
    output_dir: Union[str, Path],
    file_type: str,
    converter: str,
    ner_map: Optional[Path],
)

Source from the content-addressed store, hash-verified

226
227
228def verify_cli_args(
229 msg: Printer,
230 input_path: Path,
231 output_dir: Union[str, Path],
232 file_type: str,
233 converter: str,
234 ner_map: Optional[Path],
235):
236 if file_type not in FILE_TYPES_STDOUT and output_dir == "-":
237 msg.fail(
238 f"Can't write .{file_type} data to stdout. Please specify an output directory.",
239 exits=1,
240 )
241 if not input_path.exists():
242 msg.fail("Input file not found", input_path, exits=1)
243 if output_dir != "-" and not Path(output_dir).exists():
244 msg.fail("Output directory not found", output_dir, exits=1)
245 if ner_map is not None and not Path(ner_map).exists():
246 msg.fail("NER map not found", ner_map, exits=1)
247 if input_path.is_dir():
248 input_locs = walk_directory(input_path, converter)
249 if len(input_locs) == 0:
250 msg.fail("No input files in directory", input_path, exits=1)
251 if converter not in CONVERTERS:
252 msg.fail(f"Can't find converter for {converter}", exits=1)
253
254
255def _get_converter(msg, converter, input_path: Path):

Callers 1

convert_cliFunction · 0.70

Calls 1

walk_directoryFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…