id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
220,400 | getsentry/sentry-python | sentry_sdk/integrations/wsgi.py | _get_environ | def _get_environ(environ):
# type: (Dict[str, str]) -> Iterator[Tuple[str, str]]
"""
Returns our whitelisted environment variables.
"""
keys = ["SERVER_NAME", "SERVER_PORT"]
if _should_send_default_pii():
# Add all three headers here to make debugging of proxy setup easier.
keys ... | python | def _get_environ(environ):
# type: (Dict[str, str]) -> Iterator[Tuple[str, str]]
"""
Returns our whitelisted environment variables.
"""
keys = ["SERVER_NAME", "SERVER_PORT"]
if _should_send_default_pii():
# Add all three headers here to make debugging of proxy setup easier.
keys ... | [
"def",
"_get_environ",
"(",
"environ",
")",
":",
"# type: (Dict[str, str]) -> Iterator[Tuple[str, str]]",
"keys",
"=",
"[",
"\"SERVER_NAME\"",
",",
"\"SERVER_PORT\"",
"]",
"if",
"_should_send_default_pii",
"(",
")",
":",
"# Add all three headers here to make debugging of proxy ... | Returns our whitelisted environment variables. | [
"Returns",
"our",
"whitelisted",
"environment",
"variables",
"."
] | a1d77722bdce0b94660ebf50b5c4a4645916d084 | https://github.com/getsentry/sentry-python/blob/a1d77722bdce0b94660ebf50b5c4a4645916d084/sentry_sdk/integrations/wsgi.py#L96-L108 |
220,401 | getsentry/sentry-python | sentry_sdk/integrations/wsgi.py | get_client_ip | def get_client_ip(environ):
# type: (Dict[str, str]) -> Optional[Any]
"""
Infer the user IP address from various headers. This cannot be used in
security sensitive situations since the value may be forged from a client,
but it's good enough for the event payload.
"""
try:
return envi... | python | def get_client_ip(environ):
# type: (Dict[str, str]) -> Optional[Any]
"""
Infer the user IP address from various headers. This cannot be used in
security sensitive situations since the value may be forged from a client,
but it's good enough for the event payload.
"""
try:
return envi... | [
"def",
"get_client_ip",
"(",
"environ",
")",
":",
"# type: (Dict[str, str]) -> Optional[Any]",
"try",
":",
"return",
"environ",
"[",
"\"HTTP_X_FORWARDED_FOR\"",
"]",
".",
"split",
"(",
"\",\"",
")",
"[",
"0",
"]",
".",
"strip",
"(",
")",
"except",
"(",
"KeyErr... | Infer the user IP address from various headers. This cannot be used in
security sensitive situations since the value may be forged from a client,
but it's good enough for the event payload. | [
"Infer",
"the",
"user",
"IP",
"address",
"from",
"various",
"headers",
".",
"This",
"cannot",
"be",
"used",
"in",
"security",
"sensitive",
"situations",
"since",
"the",
"value",
"may",
"be",
"forged",
"from",
"a",
"client",
"but",
"it",
"s",
"good",
"enoug... | a1d77722bdce0b94660ebf50b5c4a4645916d084 | https://github.com/getsentry/sentry-python/blob/a1d77722bdce0b94660ebf50b5c4a4645916d084/sentry_sdk/integrations/wsgi.py#L132-L149 |
220,402 | getsentry/sentry-python | sentry_sdk/utils.py | event_hint_with_exc_info | def event_hint_with_exc_info(exc_info=None):
# type: (ExcInfo) -> Dict[str, Optional[ExcInfo]]
"""Creates a hint with the exc info filled in."""
if exc_info is None:
exc_info = sys.exc_info()
else:
exc_info = exc_info_from_error(exc_info)
if exc_info[0] is None:
exc_info = No... | python | def event_hint_with_exc_info(exc_info=None):
# type: (ExcInfo) -> Dict[str, Optional[ExcInfo]]
"""Creates a hint with the exc info filled in."""
if exc_info is None:
exc_info = sys.exc_info()
else:
exc_info = exc_info_from_error(exc_info)
if exc_info[0] is None:
exc_info = No... | [
"def",
"event_hint_with_exc_info",
"(",
"exc_info",
"=",
"None",
")",
":",
"# type: (ExcInfo) -> Dict[str, Optional[ExcInfo]]",
"if",
"exc_info",
"is",
"None",
":",
"exc_info",
"=",
"sys",
".",
"exc_info",
"(",
")",
"else",
":",
"exc_info",
"=",
"exc_info_from_error... | Creates a hint with the exc info filled in. | [
"Creates",
"a",
"hint",
"with",
"the",
"exc",
"info",
"filled",
"in",
"."
] | a1d77722bdce0b94660ebf50b5c4a4645916d084 | https://github.com/getsentry/sentry-python/blob/a1d77722bdce0b94660ebf50b5c4a4645916d084/sentry_sdk/utils.py#L81-L90 |
220,403 | getsentry/sentry-python | sentry_sdk/utils.py | format_and_strip | def format_and_strip(template, params, strip_string=strip_string):
"""Format a string containing %s for placeholders and call `strip_string`
on each parameter. The string template itself does not have a maximum
length.
TODO: handle other placeholders, not just %s
"""
chunks = template.split(u"%... | python | def format_and_strip(template, params, strip_string=strip_string):
"""Format a string containing %s for placeholders and call `strip_string`
on each parameter. The string template itself does not have a maximum
length.
TODO: handle other placeholders, not just %s
"""
chunks = template.split(u"%... | [
"def",
"format_and_strip",
"(",
"template",
",",
"params",
",",
"strip_string",
"=",
"strip_string",
")",
":",
"chunks",
"=",
"template",
".",
"split",
"(",
"u\"%s\"",
")",
"if",
"not",
"chunks",
":",
"raise",
"ValueError",
"(",
"\"No formatting placeholders fou... | Format a string containing %s for placeholders and call `strip_string`
on each parameter. The string template itself does not have a maximum
length.
TODO: handle other placeholders, not just %s | [
"Format",
"a",
"string",
"containing",
"%s",
"for",
"placeholders",
"and",
"call",
"strip_string",
"on",
"each",
"parameter",
".",
"The",
"string",
"template",
"itself",
"does",
"not",
"have",
"a",
"maximum",
"length",
"."
] | a1d77722bdce0b94660ebf50b5c4a4645916d084 | https://github.com/getsentry/sentry-python/blob/a1d77722bdce0b94660ebf50b5c4a4645916d084/sentry_sdk/utils.py#L876-L930 |
220,404 | getsentry/sentry-python | sentry_sdk/utils.py | Auth.store_api_url | def store_api_url(self):
"""Returns the API url for storing events."""
return "%s://%s%sapi/%s/store/" % (
self.scheme,
self.host,
self.path,
self.project_id,
) | python | def store_api_url(self):
"""Returns the API url for storing events."""
return "%s://%s%sapi/%s/store/" % (
self.scheme,
self.host,
self.path,
self.project_id,
) | [
"def",
"store_api_url",
"(",
"self",
")",
":",
"return",
"\"%s://%s%sapi/%s/store/\"",
"%",
"(",
"self",
".",
"scheme",
",",
"self",
".",
"host",
",",
"self",
".",
"path",
",",
"self",
".",
"project_id",
",",
")"
] | Returns the API url for storing events. | [
"Returns",
"the",
"API",
"url",
"for",
"storing",
"events",
"."
] | a1d77722bdce0b94660ebf50b5c4a4645916d084 | https://github.com/getsentry/sentry-python/blob/a1d77722bdce0b94660ebf50b5c4a4645916d084/sentry_sdk/utils.py#L182-L189 |
220,405 | getsentry/sentry-python | sentry_sdk/utils.py | Auth.to_header | def to_header(self, timestamp=None):
"""Returns the auth header a string."""
rv = [("sentry_key", self.public_key), ("sentry_version", self.version)]
if timestamp is not None:
rv.append(("sentry_timestamp", str(to_timestamp(timestamp))))
if self.client is not None:
... | python | def to_header(self, timestamp=None):
"""Returns the auth header a string."""
rv = [("sentry_key", self.public_key), ("sentry_version", self.version)]
if timestamp is not None:
rv.append(("sentry_timestamp", str(to_timestamp(timestamp))))
if self.client is not None:
... | [
"def",
"to_header",
"(",
"self",
",",
"timestamp",
"=",
"None",
")",
":",
"rv",
"=",
"[",
"(",
"\"sentry_key\"",
",",
"self",
".",
"public_key",
")",
",",
"(",
"\"sentry_version\"",
",",
"self",
".",
"version",
")",
"]",
"if",
"timestamp",
"is",
"not",... | Returns the auth header a string. | [
"Returns",
"the",
"auth",
"header",
"a",
"string",
"."
] | a1d77722bdce0b94660ebf50b5c4a4645916d084 | https://github.com/getsentry/sentry-python/blob/a1d77722bdce0b94660ebf50b5c4a4645916d084/sentry_sdk/utils.py#L191-L200 |
220,406 | abseil/abseil-py | absl/flags/_defines.py | _register_bounds_validator_if_needed | def _register_bounds_validator_if_needed(parser, name, flag_values):
"""Enforces lower and upper bounds for numeric flags.
Args:
parser: NumericParser (either FloatParser or IntegerParser), provides lower
and upper bounds, and help text to display.
name: str, name of the flag
flag_values: FlagV... | python | def _register_bounds_validator_if_needed(parser, name, flag_values):
"""Enforces lower and upper bounds for numeric flags.
Args:
parser: NumericParser (either FloatParser or IntegerParser), provides lower
and upper bounds, and help text to display.
name: str, name of the flag
flag_values: FlagV... | [
"def",
"_register_bounds_validator_if_needed",
"(",
"parser",
",",
"name",
",",
"flag_values",
")",
":",
"if",
"parser",
".",
"lower_bound",
"is",
"not",
"None",
"or",
"parser",
".",
"upper_bound",
"is",
"not",
"None",
":",
"def",
"checker",
"(",
"value",
")... | Enforces lower and upper bounds for numeric flags.
Args:
parser: NumericParser (either FloatParser or IntegerParser), provides lower
and upper bounds, and help text to display.
name: str, name of the flag
flag_values: FlagValues. | [
"Enforces",
"lower",
"and",
"upper",
"bounds",
"for",
"numeric",
"flags",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_defines.py#L39-L56 |
220,407 | abseil/abseil-py | absl/flags/_defines.py | DEFINE | def DEFINE(parser, name, default, help, flag_values=_flagvalues.FLAGS, # pylint: disable=redefined-builtin,invalid-name
serializer=None, module_name=None, **args):
"""Registers a generic Flag object.
NOTE: in the docstrings of all DEFINE* functions, "registers" is short
for "creates a new flag and re... | python | def DEFINE(parser, name, default, help, flag_values=_flagvalues.FLAGS, # pylint: disable=redefined-builtin,invalid-name
serializer=None, module_name=None, **args):
"""Registers a generic Flag object.
NOTE: in the docstrings of all DEFINE* functions, "registers" is short
for "creates a new flag and re... | [
"def",
"DEFINE",
"(",
"parser",
",",
"name",
",",
"default",
",",
"help",
",",
"flag_values",
"=",
"_flagvalues",
".",
"FLAGS",
",",
"# pylint: disable=redefined-builtin,invalid-name",
"serializer",
"=",
"None",
",",
"module_name",
"=",
"None",
",",
"*",
"*",
... | Registers a generic Flag object.
NOTE: in the docstrings of all DEFINE* functions, "registers" is short
for "creates a new flag and registers it".
Auxiliary function: clients should use the specialized DEFINE_<type>
function instead.
Args:
parser: ArgumentParser, used to parse the flag arguments.
n... | [
"Registers",
"a",
"generic",
"Flag",
"object",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_defines.py#L59-L82 |
220,408 | abseil/abseil-py | absl/flags/_defines.py | DEFINE_string | def DEFINE_string( # pylint: disable=invalid-name,redefined-builtin
name, default, help, flag_values=_flagvalues.FLAGS, **args):
"""Registers a flag whose value can be any string."""
parser = _argument_parser.ArgumentParser()
serializer = _argument_parser.ArgumentSerializer()
DEFINE(parser, name, default, ... | python | def DEFINE_string( # pylint: disable=invalid-name,redefined-builtin
name, default, help, flag_values=_flagvalues.FLAGS, **args):
"""Registers a flag whose value can be any string."""
parser = _argument_parser.ArgumentParser()
serializer = _argument_parser.ArgumentSerializer()
DEFINE(parser, name, default, ... | [
"def",
"DEFINE_string",
"(",
"# pylint: disable=invalid-name,redefined-builtin",
"name",
",",
"default",
",",
"help",
",",
"flag_values",
"=",
"_flagvalues",
".",
"FLAGS",
",",
"*",
"*",
"args",
")",
":",
"parser",
"=",
"_argument_parser",
".",
"ArgumentParser",
"... | Registers a flag whose value can be any string. | [
"Registers",
"a",
"flag",
"whose",
"value",
"can",
"be",
"any",
"string",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_defines.py#L236-L241 |
220,409 | abseil/abseil-py | absl/flags/_defines.py | DEFINE_boolean | def DEFINE_boolean( # pylint: disable=invalid-name,redefined-builtin
name, default, help, flag_values=_flagvalues.FLAGS, module_name=None,
**args):
"""Registers a boolean flag.
Such a boolean flag does not take an argument. If a user wants to
specify a false value explicitly, the long option beginning ... | python | def DEFINE_boolean( # pylint: disable=invalid-name,redefined-builtin
name, default, help, flag_values=_flagvalues.FLAGS, module_name=None,
**args):
"""Registers a boolean flag.
Such a boolean flag does not take an argument. If a user wants to
specify a false value explicitly, the long option beginning ... | [
"def",
"DEFINE_boolean",
"(",
"# pylint: disable=invalid-name,redefined-builtin",
"name",
",",
"default",
",",
"help",
",",
"flag_values",
"=",
"_flagvalues",
".",
"FLAGS",
",",
"module_name",
"=",
"None",
",",
"*",
"*",
"args",
")",
":",
"DEFINE_flag",
"(",
"_f... | Registers a boolean flag.
Such a boolean flag does not take an argument. If a user wants to
specify a false value explicitly, the long option beginning with 'no'
must be used: i.e. --noflag
This flag will have a value of None, True or False. None is possible
if default=None and the user does not specify t... | [
"Registers",
"a",
"boolean",
"flag",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_defines.py#L244-L268 |
220,410 | abseil/abseil-py | absl/flags/_defines.py | DEFINE_float | def DEFINE_float( # pylint: disable=invalid-name,redefined-builtin
name, default, help, lower_bound=None, upper_bound=None,
flag_values=_flagvalues.FLAGS, **args): # pylint: disable=invalid-name
"""Registers a flag whose value must be a float.
If lower_bound or upper_bound are set, then this flag must b... | python | def DEFINE_float( # pylint: disable=invalid-name,redefined-builtin
name, default, help, lower_bound=None, upper_bound=None,
flag_values=_flagvalues.FLAGS, **args): # pylint: disable=invalid-name
"""Registers a flag whose value must be a float.
If lower_bound or upper_bound are set, then this flag must b... | [
"def",
"DEFINE_float",
"(",
"# pylint: disable=invalid-name,redefined-builtin",
"name",
",",
"default",
",",
"help",
",",
"lower_bound",
"=",
"None",
",",
"upper_bound",
"=",
"None",
",",
"flag_values",
"=",
"_flagvalues",
".",
"FLAGS",
",",
"*",
"*",
"args",
")... | Registers a flag whose value must be a float.
If lower_bound or upper_bound are set, then this flag must be
within the given range.
Args:
name: str, the flag name.
default: float|str|None, the default value of the flag.
help: str, the help message.
lower_bound: float, min value of the flag.
... | [
"Registers",
"a",
"flag",
"whose",
"value",
"must",
"be",
"a",
"float",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_defines.py#L271-L292 |
220,411 | abseil/abseil-py | absl/flags/_defines.py | DEFINE_integer | def DEFINE_integer( # pylint: disable=invalid-name,redefined-builtin
name, default, help, lower_bound=None, upper_bound=None,
flag_values=_flagvalues.FLAGS, **args):
"""Registers a flag whose value must be an integer.
If lower_bound, or upper_bound are set, then this flag must be
within the given range.... | python | def DEFINE_integer( # pylint: disable=invalid-name,redefined-builtin
name, default, help, lower_bound=None, upper_bound=None,
flag_values=_flagvalues.FLAGS, **args):
"""Registers a flag whose value must be an integer.
If lower_bound, or upper_bound are set, then this flag must be
within the given range.... | [
"def",
"DEFINE_integer",
"(",
"# pylint: disable=invalid-name,redefined-builtin",
"name",
",",
"default",
",",
"help",
",",
"lower_bound",
"=",
"None",
",",
"upper_bound",
"=",
"None",
",",
"flag_values",
"=",
"_flagvalues",
".",
"FLAGS",
",",
"*",
"*",
"args",
... | Registers a flag whose value must be an integer.
If lower_bound, or upper_bound are set, then this flag must be
within the given range.
Args:
name: str, the flag name.
default: int|str|None, the default value of the flag.
help: str, the help message.
lower_bound: int, min value of the flag.
... | [
"Registers",
"a",
"flag",
"whose",
"value",
"must",
"be",
"an",
"integer",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_defines.py#L295-L316 |
220,412 | abseil/abseil-py | absl/flags/_defines.py | DEFINE_enum_class | def DEFINE_enum_class( # pylint: disable=invalid-name,redefined-builtin
name, default, enum_class, help, flag_values=_flagvalues.FLAGS,
module_name=None, **args):
"""Registers a flag whose value can be the name of enum members.
Args:
name: str, the flag name.
default: Enum|str|None, the default va... | python | def DEFINE_enum_class( # pylint: disable=invalid-name,redefined-builtin
name, default, enum_class, help, flag_values=_flagvalues.FLAGS,
module_name=None, **args):
"""Registers a flag whose value can be the name of enum members.
Args:
name: str, the flag name.
default: Enum|str|None, the default va... | [
"def",
"DEFINE_enum_class",
"(",
"# pylint: disable=invalid-name,redefined-builtin",
"name",
",",
"default",
",",
"enum_class",
",",
"help",
",",
"flag_values",
"=",
"_flagvalues",
".",
"FLAGS",
",",
"module_name",
"=",
"None",
",",
"*",
"*",
"args",
")",
":",
"... | Registers a flag whose value can be the name of enum members.
Args:
name: str, the flag name.
default: Enum|str|None, the default value of the flag.
enum_class: class, the Enum class with all the possible values for the flag.
help: str, the help message.
flag_values: FlagValues, the FlagValues in... | [
"Registers",
"a",
"flag",
"whose",
"value",
"can",
"be",
"the",
"name",
"of",
"enum",
"members",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_defines.py#L343-L360 |
220,413 | abseil/abseil-py | absl/flags/_defines.py | DEFINE_spaceseplist | def DEFINE_spaceseplist( # pylint: disable=invalid-name,redefined-builtin
name, default, help, comma_compat=False, flag_values=_flagvalues.FLAGS,
**args):
"""Registers a flag whose value is a whitespace-separated list of strings.
Any whitespace can be used as a separator.
Args:
name: str, the flag ... | python | def DEFINE_spaceseplist( # pylint: disable=invalid-name,redefined-builtin
name, default, help, comma_compat=False, flag_values=_flagvalues.FLAGS,
**args):
"""Registers a flag whose value is a whitespace-separated list of strings.
Any whitespace can be used as a separator.
Args:
name: str, the flag ... | [
"def",
"DEFINE_spaceseplist",
"(",
"# pylint: disable=invalid-name,redefined-builtin",
"name",
",",
"default",
",",
"help",
",",
"comma_compat",
"=",
"False",
",",
"flag_values",
"=",
"_flagvalues",
".",
"FLAGS",
",",
"*",
"*",
"args",
")",
":",
"parser",
"=",
"... | Registers a flag whose value is a whitespace-separated list of strings.
Any whitespace can be used as a separator.
Args:
name: str, the flag name.
default: list|str|None, the default value of the flag.
help: str, the help message.
comma_compat: bool - Whether to support comma as an additional sepa... | [
"Registers",
"a",
"flag",
"whose",
"value",
"is",
"a",
"whitespace",
"-",
"separated",
"list",
"of",
"strings",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_defines.py#L383-L405 |
220,414 | abseil/abseil-py | absl/flags/_defines.py | DEFINE_multi_enum | def DEFINE_multi_enum( # pylint: disable=invalid-name,redefined-builtin
name, default, enum_values, help, flag_values=_flagvalues.FLAGS,
case_sensitive=True, **args):
"""Registers a flag whose value can be a list strings from enum_values.
Use the flag on the command line multiple times to place multiple
... | python | def DEFINE_multi_enum( # pylint: disable=invalid-name,redefined-builtin
name, default, enum_values, help, flag_values=_flagvalues.FLAGS,
case_sensitive=True, **args):
"""Registers a flag whose value can be a list strings from enum_values.
Use the flag on the command line multiple times to place multiple
... | [
"def",
"DEFINE_multi_enum",
"(",
"# pylint: disable=invalid-name,redefined-builtin",
"name",
",",
"default",
",",
"enum_values",
",",
"help",
",",
"flag_values",
"=",
"_flagvalues",
".",
"FLAGS",
",",
"case_sensitive",
"=",
"True",
",",
"*",
"*",
"args",
")",
":",... | Registers a flag whose value can be a list strings from enum_values.
Use the flag on the command line multiple times to place multiple
enum values into the list. The 'default' may be a single string
(which will be converted into a single-element list) or a list of
strings.
Args:
name: str, the flag nam... | [
"Registers",
"a",
"flag",
"whose",
"value",
"can",
"be",
"a",
"list",
"strings",
"from",
"enum_values",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_defines.py#L519-L544 |
220,415 | abseil/abseil-py | absl/flags/_defines.py | DEFINE_multi_enum_class | def DEFINE_multi_enum_class( # pylint: disable=invalid-name,redefined-builtin
name,
default,
enum_class,
help,
flag_values=_flagvalues.FLAGS,
module_name=None,
**args):
"""Registers a flag whose value can be a list of enum members.
Use the flag on the command line multiple times to pla... | python | def DEFINE_multi_enum_class( # pylint: disable=invalid-name,redefined-builtin
name,
default,
enum_class,
help,
flag_values=_flagvalues.FLAGS,
module_name=None,
**args):
"""Registers a flag whose value can be a list of enum members.
Use the flag on the command line multiple times to pla... | [
"def",
"DEFINE_multi_enum_class",
"(",
"# pylint: disable=invalid-name,redefined-builtin",
"name",
",",
"default",
",",
"enum_class",
",",
"help",
",",
"flag_values",
"=",
"_flagvalues",
".",
"FLAGS",
",",
"module_name",
"=",
"None",
",",
"*",
"*",
"args",
")",
":... | Registers a flag whose value can be a list of enum members.
Use the flag on the command line multiple times to place multiple
enum values into the list.
Args:
name: str, the flag name.
default: Union[Iterable[Enum], Iterable[Text], Enum, Text, None], the
default value of the flag; see
`D... | [
"Registers",
"a",
"flag",
"whose",
"value",
"can",
"be",
"a",
"list",
"of",
"enum",
"members",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_defines.py#L547-L579 |
220,416 | abseil/abseil-py | absl/flags/_argument_parser.py | ArgumentParser.parse | def parse(self, argument):
"""Parses the string argument and returns the native value.
By default it returns its argument unmodified.
Args:
argument: string argument passed in the commandline.
Raises:
ValueError: Raised when it fails to parse the argument.
TypeError: Raised when the... | python | def parse(self, argument):
"""Parses the string argument and returns the native value.
By default it returns its argument unmodified.
Args:
argument: string argument passed in the commandline.
Raises:
ValueError: Raised when it fails to parse the argument.
TypeError: Raised when the... | [
"def",
"parse",
"(",
"self",
",",
"argument",
")",
":",
"if",
"not",
"isinstance",
"(",
"argument",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'flag value must be a string, found \"{}\"'",
".",
"format",
"(",
"type",
"(",
"argument"... | Parses the string argument and returns the native value.
By default it returns its argument unmodified.
Args:
argument: string argument passed in the commandline.
Raises:
ValueError: Raised when it fails to parse the argument.
TypeError: Raised when the argument has the wrong type.
... | [
"Parses",
"the",
"string",
"argument",
"and",
"returns",
"the",
"native",
"value",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_argument_parser.py#L97-L115 |
220,417 | abseil/abseil-py | absl/flags/_argument_parser.py | NumericParser.is_outside_bounds | def is_outside_bounds(self, val):
"""Returns whether the value is outside the bounds or not."""
return ((self.lower_bound is not None and val < self.lower_bound) or
(self.upper_bound is not None and val > self.upper_bound)) | python | def is_outside_bounds(self, val):
"""Returns whether the value is outside the bounds or not."""
return ((self.lower_bound is not None and val < self.lower_bound) or
(self.upper_bound is not None and val > self.upper_bound)) | [
"def",
"is_outside_bounds",
"(",
"self",
",",
"val",
")",
":",
"return",
"(",
"(",
"self",
".",
"lower_bound",
"is",
"not",
"None",
"and",
"val",
"<",
"self",
".",
"lower_bound",
")",
"or",
"(",
"self",
".",
"upper_bound",
"is",
"not",
"None",
"and",
... | Returns whether the value is outside the bounds or not. | [
"Returns",
"whether",
"the",
"value",
"is",
"outside",
"the",
"bounds",
"or",
"not",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_argument_parser.py#L145-L148 |
220,418 | abseil/abseil-py | absl/flags/_argument_parser.py | FloatParser.convert | def convert(self, argument):
"""Returns the float value of argument."""
if (_is_integer_type(argument) or isinstance(argument, float) or
isinstance(argument, six.string_types)):
return float(argument)
else:
raise TypeError(
'Expect argument to be a string, int, or float, found ... | python | def convert(self, argument):
"""Returns the float value of argument."""
if (_is_integer_type(argument) or isinstance(argument, float) or
isinstance(argument, six.string_types)):
return float(argument)
else:
raise TypeError(
'Expect argument to be a string, int, or float, found ... | [
"def",
"convert",
"(",
"self",
",",
"argument",
")",
":",
"if",
"(",
"_is_integer_type",
"(",
"argument",
")",
"or",
"isinstance",
"(",
"argument",
",",
"float",
")",
"or",
"isinstance",
"(",
"argument",
",",
"six",
".",
"string_types",
")",
")",
":",
... | Returns the float value of argument. | [
"Returns",
"the",
"float",
"value",
"of",
"argument",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_argument_parser.py#L209-L217 |
220,419 | abseil/abseil-py | absl/flags/_argument_parser.py | IntegerParser.convert | def convert(self, argument):
"""Returns the int value of argument."""
if _is_integer_type(argument):
return argument
elif isinstance(argument, six.string_types):
base = 10
if len(argument) > 2 and argument[0] == '0':
if argument[1] == 'o':
base = 8
elif argument[1... | python | def convert(self, argument):
"""Returns the int value of argument."""
if _is_integer_type(argument):
return argument
elif isinstance(argument, six.string_types):
base = 10
if len(argument) > 2 and argument[0] == '0':
if argument[1] == 'o':
base = 8
elif argument[1... | [
"def",
"convert",
"(",
"self",
",",
"argument",
")",
":",
"if",
"_is_integer_type",
"(",
"argument",
")",
":",
"return",
"argument",
"elif",
"isinstance",
"(",
"argument",
",",
"six",
".",
"string_types",
")",
":",
"base",
"=",
"10",
"if",
"len",
"(",
... | Returns the int value of argument. | [
"Returns",
"the",
"int",
"value",
"of",
"argument",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_argument_parser.py#L254-L268 |
220,420 | abseil/abseil-py | absl/flags/_argument_parser.py | EnumClassParser.parse | def parse(self, argument):
"""Determines validity of argument and returns the correct element of enum.
Args:
argument: str or Enum class member, the supplied flag value.
Returns:
The first matching Enum class member in Enum class.
Raises:
ValueError: Raised when argument didn't matc... | python | def parse(self, argument):
"""Determines validity of argument and returns the correct element of enum.
Args:
argument: str or Enum class member, the supplied flag value.
Returns:
The first matching Enum class member in Enum class.
Raises:
ValueError: Raised when argument didn't matc... | [
"def",
"parse",
"(",
"self",
",",
"argument",
")",
":",
"if",
"isinstance",
"(",
"argument",
",",
"self",
".",
"enum_class",
")",
":",
"return",
"argument",
"if",
"argument",
"not",
"in",
"self",
".",
"enum_class",
".",
"__members__",
":",
"raise",
"Valu... | Determines validity of argument and returns the correct element of enum.
Args:
argument: str or Enum class member, the supplied flag value.
Returns:
The first matching Enum class member in Enum class.
Raises:
ValueError: Raised when argument didn't match anything in enum. | [
"Determines",
"validity",
"of",
"argument",
"and",
"returns",
"the",
"correct",
"element",
"of",
"enum",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_argument_parser.py#L380-L398 |
220,421 | abseil/abseil-py | absl/flags/_argument_parser.py | ListParser.parse | def parse(self, argument):
"""Parses argument as comma-separated list of strings."""
if isinstance(argument, list):
return argument
elif not argument:
return []
else:
try:
return [s.strip() for s in list(csv.reader([argument], strict=True))[0]]
except csv.Error as e:
... | python | def parse(self, argument):
"""Parses argument as comma-separated list of strings."""
if isinstance(argument, list):
return argument
elif not argument:
return []
else:
try:
return [s.strip() for s in list(csv.reader([argument], strict=True))[0]]
except csv.Error as e:
... | [
"def",
"parse",
"(",
"self",
",",
"argument",
")",
":",
"if",
"isinstance",
"(",
"argument",
",",
"list",
")",
":",
"return",
"argument",
"elif",
"not",
"argument",
":",
"return",
"[",
"]",
"else",
":",
"try",
":",
"return",
"[",
"s",
".",
"strip",
... | Parses argument as comma-separated list of strings. | [
"Parses",
"argument",
"as",
"comma",
"-",
"separated",
"list",
"of",
"strings",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_argument_parser.py#L494-L510 |
220,422 | abseil/abseil-py | absl/flags/_argument_parser.py | WhitespaceSeparatedListParser.parse | def parse(self, argument):
"""Parses argument as whitespace-separated list of strings.
It also parses argument as comma-separated list of strings if requested.
Args:
argument: string argument passed in the commandline.
Returns:
[str], the parsed flag value.
"""
if isinstance(argum... | python | def parse(self, argument):
"""Parses argument as whitespace-separated list of strings.
It also parses argument as comma-separated list of strings if requested.
Args:
argument: string argument passed in the commandline.
Returns:
[str], the parsed flag value.
"""
if isinstance(argum... | [
"def",
"parse",
"(",
"self",
",",
"argument",
")",
":",
"if",
"isinstance",
"(",
"argument",
",",
"list",
")",
":",
"return",
"argument",
"elif",
"not",
"argument",
":",
"return",
"[",
"]",
"else",
":",
"if",
"self",
".",
"_comma_compat",
":",
"argumen... | Parses argument as whitespace-separated list of strings.
It also parses argument as comma-separated list of strings if requested.
Args:
argument: string argument passed in the commandline.
Returns:
[str], the parsed flag value. | [
"Parses",
"argument",
"as",
"whitespace",
"-",
"separated",
"list",
"of",
"strings",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_argument_parser.py#L534-L552 |
220,423 | abseil/abseil-py | absl/flags/_flagvalues.py | FlagValues.set_gnu_getopt | def set_gnu_getopt(self, gnu_getopt=True):
"""Sets whether or not to use GNU style scanning.
GNU style allows mixing of flag and non-flag arguments. See
http://docs.python.org/library/getopt.html#getopt.gnu_getopt
Args:
gnu_getopt: bool, whether or not to use GNU style scanning.
"""
self... | python | def set_gnu_getopt(self, gnu_getopt=True):
"""Sets whether or not to use GNU style scanning.
GNU style allows mixing of flag and non-flag arguments. See
http://docs.python.org/library/getopt.html#getopt.gnu_getopt
Args:
gnu_getopt: bool, whether or not to use GNU style scanning.
"""
self... | [
"def",
"set_gnu_getopt",
"(",
"self",
",",
"gnu_getopt",
"=",
"True",
")",
":",
"self",
".",
"__dict__",
"[",
"'__use_gnu_getopt'",
"]",
"=",
"gnu_getopt",
"self",
".",
"__dict__",
"[",
"'__use_gnu_getopt_explicitly_set'",
"]",
"=",
"True"
] | Sets whether or not to use GNU style scanning.
GNU style allows mixing of flag and non-flag arguments. See
http://docs.python.org/library/getopt.html#getopt.gnu_getopt
Args:
gnu_getopt: bool, whether or not to use GNU style scanning. | [
"Sets",
"whether",
"or",
"not",
"to",
"use",
"GNU",
"style",
"scanning",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_flagvalues.py#L126-L136 |
220,424 | abseil/abseil-py | absl/flags/_flagvalues.py | FlagValues._assert_validators | def _assert_validators(self, validators):
"""Asserts if all validators in the list are satisfied.
It asserts validators in the order they were created.
Args:
validators: Iterable(validators.Validator), validators to be
verified.
Raises:
AttributeError: Raised if validators work w... | python | def _assert_validators(self, validators):
"""Asserts if all validators in the list are satisfied.
It asserts validators in the order they were created.
Args:
validators: Iterable(validators.Validator), validators to be
verified.
Raises:
AttributeError: Raised if validators work w... | [
"def",
"_assert_validators",
"(",
"self",
",",
"validators",
")",
":",
"for",
"validator",
"in",
"sorted",
"(",
"validators",
",",
"key",
"=",
"lambda",
"validator",
":",
"validator",
".",
"insertion_index",
")",
":",
"try",
":",
"validator",
".",
"verify",
... | Asserts if all validators in the list are satisfied.
It asserts validators in the order they were created.
Args:
validators: Iterable(validators.Validator), validators to be
verified.
Raises:
AttributeError: Raised if validators work with a non-existing flag.
IllegalFlagValueEr... | [
"Asserts",
"if",
"all",
"validators",
"in",
"the",
"list",
"are",
"satisfied",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_flagvalues.py#L512-L531 |
220,425 | abseil/abseil-py | absl/flags/_flagvalues.py | FlagValues.set_default | def set_default(self, name, value):
"""Changes the default value of the named flag object.
The flag's current value is also updated if the flag is currently using
the default value, i.e. not specified in the command line, and not set
by FLAGS.name = value.
Args:
name: str, the name of the fl... | python | def set_default(self, name, value):
"""Changes the default value of the named flag object.
The flag's current value is also updated if the flag is currently using
the default value, i.e. not specified in the command line, and not set
by FLAGS.name = value.
Args:
name: str, the name of the fl... | [
"def",
"set_default",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"fl",
"=",
"self",
".",
"_flags",
"(",
")",
"if",
"name",
"not",
"in",
"fl",
":",
"self",
".",
"_set_unknown_flag",
"(",
"name",
",",
"value",
")",
"return",
"fl",
"[",
"name",... | Changes the default value of the named flag object.
The flag's current value is also updated if the flag is currently using
the default value, i.e. not specified in the command line, and not set
by FLAGS.name = value.
Args:
name: str, the name of the flag to modify.
value: The new default ... | [
"Changes",
"the",
"default",
"value",
"of",
"the",
"named",
"flag",
"object",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_flagvalues.py#L563-L583 |
220,426 | abseil/abseil-py | absl/flags/_flagvalues.py | FlagValues.flag_values_dict | def flag_values_dict(self):
"""Returns a dictionary that maps flag names to flag values."""
return {name: flag.value for name, flag in six.iteritems(self._flags())} | python | def flag_values_dict(self):
"""Returns a dictionary that maps flag names to flag values."""
return {name: flag.value for name, flag in six.iteritems(self._flags())} | [
"def",
"flag_values_dict",
"(",
"self",
")",
":",
"return",
"{",
"name",
":",
"flag",
".",
"value",
"for",
"name",
",",
"flag",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"_flags",
"(",
")",
")",
"}"
] | Returns a dictionary that maps flag names to flag values. | [
"Returns",
"a",
"dictionary",
"that",
"maps",
"flag",
"names",
"to",
"flag",
"values",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_flagvalues.py#L821-L823 |
220,427 | abseil/abseil-py | absl/flags/_flagvalues.py | FlagValues.get_help | def get_help(self, prefix='', include_special_flags=True):
"""Returns a help string for all known flags.
Args:
prefix: str, per-line output prefix.
include_special_flags: bool, whether to include description of
SPECIAL_FLAGS, i.e. --flagfile and --undefok.
Returns:
str, formatted... | python | def get_help(self, prefix='', include_special_flags=True):
"""Returns a help string for all known flags.
Args:
prefix: str, per-line output prefix.
include_special_flags: bool, whether to include description of
SPECIAL_FLAGS, i.e. --flagfile and --undefok.
Returns:
str, formatted... | [
"def",
"get_help",
"(",
"self",
",",
"prefix",
"=",
"''",
",",
"include_special_flags",
"=",
"True",
")",
":",
"flags_by_module",
"=",
"self",
".",
"flags_by_module_dict",
"(",
")",
"if",
"flags_by_module",
":",
"modules",
"=",
"sorted",
"(",
"flags_by_module"... | Returns a help string for all known flags.
Args:
prefix: str, per-line output prefix.
include_special_flags: bool, whether to include description of
SPECIAL_FLAGS, i.e. --flagfile and --undefok.
Returns:
str, formatted help message. | [
"Returns",
"a",
"help",
"string",
"for",
"all",
"known",
"flags",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_flagvalues.py#L829-L857 |
220,428 | abseil/abseil-py | absl/flags/_flagvalues.py | FlagValues._get_help_for_modules | def _get_help_for_modules(self, modules, prefix, include_special_flags):
"""Returns the help string for a list of modules.
Private to absl.flags package.
Args:
modules: List[str], a list of modules to get the help string for.
prefix: str, a string that is prepended to each generated help line.... | python | def _get_help_for_modules(self, modules, prefix, include_special_flags):
"""Returns the help string for a list of modules.
Private to absl.flags package.
Args:
modules: List[str], a list of modules to get the help string for.
prefix: str, a string that is prepended to each generated help line.... | [
"def",
"_get_help_for_modules",
"(",
"self",
",",
"modules",
",",
"prefix",
",",
"include_special_flags",
")",
":",
"output_lines",
"=",
"[",
"]",
"for",
"module",
"in",
"modules",
":",
"self",
".",
"_render_our_module_flags",
"(",
"module",
",",
"output_lines",... | Returns the help string for a list of modules.
Private to absl.flags package.
Args:
modules: List[str], a list of modules to get the help string for.
prefix: str, a string that is prepended to each generated help line.
include_special_flags: bool, whether to include description of
SP... | [
"Returns",
"the",
"help",
"string",
"for",
"a",
"list",
"of",
"modules",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_flagvalues.py#L859-L879 |
220,429 | abseil/abseil-py | absl/flags/_flagvalues.py | FlagValues._render_our_module_key_flags | def _render_our_module_key_flags(self, module, output_lines, prefix=''):
"""Returns a help string for the key flags of a given module.
Args:
module: module|str, the module to render key flags for.
output_lines: [str], a list of strings. The generated help message
lines will be appended t... | python | def _render_our_module_key_flags(self, module, output_lines, prefix=''):
"""Returns a help string for the key flags of a given module.
Args:
module: module|str, the module to render key flags for.
output_lines: [str], a list of strings. The generated help message
lines will be appended t... | [
"def",
"_render_our_module_key_flags",
"(",
"self",
",",
"module",
",",
"output_lines",
",",
"prefix",
"=",
"''",
")",
":",
"key_flags",
"=",
"self",
".",
"get_key_flags_for_module",
"(",
"module",
")",
"if",
"key_flags",
":",
"self",
".",
"_render_module_flags"... | Returns a help string for the key flags of a given module.
Args:
module: module|str, the module to render key flags for.
output_lines: [str], a list of strings. The generated help message
lines will be appended to this list.
prefix: str, a string that is prepended to each generated hel... | [
"Returns",
"a",
"help",
"string",
"for",
"the",
"key",
"flags",
"of",
"a",
"given",
"module",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_flagvalues.py#L894-L905 |
220,430 | abseil/abseil-py | absl/flags/_flagvalues.py | FlagValues.module_help | def module_help(self, module):
"""Describes the key flags of a module.
Args:
module: module|str, the module to describe the key flags for.
Returns:
str, describing the key flags of a module.
"""
helplist = []
self._render_our_module_key_flags(module, helplist)
return '\n'.join(... | python | def module_help(self, module):
"""Describes the key flags of a module.
Args:
module: module|str, the module to describe the key flags for.
Returns:
str, describing the key flags of a module.
"""
helplist = []
self._render_our_module_key_flags(module, helplist)
return '\n'.join(... | [
"def",
"module_help",
"(",
"self",
",",
"module",
")",
":",
"helplist",
"=",
"[",
"]",
"self",
".",
"_render_our_module_key_flags",
"(",
"module",
",",
"helplist",
")",
"return",
"'\\n'",
".",
"join",
"(",
"helplist",
")"
] | Describes the key flags of a module.
Args:
module: module|str, the module to describe the key flags for.
Returns:
str, describing the key flags of a module. | [
"Describes",
"the",
"key",
"flags",
"of",
"a",
"module",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_flagvalues.py#L907-L918 |
220,431 | abseil/abseil-py | absl/flags/_flagvalues.py | FlagValues.write_help_in_xml_format | def write_help_in_xml_format(self, outfile=None):
"""Outputs flag documentation in XML format.
NOTE: We use element names that are consistent with those used by
the C++ command-line flag library, from
https://github.com/gflags/gflags.
We also use a few new elements (e.g., <key>), but we do not
... | python | def write_help_in_xml_format(self, outfile=None):
"""Outputs flag documentation in XML format.
NOTE: We use element names that are consistent with those used by
the C++ command-line flag library, from
https://github.com/gflags/gflags.
We also use a few new elements (e.g., <key>), but we do not
... | [
"def",
"write_help_in_xml_format",
"(",
"self",
",",
"outfile",
"=",
"None",
")",
":",
"doc",
"=",
"minidom",
".",
"Document",
"(",
")",
"all_flag",
"=",
"doc",
".",
"createElement",
"(",
"'AllFlags'",
")",
"doc",
".",
"appendChild",
"(",
"all_flag",
")",
... | Outputs flag documentation in XML format.
NOTE: We use element names that are consistent with those used by
the C++ command-line flag library, from
https://github.com/gflags/gflags.
We also use a few new elements (e.g., <key>), but we do not
interfere / overlap with existing XML elements used by th... | [
"Outputs",
"flag",
"documentation",
"in",
"XML",
"format",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_flagvalues.py#L1206-L1255 |
220,432 | abseil/abseil-py | absl/logging/converter.py | absl_to_cpp | def absl_to_cpp(level):
"""Converts an absl log level to a cpp log level.
Args:
level: int, an absl.logging level.
Raises:
TypeError: Raised when level is not an integer.
Returns:
The corresponding integer level for use in Abseil C++.
"""
if not isinstance(level, int):
raise TypeError('Ex... | python | def absl_to_cpp(level):
"""Converts an absl log level to a cpp log level.
Args:
level: int, an absl.logging level.
Raises:
TypeError: Raised when level is not an integer.
Returns:
The corresponding integer level for use in Abseil C++.
"""
if not isinstance(level, int):
raise TypeError('Ex... | [
"def",
"absl_to_cpp",
"(",
"level",
")",
":",
"if",
"not",
"isinstance",
"(",
"level",
",",
"int",
")",
":",
"raise",
"TypeError",
"(",
"'Expect an int level, found {}'",
".",
"format",
"(",
"type",
"(",
"level",
")",
")",
")",
"if",
"level",
">=",
"0",
... | Converts an absl log level to a cpp log level.
Args:
level: int, an absl.logging level.
Raises:
TypeError: Raised when level is not an integer.
Returns:
The corresponding integer level for use in Abseil C++. | [
"Converts",
"an",
"absl",
"log",
"level",
"to",
"a",
"cpp",
"log",
"level",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/converter.py#L117-L135 |
220,433 | abseil/abseil-py | absl/logging/converter.py | absl_to_standard | def absl_to_standard(level):
"""Converts an integer level from the absl value to the standard value.
Args:
level: int, an absl.logging level.
Raises:
TypeError: Raised when level is not an integer.
Returns:
The corresponding integer level for use in standard logging.
"""
if not isinstance(lev... | python | def absl_to_standard(level):
"""Converts an integer level from the absl value to the standard value.
Args:
level: int, an absl.logging level.
Raises:
TypeError: Raised when level is not an integer.
Returns:
The corresponding integer level for use in standard logging.
"""
if not isinstance(lev... | [
"def",
"absl_to_standard",
"(",
"level",
")",
":",
"if",
"not",
"isinstance",
"(",
"level",
",",
"int",
")",
":",
"raise",
"TypeError",
"(",
"'Expect an int level, found {}'",
".",
"format",
"(",
"type",
"(",
"level",
")",
")",
")",
"if",
"level",
"<",
"... | Converts an integer level from the absl value to the standard value.
Args:
level: int, an absl.logging level.
Raises:
TypeError: Raised when level is not an integer.
Returns:
The corresponding integer level for use in standard logging. | [
"Converts",
"an",
"integer",
"level",
"from",
"the",
"absl",
"value",
"to",
"the",
"standard",
"value",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/converter.py#L138-L157 |
220,434 | abseil/abseil-py | absl/logging/converter.py | standard_to_absl | def standard_to_absl(level):
"""Converts an integer level from the standard value to the absl value.
Args:
level: int, a Python standard logging level.
Raises:
TypeError: Raised when level is not an integer.
Returns:
The corresponding integer level for use in absl logging.
"""
if not isinstan... | python | def standard_to_absl(level):
"""Converts an integer level from the standard value to the absl value.
Args:
level: int, a Python standard logging level.
Raises:
TypeError: Raised when level is not an integer.
Returns:
The corresponding integer level for use in absl logging.
"""
if not isinstan... | [
"def",
"standard_to_absl",
"(",
"level",
")",
":",
"if",
"not",
"isinstance",
"(",
"level",
",",
"int",
")",
":",
"raise",
"TypeError",
"(",
"'Expect an int level, found {}'",
".",
"format",
"(",
"type",
"(",
"level",
")",
")",
")",
"if",
"level",
"<",
"... | Converts an integer level from the standard value to the absl value.
Args:
level: int, a Python standard logging level.
Raises:
TypeError: Raised when level is not an integer.
Returns:
The corresponding integer level for use in absl logging. | [
"Converts",
"an",
"integer",
"level",
"from",
"the",
"standard",
"value",
"to",
"the",
"absl",
"value",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/converter.py#L172-L200 |
220,435 | abseil/abseil-py | absl/app.py | parse_flags_with_usage | def parse_flags_with_usage(args):
"""Tries to parse the flags, print usage, and exit if unparseable.
Args:
args: [str], a non-empty list of the command line arguments including
program name.
Returns:
[str], a non-empty list of remaining command line arguments after parsing
flags, including p... | python | def parse_flags_with_usage(args):
"""Tries to parse the flags, print usage, and exit if unparseable.
Args:
args: [str], a non-empty list of the command line arguments including
program name.
Returns:
[str], a non-empty list of remaining command line arguments after parsing
flags, including p... | [
"def",
"parse_flags_with_usage",
"(",
"args",
")",
":",
"try",
":",
"return",
"FLAGS",
"(",
"args",
")",
"except",
"flags",
".",
"Error",
"as",
"error",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"'FATAL Flags parsing error: %s\\n'",
"%",
"error",
")",
... | Tries to parse the flags, print usage, and exit if unparseable.
Args:
args: [str], a non-empty list of the command line arguments including
program name.
Returns:
[str], a non-empty list of remaining command line arguments after parsing
flags, including program name. | [
"Tries",
"to",
"parse",
"the",
"flags",
"print",
"usage",
"and",
"exit",
"if",
"unparseable",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/app.py#L147-L163 |
220,436 | abseil/abseil-py | absl/app.py | define_help_flags | def define_help_flags():
"""Registers help flags. Idempotent."""
# Use a global to ensure idempotence.
global _define_help_flags_called
if not _define_help_flags_called:
flags.DEFINE_flag(HelpFlag())
flags.DEFINE_flag(HelpshortFlag()) # alias for --help
flags.DEFINE_flag(HelpfullFlag())
flags.... | python | def define_help_flags():
"""Registers help flags. Idempotent."""
# Use a global to ensure idempotence.
global _define_help_flags_called
if not _define_help_flags_called:
flags.DEFINE_flag(HelpFlag())
flags.DEFINE_flag(HelpshortFlag()) # alias for --help
flags.DEFINE_flag(HelpfullFlag())
flags.... | [
"def",
"define_help_flags",
"(",
")",
":",
"# Use a global to ensure idempotence.",
"global",
"_define_help_flags_called",
"if",
"not",
"_define_help_flags_called",
":",
"flags",
".",
"DEFINE_flag",
"(",
"HelpFlag",
"(",
")",
")",
"flags",
".",
"DEFINE_flag",
"(",
"He... | Registers help flags. Idempotent. | [
"Registers",
"help",
"flags",
".",
"Idempotent",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/app.py#L169-L179 |
220,437 | abseil/abseil-py | absl/app.py | _register_and_parse_flags_with_usage | def _register_and_parse_flags_with_usage(
argv=None,
flags_parser=parse_flags_with_usage,
):
"""Registers help flags, parses arguments and shows usage if appropriate.
This also calls sys.exit(0) if flag --only_check_args is True.
Args:
argv: [str], a non-empty list of the command line arguments incl... | python | def _register_and_parse_flags_with_usage(
argv=None,
flags_parser=parse_flags_with_usage,
):
"""Registers help flags, parses arguments and shows usage if appropriate.
This also calls sys.exit(0) if flag --only_check_args is True.
Args:
argv: [str], a non-empty list of the command line arguments incl... | [
"def",
"_register_and_parse_flags_with_usage",
"(",
"argv",
"=",
"None",
",",
"flags_parser",
"=",
"parse_flags_with_usage",
",",
")",
":",
"if",
"_register_and_parse_flags_with_usage",
".",
"done",
":",
"raise",
"SystemError",
"(",
"'Flag registration can be done only once... | Registers help flags, parses arguments and shows usage if appropriate.
This also calls sys.exit(0) if flag --only_check_args is True.
Args:
argv: [str], a non-empty list of the command line arguments including
program name, sys.argv is used if None.
flags_parser: Callable[[List[Text]], Any], the f... | [
"Registers",
"help",
"flags",
"parses",
"arguments",
"and",
"shows",
"usage",
"if",
"appropriate",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/app.py#L182-L226 |
220,438 | abseil/abseil-py | absl/app.py | _run_main | def _run_main(main, argv):
"""Calls main, optionally with pdb or profiler."""
if FLAGS.run_with_pdb:
sys.exit(pdb.runcall(main, argv))
elif FLAGS.run_with_profiling or FLAGS.profile_file:
# Avoid import overhead since most apps (including performance-sensitive
# ones) won't be run with profiling.
... | python | def _run_main(main, argv):
"""Calls main, optionally with pdb or profiler."""
if FLAGS.run_with_pdb:
sys.exit(pdb.runcall(main, argv))
elif FLAGS.run_with_profiling or FLAGS.profile_file:
# Avoid import overhead since most apps (including performance-sensitive
# ones) won't be run with profiling.
... | [
"def",
"_run_main",
"(",
"main",
",",
"argv",
")",
":",
"if",
"FLAGS",
".",
"run_with_pdb",
":",
"sys",
".",
"exit",
"(",
"pdb",
".",
"runcall",
"(",
"main",
",",
"argv",
")",
")",
"elif",
"FLAGS",
".",
"run_with_profiling",
"or",
"FLAGS",
".",
"prof... | Calls main, optionally with pdb or profiler. | [
"Calls",
"main",
"optionally",
"with",
"pdb",
"or",
"profiler",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/app.py#L231-L251 |
220,439 | abseil/abseil-py | absl/app.py | _call_exception_handlers | def _call_exception_handlers(exception):
"""Calls any installed exception handlers."""
for handler in EXCEPTION_HANDLERS:
try:
if handler.wants(exception):
handler.handle(exception)
except: # pylint: disable=bare-except
try:
# We don't want to stop for exceptions in the exceptio... | python | def _call_exception_handlers(exception):
"""Calls any installed exception handlers."""
for handler in EXCEPTION_HANDLERS:
try:
if handler.wants(exception):
handler.handle(exception)
except: # pylint: disable=bare-except
try:
# We don't want to stop for exceptions in the exceptio... | [
"def",
"_call_exception_handlers",
"(",
"exception",
")",
":",
"for",
"handler",
"in",
"EXCEPTION_HANDLERS",
":",
"try",
":",
"if",
"handler",
".",
"wants",
"(",
"exception",
")",
":",
"handler",
".",
"handle",
"(",
"exception",
")",
"except",
":",
"# pylint... | Calls any installed exception handlers. | [
"Calls",
"any",
"installed",
"exception",
"handlers",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/app.py#L254-L267 |
220,440 | abseil/abseil-py | absl/app.py | run | def run(
main,
argv=None,
flags_parser=parse_flags_with_usage,
):
"""Begins executing the program.
Args:
main: The main function to execute. It takes an single argument "argv",
which is a list of command line arguments with parsed flags removed.
If it returns an integer, it is used ... | python | def run(
main,
argv=None,
flags_parser=parse_flags_with_usage,
):
"""Begins executing the program.
Args:
main: The main function to execute. It takes an single argument "argv",
which is a list of command line arguments with parsed flags removed.
If it returns an integer, it is used ... | [
"def",
"run",
"(",
"main",
",",
"argv",
"=",
"None",
",",
"flags_parser",
"=",
"parse_flags_with_usage",
",",
")",
":",
"try",
":",
"args",
"=",
"_run_init",
"(",
"sys",
".",
"argv",
"if",
"argv",
"is",
"None",
"else",
"argv",
",",
"flags_parser",
",",... | Begins executing the program.
Args:
main: The main function to execute. It takes an single argument "argv",
which is a list of command line arguments with parsed flags removed.
If it returns an integer, it is used as the process's exit code.
argv: A non-empty list of the command line argument... | [
"Begins",
"executing",
"the",
"program",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/app.py#L270-L310 |
220,441 | abseil/abseil-py | absl/app.py | _run_init | def _run_init(
argv,
flags_parser,
):
"""Does one-time initialization and re-parses flags on rerun."""
if _run_init.done:
return flags_parser(argv)
command_name.make_process_name_useful()
# Set up absl logging handler.
logging.use_absl_handler()
args = _register_and_parse_flags_with_usage(
... | python | def _run_init(
argv,
flags_parser,
):
"""Does one-time initialization and re-parses flags on rerun."""
if _run_init.done:
return flags_parser(argv)
command_name.make_process_name_useful()
# Set up absl logging handler.
logging.use_absl_handler()
args = _register_and_parse_flags_with_usage(
... | [
"def",
"_run_init",
"(",
"argv",
",",
"flags_parser",
",",
")",
":",
"if",
"_run_init",
".",
"done",
":",
"return",
"flags_parser",
"(",
"argv",
")",
"command_name",
".",
"make_process_name_useful",
"(",
")",
"# Set up absl logging handler.",
"logging",
".",
"us... | Does one-time initialization and re-parses flags on rerun. | [
"Does",
"one",
"-",
"time",
"initialization",
"and",
"re",
"-",
"parses",
"flags",
"on",
"rerun",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/app.py#L339-L361 |
220,442 | abseil/abseil-py | absl/app.py | install_exception_handler | def install_exception_handler(handler):
"""Installs an exception handler.
Args:
handler: ExceptionHandler, the exception handler to install.
Raises:
TypeError: Raised when the handler was not of the correct type.
All installed exception handlers will be called if main() exits via
an abnormal except... | python | def install_exception_handler(handler):
"""Installs an exception handler.
Args:
handler: ExceptionHandler, the exception handler to install.
Raises:
TypeError: Raised when the handler was not of the correct type.
All installed exception handlers will be called if main() exits via
an abnormal except... | [
"def",
"install_exception_handler",
"(",
"handler",
")",
":",
"if",
"not",
"isinstance",
"(",
"handler",
",",
"ExceptionHandler",
")",
":",
"raise",
"TypeError",
"(",
"'handler of type %s does not inherit from ExceptionHandler'",
"%",
"type",
"(",
"handler",
")",
")",... | Installs an exception handler.
Args:
handler: ExceptionHandler, the exception handler to install.
Raises:
TypeError: Raised when the handler was not of the correct type.
All installed exception handlers will be called if main() exits via
an abnormal exception, i.e. not one of SystemExit, KeyboardInte... | [
"Installs",
"an",
"exception",
"handler",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/app.py#L444-L460 |
220,443 | abseil/abseil-py | absl/flags/_validators.py | register_validator | def register_validator(flag_name,
checker,
message='Flag validation failed',
flag_values=_flagvalues.FLAGS):
"""Adds a constraint, which will be enforced during program execution.
The constraint is validated when flags are initially parsed, and a... | python | def register_validator(flag_name,
checker,
message='Flag validation failed',
flag_values=_flagvalues.FLAGS):
"""Adds a constraint, which will be enforced during program execution.
The constraint is validated when flags are initially parsed, and a... | [
"def",
"register_validator",
"(",
"flag_name",
",",
"checker",
",",
"message",
"=",
"'Flag validation failed'",
",",
"flag_values",
"=",
"_flagvalues",
".",
"FLAGS",
")",
":",
"v",
"=",
"SingleFlagValidator",
"(",
"flag_name",
",",
"checker",
",",
"message",
")"... | Adds a constraint, which will be enforced during program execution.
The constraint is validated when flags are initially parsed, and after each
change of the corresponding flag's value.
Args:
flag_name: str, name of the flag to be checked.
checker: callable, a function to validate the flag.
input... | [
"Adds",
"a",
"constraint",
"which",
"will",
"be",
"enforced",
"during",
"program",
"execution",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_validators.py#L196-L223 |
220,444 | abseil/abseil-py | absl/flags/_validators.py | validator | def validator(flag_name, message='Flag validation failed',
flag_values=_flagvalues.FLAGS):
"""A function decorator for defining a flag validator.
Registers the decorated function as a validator for flag_name, e.g.
@flags.validator('foo')
def _CheckFoo(foo):
...
See register_validator() fo... | python | def validator(flag_name, message='Flag validation failed',
flag_values=_flagvalues.FLAGS):
"""A function decorator for defining a flag validator.
Registers the decorated function as a validator for flag_name, e.g.
@flags.validator('foo')
def _CheckFoo(foo):
...
See register_validator() fo... | [
"def",
"validator",
"(",
"flag_name",
",",
"message",
"=",
"'Flag validation failed'",
",",
"flag_values",
"=",
"_flagvalues",
".",
"FLAGS",
")",
":",
"def",
"decorate",
"(",
"function",
")",
":",
"register_validator",
"(",
"flag_name",
",",
"function",
",",
"... | A function decorator for defining a flag validator.
Registers the decorated function as a validator for flag_name, e.g.
@flags.validator('foo')
def _CheckFoo(foo):
...
See register_validator() for the specification of checker function.
Args:
flag_name: str, name of the flag to be checked.
mess... | [
"A",
"function",
"decorator",
"for",
"defining",
"a",
"flag",
"validator",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_validators.py#L226-L257 |
220,445 | abseil/abseil-py | absl/flags/_validators.py | mark_flags_as_required | def mark_flags_as_required(flag_names, flag_values=_flagvalues.FLAGS):
"""Ensures that flags are not None during program execution.
Recommended usage:
if __name__ == '__main__':
flags.mark_flags_as_required(['flag1', 'flag2', 'flag3'])
app.run()
Args:
flag_names: Sequence[str], names of the... | python | def mark_flags_as_required(flag_names, flag_values=_flagvalues.FLAGS):
"""Ensures that flags are not None during program execution.
Recommended usage:
if __name__ == '__main__':
flags.mark_flags_as_required(['flag1', 'flag2', 'flag3'])
app.run()
Args:
flag_names: Sequence[str], names of the... | [
"def",
"mark_flags_as_required",
"(",
"flag_names",
",",
"flag_values",
"=",
"_flagvalues",
".",
"FLAGS",
")",
":",
"for",
"flag_name",
"in",
"flag_names",
":",
"mark_flag_as_required",
"(",
"flag_name",
",",
"flag_values",
")"
] | Ensures that flags are not None during program execution.
Recommended usage:
if __name__ == '__main__':
flags.mark_flags_as_required(['flag1', 'flag2', 'flag3'])
app.run()
Args:
flag_names: Sequence[str], names of the flags.
flag_values: flags.FlagValues, optional FlagValues instance wher... | [
"Ensures",
"that",
"flags",
"are",
"not",
"None",
"during",
"program",
"execution",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_validators.py#L367-L384 |
220,446 | abseil/abseil-py | absl/flags/_validators.py | mark_flags_as_mutual_exclusive | def mark_flags_as_mutual_exclusive(flag_names, required=False,
flag_values=_flagvalues.FLAGS):
"""Ensures that only one flag among flag_names is not None.
Important note: This validator checks if flag values are None, and it does not
distinguish between default and explicit val... | python | def mark_flags_as_mutual_exclusive(flag_names, required=False,
flag_values=_flagvalues.FLAGS):
"""Ensures that only one flag among flag_names is not None.
Important note: This validator checks if flag values are None, and it does not
distinguish between default and explicit val... | [
"def",
"mark_flags_as_mutual_exclusive",
"(",
"flag_names",
",",
"required",
"=",
"False",
",",
"flag_values",
"=",
"_flagvalues",
".",
"FLAGS",
")",
":",
"for",
"flag_name",
"in",
"flag_names",
":",
"if",
"flag_values",
"[",
"flag_name",
"]",
".",
"default",
... | Ensures that only one flag among flag_names is not None.
Important note: This validator checks if flag values are None, and it does not
distinguish between default and explicit values. Therefore, this validator
does not make sense when applied to flags with default values other than None,
including other false... | [
"Ensures",
"that",
"only",
"one",
"flag",
"among",
"flag_names",
"is",
"not",
"None",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_validators.py#L387-L421 |
220,447 | abseil/abseil-py | absl/flags/_validators.py | mark_bool_flags_as_mutual_exclusive | def mark_bool_flags_as_mutual_exclusive(flag_names, required=False,
flag_values=_flagvalues.FLAGS):
"""Ensures that only one flag among flag_names is True.
Args:
flag_names: [str], names of the flags.
required: bool. If true, exactly one flag must be True. Otherwise,... | python | def mark_bool_flags_as_mutual_exclusive(flag_names, required=False,
flag_values=_flagvalues.FLAGS):
"""Ensures that only one flag among flag_names is True.
Args:
flag_names: [str], names of the flags.
required: bool. If true, exactly one flag must be True. Otherwise,... | [
"def",
"mark_bool_flags_as_mutual_exclusive",
"(",
"flag_names",
",",
"required",
"=",
"False",
",",
"flag_values",
"=",
"_flagvalues",
".",
"FLAGS",
")",
":",
"for",
"flag_name",
"in",
"flag_names",
":",
"if",
"not",
"flag_values",
"[",
"flag_name",
"]",
".",
... | Ensures that only one flag among flag_names is True.
Args:
flag_names: [str], names of the flags.
required: bool. If true, exactly one flag must be True. Otherwise, at most
one flag can be True, and it is valid for all flags to be False.
flag_values: flags.FlagValues, optional FlagValues instance... | [
"Ensures",
"that",
"only",
"one",
"flag",
"among",
"flag_names",
"is",
"True",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_validators.py#L424-L450 |
220,448 | abseil/abseil-py | absl/flags/_validators.py | _add_validator | def _add_validator(fv, validator_instance):
"""Register new flags validator to be checked.
Args:
fv: flags.FlagValues, the FlagValues instance to add the validator.
validator_instance: validators.Validator, the validator to add.
Raises:
KeyError: Raised when validators work with a non-existing flag.
... | python | def _add_validator(fv, validator_instance):
"""Register new flags validator to be checked.
Args:
fv: flags.FlagValues, the FlagValues instance to add the validator.
validator_instance: validators.Validator, the validator to add.
Raises:
KeyError: Raised when validators work with a non-existing flag.
... | [
"def",
"_add_validator",
"(",
"fv",
",",
"validator_instance",
")",
":",
"for",
"flag_name",
"in",
"validator_instance",
".",
"get_flags_names",
"(",
")",
":",
"fv",
"[",
"flag_name",
"]",
".",
"validators",
".",
"append",
"(",
"validator_instance",
")"
] | Register new flags validator to be checked.
Args:
fv: flags.FlagValues, the FlagValues instance to add the validator.
validator_instance: validators.Validator, the validator to add.
Raises:
KeyError: Raised when validators work with a non-existing flag. | [
"Register",
"new",
"flags",
"validator",
"to",
"be",
"checked",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_validators.py#L453-L463 |
220,449 | abseil/abseil-py | absl/flags/_validators.py | Validator.verify | def verify(self, flag_values):
"""Verifies that constraint is satisfied.
flags library calls this method to verify Validator's constraint.
Args:
flag_values: flags.FlagValues, the FlagValues instance to get flags from.
Raises:
Error: Raised if constraint is not satisfied.
"""
param... | python | def verify(self, flag_values):
"""Verifies that constraint is satisfied.
flags library calls this method to verify Validator's constraint.
Args:
flag_values: flags.FlagValues, the FlagValues instance to get flags from.
Raises:
Error: Raised if constraint is not satisfied.
"""
param... | [
"def",
"verify",
"(",
"self",
",",
"flag_values",
")",
":",
"param",
"=",
"self",
".",
"_get_input_to_checker_function",
"(",
"flag_values",
")",
"if",
"not",
"self",
".",
"checker",
"(",
"param",
")",
":",
"raise",
"_exceptions",
".",
"ValidationError",
"("... | Verifies that constraint is satisfied.
flags library calls this method to verify Validator's constraint.
Args:
flag_values: flags.FlagValues, the FlagValues instance to get flags from.
Raises:
Error: Raised if constraint is not satisfied. | [
"Verifies",
"that",
"constraint",
"is",
"satisfied",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_validators.py#L70-L82 |
220,450 | abseil/abseil-py | absl/flags/_validators.py | MultiFlagsValidator._get_input_to_checker_function | def _get_input_to_checker_function(self, flag_values):
"""Given flag values, returns the input to be given to checker.
Args:
flag_values: flags.FlagValues, the FlagValues instance to get flags from.
Returns:
dict, with keys() being self.lag_names, and value for each key
being the value of... | python | def _get_input_to_checker_function(self, flag_values):
"""Given flag values, returns the input to be given to checker.
Args:
flag_values: flags.FlagValues, the FlagValues instance to get flags from.
Returns:
dict, with keys() being self.lag_names, and value for each key
being the value of... | [
"def",
"_get_input_to_checker_function",
"(",
"self",
",",
"flag_values",
")",
":",
"return",
"dict",
"(",
"[",
"key",
",",
"flag_values",
"[",
"key",
"]",
".",
"value",
"]",
"for",
"key",
"in",
"self",
".",
"flag_names",
")"
] | Given flag values, returns the input to be given to checker.
Args:
flag_values: flags.FlagValues, the FlagValues instance to get flags from.
Returns:
dict, with keys() being self.lag_names, and value for each key
being the value of the corresponding flag (string, boolean, etc). | [
"Given",
"flag",
"values",
"returns",
"the",
"input",
"to",
"be",
"given",
"to",
"checker",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_validators.py#L174-L183 |
220,451 | abseil/abseil-py | absl/flags/_exceptions.py | DuplicateFlagError.from_flag | def from_flag(cls, flagname, flag_values, other_flag_values=None):
"""Creates a DuplicateFlagError by providing flag name and values.
Args:
flagname: str, the name of the flag being redefined.
flag_values: FlagValues, the FlagValues instance containing the first
definition of flagname.
... | python | def from_flag(cls, flagname, flag_values, other_flag_values=None):
"""Creates a DuplicateFlagError by providing flag name and values.
Args:
flagname: str, the name of the flag being redefined.
flag_values: FlagValues, the FlagValues instance containing the first
definition of flagname.
... | [
"def",
"from_flag",
"(",
"cls",
",",
"flagname",
",",
"flag_values",
",",
"other_flag_values",
"=",
"None",
")",
":",
"first_module",
"=",
"flag_values",
".",
"find_module_defining_flag",
"(",
"flagname",
",",
"default",
"=",
"'<unknown>'",
")",
"if",
"other_fla... | Creates a DuplicateFlagError by providing flag name and values.
Args:
flagname: str, the name of the flag being redefined.
flag_values: FlagValues, the FlagValues instance containing the first
definition of flagname.
other_flag_values: FlagValues, if it is not None, it should be the
... | [
"Creates",
"a",
"DuplicateFlagError",
"by",
"providing",
"flag",
"name",
"and",
"values",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_exceptions.py#L48-L75 |
220,452 | abseil/abseil-py | absl/logging/__init__.py | set_verbosity | def set_verbosity(v):
"""Sets the logging verbosity.
Causes all messages of level <= v to be logged,
and all messages of level > v to be silently discarded.
Args:
v: int|str, the verbosity level as an integer or string. Legal string values
are those that can be coerced to an integer as well as cas... | python | def set_verbosity(v):
"""Sets the logging verbosity.
Causes all messages of level <= v to be logged,
and all messages of level > v to be silently discarded.
Args:
v: int|str, the verbosity level as an integer or string. Legal string values
are those that can be coerced to an integer as well as cas... | [
"def",
"set_verbosity",
"(",
"v",
")",
":",
"try",
":",
"new_level",
"=",
"int",
"(",
"v",
")",
"except",
"ValueError",
":",
"new_level",
"=",
"converter",
".",
"ABSL_NAMES",
"[",
"v",
".",
"upper",
"(",
")",
"]",
"FLAGS",
".",
"verbosity",
"=",
"new... | Sets the logging verbosity.
Causes all messages of level <= v to be logged,
and all messages of level > v to be silently discarded.
Args:
v: int|str, the verbosity level as an integer or string. Legal string values
are those that can be coerced to an integer as well as case-insensitive
'debu... | [
"Sets",
"the",
"logging",
"verbosity",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L266-L281 |
220,453 | abseil/abseil-py | absl/logging/__init__.py | set_stderrthreshold | def set_stderrthreshold(s):
"""Sets the stderr threshold to the value passed in.
Args:
s: str|int, valid strings values are case-insensitive 'debug',
'info', 'warning', 'error', and 'fatal'; valid integer values are
logging.DEBUG|INFO|WARNING|ERROR|FATAL.
Raises:
ValueError: Raised whe... | python | def set_stderrthreshold(s):
"""Sets the stderr threshold to the value passed in.
Args:
s: str|int, valid strings values are case-insensitive 'debug',
'info', 'warning', 'error', and 'fatal'; valid integer values are
logging.DEBUG|INFO|WARNING|ERROR|FATAL.
Raises:
ValueError: Raised whe... | [
"def",
"set_stderrthreshold",
"(",
"s",
")",
":",
"if",
"s",
"in",
"converter",
".",
"ABSL_LEVELS",
":",
"FLAGS",
".",
"stderrthreshold",
"=",
"converter",
".",
"ABSL_LEVELS",
"[",
"s",
"]",
"elif",
"isinstance",
"(",
"s",
",",
"str",
")",
"and",
"s",
... | Sets the stderr threshold to the value passed in.
Args:
s: str|int, valid strings values are case-insensitive 'debug',
'info', 'warning', 'error', and 'fatal'; valid integer values are
logging.DEBUG|INFO|WARNING|ERROR|FATAL.
Raises:
ValueError: Raised when s is an invalid value. | [
"Sets",
"the",
"stderr",
"threshold",
"to",
"the",
"value",
"passed",
"in",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L284-L304 |
220,454 | abseil/abseil-py | absl/logging/__init__.py | log_every_n | def log_every_n(level, msg, n, *args):
"""Logs 'msg % args' at level 'level' once per 'n' times.
Logs the 1st call, (N+1)st call, (2N+1)st call, etc.
Not threadsafe.
Args:
level: int, the absl logging level at which to log.
msg: str, the message to be logged.
n: int, the number of times this shou... | python | def log_every_n(level, msg, n, *args):
"""Logs 'msg % args' at level 'level' once per 'n' times.
Logs the 1st call, (N+1)st call, (2N+1)st call, etc.
Not threadsafe.
Args:
level: int, the absl logging level at which to log.
msg: str, the message to be logged.
n: int, the number of times this shou... | [
"def",
"log_every_n",
"(",
"level",
",",
"msg",
",",
"n",
",",
"*",
"args",
")",
":",
"count",
"=",
"_get_next_log_count_per_token",
"(",
"get_absl_logger",
"(",
")",
".",
"findCaller",
"(",
")",
")",
"log_if",
"(",
"level",
",",
"msg",
",",
"not",
"("... | Logs 'msg % args' at level 'level' once per 'n' times.
Logs the 1st call, (N+1)st call, (2N+1)st call, etc.
Not threadsafe.
Args:
level: int, the absl logging level at which to log.
msg: str, the message to be logged.
n: int, the number of times this should be called before it is logged.
*args:... | [
"Logs",
"msg",
"%",
"args",
"at",
"level",
"level",
"once",
"per",
"n",
"times",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L367-L380 |
220,455 | abseil/abseil-py | absl/logging/__init__.py | _seconds_have_elapsed | def _seconds_have_elapsed(token, num_seconds):
"""Tests if 'num_seconds' have passed since 'token' was requested.
Not strictly thread-safe - may log with the wrong frequency if called
concurrently from multiple threads. Accuracy depends on resolution of
'timeit.default_timer()'.
Always returns True on the f... | python | def _seconds_have_elapsed(token, num_seconds):
"""Tests if 'num_seconds' have passed since 'token' was requested.
Not strictly thread-safe - may log with the wrong frequency if called
concurrently from multiple threads. Accuracy depends on resolution of
'timeit.default_timer()'.
Always returns True on the f... | [
"def",
"_seconds_have_elapsed",
"(",
"token",
",",
"num_seconds",
")",
":",
"now",
"=",
"timeit",
".",
"default_timer",
"(",
")",
"then",
"=",
"_log_timer_per_token",
".",
"get",
"(",
"token",
",",
"None",
")",
"if",
"then",
"is",
"None",
"or",
"(",
"now... | Tests if 'num_seconds' have passed since 'token' was requested.
Not strictly thread-safe - may log with the wrong frequency if called
concurrently from multiple threads. Accuracy depends on resolution of
'timeit.default_timer()'.
Always returns True on the first call for a given 'token'.
Args:
token: T... | [
"Tests",
"if",
"num_seconds",
"have",
"passed",
"since",
"token",
"was",
"requested",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L389-L411 |
220,456 | abseil/abseil-py | absl/logging/__init__.py | log_every_n_seconds | def log_every_n_seconds(level, msg, n_seconds, *args):
"""Logs 'msg % args' at level 'level' iff 'n_seconds' elapsed since last call.
Logs the first call, logs subsequent calls if 'n' seconds have elapsed since
the last logging call from the same call site (file + line). Not thread-safe.
Args:
level: int,... | python | def log_every_n_seconds(level, msg, n_seconds, *args):
"""Logs 'msg % args' at level 'level' iff 'n_seconds' elapsed since last call.
Logs the first call, logs subsequent calls if 'n' seconds have elapsed since
the last logging call from the same call site (file + line). Not thread-safe.
Args:
level: int,... | [
"def",
"log_every_n_seconds",
"(",
"level",
",",
"msg",
",",
"n_seconds",
",",
"*",
"args",
")",
":",
"should_log",
"=",
"_seconds_have_elapsed",
"(",
"get_absl_logger",
"(",
")",
".",
"findCaller",
"(",
")",
",",
"n_seconds",
")",
"log_if",
"(",
"level",
... | Logs 'msg % args' at level 'level' iff 'n_seconds' elapsed since last call.
Logs the first call, logs subsequent calls if 'n' seconds have elapsed since
the last logging call from the same call site (file + line). Not thread-safe.
Args:
level: int, the absl logging level at which to log.
msg: str, the m... | [
"Logs",
"msg",
"%",
"args",
"at",
"level",
"level",
"iff",
"n_seconds",
"elapsed",
"since",
"last",
"call",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L414-L427 |
220,457 | abseil/abseil-py | absl/logging/__init__.py | log_if | def log_if(level, msg, condition, *args):
"""Logs 'msg % args' at level 'level' only if condition is fulfilled."""
if condition:
log(level, msg, *args) | python | def log_if(level, msg, condition, *args):
"""Logs 'msg % args' at level 'level' only if condition is fulfilled."""
if condition:
log(level, msg, *args) | [
"def",
"log_if",
"(",
"level",
",",
"msg",
",",
"condition",
",",
"*",
"args",
")",
":",
"if",
"condition",
":",
"log",
"(",
"level",
",",
"msg",
",",
"*",
"args",
")"
] | Logs 'msg % args' at level 'level' only if condition is fulfilled. | [
"Logs",
"msg",
"%",
"args",
"at",
"level",
"level",
"only",
"if",
"condition",
"is",
"fulfilled",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L445-L448 |
220,458 | abseil/abseil-py | absl/logging/__init__.py | log | def log(level, msg, *args, **kwargs):
"""Logs 'msg % args' at absl logging level 'level'.
If no args are given just print msg, ignoring any interpolation specifiers.
Args:
level: int, the absl logging level at which to log the message
(logging.DEBUG|INFO|WARNING|ERROR|FATAL). While some C++ verbose ... | python | def log(level, msg, *args, **kwargs):
"""Logs 'msg % args' at absl logging level 'level'.
If no args are given just print msg, ignoring any interpolation specifiers.
Args:
level: int, the absl logging level at which to log the message
(logging.DEBUG|INFO|WARNING|ERROR|FATAL). While some C++ verbose ... | [
"def",
"log",
"(",
"level",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"level",
">",
"converter",
".",
"ABSL_DEBUG",
":",
"# Even though this function supports level that is greater than 1, users",
"# should use logging.vlog instead for such ... | Logs 'msg % args' at absl logging level 'level'.
If no args are given just print msg, ignoring any interpolation specifiers.
Args:
level: int, the absl logging level at which to log the message
(logging.DEBUG|INFO|WARNING|ERROR|FATAL). While some C++ verbose logging
level constants are also su... | [
"Logs",
"msg",
"%",
"args",
"at",
"absl",
"logging",
"level",
"level",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L451-L476 |
220,459 | abseil/abseil-py | absl/logging/__init__.py | vlog_is_on | def vlog_is_on(level):
"""Checks if vlog is enabled for the given level in caller's source file.
Args:
level: int, the C++ verbose logging level at which to log the message,
e.g. 1, 2, 3, 4... While absl level constants are also supported,
callers should prefer level_debug|level_info|... calls ... | python | def vlog_is_on(level):
"""Checks if vlog is enabled for the given level in caller's source file.
Args:
level: int, the C++ verbose logging level at which to log the message,
e.g. 1, 2, 3, 4... While absl level constants are also supported,
callers should prefer level_debug|level_info|... calls ... | [
"def",
"vlog_is_on",
"(",
"level",
")",
":",
"if",
"level",
">",
"converter",
".",
"ABSL_DEBUG",
":",
"# Even though this function supports level that is greater than 1, users",
"# should use logging.vlog instead for such cases.",
"# Treat this as vlog, 1 is equivalent to DEBUG.",
"s... | Checks if vlog is enabled for the given level in caller's source file.
Args:
level: int, the C++ verbose logging level at which to log the message,
e.g. 1, 2, 3, 4... While absl level constants are also supported,
callers should prefer level_debug|level_info|... calls for
checking those.
... | [
"Checks",
"if",
"vlog",
"is",
"enabled",
"for",
"the",
"given",
"level",
"in",
"caller",
"s",
"source",
"file",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L493-L515 |
220,460 | abseil/abseil-py | absl/logging/__init__.py | get_log_file_name | def get_log_file_name(level=INFO):
"""Returns the name of the log file.
For Python logging, only one file is used and level is ignored. And it returns
empty string if it logs to stderr/stdout or the log stream has no `name`
attribute.
Args:
level: int, the absl.logging level.
Raises:
ValueError: ... | python | def get_log_file_name(level=INFO):
"""Returns the name of the log file.
For Python logging, only one file is used and level is ignored. And it returns
empty string if it logs to stderr/stdout or the log stream has no `name`
attribute.
Args:
level: int, the absl.logging level.
Raises:
ValueError: ... | [
"def",
"get_log_file_name",
"(",
"level",
"=",
"INFO",
")",
":",
"if",
"level",
"not",
"in",
"converter",
".",
"ABSL_LEVELS",
":",
"raise",
"ValueError",
"(",
"'Invalid absl.logging level {}'",
".",
"format",
"(",
"level",
")",
")",
"stream",
"=",
"get_absl_ha... | Returns the name of the log file.
For Python logging, only one file is used and level is ignored. And it returns
empty string if it logs to stderr/stdout or the log stream has no `name`
attribute.
Args:
level: int, the absl.logging level.
Raises:
ValueError: Raised when `level` has an invalid value... | [
"Returns",
"the",
"name",
"of",
"the",
"log",
"file",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L546-L566 |
220,461 | abseil/abseil-py | absl/logging/__init__.py | find_log_dir_and_names | def find_log_dir_and_names(program_name=None, log_dir=None):
"""Computes the directory and filename prefix for log file.
Args:
program_name: str|None, the filename part of the path to the program that
is running without its extension. e.g: if your program is called
'usr/bin/foobar.py' this met... | python | def find_log_dir_and_names(program_name=None, log_dir=None):
"""Computes the directory and filename prefix for log file.
Args:
program_name: str|None, the filename part of the path to the program that
is running without its extension. e.g: if your program is called
'usr/bin/foobar.py' this met... | [
"def",
"find_log_dir_and_names",
"(",
"program_name",
"=",
"None",
",",
"log_dir",
"=",
"None",
")",
":",
"if",
"not",
"program_name",
":",
"# Strip the extension (foobar.par becomes foobar, and",
"# fubar.py becomes fubar). We do this so that the log",
"# file names are similar ... | Computes the directory and filename prefix for log file.
Args:
program_name: str|None, the filename part of the path to the program that
is running without its extension. e.g: if your program is called
'usr/bin/foobar.py' this method should probably be called with
program_name='foobar' H... | [
"Computes",
"the",
"directory",
"and",
"filename",
"prefix",
"for",
"log",
"file",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L569-L611 |
220,462 | abseil/abseil-py | absl/logging/__init__.py | find_log_dir | def find_log_dir(log_dir=None):
"""Returns the most suitable directory to put log files into.
Args:
log_dir: str|None, if specified, the logfile(s) will be created in that
directory. Otherwise if the --log_dir command-line flag is provided,
the logfile will be created in that directory. Other... | python | def find_log_dir(log_dir=None):
"""Returns the most suitable directory to put log files into.
Args:
log_dir: str|None, if specified, the logfile(s) will be created in that
directory. Otherwise if the --log_dir command-line flag is provided,
the logfile will be created in that directory. Other... | [
"def",
"find_log_dir",
"(",
"log_dir",
"=",
"None",
")",
":",
"# Get a list of possible log dirs (will try to use them in order).",
"if",
"log_dir",
":",
"# log_dir was explicitly specified as an arg, so use it and it alone.",
"dirs",
"=",
"[",
"log_dir",
"]",
"elif",
"FLAGS",
... | Returns the most suitable directory to put log files into.
Args:
log_dir: str|None, if specified, the logfile(s) will be created in that
directory. Otherwise if the --log_dir command-line flag is provided,
the logfile will be created in that directory. Otherwise the logfile
will be crea... | [
"Returns",
"the",
"most",
"suitable",
"directory",
"to",
"put",
"log",
"files",
"into",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L614-L638 |
220,463 | abseil/abseil-py | absl/logging/__init__.py | get_absl_log_prefix | def get_absl_log_prefix(record):
"""Returns the absl log prefix for the log record.
Args:
record: logging.LogRecord, the record to get prefix for.
"""
created_tuple = time.localtime(record.created)
created_microsecond = int(record.created % 1.0 * 1e6)
critical_prefix = ''
level = record.levelno
if... | python | def get_absl_log_prefix(record):
"""Returns the absl log prefix for the log record.
Args:
record: logging.LogRecord, the record to get prefix for.
"""
created_tuple = time.localtime(record.created)
created_microsecond = int(record.created % 1.0 * 1e6)
critical_prefix = ''
level = record.levelno
if... | [
"def",
"get_absl_log_prefix",
"(",
"record",
")",
":",
"created_tuple",
"=",
"time",
".",
"localtime",
"(",
"record",
".",
"created",
")",
"created_microsecond",
"=",
"int",
"(",
"record",
".",
"created",
"%",
"1.0",
"*",
"1e6",
")",
"critical_prefix",
"=",
... | Returns the absl log prefix for the log record.
Args:
record: logging.LogRecord, the record to get prefix for. | [
"Returns",
"the",
"absl",
"log",
"prefix",
"for",
"the",
"log",
"record",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L641-L670 |
220,464 | abseil/abseil-py | absl/logging/__init__.py | skip_log_prefix | def skip_log_prefix(func):
"""Skips reporting the prefix of a given function or name by ABSLLogger.
This is a convenience wrapper function / decorator for
`ABSLLogger.register_frame_to_skip`.
If a callable function is provided, only that function will be skipped.
If a function name is provided, all function... | python | def skip_log_prefix(func):
"""Skips reporting the prefix of a given function or name by ABSLLogger.
This is a convenience wrapper function / decorator for
`ABSLLogger.register_frame_to_skip`.
If a callable function is provided, only that function will be skipped.
If a function name is provided, all function... | [
"def",
"skip_log_prefix",
"(",
"func",
")",
":",
"if",
"callable",
"(",
"func",
")",
":",
"func_code",
"=",
"getattr",
"(",
"func",
",",
"'__code__'",
",",
"None",
")",
"if",
"func_code",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Input callable does... | Skips reporting the prefix of a given function or name by ABSLLogger.
This is a convenience wrapper function / decorator for
`ABSLLogger.register_frame_to_skip`.
If a callable function is provided, only that function will be skipped.
If a function name is provided, all functions with the same name in the
fi... | [
"Skips",
"reporting",
"the",
"prefix",
"of",
"a",
"given",
"function",
"or",
"name",
"by",
"ABSLLogger",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L673-L709 |
220,465 | abseil/abseil-py | absl/logging/__init__.py | use_absl_handler | def use_absl_handler():
"""Uses the ABSL logging handler for logging if not yet configured.
The absl handler is already attached to root if there are no other handlers
attached when importing this module.
Otherwise, this method is called in app.run() so absl handler is used.
"""
absl_handler = get_absl_ha... | python | def use_absl_handler():
"""Uses the ABSL logging handler for logging if not yet configured.
The absl handler is already attached to root if there are no other handlers
attached when importing this module.
Otherwise, this method is called in app.run() so absl handler is used.
"""
absl_handler = get_absl_ha... | [
"def",
"use_absl_handler",
"(",
")",
":",
"absl_handler",
"=",
"get_absl_handler",
"(",
")",
"if",
"absl_handler",
"not",
"in",
"logging",
".",
"root",
".",
"handlers",
":",
"logging",
".",
"root",
".",
"addHandler",
"(",
"absl_handler",
")",
"FLAGS",
"[",
... | Uses the ABSL logging handler for logging if not yet configured.
The absl handler is already attached to root if there are no other handlers
attached when importing this module.
Otherwise, this method is called in app.run() so absl handler is used. | [
"Uses",
"the",
"ABSL",
"logging",
"handler",
"for",
"logging",
"if",
"not",
"yet",
"configured",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L1114-L1125 |
220,466 | abseil/abseil-py | absl/logging/__init__.py | _initialize | def _initialize():
"""Initializes loggers and handlers."""
global _absl_logger, _absl_handler
if _absl_logger:
return
original_logger_class = logging.getLoggerClass()
logging.setLoggerClass(ABSLLogger)
_absl_logger = logging.getLogger('absl')
logging.setLoggerClass(original_logger_class)
python_l... | python | def _initialize():
"""Initializes loggers and handlers."""
global _absl_logger, _absl_handler
if _absl_logger:
return
original_logger_class = logging.getLoggerClass()
logging.setLoggerClass(ABSLLogger)
_absl_logger = logging.getLogger('absl')
logging.setLoggerClass(original_logger_class)
python_l... | [
"def",
"_initialize",
"(",
")",
":",
"global",
"_absl_logger",
",",
"_absl_handler",
"if",
"_absl_logger",
":",
"return",
"original_logger_class",
"=",
"logging",
".",
"getLoggerClass",
"(",
")",
"logging",
".",
"setLoggerClass",
"(",
"ABSLLogger",
")",
"_absl_log... | Initializes loggers and handlers. | [
"Initializes",
"loggers",
"and",
"handlers",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L1128-L1159 |
220,467 | abseil/abseil-py | absl/logging/__init__.py | _VerbosityFlag._update_logging_levels | def _update_logging_levels(self):
"""Updates absl logging levels to the current verbosity."""
if not _absl_logger:
return
if self._value <= converter.ABSL_DEBUG:
standard_verbosity = converter.absl_to_standard(self._value)
else:
# --verbosity is set to higher than 1 for vlog.
st... | python | def _update_logging_levels(self):
"""Updates absl logging levels to the current verbosity."""
if not _absl_logger:
return
if self._value <= converter.ABSL_DEBUG:
standard_verbosity = converter.absl_to_standard(self._value)
else:
# --verbosity is set to higher than 1 for vlog.
st... | [
"def",
"_update_logging_levels",
"(",
"self",
")",
":",
"if",
"not",
"_absl_logger",
":",
"return",
"if",
"self",
".",
"_value",
"<=",
"converter",
".",
"ABSL_DEBUG",
":",
"standard_verbosity",
"=",
"converter",
".",
"absl_to_standard",
"(",
"self",
".",
"_val... | Updates absl logging levels to the current verbosity. | [
"Updates",
"absl",
"logging",
"levels",
"to",
"the",
"current",
"verbosity",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L176-L189 |
220,468 | abseil/abseil-py | absl/logging/__init__.py | PythonHandler.start_logging_to_file | def start_logging_to_file(self, program_name=None, log_dir=None):
"""Starts logging messages to files instead of standard error."""
FLAGS.logtostderr = False
actual_log_dir, file_prefix, symlink_prefix = find_log_dir_and_names(
program_name=program_name, log_dir=log_dir)
basename = '%s.INFO.%s... | python | def start_logging_to_file(self, program_name=None, log_dir=None):
"""Starts logging messages to files instead of standard error."""
FLAGS.logtostderr = False
actual_log_dir, file_prefix, symlink_prefix = find_log_dir_and_names(
program_name=program_name, log_dir=log_dir)
basename = '%s.INFO.%s... | [
"def",
"start_logging_to_file",
"(",
"self",
",",
"program_name",
"=",
"None",
",",
"log_dir",
"=",
"None",
")",
":",
"FLAGS",
".",
"logtostderr",
"=",
"False",
"actual_log_dir",
",",
"file_prefix",
",",
"symlink_prefix",
"=",
"find_log_dir_and_names",
"(",
"pro... | Starts logging messages to files instead of standard error. | [
"Starts",
"logging",
"messages",
"to",
"files",
"instead",
"of",
"standard",
"error",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L733-L763 |
220,469 | abseil/abseil-py | absl/logging/__init__.py | PythonHandler.flush | def flush(self):
"""Flushes all log files."""
self.acquire()
try:
self.stream.flush()
except (EnvironmentError, ValueError):
# A ValueError is thrown if we try to flush a closed file.
pass
finally:
self.release() | python | def flush(self):
"""Flushes all log files."""
self.acquire()
try:
self.stream.flush()
except (EnvironmentError, ValueError):
# A ValueError is thrown if we try to flush a closed file.
pass
finally:
self.release() | [
"def",
"flush",
"(",
"self",
")",
":",
"self",
".",
"acquire",
"(",
")",
"try",
":",
"self",
".",
"stream",
".",
"flush",
"(",
")",
"except",
"(",
"EnvironmentError",
",",
"ValueError",
")",
":",
"# A ValueError is thrown if we try to flush a closed file.",
"p... | Flushes all log files. | [
"Flushes",
"all",
"log",
"files",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L772-L781 |
220,470 | abseil/abseil-py | absl/logging/__init__.py | PythonHandler._log_to_stderr | def _log_to_stderr(self, record):
"""Emits the record to stderr.
This temporarily sets the handler stream to stderr, calls
StreamHandler.emit, then reverts the stream back.
Args:
record: logging.LogRecord, the record to log.
"""
# emit() is protected by a lock in logging.Handler, so we d... | python | def _log_to_stderr(self, record):
"""Emits the record to stderr.
This temporarily sets the handler stream to stderr, calls
StreamHandler.emit, then reverts the stream back.
Args:
record: logging.LogRecord, the record to log.
"""
# emit() is protected by a lock in logging.Handler, so we d... | [
"def",
"_log_to_stderr",
"(",
"self",
",",
"record",
")",
":",
"# emit() is protected by a lock in logging.Handler, so we don't need to",
"# protect here again.",
"old_stream",
"=",
"self",
".",
"stream",
"self",
".",
"stream",
"=",
"sys",
".",
"stderr",
"try",
":",
"... | Emits the record to stderr.
This temporarily sets the handler stream to stderr, calls
StreamHandler.emit, then reverts the stream back.
Args:
record: logging.LogRecord, the record to log. | [
"Emits",
"the",
"record",
"to",
"stderr",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L783-L799 |
220,471 | abseil/abseil-py | absl/logging/__init__.py | PythonHandler.emit | def emit(self, record):
"""Prints a record out to some streams.
If FLAGS.logtostderr is set, it will print to sys.stderr ONLY.
If FLAGS.alsologtostderr is set, it will print to sys.stderr.
If FLAGS.logtostderr is not set, it will log to the stream
associated with the current thread.
Args:
... | python | def emit(self, record):
"""Prints a record out to some streams.
If FLAGS.logtostderr is set, it will print to sys.stderr ONLY.
If FLAGS.alsologtostderr is set, it will print to sys.stderr.
If FLAGS.logtostderr is not set, it will log to the stream
associated with the current thread.
Args:
... | [
"def",
"emit",
"(",
"self",
",",
"record",
")",
":",
"# People occasionally call logging functions at import time before",
"# our flags may have even been defined yet, let alone even parsed, as we",
"# rely on the C++ side to define some flags for us and app init to",
"# deal with parsing. Ma... | Prints a record out to some streams.
If FLAGS.logtostderr is set, it will print to sys.stderr ONLY.
If FLAGS.alsologtostderr is set, it will print to sys.stderr.
If FLAGS.logtostderr is not set, it will log to the stream
associated with the current thread.
Args:
record: logging.LogRecord, ... | [
"Prints",
"a",
"record",
"out",
"to",
"some",
"streams",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L801-L841 |
220,472 | abseil/abseil-py | absl/logging/__init__.py | PythonHandler.close | def close(self):
"""Closes the stream to which we are writing."""
self.acquire()
try:
self.flush()
try:
# Do not close the stream if it's sys.stderr|stdout. They may be
# redirected or overridden to files, which should be managed by users
# explicitly.
if self.str... | python | def close(self):
"""Closes the stream to which we are writing."""
self.acquire()
try:
self.flush()
try:
# Do not close the stream if it's sys.stderr|stdout. They may be
# redirected or overridden to files, which should be managed by users
# explicitly.
if self.str... | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"acquire",
"(",
")",
"try",
":",
"self",
".",
"flush",
"(",
")",
"try",
":",
"# Do not close the stream if it's sys.stderr|stdout. They may be",
"# redirected or overridden to files, which should be managed by users",
"#... | Closes the stream to which we are writing. | [
"Closes",
"the",
"stream",
"to",
"which",
"we",
"are",
"writing",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L843-L860 |
220,473 | abseil/abseil-py | absl/logging/__init__.py | PythonFormatter.format | def format(self, record):
"""Appends the message from the record to the results of the prefix.
Args:
record: logging.LogRecord, the record to be formatted.
Returns:
The formatted string representing the record.
"""
if (not FLAGS['showprefixforinfo'].value and
FLAGS['verbosity']... | python | def format(self, record):
"""Appends the message from the record to the results of the prefix.
Args:
record: logging.LogRecord, the record to be formatted.
Returns:
The formatted string representing the record.
"""
if (not FLAGS['showprefixforinfo'].value and
FLAGS['verbosity']... | [
"def",
"format",
"(",
"self",
",",
"record",
")",
":",
"if",
"(",
"not",
"FLAGS",
"[",
"'showprefixforinfo'",
"]",
".",
"value",
"and",
"FLAGS",
"[",
"'verbosity'",
"]",
".",
"value",
"==",
"converter",
".",
"ABSL_INFO",
"and",
"record",
".",
"levelno",
... | Appends the message from the record to the results of the prefix.
Args:
record: logging.LogRecord, the record to be formatted.
Returns:
The formatted string representing the record. | [
"Appends",
"the",
"message",
"from",
"the",
"record",
"to",
"the",
"results",
"of",
"the",
"prefix",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L912-L928 |
220,474 | abseil/abseil-py | absl/logging/__init__.py | ABSLLogger.findCaller | def findCaller(self, stack_info=False):
"""Finds the frame of the calling method on the stack.
This method skips any frames registered with the
ABSLLogger and any methods from this file, and whatever
method is currently being used to generate the prefix for the log
line. Then it returns the file n... | python | def findCaller(self, stack_info=False):
"""Finds the frame of the calling method on the stack.
This method skips any frames registered with the
ABSLLogger and any methods from this file, and whatever
method is currently being used to generate the prefix for the log
line. Then it returns the file n... | [
"def",
"findCaller",
"(",
"self",
",",
"stack_info",
"=",
"False",
")",
":",
"f_to_skip",
"=",
"ABSLLogger",
".",
"_frames_to_skip",
"# Use sys._getframe(2) instead of logging.currentframe(), it's slightly",
"# faster because there is one less frame to traverse.",
"frame",
"=",
... | Finds the frame of the calling method on the stack.
This method skips any frames registered with the
ABSLLogger and any methods from this file, and whatever
method is currently being used to generate the prefix for the log
line. Then it returns the file name, line number, and method name
of the ca... | [
"Finds",
"the",
"frame",
"of",
"the",
"calling",
"method",
"on",
"the",
"stack",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L945-L988 |
220,475 | abseil/abseil-py | absl/logging/__init__.py | ABSLLogger.fatal | def fatal(self, msg, *args, **kwargs):
"""Logs 'msg % args' with severity 'FATAL'."""
self.log(logging.FATAL, msg, *args, **kwargs) | python | def fatal(self, msg, *args, **kwargs):
"""Logs 'msg % args' with severity 'FATAL'."""
self.log(logging.FATAL, msg, *args, **kwargs) | [
"def",
"fatal",
"(",
"self",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"log",
"(",
"logging",
".",
"FATAL",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Logs 'msg % args' with severity 'FATAL'. | [
"Logs",
"msg",
"%",
"args",
"with",
"severity",
"FATAL",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L994-L996 |
220,476 | abseil/abseil-py | absl/logging/__init__.py | ABSLLogger.warn | def warn(self, msg, *args, **kwargs):
"""Logs 'msg % args' with severity 'WARN'."""
if six.PY3:
warnings.warn("The 'warn' method is deprecated, use 'warning' instead",
DeprecationWarning, 2)
self.log(logging.WARN, msg, *args, **kwargs) | python | def warn(self, msg, *args, **kwargs):
"""Logs 'msg % args' with severity 'WARN'."""
if six.PY3:
warnings.warn("The 'warn' method is deprecated, use 'warning' instead",
DeprecationWarning, 2)
self.log(logging.WARN, msg, *args, **kwargs) | [
"def",
"warn",
"(",
"self",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"six",
".",
"PY3",
":",
"warnings",
".",
"warn",
"(",
"\"The 'warn' method is deprecated, use 'warning' instead\"",
",",
"DeprecationWarning",
",",
"2",
")",
... | Logs 'msg % args' with severity 'WARN'. | [
"Logs",
"msg",
"%",
"args",
"with",
"severity",
"WARN",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L1002-L1007 |
220,477 | abseil/abseil-py | absl/logging/__init__.py | ABSLLogger.log | def log(self, level, msg, *args, **kwargs):
"""Logs a message at a cetain level substituting in the supplied arguments.
This method behaves differently in python and c++ modes.
Args:
level: int, the standard logging level at which to log the message.
msg: str, the text of the message to log.
... | python | def log(self, level, msg, *args, **kwargs):
"""Logs a message at a cetain level substituting in the supplied arguments.
This method behaves differently in python and c++ modes.
Args:
level: int, the standard logging level at which to log the message.
msg: str, the text of the message to log.
... | [
"def",
"log",
"(",
"self",
",",
"level",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"level",
">=",
"logging",
".",
"FATAL",
":",
"# Add property to the LogRecord created by this logger.",
"# This will be used by the ABSLHandler to determi... | Logs a message at a cetain level substituting in the supplied arguments.
This method behaves differently in python and c++ modes.
Args:
level: int, the standard logging level at which to log the message.
msg: str, the text of the message to log.
*args: The arguments to substitute in the mess... | [
"Logs",
"a",
"message",
"at",
"a",
"cetain",
"level",
"substituting",
"in",
"the",
"supplied",
"arguments",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L1021-L1038 |
220,478 | abseil/abseil-py | absl/logging/__init__.py | ABSLLogger.register_frame_to_skip | def register_frame_to_skip(cls, file_name, function_name, line_number=None):
"""Registers a function name to skip when walking the stack.
The ABSLLogger sometimes skips method calls on the stack
to make the log messages meaningful in their appropriate context.
This method registers a function from a pa... | python | def register_frame_to_skip(cls, file_name, function_name, line_number=None):
"""Registers a function name to skip when walking the stack.
The ABSLLogger sometimes skips method calls on the stack
to make the log messages meaningful in their appropriate context.
This method registers a function from a pa... | [
"def",
"register_frame_to_skip",
"(",
"cls",
",",
"file_name",
",",
"function_name",
",",
"line_number",
"=",
"None",
")",
":",
"if",
"line_number",
"is",
"not",
"None",
":",
"cls",
".",
"_frames_to_skip",
".",
"add",
"(",
"(",
"file_name",
",",
"function_na... | Registers a function name to skip when walking the stack.
The ABSLLogger sometimes skips method calls on the stack
to make the log messages meaningful in their appropriate context.
This method registers a function from a particular file as one
which should be skipped.
Args:
file_name: str, t... | [
"Registers",
"a",
"function",
"name",
"to",
"skip",
"when",
"walking",
"the",
"stack",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/logging/__init__.py#L1058-L1076 |
220,479 | abseil/abseil-py | absl/flags/argparse_flags.py | _is_undefok | def _is_undefok(arg, undefok_names):
"""Returns whether we can ignore arg based on a set of undefok flag names."""
if not arg.startswith('-'):
return False
if arg.startswith('--'):
arg_without_dash = arg[2:]
else:
arg_without_dash = arg[1:]
if '=' in arg_without_dash:
name, _ = arg_without_das... | python | def _is_undefok(arg, undefok_names):
"""Returns whether we can ignore arg based on a set of undefok flag names."""
if not arg.startswith('-'):
return False
if arg.startswith('--'):
arg_without_dash = arg[2:]
else:
arg_without_dash = arg[1:]
if '=' in arg_without_dash:
name, _ = arg_without_das... | [
"def",
"_is_undefok",
"(",
"arg",
",",
"undefok_names",
")",
":",
"if",
"not",
"arg",
".",
"startswith",
"(",
"'-'",
")",
":",
"return",
"False",
"if",
"arg",
".",
"startswith",
"(",
"'--'",
")",
":",
"arg_without_dash",
"=",
"arg",
"[",
"2",
":",
"]... | Returns whether we can ignore arg based on a set of undefok flag names. | [
"Returns",
"whether",
"we",
"can",
"ignore",
"arg",
"based",
"on",
"a",
"set",
"of",
"undefok",
"flag",
"names",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/argparse_flags.py#L358-L372 |
220,480 | abseil/abseil-py | absl/flags/argparse_flags.py | ArgumentParser._define_absl_flags | def _define_absl_flags(self, absl_flags):
"""Defines flags from absl_flags."""
key_flags = set(absl_flags.get_key_flags_for_module(sys.argv[0]))
for name in absl_flags:
if name in _BUILT_IN_FLAGS:
# Do not inherit built-in flags.
continue
flag_instance = absl_flags[name]
# ... | python | def _define_absl_flags(self, absl_flags):
"""Defines flags from absl_flags."""
key_flags = set(absl_flags.get_key_flags_for_module(sys.argv[0]))
for name in absl_flags:
if name in _BUILT_IN_FLAGS:
# Do not inherit built-in flags.
continue
flag_instance = absl_flags[name]
# ... | [
"def",
"_define_absl_flags",
"(",
"self",
",",
"absl_flags",
")",
":",
"key_flags",
"=",
"set",
"(",
"absl_flags",
".",
"get_key_flags_for_module",
"(",
"sys",
".",
"argv",
"[",
"0",
"]",
")",
")",
"for",
"name",
"in",
"absl_flags",
":",
"if",
"name",
"i... | Defines flags from absl_flags. | [
"Defines",
"flags",
"from",
"absl_flags",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/argparse_flags.py#L196-L210 |
220,481 | abseil/abseil-py | absl/flags/argparse_flags.py | ArgumentParser._define_absl_flag | def _define_absl_flag(self, flag_instance, suppress):
"""Defines a flag from the flag_instance."""
flag_name = flag_instance.name
short_name = flag_instance.short_name
argument_names = ['--' + flag_name]
if short_name:
argument_names.insert(0, '-' + short_name)
if suppress:
helptext ... | python | def _define_absl_flag(self, flag_instance, suppress):
"""Defines a flag from the flag_instance."""
flag_name = flag_instance.name
short_name = flag_instance.short_name
argument_names = ['--' + flag_name]
if short_name:
argument_names.insert(0, '-' + short_name)
if suppress:
helptext ... | [
"def",
"_define_absl_flag",
"(",
"self",
",",
"flag_instance",
",",
"suppress",
")",
":",
"flag_name",
"=",
"flag_instance",
".",
"name",
"short_name",
"=",
"flag_instance",
".",
"short_name",
"argument_names",
"=",
"[",
"'--'",
"+",
"flag_name",
"]",
"if",
"s... | Defines a flag from the flag_instance. | [
"Defines",
"a",
"flag",
"from",
"the",
"flag_instance",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/argparse_flags.py#L212-L235 |
220,482 | abseil/abseil-py | absl/flags/_helpers.py | get_module_object_and_name | def get_module_object_and_name(globals_dict):
"""Returns the module that defines a global environment, and its name.
Args:
globals_dict: A dictionary that should correspond to an environment
providing the values of the globals.
Returns:
_ModuleObjectAndName - pair of module object & module name.
... | python | def get_module_object_and_name(globals_dict):
"""Returns the module that defines a global environment, and its name.
Args:
globals_dict: A dictionary that should correspond to an environment
providing the values of the globals.
Returns:
_ModuleObjectAndName - pair of module object & module name.
... | [
"def",
"get_module_object_and_name",
"(",
"globals_dict",
")",
":",
"name",
"=",
"globals_dict",
".",
"get",
"(",
"'__name__'",
",",
"None",
")",
"module",
"=",
"sys",
".",
"modules",
".",
"get",
"(",
"name",
",",
"None",
")",
"# Pick a more informative name f... | Returns the module that defines a global environment, and its name.
Args:
globals_dict: A dictionary that should correspond to an environment
providing the values of the globals.
Returns:
_ModuleObjectAndName - pair of module object & module name.
Returns (None, None) if the module could not be ... | [
"Returns",
"the",
"module",
"that",
"defines",
"a",
"global",
"environment",
"and",
"its",
"name",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_helpers.py#L90-L105 |
220,483 | abseil/abseil-py | absl/flags/_helpers.py | create_xml_dom_element | def create_xml_dom_element(doc, name, value):
"""Returns an XML DOM element with name and text value.
Args:
doc: minidom.Document, the DOM document it should create nodes from.
name: str, the tag of XML element.
value: object, whose string representation will be used
as the value of the XML ele... | python | def create_xml_dom_element(doc, name, value):
"""Returns an XML DOM element with name and text value.
Args:
doc: minidom.Document, the DOM document it should create nodes from.
name: str, the tag of XML element.
value: object, whose string representation will be used
as the value of the XML ele... | [
"def",
"create_xml_dom_element",
"(",
"doc",
",",
"name",
",",
"value",
")",
":",
"s",
"=",
"str_or_unicode",
"(",
"value",
")",
"if",
"six",
".",
"PY2",
"and",
"not",
"isinstance",
"(",
"s",
",",
"unicode",
")",
":",
"# Get a valid unicode string.",
"s",
... | Returns an XML DOM element with name and text value.
Args:
doc: minidom.Document, the DOM document it should create nodes from.
name: str, the tag of XML element.
value: object, whose string representation will be used
as the value of the XML element. Illegal or highly discouraged xml 1.0
... | [
"Returns",
"an",
"XML",
"DOM",
"element",
"with",
"name",
"and",
"text",
"value",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_helpers.py#L161-L186 |
220,484 | abseil/abseil-py | absl/flags/_helpers.py | get_help_width | def get_help_width():
"""Returns the integer width of help lines that is used in TextWrap."""
if not sys.stdout.isatty() or termios is None or fcntl is None:
return _DEFAULT_HELP_WIDTH
try:
data = fcntl.ioctl(sys.stdout, termios.TIOCGWINSZ, '1234')
columns = struct.unpack('hh', data)[1]
# Emacs mo... | python | def get_help_width():
"""Returns the integer width of help lines that is used in TextWrap."""
if not sys.stdout.isatty() or termios is None or fcntl is None:
return _DEFAULT_HELP_WIDTH
try:
data = fcntl.ioctl(sys.stdout, termios.TIOCGWINSZ, '1234')
columns = struct.unpack('hh', data)[1]
# Emacs mo... | [
"def",
"get_help_width",
"(",
")",
":",
"if",
"not",
"sys",
".",
"stdout",
".",
"isatty",
"(",
")",
"or",
"termios",
"is",
"None",
"or",
"fcntl",
"is",
"None",
":",
"return",
"_DEFAULT_HELP_WIDTH",
"try",
":",
"data",
"=",
"fcntl",
".",
"ioctl",
"(",
... | Returns the integer width of help lines that is used in TextWrap. | [
"Returns",
"the",
"integer",
"width",
"of",
"help",
"lines",
"that",
"is",
"used",
"in",
"TextWrap",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_helpers.py#L189-L204 |
220,485 | abseil/abseil-py | absl/flags/_helpers.py | get_flag_suggestions | def get_flag_suggestions(attempt, longopt_list):
"""Returns helpful similar matches for an invalid flag."""
# Don't suggest on very short strings, or if no longopts are specified.
if len(attempt) <= 2 or not longopt_list:
return []
option_names = [v.split('=')[0] for v in longopt_list]
# Find close appr... | python | def get_flag_suggestions(attempt, longopt_list):
"""Returns helpful similar matches for an invalid flag."""
# Don't suggest on very short strings, or if no longopts are specified.
if len(attempt) <= 2 or not longopt_list:
return []
option_names = [v.split('=')[0] for v in longopt_list]
# Find close appr... | [
"def",
"get_flag_suggestions",
"(",
"attempt",
",",
"longopt_list",
")",
":",
"# Don't suggest on very short strings, or if no longopts are specified.",
"if",
"len",
"(",
"attempt",
")",
"<=",
"2",
"or",
"not",
"longopt_list",
":",
"return",
"[",
"]",
"option_names",
... | Returns helpful similar matches for an invalid flag. | [
"Returns",
"helpful",
"similar",
"matches",
"for",
"an",
"invalid",
"flag",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_helpers.py#L207-L233 |
220,486 | abseil/abseil-py | absl/flags/_helpers.py | _damerau_levenshtein | def _damerau_levenshtein(a, b):
"""Returns Damerau-Levenshtein edit distance from a to b."""
memo = {}
def distance(x, y):
"""Recursively defined string distance with memoization."""
if (x, y) in memo:
return memo[x, y]
if not x:
d = len(y)
elif not y:
d = len(x)
else:
... | python | def _damerau_levenshtein(a, b):
"""Returns Damerau-Levenshtein edit distance from a to b."""
memo = {}
def distance(x, y):
"""Recursively defined string distance with memoization."""
if (x, y) in memo:
return memo[x, y]
if not x:
d = len(y)
elif not y:
d = len(x)
else:
... | [
"def",
"_damerau_levenshtein",
"(",
"a",
",",
"b",
")",
":",
"memo",
"=",
"{",
"}",
"def",
"distance",
"(",
"x",
",",
"y",
")",
":",
"\"\"\"Recursively defined string distance with memoization.\"\"\"",
"if",
"(",
"x",
",",
"y",
")",
"in",
"memo",
":",
"ret... | Returns Damerau-Levenshtein edit distance from a to b. | [
"Returns",
"Damerau",
"-",
"Levenshtein",
"edit",
"distance",
"from",
"a",
"to",
"b",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_helpers.py#L236-L261 |
220,487 | abseil/abseil-py | absl/flags/_helpers.py | text_wrap | def text_wrap(text, length=None, indent='', firstline_indent=None):
"""Wraps a given text to a maximum line length and returns it.
It turns lines that only contain whitespace into empty lines, keeps new lines,
and expands tabs using 4 spaces.
Args:
text: str, text to wrap.
length: int, maximum length ... | python | def text_wrap(text, length=None, indent='', firstline_indent=None):
"""Wraps a given text to a maximum line length and returns it.
It turns lines that only contain whitespace into empty lines, keeps new lines,
and expands tabs using 4 spaces.
Args:
text: str, text to wrap.
length: int, maximum length ... | [
"def",
"text_wrap",
"(",
"text",
",",
"length",
"=",
"None",
",",
"indent",
"=",
"''",
",",
"firstline_indent",
"=",
"None",
")",
":",
"# Get defaults where callee used None",
"if",
"length",
"is",
"None",
":",
"length",
"=",
"get_help_width",
"(",
")",
"if"... | Wraps a given text to a maximum line length and returns it.
It turns lines that only contain whitespace into empty lines, keeps new lines,
and expands tabs using 4 spaces.
Args:
text: str, text to wrap.
length: int, maximum length of a line, includes indentation.
If this is None then use get_hel... | [
"Wraps",
"a",
"given",
"text",
"to",
"a",
"maximum",
"line",
"length",
"and",
"returns",
"it",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_helpers.py#L264-L318 |
220,488 | abseil/abseil-py | absl/flags/_helpers.py | trim_docstring | def trim_docstring(docstring):
"""Removes indentation from triple-quoted strings.
This is the function specified in PEP 257 to handle docstrings:
https://www.python.org/dev/peps/pep-0257/.
Args:
docstring: str, a python docstring.
Returns:
str, docstring with indentation removed.
"""
if not doc... | python | def trim_docstring(docstring):
"""Removes indentation from triple-quoted strings.
This is the function specified in PEP 257 to handle docstrings:
https://www.python.org/dev/peps/pep-0257/.
Args:
docstring: str, a python docstring.
Returns:
str, docstring with indentation removed.
"""
if not doc... | [
"def",
"trim_docstring",
"(",
"docstring",
")",
":",
"if",
"not",
"docstring",
":",
"return",
"''",
"# If you've got a line longer than this you have other problems...",
"max_indent",
"=",
"1",
"<<",
"29",
"# Convert tabs to spaces (following the normal Python rules)",
"# and s... | Removes indentation from triple-quoted strings.
This is the function specified in PEP 257 to handle docstrings:
https://www.python.org/dev/peps/pep-0257/.
Args:
docstring: str, a python docstring.
Returns:
str, docstring with indentation removed. | [
"Removes",
"indentation",
"from",
"triple",
"-",
"quoted",
"strings",
"."
] | 9d73fdaa23a6b6726aa5731390f388c0c6250ee5 | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_helpers.py#L359-L398 |
220,489 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-core/ask_sdk_core/skill.py | CustomSkill.invoke | def invoke(self, request_envelope, context):
# type: (RequestEnvelope, Any) -> ResponseEnvelope
"""Invokes the dispatcher, to handle the request envelope and
return a response envelope.
:param request_envelope: Request Envelope instance containing
request information
... | python | def invoke(self, request_envelope, context):
# type: (RequestEnvelope, Any) -> ResponseEnvelope
"""Invokes the dispatcher, to handle the request envelope and
return a response envelope.
:param request_envelope: Request Envelope instance containing
request information
... | [
"def",
"invoke",
"(",
"self",
",",
"request_envelope",
",",
"context",
")",
":",
"# type: (RequestEnvelope, Any) -> ResponseEnvelope",
"if",
"(",
"self",
".",
"skill_id",
"is",
"not",
"None",
"and",
"request_envelope",
".",
"context",
".",
"system",
".",
"applicat... | Invokes the dispatcher, to handle the request envelope and
return a response envelope.
:param request_envelope: Request Envelope instance containing
request information
:type request_envelope: RequestEnvelope
:param context: Context passed during invocation
:type con... | [
"Invokes",
"the",
"dispatcher",
"to",
"handle",
"the",
"request",
"envelope",
"and",
"return",
"a",
"response",
"envelope",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/skill.py#L159-L211 |
220,490 | alexa/alexa-skills-kit-sdk-for-python | django-ask-sdk/django_ask_sdk/skill_adapter.py | SkillAdapter.dispatch | def dispatch(self, request, *args, **kwargs):
# type: (HttpRequest, object, object) -> HttpResponse
"""Inspect the HTTP method and delegate to the view method.
This is the default implementation of the
:py:class:`django.views.View` method, which will inspect the
HTTP method in t... | python | def dispatch(self, request, *args, **kwargs):
# type: (HttpRequest, object, object) -> HttpResponse
"""Inspect the HTTP method and delegate to the view method.
This is the default implementation of the
:py:class:`django.views.View` method, which will inspect the
HTTP method in t... | [
"def",
"dispatch",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (HttpRequest, object, object) -> HttpResponse",
"return",
"super",
"(",
"SkillAdapter",
",",
"self",
")",
".",
"dispatch",
"(",
"request",
")"
] | Inspect the HTTP method and delegate to the view method.
This is the default implementation of the
:py:class:`django.views.View` method, which will inspect the
HTTP method in the input request and delegate it to the
corresponding method in the view. The only allowed method on
th... | [
"Inspect",
"the",
"HTTP",
"method",
"and",
"delegate",
"to",
"the",
"view",
"method",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/django-ask-sdk/django_ask_sdk/skill_adapter.py#L152-L173 |
220,491 | alexa/alexa-skills-kit-sdk-for-python | django-ask-sdk/django_ask_sdk/skill_adapter.py | SkillAdapter.post | def post(self, request, *args, **kwargs):
# type: (HttpRequest, object, object) -> HttpResponse
"""The method that handles HTTP POST request on the view.
This method is called when the view receives a HTTP POST
request, which is generally the request sent from Alexa during
skill... | python | def post(self, request, *args, **kwargs):
# type: (HttpRequest, object, object) -> HttpResponse
"""The method that handles HTTP POST request on the view.
This method is called when the view receives a HTTP POST
request, which is generally the request sent from Alexa during
skill... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (HttpRequest, object, object) -> HttpResponse",
"try",
":",
"content",
"=",
"request",
".",
"body",
".",
"decode",
"(",
"verifier_constants",
".",
"CHARAC... | The method that handles HTTP POST request on the view.
This method is called when the view receives a HTTP POST
request, which is generally the request sent from Alexa during
skill invocation. The request is verified through the
registered list of verifiers, before invoking the request
... | [
"The",
"method",
"that",
"handles",
"HTTP",
"POST",
"request",
"on",
"the",
"view",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/django-ask-sdk/django_ask_sdk/skill_adapter.py#L175-L211 |
220,492 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-core/ask_sdk_core/utils/viewport.py | get_orientation | def get_orientation(width, height):
# type: (int, int) -> Orientation
"""Get viewport orientation from given width and height.
:type width: int
:type height: int
:return: viewport orientation enum
:rtype: Orientation
"""
if width > height:
return Orientation.LANDSCAPE
elif w... | python | def get_orientation(width, height):
# type: (int, int) -> Orientation
"""Get viewport orientation from given width and height.
:type width: int
:type height: int
:return: viewport orientation enum
:rtype: Orientation
"""
if width > height:
return Orientation.LANDSCAPE
elif w... | [
"def",
"get_orientation",
"(",
"width",
",",
"height",
")",
":",
"# type: (int, int) -> Orientation",
"if",
"width",
">",
"height",
":",
"return",
"Orientation",
".",
"LANDSCAPE",
"elif",
"width",
"<",
"height",
":",
"return",
"Orientation",
".",
"PORTRAIT",
"el... | Get viewport orientation from given width and height.
:type width: int
:type height: int
:return: viewport orientation enum
:rtype: Orientation | [
"Get",
"viewport",
"orientation",
"from",
"given",
"width",
"and",
"height",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/utils/viewport.py#L84-L98 |
220,493 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-core/ask_sdk_core/utils/viewport.py | get_size | def get_size(size):
# type: (int) -> Size
"""Get viewport size from given size.
:type size: int
:return: viewport size enum
:rtype: Size
"""
if size in range(0, 600):
return Size.XSMALL
elif size in range(600, 960):
return Size.SMALL
elif size in range(960, 1280):
... | python | def get_size(size):
# type: (int) -> Size
"""Get viewport size from given size.
:type size: int
:return: viewport size enum
:rtype: Size
"""
if size in range(0, 600):
return Size.XSMALL
elif size in range(600, 960):
return Size.SMALL
elif size in range(960, 1280):
... | [
"def",
"get_size",
"(",
"size",
")",
":",
"# type: (int) -> Size",
"if",
"size",
"in",
"range",
"(",
"0",
",",
"600",
")",
":",
"return",
"Size",
".",
"XSMALL",
"elif",
"size",
"in",
"range",
"(",
"600",
",",
"960",
")",
":",
"return",
"Size",
".",
... | Get viewport size from given size.
:type size: int
:return: viewport size enum
:rtype: Size | [
"Get",
"viewport",
"size",
"from",
"given",
"size",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/utils/viewport.py#L101-L120 |
220,494 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-core/ask_sdk_core/utils/viewport.py | get_dpi_group | def get_dpi_group(dpi):
# type: (int) -> Density
"""Get viewport density group from given dpi.
:type dpi: int
:return: viewport density group enum
:rtype: Density
"""
if dpi in range(0, 121):
return Density.XLOW
elif dpi in range(121, 161):
return Density.LOW
elif dp... | python | def get_dpi_group(dpi):
# type: (int) -> Density
"""Get viewport density group from given dpi.
:type dpi: int
:return: viewport density group enum
:rtype: Density
"""
if dpi in range(0, 121):
return Density.XLOW
elif dpi in range(121, 161):
return Density.LOW
elif dp... | [
"def",
"get_dpi_group",
"(",
"dpi",
")",
":",
"# type: (int) -> Density",
"if",
"dpi",
"in",
"range",
"(",
"0",
",",
"121",
")",
":",
"return",
"Density",
".",
"XLOW",
"elif",
"dpi",
"in",
"range",
"(",
"121",
",",
"161",
")",
":",
"return",
"Density",... | Get viewport density group from given dpi.
:type dpi: int
:return: viewport density group enum
:rtype: Density | [
"Get",
"viewport",
"density",
"group",
"from",
"given",
"dpi",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/utils/viewport.py#L123-L144 |
220,495 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-core/ask_sdk_core/utils/viewport.py | get_viewport_profile | def get_viewport_profile(request_envelope):
# type: (RequestEnvelope) -> ViewportProfile
"""Utility method, to get viewport profile.
The viewport profile is calculated using the shape, current pixel
width and height, along with the dpi.
If there is no `viewport`
value in `request_envelope.cont... | python | def get_viewport_profile(request_envelope):
# type: (RequestEnvelope) -> ViewportProfile
"""Utility method, to get viewport profile.
The viewport profile is calculated using the shape, current pixel
width and height, along with the dpi.
If there is no `viewport`
value in `request_envelope.cont... | [
"def",
"get_viewport_profile",
"(",
"request_envelope",
")",
":",
"# type: (RequestEnvelope) -> ViewportProfile",
"viewport_state",
"=",
"request_envelope",
".",
"context",
".",
"viewport",
"if",
"viewport_state",
":",
"shape",
"=",
"viewport_state",
".",
"shape",
"curren... | Utility method, to get viewport profile.
The viewport profile is calculated using the shape, current pixel
width and height, along with the dpi.
If there is no `viewport`
value in `request_envelope.context`, then an
`ViewportProfile.UNKNOWN_VIEWPORT_PROFILE` is returned.
:param request_envelo... | [
"Utility",
"method",
"to",
"get",
"viewport",
"profile",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/utils/viewport.py#L147-L246 |
220,496 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-runtime/ask_sdk_runtime/skill_builder.py | AbstractSkillBuilder.request_handler | def request_handler(self, can_handle_func):
# type: (Callable[[Input], bool]) -> Callable
"""Decorator that can be used to add request handlers easily to
the builder.
The can_handle_func has to be a Callable instance, which takes
a single parameter and no varargs or kwargs. This... | python | def request_handler(self, can_handle_func):
# type: (Callable[[Input], bool]) -> Callable
"""Decorator that can be used to add request handlers easily to
the builder.
The can_handle_func has to be a Callable instance, which takes
a single parameter and no varargs or kwargs. This... | [
"def",
"request_handler",
"(",
"self",
",",
"can_handle_func",
")",
":",
"# type: (Callable[[Input], bool]) -> Callable",
"def",
"wrapper",
"(",
"handle_func",
")",
":",
"if",
"not",
"callable",
"(",
"can_handle_func",
")",
"or",
"not",
"callable",
"(",
"handle_func... | Decorator that can be used to add request handlers easily to
the builder.
The can_handle_func has to be a Callable instance, which takes
a single parameter and no varargs or kwargs. This is because
of the RequestHandler class signature restrictions. The
returned wrapper function... | [
"Decorator",
"that",
"can",
"be",
"used",
"to",
"add",
"request",
"handlers",
"easily",
"to",
"the",
"builder",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-runtime/ask_sdk_runtime/skill_builder.py#L97-L136 |
220,497 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-runtime/ask_sdk_runtime/skill_builder.py | AbstractSkillBuilder.exception_handler | def exception_handler(self, can_handle_func):
# type: (Callable[[Input, Exception], bool]) -> Callable
"""Decorator that can be used to add exception handlers easily
to the builder.
The can_handle_func has to be a Callable instance, which takes
two parameters and no varargs or k... | python | def exception_handler(self, can_handle_func):
# type: (Callable[[Input, Exception], bool]) -> Callable
"""Decorator that can be used to add exception handlers easily
to the builder.
The can_handle_func has to be a Callable instance, which takes
two parameters and no varargs or k... | [
"def",
"exception_handler",
"(",
"self",
",",
"can_handle_func",
")",
":",
"# type: (Callable[[Input, Exception], bool]) -> Callable",
"def",
"wrapper",
"(",
"handle_func",
")",
":",
"if",
"not",
"callable",
"(",
"can_handle_func",
")",
"or",
"not",
"callable",
"(",
... | Decorator that can be used to add exception handlers easily
to the builder.
The can_handle_func has to be a Callable instance, which takes
two parameters and no varargs or kwargs. This is because of the
ExceptionHandler class signature restrictions. The returned
wrapper function... | [
"Decorator",
"that",
"can",
"be",
"used",
"to",
"add",
"exception",
"handlers",
"easily",
"to",
"the",
"builder",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-runtime/ask_sdk_runtime/skill_builder.py#L138-L180 |
220,498 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-runtime/ask_sdk_runtime/skill_builder.py | AbstractSkillBuilder.global_request_interceptor | def global_request_interceptor(self):
# type: () -> Callable
"""Decorator that can be used to add global request
interceptors easily to the builder.
The returned wrapper function can be applied as a decorator on
any function that processes the input. The function should
... | python | def global_request_interceptor(self):
# type: () -> Callable
"""Decorator that can be used to add global request
interceptors easily to the builder.
The returned wrapper function can be applied as a decorator on
any function that processes the input. The function should
... | [
"def",
"global_request_interceptor",
"(",
"self",
")",
":",
"# type: () -> Callable",
"def",
"wrapper",
"(",
"process_func",
")",
":",
"if",
"not",
"callable",
"(",
"process_func",
")",
":",
"raise",
"SkillBuilderException",
"(",
"\"Global Request Interceptor process_fu... | Decorator that can be used to add global request
interceptors easily to the builder.
The returned wrapper function can be applied as a decorator on
any function that processes the input. The function should
follow the signature of the process function in
:py:class:`ask_sdk_runti... | [
"Decorator",
"that",
"can",
"be",
"used",
"to",
"add",
"global",
"request",
"interceptors",
"easily",
"to",
"the",
"builder",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-runtime/ask_sdk_runtime/skill_builder.py#L182-L214 |
220,499 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-runtime/ask_sdk_runtime/skill_builder.py | AbstractSkillBuilder.global_response_interceptor | def global_response_interceptor(self):
# type: () -> Callable
"""Decorator that can be used to add global
response interceptors easily to the builder.
The returned wrapper function can be applied as a decorator
on any function that processes the input and the response
ge... | python | def global_response_interceptor(self):
# type: () -> Callable
"""Decorator that can be used to add global
response interceptors easily to the builder.
The returned wrapper function can be applied as a decorator
on any function that processes the input and the response
ge... | [
"def",
"global_response_interceptor",
"(",
"self",
")",
":",
"# type: () -> Callable",
"def",
"wrapper",
"(",
"process_func",
")",
":",
"if",
"not",
"callable",
"(",
"process_func",
")",
":",
"raise",
"SkillBuilderException",
"(",
"\"Global Response Interceptor process_... | Decorator that can be used to add global
response interceptors easily to the builder.
The returned wrapper function can be applied as a decorator
on any function that processes the input and the response
generated by the request handler. The function should follow
the signature ... | [
"Decorator",
"that",
"can",
"be",
"used",
"to",
"add",
"global",
"response",
"interceptors",
"easily",
"to",
"the",
"builder",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-runtime/ask_sdk_runtime/skill_builder.py#L216-L250 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.