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
partition
stringclasses
1 value
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/utils/request_util.py
get_intent_name
def get_intent_name(handler_input): # type: (HandlerInput) -> AnyStr """Return the name of the intent request. The method retrieves the intent ``name`` from the input request, only if the input request is an :py:class:`ask_sdk_model.intent_request.IntentRequest`. If the input is not an IntentRe...
python
def get_intent_name(handler_input): # type: (HandlerInput) -> AnyStr """Return the name of the intent request. The method retrieves the intent ``name`` from the input request, only if the input request is an :py:class:`ask_sdk_model.intent_request.IntentRequest`. If the input is not an IntentRe...
[ "def", "get_intent_name", "(", "handler_input", ")", ":", "# type: (HandlerInput) -> AnyStr", "request", "=", "handler_input", ".", "request_envelope", ".", "request", "if", "isinstance", "(", "request", ",", "IntentRequest", ")", ":", "return", "request", ".", "int...
Return the name of the intent request. The method retrieves the intent ``name`` from the input request, only if the input request is an :py:class:`ask_sdk_model.intent_request.IntentRequest`. If the input is not an IntentRequest, a :py:class:`TypeError` is raised. :param handler_input: The handler...
[ "Return", "the", "name", "of", "the", "intent", "request", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/utils/request_util.py#L65-L85
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/utils/request_util.py
get_device_id
def get_device_id(handler_input): # type: (HandlerInput) -> Optional[AnyStr] """Return the device id from the input request. The method retrieves the `deviceId` property from the input request. This value uniquely identifies the device and is generally used as input for some Alexa-specific API call...
python
def get_device_id(handler_input): # type: (HandlerInput) -> Optional[AnyStr] """Return the device id from the input request. The method retrieves the `deviceId` property from the input request. This value uniquely identifies the device and is generally used as input for some Alexa-specific API call...
[ "def", "get_device_id", "(", "handler_input", ")", ":", "# type: (HandlerInput) -> Optional[AnyStr]", "device", "=", "handler_input", ".", "request_envelope", ".", "context", ".", "system", ".", "device", "if", "device", ":", "return", "device", ".", "device_id", "e...
Return the device id from the input request. The method retrieves the `deviceId` property from the input request. This value uniquely identifies the device and is generally used as input for some Alexa-specific API calls. More information about this can be found here : https://developer.amazon.com/...
[ "Return", "the", "device", "id", "from", "the", "input", "request", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/utils/request_util.py#L133-L157
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/utils/request_util.py
get_dialog_state
def get_dialog_state(handler_input): # type: (HandlerInput) -> Optional[DialogState] """Return the dialog state enum from the intent request. The method retrieves the `dialogState` from the intent request, if the skill's interaction model includes a dialog model. This can be used to determine the c...
python
def get_dialog_state(handler_input): # type: (HandlerInput) -> Optional[DialogState] """Return the dialog state enum from the intent request. The method retrieves the `dialogState` from the intent request, if the skill's interaction model includes a dialog model. This can be used to determine the c...
[ "def", "get_dialog_state", "(", "handler_input", ")", ":", "# type: (HandlerInput) -> Optional[DialogState]", "request", "=", "handler_input", ".", "request_envelope", ".", "request", "if", "isinstance", "(", "request", ",", "IntentRequest", ")", ":", "return", "request...
Return the dialog state enum from the intent request. The method retrieves the `dialogState` from the intent request, if the skill's interaction model includes a dialog model. This can be used to determine the current status of user conversation and return the appropriate dialog directives if the conve...
[ "Return", "the", "dialog", "state", "enum", "from", "the", "intent", "request", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/utils/request_util.py#L160-L186
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/utils/request_util.py
get_slot
def get_slot(handler_input, slot_name): # type: (HandlerInput, str) -> Optional[Slot] """Return the slot information from intent request. The method retrieves the slot information :py:class:`ask_sdk_model.slot.Slot` from the input intent request for the given ``slot_name``. More information on the ...
python
def get_slot(handler_input, slot_name): # type: (HandlerInput, str) -> Optional[Slot] """Return the slot information from intent request. The method retrieves the slot information :py:class:`ask_sdk_model.slot.Slot` from the input intent request for the given ``slot_name``. More information on the ...
[ "def", "get_slot", "(", "handler_input", ",", "slot_name", ")", ":", "# type: (HandlerInput, str) -> Optional[Slot]", "request", "=", "handler_input", ".", "request_envelope", ".", "request", "if", "isinstance", "(", "request", ",", "IntentRequest", ")", ":", "if", ...
Return the slot information from intent request. The method retrieves the slot information :py:class:`ask_sdk_model.slot.Slot` from the input intent request for the given ``slot_name``. More information on the slots can be found here : https://developer.amazon.com/docs/custom-skills/request-types-r...
[ "Return", "the", "slot", "information", "from", "intent", "request", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/utils/request_util.py#L189-L221
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/utils/request_util.py
get_slot_value
def get_slot_value(handler_input, slot_name): # type: (HandlerInput, str) -> AnyStr """Return the slot value from intent request. The method retrieves the slot value from the input intent request for the given ``slot_name``. More information on the slots can be found here : https://developer.am...
python
def get_slot_value(handler_input, slot_name): # type: (HandlerInput, str) -> AnyStr """Return the slot value from intent request. The method retrieves the slot value from the input intent request for the given ``slot_name``. More information on the slots can be found here : https://developer.am...
[ "def", "get_slot_value", "(", "handler_input", ",", "slot_name", ")", ":", "# type: (HandlerInput, str) -> AnyStr", "slot", "=", "get_slot", "(", "handler_input", "=", "handler_input", ",", "slot_name", "=", "slot_name", ")", "if", "slot", "is", "not", "None", ":"...
Return the slot value from intent request. The method retrieves the slot value from the input intent request for the given ``slot_name``. More information on the slots can be found here : https://developer.amazon.com/docs/custom-skills/request-types-reference.html#slot-object If there is no such s...
[ "Return", "the", "slot", "value", "from", "intent", "request", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/utils/request_util.py#L224-L255
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/utils/request_util.py
is_new_session
def is_new_session(handler_input): # type: (HandlerInput) -> bool """Return if the session is new for the input request. The method retrieves the ``new`` value from the input request's session, which indicates if it's a new session or not. The :py:class:`ask_sdk_model.session.Session` is only inclu...
python
def is_new_session(handler_input): # type: (HandlerInput) -> bool """Return if the session is new for the input request. The method retrieves the ``new`` value from the input request's session, which indicates if it's a new session or not. The :py:class:`ask_sdk_model.session.Session` is only inclu...
[ "def", "is_new_session", "(", "handler_input", ")", ":", "# type: (HandlerInput) -> bool", "session", "=", "handler_input", ".", "request_envelope", ".", "session", "if", "session", "is", "not", "None", ":", "return", "session", ".", "new", "raise", "TypeError", "...
Return if the session is new for the input request. The method retrieves the ``new`` value from the input request's session, which indicates if it's a new session or not. The :py:class:`ask_sdk_model.session.Session` is only included on all standard requests except ``AudioPlayer``, ``VideoApp`` and ...
[ "Return", "if", "the", "session", "is", "new", "for", "the", "input", "request", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/utils/request_util.py#L284-L310
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/response_helper.py
__set_text_field
def __set_text_field(text, text_type): # type: (str, str) -> Union[None, PlainText, RichText] """Helper method to create text field according to text type. :type text: str :param text_type: Type of the primary text field. Allowed values are `PlainText` and `RichText`. :type text_type: str ...
python
def __set_text_field(text, text_type): # type: (str, str) -> Union[None, PlainText, RichText] """Helper method to create text field according to text type. :type text: str :param text_type: Type of the primary text field. Allowed values are `PlainText` and `RichText`. :type text_type: str ...
[ "def", "__set_text_field", "(", "text", ",", "text_type", ")", ":", "# type: (str, str) -> Union[None, PlainText, RichText]", "if", "text", ":", "if", "text_type", "not", "in", "[", "PLAIN_TEXT_TYPE", ",", "RICH_TEXT_TYPE", "]", ":", "raise", "ValueError", "(", "\"I...
Helper method to create text field according to text type. :type text: str :param text_type: Type of the primary text field. Allowed values are `PlainText` and `RichText`. :type text_type: str :return: Object of type :py:class:`ask_sdk_model.interfaces.display.PlainText` or :py:...
[ "Helper", "method", "to", "create", "text", "field", "according", "to", "text", "type", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/response_helper.py#L290-L314
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/response_helper.py
ResponseFactory.speak
def speak(self, speech, play_behavior=None): # type: (str, PlayBehavior) -> 'ResponseFactory' """Say the provided speech to the user. :param speech: the output speech sent back to the user. :type speech: str :param play_behavior: attribute to control alexa's speech i...
python
def speak(self, speech, play_behavior=None): # type: (str, PlayBehavior) -> 'ResponseFactory' """Say the provided speech to the user. :param speech: the output speech sent back to the user. :type speech: str :param play_behavior: attribute to control alexa's speech i...
[ "def", "speak", "(", "self", ",", "speech", ",", "play_behavior", "=", "None", ")", ":", "# type: (str, PlayBehavior) -> 'ResponseFactory'", "ssml", "=", "\"<speak>{}</speak>\"", ".", "format", "(", "self", ".", "__trim_outputspeech", "(", "speech_output", "=", "spe...
Say the provided speech to the user. :param speech: the output speech sent back to the user. :type speech: str :param play_behavior: attribute to control alexa's speech interruption :type play_behavior: ask_sdk_model.ui.play_behavior.PlayBehavior :return: response fa...
[ "Say", "the", "provided", "speech", "to", "the", "user", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/response_helper.py#L55-L72
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/response_helper.py
ResponseFactory.ask
def ask(self, reprompt, play_behavior=None): # type: (str, PlayBehavior) -> 'ResponseFactory' """Provide reprompt speech to the user, if no response for 8 seconds. The should_end_session value will be set to false except when the video app launch directive is present in directiv...
python
def ask(self, reprompt, play_behavior=None): # type: (str, PlayBehavior) -> 'ResponseFactory' """Provide reprompt speech to the user, if no response for 8 seconds. The should_end_session value will be set to false except when the video app launch directive is present in directiv...
[ "def", "ask", "(", "self", ",", "reprompt", ",", "play_behavior", "=", "None", ")", ":", "# type: (str, PlayBehavior) -> 'ResponseFactory'", "ssml", "=", "\"<speak>{}</speak>\"", ".", "format", "(", "self", ".", "__trim_outputspeech", "(", "speech_output", "=", "rep...
Provide reprompt speech to the user, if no response for 8 seconds. The should_end_session value will be set to false except when the video app launch directive is present in directives. :param reprompt: the output speech to reprompt. :type reprompt: str :param play_beha...
[ "Provide", "reprompt", "speech", "to", "the", "user", "if", "no", "response", "for", "8", "seconds", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/response_helper.py#L74-L98
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/response_helper.py
ResponseFactory.add_directive
def add_directive(self, directive): # type: (Directive) -> 'ResponseFactory' """Adds directive to response. :param directive: the directive sent back to Alexa device. :type directive: ask_sdk_model.directive.Directive :return: response factory with partial response being built a...
python
def add_directive(self, directive): # type: (Directive) -> 'ResponseFactory' """Adds directive to response. :param directive: the directive sent back to Alexa device. :type directive: ask_sdk_model.directive.Directive :return: response factory with partial response being built a...
[ "def", "add_directive", "(", "self", ",", "directive", ")", ":", "# type: (Directive) -> 'ResponseFactory'", "if", "self", ".", "response", ".", "directives", "is", "None", ":", "self", ".", "response", ".", "directives", "=", "[", "]", "if", "(", "directive",...
Adds directive to response. :param directive: the directive sent back to Alexa device. :type directive: ask_sdk_model.directive.Directive :return: response factory with partial response being built and access from self.response. :rtype: ResponseFactory
[ "Adds", "directive", "to", "response", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/response_helper.py#L116-L133
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/response_helper.py
ResponseFactory.__is_video_app_launch_directive_present
def __is_video_app_launch_directive_present(self): # type: () -> bool """Checks if the video app launch directive is present or not. :return: boolean to show if video app launch directive is present or not. :rtype: bool """ if self.response.directives is None...
python
def __is_video_app_launch_directive_present(self): # type: () -> bool """Checks if the video app launch directive is present or not. :return: boolean to show if video app launch directive is present or not. :rtype: bool """ if self.response.directives is None...
[ "def", "__is_video_app_launch_directive_present", "(", "self", ")", ":", "# type: () -> bool", "if", "self", ".", "response", ".", "directives", "is", "None", ":", "return", "False", "for", "directive", "in", "self", ".", "response", ".", "directives", ":", "if"...
Checks if the video app launch directive is present or not. :return: boolean to show if video app launch directive is present or not. :rtype: bool
[ "Checks", "if", "the", "video", "app", "launch", "directive", "is", "present", "or", "not", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/response_helper.py#L183-L198
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-runtime/ask_sdk_runtime/dispatch.py
GenericRequestDispatcher.dispatch
def dispatch(self, handler_input): # type: (Input) -> Union[Output, None] """Dispatches an incoming request to the appropriate request handler and returns the output. Before running the request on the appropriate request handler, dispatcher runs any predefined global request int...
python
def dispatch(self, handler_input): # type: (Input) -> Union[Output, None] """Dispatches an incoming request to the appropriate request handler and returns the output. Before running the request on the appropriate request handler, dispatcher runs any predefined global request int...
[ "def", "dispatch", "(", "self", ",", "handler_input", ")", ":", "# type: (Input) -> Union[Output, None]", "try", ":", "for", "request_interceptor", "in", "self", ".", "request_interceptors", ":", "request_interceptor", ".", "process", "(", "handler_input", "=", "handl...
Dispatches an incoming request to the appropriate request handler and returns the output. Before running the request on the appropriate request handler, dispatcher runs any predefined global request interceptors. On successful response returned from request handler, dispatcher r...
[ "Dispatches", "an", "incoming", "request", "to", "the", "appropriate", "request", "handler", "and", "returns", "the", "output", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-runtime/ask_sdk_runtime/dispatch.py#L96-L133
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-runtime/ask_sdk_runtime/dispatch.py
GenericRequestDispatcher.__dispatch_request
def __dispatch_request(self, handler_input): # type: (Input) -> Union[Output, None] """Process the request and return handler output. When the method is invoked, using the registered list of :py:class:`RequestMapper`, a Handler Chain is found that can handle the request. The han...
python
def __dispatch_request(self, handler_input): # type: (Input) -> Union[Output, None] """Process the request and return handler output. When the method is invoked, using the registered list of :py:class:`RequestMapper`, a Handler Chain is found that can handle the request. The han...
[ "def", "__dispatch_request", "(", "self", ",", "handler_input", ")", ":", "# type: (Input) -> Union[Output, None]", "request_handler_chain", "=", "None", "for", "mapper", "in", "self", ".", "request_mappers", ":", "request_handler_chain", "=", "mapper", ".", "get_reques...
Process the request and return handler output. When the method is invoked, using the registered list of :py:class:`RequestMapper`, a Handler Chain is found that can handle the request. The handler invocation is delegated to the supported :py:class:`HandlerAdapter`. The registered ...
[ "Process", "the", "request", "and", "return", "handler", "output", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-runtime/ask_sdk_runtime/dispatch.py#L135-L191
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/skill_builder.py
SkillBuilder.lambda_handler
def lambda_handler(self): # type: () -> Callable[[RequestEnvelope, T], Dict[str, T]] """Create a handler function that can be used as handler in AWS Lambda console. The lambda handler provides a handler function, that acts as an entry point to the AWS Lambda console. Users can s...
python
def lambda_handler(self): # type: () -> Callable[[RequestEnvelope, T], Dict[str, T]] """Create a handler function that can be used as handler in AWS Lambda console. The lambda handler provides a handler function, that acts as an entry point to the AWS Lambda console. Users can s...
[ "def", "lambda_handler", "(", "self", ")", ":", "# type: () -> Callable[[RequestEnvelope, T], Dict[str, T]]", "def", "wrapper", "(", "event", ",", "context", ")", ":", "# type: (RequestEnvelope, T) -> Dict[str, T]", "skill", "=", "CustomSkill", "(", "skill_configuration", "...
Create a handler function that can be used as handler in AWS Lambda console. The lambda handler provides a handler function, that acts as an entry point to the AWS Lambda console. Users can set the lambda_handler output to a variable and set the variable as AWS Lambda Handler on...
[ "Create", "a", "handler", "function", "that", "can", "be", "used", "as", "handler", "in", "AWS", "Lambda", "console", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/skill_builder.py#L80-L100
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-webservice-support/ask_sdk_webservice_support/webservice_handler.py
WebserviceSkillHandler.verify_request_and_dispatch
def verify_request_and_dispatch( self, http_request_headers, http_request_body): # type: (Dict[str, Any], str) -> str """Entry point for webservice skill invocation. This method takes in the input request headers and request body, handles the deserialization of the input req...
python
def verify_request_and_dispatch( self, http_request_headers, http_request_body): # type: (Dict[str, Any], str) -> str """Entry point for webservice skill invocation. This method takes in the input request headers and request body, handles the deserialization of the input req...
[ "def", "verify_request_and_dispatch", "(", "self", ",", "http_request_headers", ",", "http_request_body", ")", ":", "# type: (Dict[str, Any], str) -> str", "request_envelope", "=", "self", ".", "_skill", ".", "serializer", ".", "deserialize", "(", "payload", "=", "http_...
Entry point for webservice skill invocation. This method takes in the input request headers and request body, handles the deserialization of the input request to the :py:class:`ask_sdk_model.request_envelope.RequestEnvelope` object, run the input through registered verifiers, invoke the...
[ "Entry", "point", "for", "webservice", "skill", "invocation", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-webservice-support/ask_sdk_webservice_support/webservice_handler.py#L99-L136
train
alexa/alexa-skills-kit-sdk-for-python
flask-ask-sdk/flask_ask_sdk/skill_adapter.py
SkillAdapter.init_app
def init_app(self, app): # type: (Flask) -> None """Register the extension on the given Flask application. Use this function only when no Flask application was provided in the ``app`` keyword argument to the constructor of this class. The function sets ``True`` defaults for ...
python
def init_app(self, app): # type: (Flask) -> None """Register the extension on the given Flask application. Use this function only when no Flask application was provided in the ``app`` keyword argument to the constructor of this class. The function sets ``True`` defaults for ...
[ "def", "init_app", "(", "self", ",", "app", ")", ":", "# type: (Flask) -> None", "app", ".", "config", ".", "setdefault", "(", "VERIFY_SIGNATURE_APP_CONFIG", ",", "True", ")", "app", ".", "config", ".", "setdefault", "(", "VERIFY_TIMESTAMP_APP_CONFIG", ",", "Tru...
Register the extension on the given Flask application. Use this function only when no Flask application was provided in the ``app`` keyword argument to the constructor of this class. The function sets ``True`` defaults for :py:const:`VERIFY_SIGNATURE_APP_CONFIG` and :py:const:`...
[ "Register", "the", "extension", "on", "the", "given", "Flask", "application", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/flask-ask-sdk/flask_ask_sdk/skill_adapter.py#L156-L184
train
alexa/alexa-skills-kit-sdk-for-python
flask-ask-sdk/flask_ask_sdk/skill_adapter.py
SkillAdapter._create_webservice_handler
def _create_webservice_handler(self, skill, verifiers): # type: (CustomSkill, List[AbstractVerifier]) -> None """Create the handler for request verification and dispatch. :param skill: A :py:class:`ask_sdk_core.skill.CustomSkill` instance. If you are using the skill builder from ask...
python
def _create_webservice_handler(self, skill, verifiers): # type: (CustomSkill, List[AbstractVerifier]) -> None """Create the handler for request verification and dispatch. :param skill: A :py:class:`ask_sdk_core.skill.CustomSkill` instance. If you are using the skill builder from ask...
[ "def", "_create_webservice_handler", "(", "self", ",", "skill", ",", "verifiers", ")", ":", "# type: (CustomSkill, List[AbstractVerifier]) -> None", "if", "verifiers", "is", "None", ":", "verifiers", "=", "[", "]", "self", ".", "_webservice_handler", "=", "WebserviceS...
Create the handler for request verification and dispatch. :param skill: A :py:class:`ask_sdk_core.skill.CustomSkill` instance. If you are using the skill builder from ask-sdk, then you can use the ``create`` method under it, to create a skill instance :type skill: as...
[ "Create", "the", "handler", "for", "request", "verification", "and", "dispatch", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/flask-ask-sdk/flask_ask_sdk/skill_adapter.py#L186-L211
train
alexa/alexa-skills-kit-sdk-for-python
flask-ask-sdk/flask_ask_sdk/skill_adapter.py
SkillAdapter.dispatch_request
def dispatch_request(self): # type: () -> Response """Method that handles request verification and routing. This method can be used as a function to register on the URL rule. The request is verified through the registered list of verifiers, before invoking the request handlers. ...
python
def dispatch_request(self): # type: () -> Response """Method that handles request verification and routing. This method can be used as a function to register on the URL rule. The request is verified through the registered list of verifiers, before invoking the request handlers. ...
[ "def", "dispatch_request", "(", "self", ")", ":", "# type: () -> Response", "if", "flask_request", ".", "method", "!=", "\"POST\"", ":", "raise", "exceptions", ".", "MethodNotAllowed", "(", ")", "try", ":", "content", "=", "flask_request", ".", "data", ".", "d...
Method that handles request verification and routing. This method can be used as a function to register on the URL rule. The request is verified through the registered list of verifiers, before invoking the request handlers. The method returns a JSON response for the Alexa service to re...
[ "Method", "that", "handles", "request", "verification", "and", "routing", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/flask-ask-sdk/flask_ask_sdk/skill_adapter.py#L213-L252
train
alexa/alexa-skills-kit-sdk-for-python
flask-ask-sdk/flask_ask_sdk/skill_adapter.py
SkillAdapter.register
def register(self, app, route, endpoint=None): # type: (Flask, str, str) -> None """Method to register the routing on the app at provided route. This is a utility method, that can be used for registering the ``dispatch_request`` on the provided :py:class:`flask.Flask` applicatio...
python
def register(self, app, route, endpoint=None): # type: (Flask, str, str) -> None """Method to register the routing on the app at provided route. This is a utility method, that can be used for registering the ``dispatch_request`` on the provided :py:class:`flask.Flask` applicatio...
[ "def", "register", "(", "self", ",", "app", ",", "route", ",", "endpoint", "=", "None", ")", ":", "# type: (Flask, str, str) -> None", "if", "app", "is", "None", "or", "not", "isinstance", "(", "app", ",", "Flask", ")", ":", "raise", "TypeError", "(", "\...
Method to register the routing on the app at provided route. This is a utility method, that can be used for registering the ``dispatch_request`` on the provided :py:class:`flask.Flask` application at the provided URL ``route``. :param app: A :py:class:`flask.Flask` application instance...
[ "Method", "to", "register", "the", "routing", "on", "the", "app", "at", "provided", "route", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/flask-ask-sdk/flask_ask_sdk/skill_adapter.py#L254-L282
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/serialize.py
DefaultSerializer.serialize
def serialize(self, obj): # type: ignore # type: (Any) -> Union[Dict[str, Any], List, Tuple, str, int, float, None] """Builds a serialized object. * If obj is None, return None. * If obj is str, int, long, float, bool, return directly. * If obj is datetime.datetime, datetime.da...
python
def serialize(self, obj): # type: ignore # type: (Any) -> Union[Dict[str, Any], List, Tuple, str, int, float, None] """Builds a serialized object. * If obj is None, return None. * If obj is str, int, long, float, bool, return directly. * If obj is datetime.datetime, datetime.da...
[ "def", "serialize", "(", "self", ",", "obj", ")", ":", "# type: ignore", "# type: (Any) -> Union[Dict[str, Any], List, Tuple, str, int, float, None]", "if", "obj", "is", "None", ":", "return", "None", "elif", "isinstance", "(", "obj", ",", "self", ".", "PRIMITIVE_TYPE...
Builds a serialized object. * If obj is None, return None. * If obj is str, int, long, float, bool, return directly. * If obj is datetime.datetime, datetime.date convert to string in iso8601 format. * If obj is list, serialize each element in the list. * If obj is dict...
[ "Builds", "a", "serialized", "object", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/serialize.py#L61-L125
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/serialize.py
DefaultSerializer.deserialize
def deserialize(self, payload, obj_type): # type: (str, Union[T, str]) -> Any """Deserializes payload into an instance of provided ``obj_type``. The ``obj_type`` parameter can be a primitive type, a generic model object or a list / dict of model objects. The list or dict object...
python
def deserialize(self, payload, obj_type): # type: (str, Union[T, str]) -> Any """Deserializes payload into an instance of provided ``obj_type``. The ``obj_type`` parameter can be a primitive type, a generic model object or a list / dict of model objects. The list or dict object...
[ "def", "deserialize", "(", "self", ",", "payload", ",", "obj_type", ")", ":", "# type: (str, Union[T, str]) -> Any", "if", "payload", "is", "None", ":", "return", "None", "try", ":", "payload", "=", "json", ".", "loads", "(", "payload", ")", "except", "Excep...
Deserializes payload into an instance of provided ``obj_type``. The ``obj_type`` parameter can be a primitive type, a generic model object or a list / dict of model objects. The list or dict object type has to be provided as a string format. For eg: * ``'list[a.b.C]'`` if the ...
[ "Deserializes", "payload", "into", "an", "instance", "of", "provided", "obj_type", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/serialize.py#L127-L169
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/serialize.py
DefaultSerializer.__deserialize
def __deserialize(self, payload, obj_type): # type: (str, Union[T, str]) -> Any """Deserializes payload into a model object. :param payload: data to be deserialized. :type payload: str :param obj_type: resolved class name for deserialized object :type obj_type: Union[obj...
python
def __deserialize(self, payload, obj_type): # type: (str, Union[T, str]) -> Any """Deserializes payload into a model object. :param payload: data to be deserialized. :type payload: str :param obj_type: resolved class name for deserialized object :type obj_type: Union[obj...
[ "def", "__deserialize", "(", "self", ",", "payload", ",", "obj_type", ")", ":", "# type: (str, Union[T, str]) -> Any", "if", "payload", "is", "None", ":", "return", "None", "if", "isinstance", "(", "obj_type", ",", "str", ")", ":", "if", "obj_type", ".", "st...
Deserializes payload into a model object. :param payload: data to be deserialized. :type payload: str :param obj_type: resolved class name for deserialized object :type obj_type: Union[object, str] :return: deserialized object :rtype: object
[ "Deserializes", "payload", "into", "a", "model", "object", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/serialize.py#L171-L235
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/serialize.py
DefaultSerializer.__load_class_from_name
def __load_class_from_name(self, class_name): # type: (str) -> T """Load the class from the ``class_name`` provided. Resolve the class name from the ``class_name`` provided, load the class on path and return the resolved class. If the module information is not provided in the ``...
python
def __load_class_from_name(self, class_name): # type: (str) -> T """Load the class from the ``class_name`` provided. Resolve the class name from the ``class_name`` provided, load the class on path and return the resolved class. If the module information is not provided in the ``...
[ "def", "__load_class_from_name", "(", "self", ",", "class_name", ")", ":", "# type: (str) -> T", "try", ":", "module_class_list", "=", "class_name", ".", "rsplit", "(", "\".\"", ",", "1", ")", "if", "len", "(", "module_class_list", ")", ">", "1", ":", "modul...
Load the class from the ``class_name`` provided. Resolve the class name from the ``class_name`` provided, load the class on path and return the resolved class. If the module information is not provided in the ``class_name``, then look for the class on sys ``modules``. :param cl...
[ "Load", "the", "class", "from", "the", "class_name", "provided", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/serialize.py#L237-L268
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/serialize.py
DefaultSerializer.__deserialize_primitive
def __deserialize_primitive(self, payload, obj_type): # type: (str, Union[T, str]) -> Any """Deserialize primitive datatypes. :param payload: data to be deserialized :type payload: str :param obj_type: primitive datatype str :type obj_type: Union[object, str] :re...
python
def __deserialize_primitive(self, payload, obj_type): # type: (str, Union[T, str]) -> Any """Deserialize primitive datatypes. :param payload: data to be deserialized :type payload: str :param obj_type: primitive datatype str :type obj_type: Union[object, str] :re...
[ "def", "__deserialize_primitive", "(", "self", ",", "payload", ",", "obj_type", ")", ":", "# type: (str, Union[T, str]) -> Any", "obj_cast", "=", "cast", "(", "Any", ",", "obj_type", ")", "try", ":", "return", "obj_cast", "(", "payload", ")", "except", "UnicodeE...
Deserialize primitive datatypes. :param payload: data to be deserialized :type payload: str :param obj_type: primitive datatype str :type obj_type: Union[object, str] :return: deserialized primitive datatype object :rtype: object :raises: :py:class:`ask_sdk_core....
[ "Deserialize", "primitive", "datatypes", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/serialize.py#L270-L292
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/serialize.py
DefaultSerializer.__deserialize_model
def __deserialize_model(self, payload, obj_type): # type: (str, Union[T, str]) -> Any """Deserialize instance to model object. :param payload: data to be deserialized :type payload: str :param obj_type: sdk model class :type obj_type: Union[object, str] :return: ...
python
def __deserialize_model(self, payload, obj_type): # type: (str, Union[T, str]) -> Any """Deserialize instance to model object. :param payload: data to be deserialized :type payload: str :param obj_type: sdk model class :type obj_type: Union[object, str] :return: ...
[ "def", "__deserialize_model", "(", "self", ",", "payload", ",", "obj_type", ")", ":", "# type: (str, Union[T, str]) -> Any", "try", ":", "obj_cast", "=", "cast", "(", "Any", ",", "obj_type", ")", "if", "issubclass", "(", "obj_cast", ",", "Enum", ")", ":", "r...
Deserialize instance to model object. :param payload: data to be deserialized :type payload: str :param obj_type: sdk model class :type obj_type: Union[object, str] :return: deserialized sdk model object :rtype: object :raises: :py:class:`ask_sdk_core.exceptions....
[ "Deserialize", "instance", "to", "model", "object", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/serialize.py#L322-L374
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/serialize.py
DefaultSerializer.__get_obj_by_discriminator
def __get_obj_by_discriminator(self, payload, obj_type): # type: (str, Union[T, str]) -> T """Get correct subclass instance using the discriminator in payload. :param payload: Payload for deserialization :type payload: str :param obj_type: parent class for deserializing ...
python
def __get_obj_by_discriminator(self, payload, obj_type): # type: (str, Union[T, str]) -> T """Get correct subclass instance using the discriminator in payload. :param payload: Payload for deserialization :type payload: str :param obj_type: parent class for deserializing ...
[ "def", "__get_obj_by_discriminator", "(", "self", ",", "payload", ",", "obj_type", ")", ":", "# type: (str, Union[T, str]) -> T", "obj_cast", "=", "cast", "(", "Any", ",", "obj_type", ")", "namespaced_class_name", "=", "obj_cast", ".", "get_real_child_model", "(", "...
Get correct subclass instance using the discriminator in payload. :param payload: Payload for deserialization :type payload: str :param obj_type: parent class for deserializing payload into :type obj_type: Union[object, str] :return: Subclass of provided parent class, th...
[ "Get", "correct", "subclass", "instance", "using", "the", "discriminator", "in", "payload", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/serialize.py#L376-L397
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/attributes_manager.py
AttributesManager.persistent_attributes
def persistent_attributes(self): # type: () -> Dict[str, object] """Attributes stored at the Persistence level of the skill lifecycle. :return: persistent_attributes retrieved from persistence adapter :rtype: Dict[str, object] :raises: :py:class:`ask_sdk_core.exceptions.Attribut...
python
def persistent_attributes(self): # type: () -> Dict[str, object] """Attributes stored at the Persistence level of the skill lifecycle. :return: persistent_attributes retrieved from persistence adapter :rtype: Dict[str, object] :raises: :py:class:`ask_sdk_core.exceptions.Attribut...
[ "def", "persistent_attributes", "(", "self", ")", ":", "# type: () -> Dict[str, object]", "if", "not", "self", ".", "_persistence_adapter", ":", "raise", "AttributesManagerException", "(", "\"Cannot get PersistentAttributes without Persistence adapter\"", ")", "if", "not", "s...
Attributes stored at the Persistence level of the skill lifecycle. :return: persistent_attributes retrieved from persistence adapter :rtype: Dict[str, object] :raises: :py:class:`ask_sdk_core.exceptions.AttributesManagerException` if trying to get persistent attributes without persi...
[ "Attributes", "stored", "at", "the", "Persistence", "level", "of", "the", "skill", "lifecycle", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/attributes_manager.py#L165-L182
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/attributes_manager.py
AttributesManager.persistent_attributes
def persistent_attributes(self, persistent_attributes): # type: (Dict[str, object]) -> None """Overwrites and caches the persistent attributes value. Note that the persistent attributes will not be saved to persistence layer until the save_persistent_attributes method is called....
python
def persistent_attributes(self, persistent_attributes): # type: (Dict[str, object]) -> None """Overwrites and caches the persistent attributes value. Note that the persistent attributes will not be saved to persistence layer until the save_persistent_attributes method is called....
[ "def", "persistent_attributes", "(", "self", ",", "persistent_attributes", ")", ":", "# type: (Dict[str, object]) -> None", "if", "not", "self", ".", "_persistence_adapter", ":", "raise", "AttributesManagerException", "(", "\"Cannot set PersistentAttributes without persistence ad...
Overwrites and caches the persistent attributes value. Note that the persistent attributes will not be saved to persistence layer until the save_persistent_attributes method is called. :param persistent_attributes: attributes in persistence layer :type persistent_attributes: Di...
[ "Overwrites", "and", "caches", "the", "persistent", "attributes", "value", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/attributes_manager.py#L185-L202
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/attributes_manager.py
AttributesManager.save_persistent_attributes
def save_persistent_attributes(self): # type: () -> None """Save persistent attributes to the persistence layer if a persistence adapter is provided. :rtype: None :raises: :py:class:`ask_sdk_core.exceptions.AttributesManagerException` if trying to save persistence at...
python
def save_persistent_attributes(self): # type: () -> None """Save persistent attributes to the persistence layer if a persistence adapter is provided. :rtype: None :raises: :py:class:`ask_sdk_core.exceptions.AttributesManagerException` if trying to save persistence at...
[ "def", "save_persistent_attributes", "(", "self", ")", ":", "# type: () -> None", "if", "not", "self", ".", "_persistence_adapter", ":", "raise", "AttributesManagerException", "(", "\"Cannot save PersistentAttributes without \"", "\"persistence adapter!\"", ")", "if", "self",...
Save persistent attributes to the persistence layer if a persistence adapter is provided. :rtype: None :raises: :py:class:`ask_sdk_core.exceptions.AttributesManagerException` if trying to save persistence attributes without persistence adapter
[ "Save", "persistent", "attributes", "to", "the", "persistence", "layer", "if", "a", "persistence", "adapter", "is", "provided", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/attributes_manager.py#L204-L220
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-runtime/ask_sdk_runtime/utils.py
user_agent_info
def user_agent_info(sdk_version, custom_user_agent): # type: (str, str) -> str """Return the user agent info along with the SDK and Python Version information. :param sdk_version: Version of the SDK being used. :type sdk_version: str :param custom_user_agent: Custom User Agent string provided b...
python
def user_agent_info(sdk_version, custom_user_agent): # type: (str, str) -> str """Return the user agent info along with the SDK and Python Version information. :param sdk_version: Version of the SDK being used. :type sdk_version: str :param custom_user_agent: Custom User Agent string provided b...
[ "def", "user_agent_info", "(", "sdk_version", ",", "custom_user_agent", ")", ":", "# type: (str, str) -> str", "python_version", "=", "\".\"", ".", "join", "(", "str", "(", "x", ")", "for", "x", "in", "sys", ".", "version_info", "[", "0", ":", "3", "]", ")...
Return the user agent info along with the SDK and Python Version information. :param sdk_version: Version of the SDK being used. :type sdk_version: str :param custom_user_agent: Custom User Agent string provided by the developer. :type custom_user_agent: str :return: User Agent Info str...
[ "Return", "the", "user", "agent", "info", "along", "with", "the", "SDK", "and", "Python", "Version", "information", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-runtime/ask_sdk_runtime/utils.py#L20-L39
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-dynamodb-persistence-adapter/ask_sdk_dynamodb/adapter.py
DynamoDbAdapter.get_attributes
def get_attributes(self, request_envelope): # type: (RequestEnvelope) -> Dict[str, object] """Get attributes from table in Dynamodb resource. Retrieves the attributes from Dynamodb table. If the table doesn't exist, returns an empty dict if the ``create_table`` variable is set a...
python
def get_attributes(self, request_envelope): # type: (RequestEnvelope) -> Dict[str, object] """Get attributes from table in Dynamodb resource. Retrieves the attributes from Dynamodb table. If the table doesn't exist, returns an empty dict if the ``create_table`` variable is set a...
[ "def", "get_attributes", "(", "self", ",", "request_envelope", ")", ":", "# type: (RequestEnvelope) -> Dict[str, object]", "try", ":", "table", "=", "self", ".", "dynamodb", ".", "Table", "(", "self", ".", "table_name", ")", "partition_key_val", "=", "self", ".", ...
Get attributes from table in Dynamodb resource. Retrieves the attributes from Dynamodb table. If the table doesn't exist, returns an empty dict if the ``create_table`` variable is set as True, else it raises PersistenceException. Raises PersistenceException if `get_item` fails o...
[ "Get", "attributes", "from", "table", "in", "Dynamodb", "resource", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-dynamodb-persistence-adapter/ask_sdk_dynamodb/adapter.py#L104-L141
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-dynamodb-persistence-adapter/ask_sdk_dynamodb/adapter.py
DynamoDbAdapter.save_attributes
def save_attributes(self, request_envelope, attributes): # type: (RequestEnvelope, Dict[str, object]) -> None """Saves attributes to table in Dynamodb resource. Saves the attributes into Dynamodb table. Raises PersistenceException if table doesn't exist or ``put_item`` fails on ...
python
def save_attributes(self, request_envelope, attributes): # type: (RequestEnvelope, Dict[str, object]) -> None """Saves attributes to table in Dynamodb resource. Saves the attributes into Dynamodb table. Raises PersistenceException if table doesn't exist or ``put_item`` fails on ...
[ "def", "save_attributes", "(", "self", ",", "request_envelope", ",", "attributes", ")", ":", "# type: (RequestEnvelope, Dict[str, object]) -> None", "try", ":", "table", "=", "self", ".", "dynamodb", ".", "Table", "(", "self", ".", "table_name", ")", "partition_key_...
Saves attributes to table in Dynamodb resource. Saves the attributes into Dynamodb table. Raises PersistenceException if table doesn't exist or ``put_item`` fails on the table. :param request_envelope: Request Envelope passed during skill invocation :type request_en...
[ "Saves", "attributes", "to", "table", "in", "Dynamodb", "resource", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-dynamodb-persistence-adapter/ask_sdk_dynamodb/adapter.py#L143-L175
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-dynamodb-persistence-adapter/ask_sdk_dynamodb/adapter.py
DynamoDbAdapter.delete_attributes
def delete_attributes(self, request_envelope): # type: (RequestEnvelope) -> None """Deletes attributes from table in Dynamodb resource. Deletes the attributes from Dynamodb table. Raises PersistenceException if table doesn't exist or ``delete_item`` fails on the table. ...
python
def delete_attributes(self, request_envelope): # type: (RequestEnvelope) -> None """Deletes attributes from table in Dynamodb resource. Deletes the attributes from Dynamodb table. Raises PersistenceException if table doesn't exist or ``delete_item`` fails on the table. ...
[ "def", "delete_attributes", "(", "self", ",", "request_envelope", ")", ":", "# type: (RequestEnvelope) -> None", "try", ":", "table", "=", "self", ".", "dynamodb", ".", "Table", "(", "self", ".", "table_name", ")", "partition_key_val", "=", "self", ".", "partiti...
Deletes attributes from table in Dynamodb resource. Deletes the attributes from Dynamodb table. Raises PersistenceException if table doesn't exist or ``delete_item`` fails on the table. :param request_envelope: Request Envelope passed during skill invocation :type r...
[ "Deletes", "attributes", "from", "table", "in", "Dynamodb", "resource", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-dynamodb-persistence-adapter/ask_sdk_dynamodb/adapter.py#L177-L205
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-dynamodb-persistence-adapter/ask_sdk_dynamodb/adapter.py
DynamoDbAdapter.__create_table_if_not_exists
def __create_table_if_not_exists(self): # type: () -> None """Creates table in Dynamodb resource if it doesn't exist and create_table is set as True. :rtype: None :raises: PersistenceException: When `create_table` fails on dynamodb resource. """ if se...
python
def __create_table_if_not_exists(self): # type: () -> None """Creates table in Dynamodb resource if it doesn't exist and create_table is set as True. :rtype: None :raises: PersistenceException: When `create_table` fails on dynamodb resource. """ if se...
[ "def", "__create_table_if_not_exists", "(", "self", ")", ":", "# type: () -> None", "if", "self", ".", "create_table", ":", "try", ":", "self", ".", "dynamodb", ".", "create_table", "(", "TableName", "=", "self", ".", "table_name", ",", "KeySchema", "=", "[", ...
Creates table in Dynamodb resource if it doesn't exist and create_table is set as True. :rtype: None :raises: PersistenceException: When `create_table` fails on dynamodb resource.
[ "Creates", "table", "in", "Dynamodb", "resource", "if", "it", "doesn", "t", "exist", "and", "create_table", "is", "set", "as", "True", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-dynamodb-persistence-adapter/ask_sdk_dynamodb/adapter.py#L207-L244
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-runtime/ask_sdk_runtime/skill.py
RuntimeConfigurationBuilder.add_request_handler
def add_request_handler(self, request_handler): # type: (AbstractRequestHandler) -> None """Register input to the request handlers list. :param request_handler: Request Handler instance to be registered. :type request_handler: AbstractRequestHandler :return: None ...
python
def add_request_handler(self, request_handler): # type: (AbstractRequestHandler) -> None """Register input to the request handlers list. :param request_handler: Request Handler instance to be registered. :type request_handler: AbstractRequestHandler :return: None ...
[ "def", "add_request_handler", "(", "self", ",", "request_handler", ")", ":", "# type: (AbstractRequestHandler) -> None", "if", "request_handler", "is", "None", ":", "raise", "RuntimeConfigException", "(", "\"Valid Request Handler instance to be provided\"", ")", "if", "not", ...
Register input to the request handlers list. :param request_handler: Request Handler instance to be registered. :type request_handler: AbstractRequestHandler :return: None
[ "Register", "input", "to", "the", "request", "handlers", "list", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-runtime/ask_sdk_runtime/skill.py#L108-L126
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-runtime/ask_sdk_runtime/skill.py
RuntimeConfigurationBuilder.add_exception_handler
def add_exception_handler(self, exception_handler): # type: (AbstractExceptionHandler) -> None """Register input to the exception handlers list. :param exception_handler: Exception Handler instance to be registered. :type exception_handler: AbstractExceptionHandler :...
python
def add_exception_handler(self, exception_handler): # type: (AbstractExceptionHandler) -> None """Register input to the exception handlers list. :param exception_handler: Exception Handler instance to be registered. :type exception_handler: AbstractExceptionHandler :...
[ "def", "add_exception_handler", "(", "self", ",", "exception_handler", ")", ":", "# type: (AbstractExceptionHandler) -> None", "if", "exception_handler", "is", "None", ":", "raise", "RuntimeConfigException", "(", "\"Valid Exception Handler instance to be provided\"", ")", "if",...
Register input to the exception handlers list. :param exception_handler: Exception Handler instance to be registered. :type exception_handler: AbstractExceptionHandler :return: None
[ "Register", "input", "to", "the", "exception", "handlers", "list", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-runtime/ask_sdk_runtime/skill.py#L140-L157
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-runtime/ask_sdk_runtime/skill.py
RuntimeConfigurationBuilder.add_global_request_interceptor
def add_global_request_interceptor(self, request_interceptor): # type: (AbstractRequestInterceptor) -> None """Register input to the global request interceptors list. :param request_interceptor: Request Interceptor instance to be registered. :type request_interceptor: Abstra...
python
def add_global_request_interceptor(self, request_interceptor): # type: (AbstractRequestInterceptor) -> None """Register input to the global request interceptors list. :param request_interceptor: Request Interceptor instance to be registered. :type request_interceptor: Abstra...
[ "def", "add_global_request_interceptor", "(", "self", ",", "request_interceptor", ")", ":", "# type: (AbstractRequestInterceptor) -> None", "if", "request_interceptor", "is", "None", ":", "raise", "RuntimeConfigException", "(", "\"Valid Request Interceptor instance to be provided\"...
Register input to the global request interceptors list. :param request_interceptor: Request Interceptor instance to be registered. :type request_interceptor: AbstractRequestInterceptor :return: None
[ "Register", "input", "to", "the", "global", "request", "interceptors", "list", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-runtime/ask_sdk_runtime/skill.py#L159-L176
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-runtime/ask_sdk_runtime/skill.py
RuntimeConfigurationBuilder.add_global_response_interceptor
def add_global_response_interceptor(self, response_interceptor): # type: (AbstractResponseInterceptor) -> None """Register input to the global response interceptors list. :param response_interceptor: Response Interceptor instance to be registered. :type response_interceptor:...
python
def add_global_response_interceptor(self, response_interceptor): # type: (AbstractResponseInterceptor) -> None """Register input to the global response interceptors list. :param response_interceptor: Response Interceptor instance to be registered. :type response_interceptor:...
[ "def", "add_global_response_interceptor", "(", "self", ",", "response_interceptor", ")", ":", "# type: (AbstractResponseInterceptor) -> None", "if", "response_interceptor", "is", "None", ":", "raise", "RuntimeConfigException", "(", "\"Valid Response Interceptor instance to be provi...
Register input to the global response interceptors list. :param response_interceptor: Response Interceptor instance to be registered. :type response_interceptor: AbstractResponseInterceptor :return: None
[ "Register", "input", "to", "the", "global", "response", "interceptors", "list", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-runtime/ask_sdk_runtime/skill.py#L178-L195
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-runtime/ask_sdk_runtime/skill.py
RuntimeConfigurationBuilder.get_runtime_configuration
def get_runtime_configuration(self): # type: () -> RuntimeConfiguration """Build the runtime configuration object from the registered components. :return: Runtime Configuration Object :rtype: RuntimeConfiguration """ request_mapper = GenericRequestMapper( ...
python
def get_runtime_configuration(self): # type: () -> RuntimeConfiguration """Build the runtime configuration object from the registered components. :return: Runtime Configuration Object :rtype: RuntimeConfiguration """ request_mapper = GenericRequestMapper( ...
[ "def", "get_runtime_configuration", "(", "self", ")", ":", "# type: () -> RuntimeConfiguration", "request_mapper", "=", "GenericRequestMapper", "(", "request_handler_chains", "=", "self", ".", "request_handler_chains", ")", "exception_mapper", "=", "GenericExceptionMapper", "...
Build the runtime configuration object from the registered components. :return: Runtime Configuration Object :rtype: RuntimeConfiguration
[ "Build", "the", "runtime", "configuration", "object", "from", "the", "registered", "components", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-runtime/ask_sdk_runtime/skill.py#L197-L218
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-dynamodb-persistence-adapter/ask_sdk_dynamodb/partition_keygen.py
user_id_partition_keygen
def user_id_partition_keygen(request_envelope): # type: (RequestEnvelope) -> str """Retrieve user id from request envelope, to use as partition key. :param request_envelope: Request Envelope passed during skill invocation :type request_envelope: ask_sdk_model.RequestEnvelope :return: User I...
python
def user_id_partition_keygen(request_envelope): # type: (RequestEnvelope) -> str """Retrieve user id from request envelope, to use as partition key. :param request_envelope: Request Envelope passed during skill invocation :type request_envelope: ask_sdk_model.RequestEnvelope :return: User I...
[ "def", "user_id_partition_keygen", "(", "request_envelope", ")", ":", "# type: (RequestEnvelope) -> str", "try", ":", "user_id", "=", "request_envelope", ".", "context", ".", "system", ".", "user", ".", "user_id", "return", "user_id", "except", "AttributeError", ":", ...
Retrieve user id from request envelope, to use as partition key. :param request_envelope: Request Envelope passed during skill invocation :type request_envelope: ask_sdk_model.RequestEnvelope :return: User Id retrieved from request envelope :rtype: str :raises: :py:class:`ask_sdk_core.excep...
[ "Retrieve", "user", "id", "from", "request", "envelope", "to", "use", "as", "partition", "key", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-dynamodb-persistence-adapter/ask_sdk_dynamodb/partition_keygen.py#L26-L42
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-dynamodb-persistence-adapter/ask_sdk_dynamodb/partition_keygen.py
device_id_partition_keygen
def device_id_partition_keygen(request_envelope): # type: (RequestEnvelope) -> str """Retrieve device id from request envelope, to use as partition key. :param request_envelope: Request Envelope passed during skill invocation :type request_envelope: ask_sdk_model.RequestEnvelope :return: De...
python
def device_id_partition_keygen(request_envelope): # type: (RequestEnvelope) -> str """Retrieve device id from request envelope, to use as partition key. :param request_envelope: Request Envelope passed during skill invocation :type request_envelope: ask_sdk_model.RequestEnvelope :return: De...
[ "def", "device_id_partition_keygen", "(", "request_envelope", ")", ":", "# type: (RequestEnvelope) -> str", "try", ":", "device_id", "=", "request_envelope", ".", "context", ".", "system", ".", "device", ".", "device_id", "return", "device_id", "except", "AttributeError...
Retrieve device id from request envelope, to use as partition key. :param request_envelope: Request Envelope passed during skill invocation :type request_envelope: ask_sdk_model.RequestEnvelope :return: Device Id retrieved from request envelope :rtype: str :raises: :py:class:`ask_sdk_core.e...
[ "Retrieve", "device", "id", "from", "request", "envelope", "to", "use", "as", "partition", "key", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-dynamodb-persistence-adapter/ask_sdk_dynamodb/partition_keygen.py#L45-L61
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/utils/predicate.py
is_canfulfill_intent_name
def is_canfulfill_intent_name(name): # type: (str) -> Callable[[HandlerInput], bool] """A predicate function returning a boolean, when name matches the intent name in a CanFulfill Intent Request. The function can be applied on a :py:class:`ask_sdk_core.handler_input.HandlerInput`, to check if t...
python
def is_canfulfill_intent_name(name): # type: (str) -> Callable[[HandlerInput], bool] """A predicate function returning a boolean, when name matches the intent name in a CanFulfill Intent Request. The function can be applied on a :py:class:`ask_sdk_core.handler_input.HandlerInput`, to check if t...
[ "def", "is_canfulfill_intent_name", "(", "name", ")", ":", "# type: (str) -> Callable[[HandlerInput], bool]", "def", "can_handle_wrapper", "(", "handler_input", ")", ":", "# type: (HandlerInput) -> bool", "return", "(", "isinstance", "(", "handler_input", ".", "request_envelo...
A predicate function returning a boolean, when name matches the intent name in a CanFulfill Intent Request. The function can be applied on a :py:class:`ask_sdk_core.handler_input.HandlerInput`, to check if the input is of :py:class:`ask_sdk_model.intent_request.CanFulfillIntentRequest` type and if ...
[ "A", "predicate", "function", "returning", "a", "boolean", "when", "name", "matches", "the", "intent", "name", "in", "a", "CanFulfill", "Intent", "Request", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/utils/predicate.py#L28-L50
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/utils/predicate.py
is_intent_name
def is_intent_name(name): # type: (str) -> Callable[[HandlerInput], bool] """A predicate function returning a boolean, when name matches the name in Intent Request. The function can be applied on a :py:class:`ask_sdk_core.handler_input.HandlerInput`, to check if the input is of :py:class:`a...
python
def is_intent_name(name): # type: (str) -> Callable[[HandlerInput], bool] """A predicate function returning a boolean, when name matches the name in Intent Request. The function can be applied on a :py:class:`ask_sdk_core.handler_input.HandlerInput`, to check if the input is of :py:class:`a...
[ "def", "is_intent_name", "(", "name", ")", ":", "# type: (str) -> Callable[[HandlerInput], bool]", "def", "can_handle_wrapper", "(", "handler_input", ")", ":", "# type: (HandlerInput) -> bool", "return", "(", "isinstance", "(", "handler_input", ".", "request_envelope", ".",...
A predicate function returning a boolean, when name matches the name in Intent Request. The function can be applied on a :py:class:`ask_sdk_core.handler_input.HandlerInput`, to check if the input is of :py:class:`ask_sdk_model.intent_request.IntentRequest` type and if the name of the request ma...
[ "A", "predicate", "function", "returning", "a", "boolean", "when", "name", "matches", "the", "name", "in", "Intent", "Request", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/utils/predicate.py#L53-L75
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/utils/predicate.py
is_request_type
def is_request_type(request_type): # type: (str) -> Callable[[HandlerInput], bool] """A predicate function returning a boolean, when request type is the passed-in type. The function can be applied on a :py:class:`ask_sdk_core.handler_input.HandlerInput`, to check if the input request type is th...
python
def is_request_type(request_type): # type: (str) -> Callable[[HandlerInput], bool] """A predicate function returning a boolean, when request type is the passed-in type. The function can be applied on a :py:class:`ask_sdk_core.handler_input.HandlerInput`, to check if the input request type is th...
[ "def", "is_request_type", "(", "request_type", ")", ":", "# type: (str) -> Callable[[HandlerInput], bool]", "def", "can_handle_wrapper", "(", "handler_input", ")", ":", "# type: (HandlerInput) -> bool", "return", "(", "handler_input", ".", "request_envelope", ".", "request", ...
A predicate function returning a boolean, when request type is the passed-in type. The function can be applied on a :py:class:`ask_sdk_core.handler_input.HandlerInput`, to check if the input request type is the passed in request type. :param request_type: request type to be matched with the input'...
[ "A", "predicate", "function", "returning", "a", "boolean", "when", "request", "type", "is", "the", "passed", "-", "in", "type", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/utils/predicate.py#L78-L97
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/api_client.py
DefaultApiClient.invoke
def invoke(self, request): # type: (ApiClientRequest) -> ApiClientResponse """Dispatches a request to an API endpoint described in the request. Resolves the method from input request object, converts the list of header tuples to the required format (dict) for the `reques...
python
def invoke(self, request): # type: (ApiClientRequest) -> ApiClientResponse """Dispatches a request to an API endpoint described in the request. Resolves the method from input request object, converts the list of header tuples to the required format (dict) for the `reques...
[ "def", "invoke", "(", "self", ",", "request", ")", ":", "# type: (ApiClientRequest) -> ApiClientResponse", "try", ":", "http_method", "=", "self", ".", "_resolve_method", "(", "request", ")", "http_headers", "=", "self", ".", "_convert_list_tuples_to_dict", "(", "he...
Dispatches a request to an API endpoint described in the request. Resolves the method from input request object, converts the list of header tuples to the required format (dict) for the `requests` lib call and invokes the method with corresponding parameters on `requests` librar...
[ "Dispatches", "a", "request", "to", "an", "API", "endpoint", "described", "in", "the", "request", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/api_client.py#L40-L89
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/api_client.py
DefaultApiClient._resolve_method
def _resolve_method(self, request): # type: (ApiClientRequest) -> Callable """Resolve the method from request object to `requests` http call. :param request: Request to dispatch to the ApiClient :type request: ApiClientRequest :return: The HTTP method that maps to the re...
python
def _resolve_method(self, request): # type: (ApiClientRequest) -> Callable """Resolve the method from request object to `requests` http call. :param request: Request to dispatch to the ApiClient :type request: ApiClientRequest :return: The HTTP method that maps to the re...
[ "def", "_resolve_method", "(", "self", ",", "request", ")", ":", "# type: (ApiClientRequest) -> Callable", "try", ":", "return", "getattr", "(", "requests", ",", "request", ".", "method", ".", "lower", "(", ")", ")", "except", "AttributeError", ":", "raise", "...
Resolve the method from request object to `requests` http call. :param request: Request to dispatch to the ApiClient :type request: ApiClientRequest :return: The HTTP method that maps to the request call. :rtype: Callable :raises :py:class:`ask_sdk_core.exceptions.ApiCli...
[ "Resolve", "the", "method", "from", "request", "object", "to", "requests", "http", "call", "." ]
097b6406aa12d5ca0b825b00c936861b530cbf39
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/api_client.py#L91-L107
train