MCPcopy Create free account
hub / github.com/OpenDCAI/Paper2Any / validate_input

Function validate_input

script/run_paper2ppt_cli.py:176–195  ·  view source on GitHub ↗

Validate input and return (input_content, resolved_input_type)

(input_str: str, input_type: str)

Source from the content-addressed store, hash-verified

174
175
176def validate_input(input_str: str, input_type: str) -> tuple[str, str]:
177 """
178 Validate input and return (input_content, resolved_input_type)
179 """
180 if input_type in ["PDF", "PPTX"]:
181 path = Path(input_str)
182 if not path.exists():
183 raise FileNotFoundError(f"Input file not found: {input_str}")
184
185 # Validate extension
186 ext = path.suffix.lower()
187 if input_type == "PDF" and ext != ".pdf":
188 raise ValueError(f"Expected PDF file, got {ext}")
189 elif input_type == "PPTX" and ext not in [".pptx", ".ppt"]:
190 raise ValueError(f"Expected PPTX file, got {ext}")
191
192 return str(path.resolve()), input_type
193 else:
194 # TEXT or TOPIC input
195 return input_str, input_type
196
197
198def create_output_dir(args) -> Path:

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected