MCPcopy
hub / github.com/tornadoweb/tornado / parse

Method parse

tornado/options.py:563–587  ·  view source on GitHub ↗
(self, value: str)

Source from the content-addressed store, hash-verified

561 return self.default if self._value is _Option.UNSET else self._value
562
563 def parse(self, value: str) -> Any:
564 _parse = {
565 datetime.datetime: self._parse_datetime,
566 datetime.timedelta: self._parse_timedelta,
567 bool: self._parse_bool,
568 basestring_type: self._parse_string,
569 }.get(
570 self.type, self.type
571 ) # type: Callable[[str], Any]
572 if self.multiple:
573 self._value = []
574 for part in value.split(","):
575 if issubclass(self.type, numbers.Integral):
576 # allow ranges of the form X:Y (inclusive at both ends)
577 lo_str, _, hi_str = part.partition(":")
578 lo = _parse(lo_str)
579 hi = _parse(hi_str) if hi_str else lo
580 self._value.extend(range(lo, hi + 1))
581 else:
582 self._value.append(_parse(part))
583 else:
584 self._value = _parse(value)
585 if self.callback is not None:
586 self.callback(self._value)
587 return self.value()
588
589 def set(self, value: Any) -> None:
590 if self.multiple:

Callers 15

parse_command_lineMethod · 0.45
parse_config_fileMethod · 0.45
_parse_headersMethod · 0.45
test_future_interfaceMethod · 0.45
test_100_continueMethod · 0.45
test_unix_socketMethod · 0.45
read_headersMethod · 0.45
test_multi_lineMethod · 0.45
test_continuationMethod · 0.45
test_unicode_newlinesMethod · 0.45

Calls 6

valueMethod · 0.95
_parseFunction · 0.85
splitMethod · 0.80
appendMethod · 0.80
getMethod · 0.45
callbackMethod · 0.45

Tested by 11

test_future_interfaceMethod · 0.36
test_100_continueMethod · 0.36
test_unix_socketMethod · 0.36
read_headersMethod · 0.36
test_multi_lineMethod · 0.36
test_continuationMethod · 0.36
test_unicode_newlinesMethod · 0.36
test_optional_crMethod · 0.36
test_stringMethod · 0.36