MCPcopy Index your code
hub / github.com/plotly/plotly.py / as_path_object

Function as_path_object

plotly/io/_kaleido.py:187–203  ·  view source on GitHub ↗

Cast the `file` argument, which may be either a string or a Path object, to a Path object. If `file` is neither a string nor a Path object, None will be returned.

(file: Union[str, Path])

Source from the content-addressed store, hash-verified

185
186
187def as_path_object(file: Union[str, Path]) -> Union[Path, None]:
188 """
189 Cast the `file` argument, which may be either a string or a Path object,
190 to a Path object.
191 If `file` is neither a string nor a Path object, None will be returned.
192 """
193 if isinstance(file, str):
194 # Use the standard Path constructor to make a pathlib object.
195 path = Path(file)
196 elif isinstance(file, Path):
197 # `file` is already a Path object.
198 path = file
199 else:
200 # We could not make a Path object out of file. Either `file` is an open file
201 # descriptor with a `write()` method or it's an invalid object.
202 path = None
203 return path
204
205
206def infer_format(path: Union[Path, None], format: Union[str, None]) -> Union[str, None]:

Callers 2

write_imageFunction · 0.85
write_imagesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected