MCPcopy Create free account
hub / github.com/EasyIME/PIME / parse

Method parse

python/python3/tornado/options.py:565–589  ·  view source on GitHub ↗
(self, value: str)

Source from the content-addressed store, hash-verified

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

Calls 6

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

Tested by 8

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_unicode_newlinesMethod · 0.36
test_optional_crMethod · 0.36
test_stringMethod · 0.36