MCPcopy
hub / github.com/pallets/click / convert

Method convert

src/click/types.py:508–529  ·  view source on GitHub ↗
(
        self, value: t.Any, param: Parameter | None, ctx: Context | None
    )

Source from the content-addressed store, hash-verified

506 return None
507
508 def convert(
509 self, value: t.Any, param: Parameter | None, ctx: Context | None
510 ) -> datetime:
511 if isinstance(value, datetime):
512 return value
513
514 for format in self.formats:
515 converted = self._try_to_convert_date(value, format)
516
517 if converted is not None:
518 return converted
519
520 formats_str = ", ".join(map(repr, self.formats))
521 self.fail(
522 ngettext(
523 "{value!r} does not match the format {format}.",
524 "{value!r} does not match the formats {formats}.",
525 len(self.formats),
526 ).format(value=value, format=formats_str, formats=formats_str),
527 param,
528 ctx,
529 )
530
531 def __repr__(self) -> str:
532 return "DateTime"

Callers

nothing calls this directly

Calls 2

_try_to_convert_dateMethod · 0.95
failMethod · 0.45

Tested by

no test coverage detected