id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
220,500 | 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 |
220,501 | 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 |
220,502 | 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 |
220,503 | 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 |
220,504 | 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 |
220,505 | 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 |
220,506 | 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 |
220,507 | 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 |
220,508 | 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 |
220,509 | 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 |
220,510 | 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 |
220,511 | 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 |
220,512 | 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 |
220,513 | 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 |
220,514 | 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 |
220,515 | 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 |
220,516 | 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 |
220,517 | 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 |
220,518 | 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 |
220,519 | 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 |
220,520 | 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 |
220,521 | 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 |
220,522 | 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 |
220,523 | 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 |
220,524 | 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 |
220,525 | 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 |
220,526 | 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 |
220,527 | 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 |
220,528 | 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 |
220,529 | 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 |
220,530 | 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 |
220,531 | 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 |
220,532 | 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 |
220,533 | 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 |
220,534 | 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 |
220,535 | 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 |
220,536 | 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 |
220,537 | 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 |
220,538 | 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 |
220,539 | 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 |
220,540 | 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 |
220,541 | 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 |
220,542 | 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 |
220,543 | 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 |
220,544 | 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 |
220,545 | 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 |
220,546 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-core/ask_sdk_core/api_client.py | DefaultApiClient._convert_list_tuples_to_dict | def _convert_list_tuples_to_dict(self, headers_list):
# type: (List[Tuple[str, str]]) -> Dict[str, str]
"""Convert list of tuples from headers of request object to
dictionary format.
:param headers_list: List of tuples made up of two element
strings from `ApiClientRequest` h... | python | def _convert_list_tuples_to_dict(self, headers_list):
# type: (List[Tuple[str, str]]) -> Dict[str, str]
"""Convert list of tuples from headers of request object to
dictionary format.
:param headers_list: List of tuples made up of two element
strings from `ApiClientRequest` h... | [
"def",
"_convert_list_tuples_to_dict",
"(",
"self",
",",
"headers_list",
")",
":",
"# type: (List[Tuple[str, str]]) -> Dict[str, str]",
"headers_dict",
"=",
"{",
"}",
"# type: Dict",
"if",
"headers_list",
"is",
"not",
"None",
":",
"for",
"header_tuple",
"in",
"headers_l... | Convert list of tuples from headers of request object to
dictionary format.
:param headers_list: List of tuples made up of two element
strings from `ApiClientRequest` headers variable
:type headers_list: List[Tuple[str, str]]
:return: Dictionary of headers in keys as strings... | [
"Convert",
"list",
"of",
"tuples",
"from",
"headers",
"of",
"request",
"object",
"to",
"dictionary",
"format",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/api_client.py#L109-L130 |
220,547 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-core/ask_sdk_core/api_client.py | DefaultApiClient._convert_dict_to_list_tuples | def _convert_dict_to_list_tuples(self, headers_dict):
# type: (Dict[str, str]) -> List[Tuple[str, str]]
"""Convert headers dict to list of string tuples format for
`ApiClientResponse` headers variable.
:param headers_dict: Dictionary of headers in keys as strings
and values ... | python | def _convert_dict_to_list_tuples(self, headers_dict):
# type: (Dict[str, str]) -> List[Tuple[str, str]]
"""Convert headers dict to list of string tuples format for
`ApiClientResponse` headers variable.
:param headers_dict: Dictionary of headers in keys as strings
and values ... | [
"def",
"_convert_dict_to_list_tuples",
"(",
"self",
",",
"headers_dict",
")",
":",
"# type: (Dict[str, str]) -> List[Tuple[str, str]]",
"headers_list",
"=",
"[",
"]",
"if",
"headers_dict",
"is",
"not",
"None",
":",
"for",
"key",
",",
"values",
"in",
"six",
".",
"i... | Convert headers dict to list of string tuples format for
`ApiClientResponse` headers variable.
:param headers_dict: Dictionary of headers in keys as strings
and values as comma separated strings
:type headers_dict: Dict[str, str]
:return: List of tuples made up of two elemen... | [
"Convert",
"headers",
"dict",
"to",
"list",
"of",
"string",
"tuples",
"format",
"for",
"ApiClientResponse",
"headers",
"variable",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/api_client.py#L132-L151 |
220,548 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-runtime/ask_sdk_runtime/dispatch_components/request_components.py | GenericRequestMapper.add_request_handler_chain | def add_request_handler_chain(self, request_handler_chain):
# type: (GenericRequestHandlerChain) -> None
"""Checks the type before adding it to the
request_handler_chains instance variable.
:param request_handler_chain: Request Handler Chain instance.
:type request_handler_chai... | python | def add_request_handler_chain(self, request_handler_chain):
# type: (GenericRequestHandlerChain) -> None
"""Checks the type before adding it to the
request_handler_chains instance variable.
:param request_handler_chain: Request Handler Chain instance.
:type request_handler_chai... | [
"def",
"add_request_handler_chain",
"(",
"self",
",",
"request_handler_chain",
")",
":",
"# type: (GenericRequestHandlerChain) -> None",
"if",
"request_handler_chain",
"is",
"None",
"or",
"not",
"isinstance",
"(",
"request_handler_chain",
",",
"GenericRequestHandlerChain",
")... | Checks the type before adding it to the
request_handler_chains instance variable.
:param request_handler_chain: Request Handler Chain instance.
:type request_handler_chain: RequestHandlerChain
:raises: :py:class:`ask_sdk_runtime.exceptions.DispatchException`
if a null input... | [
"Checks",
"the",
"type",
"before",
"adding",
"it",
"to",
"the",
"request_handler_chains",
"instance",
"variable",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-runtime/ask_sdk_runtime/dispatch_components/request_components.py#L331-L346 |
220,549 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-runtime/ask_sdk_runtime/dispatch_components/request_components.py | GenericRequestMapper.get_request_handler_chain | def get_request_handler_chain(self, handler_input):
# type: (Input) -> Union[GenericRequestHandlerChain, None]
"""Get the request handler chain that can handle the dispatch
input.
:param handler_input: Generic input passed to the
dispatcher.
:type handler_input: Inpu... | python | def get_request_handler_chain(self, handler_input):
# type: (Input) -> Union[GenericRequestHandlerChain, None]
"""Get the request handler chain that can handle the dispatch
input.
:param handler_input: Generic input passed to the
dispatcher.
:type handler_input: Inpu... | [
"def",
"get_request_handler_chain",
"(",
"self",
",",
"handler_input",
")",
":",
"# type: (Input) -> Union[GenericRequestHandlerChain, None]",
"for",
"chain",
"in",
"self",
".",
"request_handler_chains",
":",
"handler",
"=",
"chain",
".",
"request_handler",
"# type: Abstrac... | Get the request handler chain that can handle the dispatch
input.
:param handler_input: Generic input passed to the
dispatcher.
:type handler_input: Input
:return: Handler Chain that can handle the input.
:rtype: Union[None, GenericRequestHandlerChain] | [
"Get",
"the",
"request",
"handler",
"chain",
"that",
"can",
"handle",
"the",
"dispatch",
"input",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-runtime/ask_sdk_runtime/dispatch_components/request_components.py#L348-L363 |
220,550 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-runtime/ask_sdk_runtime/dispatch_components/exception_components.py | GenericExceptionMapper.add_exception_handler | def add_exception_handler(self, exception_handler):
# type: (AbstractExceptionHandler) -> None
"""Checks the type before adding it to the exception_handlers
instance variable.
:param exception_handler: Exception Handler instance.
:type exception_handler: ask_sdk_runtime.dispatch... | python | def add_exception_handler(self, exception_handler):
# type: (AbstractExceptionHandler) -> None
"""Checks the type before adding it to the exception_handlers
instance variable.
:param exception_handler: Exception Handler instance.
:type exception_handler: ask_sdk_runtime.dispatch... | [
"def",
"add_exception_handler",
"(",
"self",
",",
"exception_handler",
")",
":",
"# type: (AbstractExceptionHandler) -> None",
"if",
"exception_handler",
"is",
"None",
"or",
"not",
"isinstance",
"(",
"exception_handler",
",",
"AbstractExceptionHandler",
")",
":",
"raise",... | Checks the type before adding it to the exception_handlers
instance variable.
:param exception_handler: Exception Handler instance.
:type exception_handler: ask_sdk_runtime.dispatch_components.exception_components.AbstractExceptionHandler
:raises: :py:class:`ask_sdk_runtime.exceptions.D... | [
"Checks",
"the",
"type",
"before",
"adding",
"it",
"to",
"the",
"exception_handlers",
"instance",
"variable",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-runtime/ask_sdk_runtime/dispatch_components/exception_components.py#L165-L179 |
220,551 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-runtime/ask_sdk_runtime/dispatch_components/exception_components.py | GenericExceptionMapper.get_handler | def get_handler(self, handler_input, exception):
# type: (Input, Exception) -> Union[AbstractExceptionHandler, None]
"""Get the exception handler that can handle the input and
exception.
:param handler_input: Generic input passed to the
dispatcher.
:type handler_inpu... | python | def get_handler(self, handler_input, exception):
# type: (Input, Exception) -> Union[AbstractExceptionHandler, None]
"""Get the exception handler that can handle the input and
exception.
:param handler_input: Generic input passed to the
dispatcher.
:type handler_inpu... | [
"def",
"get_handler",
"(",
"self",
",",
"handler_input",
",",
"exception",
")",
":",
"# type: (Input, Exception) -> Union[AbstractExceptionHandler, None]",
"for",
"handler",
"in",
"self",
".",
"exception_handlers",
":",
"if",
"handler",
".",
"can_handle",
"(",
"handler_... | Get the exception handler that can handle the input and
exception.
:param handler_input: Generic input passed to the
dispatcher.
:type handler_input: Input
:param exception: Exception thrown by
:py:class:`ask_sdk_runtime.dispatch.GenericRequestDispatcher`
... | [
"Get",
"the",
"exception",
"handler",
"that",
"can",
"handle",
"the",
"input",
"and",
"exception",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-runtime/ask_sdk_runtime/dispatch_components/exception_components.py#L181-L200 |
220,552 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-webservice-support/ask_sdk_webservice_support/verifier.py | RequestVerifier.verify | def verify(
self, headers, serialized_request_env, deserialized_request_env):
# type: (Dict[str, Any], str, RequestEnvelope) -> None
"""Verify if the input request signature and the body matches.
The verify method retrieves the Signature Certificate Chain URL,
validates the ... | python | def verify(
self, headers, serialized_request_env, deserialized_request_env):
# type: (Dict[str, Any], str, RequestEnvelope) -> None
"""Verify if the input request signature and the body matches.
The verify method retrieves the Signature Certificate Chain URL,
validates the ... | [
"def",
"verify",
"(",
"self",
",",
"headers",
",",
"serialized_request_env",
",",
"deserialized_request_env",
")",
":",
"# type: (Dict[str, Any], str, RequestEnvelope) -> None",
"cert_url",
"=",
"headers",
".",
"get",
"(",
"self",
".",
"_signature_cert_chain_url_key",
")"... | Verify if the input request signature and the body matches.
The verify method retrieves the Signature Certificate Chain URL,
validates the URL, retrieves the chain from the URL, validates
the signing certificate, extract the public key, base64 decode
the Signature and verifies if the ha... | [
"Verify",
"if",
"the",
"input",
"request",
"signature",
"and",
"the",
"body",
"matches",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-webservice-support/ask_sdk_webservice_support/verifier.py#L165-L198 |
220,553 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-webservice-support/ask_sdk_webservice_support/verifier.py | RequestVerifier._retrieve_and_validate_certificate_chain | def _retrieve_and_validate_certificate_chain(self, cert_url):
# type: (str) -> Certificate
"""Retrieve and validate certificate chain.
This method validates if the URL is valid and loads and
validates the certificate chain, before returning it.
:param cert_url: URL for retrievi... | python | def _retrieve_and_validate_certificate_chain(self, cert_url):
# type: (str) -> Certificate
"""Retrieve and validate certificate chain.
This method validates if the URL is valid and loads and
validates the certificate chain, before returning it.
:param cert_url: URL for retrievi... | [
"def",
"_retrieve_and_validate_certificate_chain",
"(",
"self",
",",
"cert_url",
")",
":",
"# type: (str) -> Certificate",
"self",
".",
"_validate_certificate_url",
"(",
"cert_url",
")",
"cert_chain",
"=",
"self",
".",
"_load_cert_chain",
"(",
"cert_url",
")",
"self",
... | Retrieve and validate certificate chain.
This method validates if the URL is valid and loads and
validates the certificate chain, before returning it.
:param cert_url: URL for retrieving certificate chain
:type cert_url: str
:return The certificate chain loaded from the URL
... | [
"Retrieve",
"and",
"validate",
"certificate",
"chain",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-webservice-support/ask_sdk_webservice_support/verifier.py#L200-L218 |
220,554 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-webservice-support/ask_sdk_webservice_support/verifier.py | RequestVerifier._validate_certificate_url | def _validate_certificate_url(self, cert_url):
# type: (str) -> None
"""Validate the URL containing the certificate chain.
This method validates if the URL provided adheres to the format
mentioned here :
https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-a-we... | python | def _validate_certificate_url(self, cert_url):
# type: (str) -> None
"""Validate the URL containing the certificate chain.
This method validates if the URL provided adheres to the format
mentioned here :
https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-a-we... | [
"def",
"_validate_certificate_url",
"(",
"self",
",",
"cert_url",
")",
":",
"# type: (str) -> None",
"parsed_url",
"=",
"urlparse",
"(",
"cert_url",
")",
"protocol",
"=",
"parsed_url",
".",
"scheme",
"if",
"protocol",
".",
"lower",
"(",
")",
"!=",
"CERT_CHAIN_UR... | Validate the URL containing the certificate chain.
This method validates if the URL provided adheres to the format
mentioned here :
https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-a-web-service.html#cert-verify-signature-certificate-url
:param cert_url: URL for r... | [
"Validate",
"the",
"URL",
"containing",
"the",
"certificate",
"chain",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-webservice-support/ask_sdk_webservice_support/verifier.py#L220-L258 |
220,555 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-webservice-support/ask_sdk_webservice_support/verifier.py | RequestVerifier._load_cert_chain | def _load_cert_chain(self, cert_url, x509_backend=default_backend()):
# type: (str, X509Backend) -> Certificate
"""Loads the certificate chain from the URL.
This method loads the certificate chain from the certificate
cache. If there is a cache miss, the certificate chain is
loa... | python | def _load_cert_chain(self, cert_url, x509_backend=default_backend()):
# type: (str, X509Backend) -> Certificate
"""Loads the certificate chain from the URL.
This method loads the certificate chain from the certificate
cache. If there is a cache miss, the certificate chain is
loa... | [
"def",
"_load_cert_chain",
"(",
"self",
",",
"cert_url",
",",
"x509_backend",
"=",
"default_backend",
"(",
")",
")",
":",
"# type: (str, X509Backend) -> Certificate",
"try",
":",
"if",
"cert_url",
"in",
"self",
".",
"_cert_cache",
":",
"return",
"self",
".",
"_c... | Loads the certificate chain from the URL.
This method loads the certificate chain from the certificate
cache. If there is a cache miss, the certificate chain is
loaded from the certificate URL using the
:py:func:`cryptography.x509.load_pem_x509_certificate` method.
The x509 back... | [
"Loads",
"the",
"certificate",
"chain",
"from",
"the",
"URL",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-webservice-support/ask_sdk_webservice_support/verifier.py#L260-L296 |
220,556 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-webservice-support/ask_sdk_webservice_support/verifier.py | RequestVerifier._validate_cert_chain | def _validate_cert_chain(self, cert_chain):
# type: (Certificate) -> None
"""Validate the certificate chain.
This method checks if the passed in certificate chain is valid,
i.e it is not expired and the Alexa domain is present in the
SAN extensions of the certificate chain. A
... | python | def _validate_cert_chain(self, cert_chain):
# type: (Certificate) -> None
"""Validate the certificate chain.
This method checks if the passed in certificate chain is valid,
i.e it is not expired and the Alexa domain is present in the
SAN extensions of the certificate chain. A
... | [
"def",
"_validate_cert_chain",
"(",
"self",
",",
"cert_chain",
")",
":",
"# type: (Certificate) -> None",
"now",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"if",
"not",
"(",
"cert_chain",
".",
"not_valid_before",
"<=",
"now",
"<=",
"cert_chain",
".",
"not_valid_a... | Validate the certificate chain.
This method checks if the passed in certificate chain is valid,
i.e it is not expired and the Alexa domain is present in the
SAN extensions of the certificate chain. A
:py:class:`VerificationException` is raised if the certificate
chain is not val... | [
"Validate",
"the",
"certificate",
"chain",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-webservice-support/ask_sdk_webservice_support/verifier.py#L298-L325 |
220,557 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-webservice-support/ask_sdk_webservice_support/verifier.py | RequestVerifier._valid_request_body | def _valid_request_body(
self, cert_chain, signature, serialized_request_env):
# type: (Certificate, str, str) -> None
"""Validate the request body hash with signature.
This method checks if the hash value of the request body
matches with the hash value of the signature, dec... | python | def _valid_request_body(
self, cert_chain, signature, serialized_request_env):
# type: (Certificate, str, str) -> None
"""Validate the request body hash with signature.
This method checks if the hash value of the request body
matches with the hash value of the signature, dec... | [
"def",
"_valid_request_body",
"(",
"self",
",",
"cert_chain",
",",
"signature",
",",
"serialized_request_env",
")",
":",
"# type: (Certificate, str, str) -> None",
"decoded_signature",
"=",
"base64",
".",
"b64decode",
"(",
"signature",
")",
"public_key",
"=",
"cert_chai... | Validate the request body hash with signature.
This method checks if the hash value of the request body
matches with the hash value of the signature, decrypted using
certificate chain. A
:py:class:`VerificationException` is raised if there is a
mismatch.
:param cert_cha... | [
"Validate",
"the",
"request",
"body",
"hash",
"with",
"signature",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-webservice-support/ask_sdk_webservice_support/verifier.py#L327-L356 |
220,558 | alexa/alexa-skills-kit-sdk-for-python | ask-sdk-webservice-support/ask_sdk_webservice_support/verifier.py | TimestampVerifier.verify | def verify(
self, headers, serialized_request_env, deserialized_request_env):
# type: (Dict[str, Any], str, RequestEnvelope) -> None
"""Verify if the input request timestamp is in tolerated limits.
The verify method retrieves the request timestamp and check if
it falls in th... | python | def verify(
self, headers, serialized_request_env, deserialized_request_env):
# type: (Dict[str, Any], str, RequestEnvelope) -> None
"""Verify if the input request timestamp is in tolerated limits.
The verify method retrieves the request timestamp and check if
it falls in th... | [
"def",
"verify",
"(",
"self",
",",
"headers",
",",
"serialized_request_env",
",",
"deserialized_request_env",
")",
":",
"# type: (Dict[str, Any], str, RequestEnvelope) -> None",
"local_now",
"=",
"datetime",
".",
"now",
"(",
"tz",
".",
"tzutc",
"(",
")",
")",
"reque... | Verify if the input request timestamp is in tolerated limits.
The verify method retrieves the request timestamp and check if
it falls in the limit set by the tolerance, by checking with
the current timestamp in UTC.
:param headers: headers of the input POST request
:type header... | [
"Verify",
"if",
"the",
"input",
"request",
"timestamp",
"is",
"in",
"tolerated",
"limits",
"."
] | 097b6406aa12d5ca0b825b00c936861b530cbf39 | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-webservice-support/ask_sdk_webservice_support/verifier.py#L411-L437 |
220,559 | mozilla/moz-sql-parser | moz_sql_parser/formatting.py | escape | def escape(identifier, ansi_quotes, should_quote):
"""
Escape identifiers.
ANSI uses single quotes, but many databases use back quotes.
"""
if not should_quote(identifier):
return identifier
quote = '"' if ansi_quotes else '`'
identifier = identifier.replace(quote, 2*quote)
re... | python | def escape(identifier, ansi_quotes, should_quote):
"""
Escape identifiers.
ANSI uses single quotes, but many databases use back quotes.
"""
if not should_quote(identifier):
return identifier
quote = '"' if ansi_quotes else '`'
identifier = identifier.replace(quote, 2*quote)
re... | [
"def",
"escape",
"(",
"identifier",
",",
"ansi_quotes",
",",
"should_quote",
")",
":",
"if",
"not",
"should_quote",
"(",
"identifier",
")",
":",
"return",
"identifier",
"quote",
"=",
"'\"'",
"if",
"ansi_quotes",
"else",
"'`'",
"identifier",
"=",
"identifier",
... | Escape identifiers.
ANSI uses single quotes, but many databases use back quotes. | [
"Escape",
"identifiers",
"."
] | 35fcc69b8f73b48e1fd48025cae1e174d57c3921 | https://github.com/mozilla/moz-sql-parser/blob/35fcc69b8f73b48e1fd48025cae1e174d57c3921/moz_sql_parser/formatting.py#L39-L51 |
220,560 | mlouielu/twstock | twstock/analytics.py | Analytics.ma_bias_ratio | def ma_bias_ratio(self, day1, day2):
"""Calculate moving average bias ratio"""
data1 = self.moving_average(self.price, day1)
data2 = self.moving_average(self.price, day2)
result = [data1[-i] - data2[-i] for i in range(1, min(len(data1), len(data2)) + 1)]
return result[::-1] | python | def ma_bias_ratio(self, day1, day2):
"""Calculate moving average bias ratio"""
data1 = self.moving_average(self.price, day1)
data2 = self.moving_average(self.price, day2)
result = [data1[-i] - data2[-i] for i in range(1, min(len(data1), len(data2)) + 1)]
return result[::-1] | [
"def",
"ma_bias_ratio",
"(",
"self",
",",
"day1",
",",
"day2",
")",
":",
"data1",
"=",
"self",
".",
"moving_average",
"(",
"self",
".",
"price",
",",
"day1",
")",
"data2",
"=",
"self",
".",
"moving_average",
"(",
"self",
".",
"price",
",",
"day2",
")... | Calculate moving average bias ratio | [
"Calculate",
"moving",
"average",
"bias",
"ratio"
] | cddddcc084d2d00497d591ab3059e3205b755825 | https://github.com/mlouielu/twstock/blob/cddddcc084d2d00497d591ab3059e3205b755825/twstock/analytics.py#L24-L30 |
220,561 | mlouielu/twstock | twstock/analytics.py | Analytics.ma_bias_ratio_pivot | def ma_bias_ratio_pivot(self, data, sample_size=5, position=False):
"""Calculate pivot point"""
sample = data[-sample_size:]
if position is True:
check_value = max(sample)
pre_check_value = max(sample) > 0
elif position is False:
check_value = min(sam... | python | def ma_bias_ratio_pivot(self, data, sample_size=5, position=False):
"""Calculate pivot point"""
sample = data[-sample_size:]
if position is True:
check_value = max(sample)
pre_check_value = max(sample) > 0
elif position is False:
check_value = min(sam... | [
"def",
"ma_bias_ratio_pivot",
"(",
"self",
",",
"data",
",",
"sample_size",
"=",
"5",
",",
"position",
"=",
"False",
")",
":",
"sample",
"=",
"data",
"[",
"-",
"sample_size",
":",
"]",
"if",
"position",
"is",
"True",
":",
"check_value",
"=",
"max",
"("... | Calculate pivot point | [
"Calculate",
"pivot",
"point"
] | cddddcc084d2d00497d591ab3059e3205b755825 | https://github.com/mlouielu/twstock/blob/cddddcc084d2d00497d591ab3059e3205b755825/twstock/analytics.py#L32-L46 |
220,562 | mlouielu/twstock | twstock/stock.py | Stock.fetch | def fetch(self, year: int, month: int):
"""Fetch year month data"""
self.raw_data = [self.fetcher.fetch(year, month, self.sid)]
self.data = self.raw_data[0]['data']
return self.data | python | def fetch(self, year: int, month: int):
"""Fetch year month data"""
self.raw_data = [self.fetcher.fetch(year, month, self.sid)]
self.data = self.raw_data[0]['data']
return self.data | [
"def",
"fetch",
"(",
"self",
",",
"year",
":",
"int",
",",
"month",
":",
"int",
")",
":",
"self",
".",
"raw_data",
"=",
"[",
"self",
".",
"fetcher",
".",
"fetch",
"(",
"year",
",",
"month",
",",
"self",
".",
"sid",
")",
"]",
"self",
".",
"data"... | Fetch year month data | [
"Fetch",
"year",
"month",
"data"
] | cddddcc084d2d00497d591ab3059e3205b755825 | https://github.com/mlouielu/twstock/blob/cddddcc084d2d00497d591ab3059e3205b755825/twstock/stock.py#L151-L155 |
220,563 | mlouielu/twstock | twstock/stock.py | Stock.fetch_from | def fetch_from(self, year: int, month: int):
"""Fetch data from year, month to current year month data"""
self.raw_data = []
self.data = []
today = datetime.datetime.today()
for year, month in self._month_year_iter(month, year, today.month, today.year):
self.raw_data.... | python | def fetch_from(self, year: int, month: int):
"""Fetch data from year, month to current year month data"""
self.raw_data = []
self.data = []
today = datetime.datetime.today()
for year, month in self._month_year_iter(month, year, today.month, today.year):
self.raw_data.... | [
"def",
"fetch_from",
"(",
"self",
",",
"year",
":",
"int",
",",
"month",
":",
"int",
")",
":",
"self",
".",
"raw_data",
"=",
"[",
"]",
"self",
".",
"data",
"=",
"[",
"]",
"today",
"=",
"datetime",
".",
"datetime",
".",
"today",
"(",
")",
"for",
... | Fetch data from year, month to current year month data | [
"Fetch",
"data",
"from",
"year",
"month",
"to",
"current",
"year",
"month",
"data"
] | cddddcc084d2d00497d591ab3059e3205b755825 | https://github.com/mlouielu/twstock/blob/cddddcc084d2d00497d591ab3059e3205b755825/twstock/stock.py#L157-L165 |
220,564 | mlouielu/twstock | twstock/stock.py | Stock.fetch_31 | def fetch_31(self):
"""Fetch 31 days data"""
today = datetime.datetime.today()
before = today - datetime.timedelta(days=60)
self.fetch_from(before.year, before.month)
self.data = self.data[-31:]
return self.data | python | def fetch_31(self):
"""Fetch 31 days data"""
today = datetime.datetime.today()
before = today - datetime.timedelta(days=60)
self.fetch_from(before.year, before.month)
self.data = self.data[-31:]
return self.data | [
"def",
"fetch_31",
"(",
"self",
")",
":",
"today",
"=",
"datetime",
".",
"datetime",
".",
"today",
"(",
")",
"before",
"=",
"today",
"-",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"60",
")",
"self",
".",
"fetch_from",
"(",
"before",
".",
"year"... | Fetch 31 days data | [
"Fetch",
"31",
"days",
"data"
] | cddddcc084d2d00497d591ab3059e3205b755825 | https://github.com/mlouielu/twstock/blob/cddddcc084d2d00497d591ab3059e3205b755825/twstock/stock.py#L167-L173 |
220,565 | hellock/icrawler | icrawler/utils/proxy_pool.py | Proxy.to_dict | def to_dict(self):
"""convert detailed proxy info into a dict
Returns:
dict: A dict with four keys: ``addr``, ``protocol``,
``weight`` and ``last_checked``
"""
return dict(
addr=self.addr,
protocol=self.protocol,
weight=s... | python | def to_dict(self):
"""convert detailed proxy info into a dict
Returns:
dict: A dict with four keys: ``addr``, ``protocol``,
``weight`` and ``last_checked``
"""
return dict(
addr=self.addr,
protocol=self.protocol,
weight=s... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"addr",
"=",
"self",
".",
"addr",
",",
"protocol",
"=",
"self",
".",
"protocol",
",",
"weight",
"=",
"self",
".",
"weight",
",",
"last_checked",
"=",
"self",
".",
"last_checked",
")"
] | convert detailed proxy info into a dict
Returns:
dict: A dict with four keys: ``addr``, ``protocol``,
``weight`` and ``last_checked`` | [
"convert",
"detailed",
"proxy",
"info",
"into",
"a",
"dict"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/proxy_pool.py#L47-L58 |
220,566 | hellock/icrawler | icrawler/utils/proxy_pool.py | ProxyPool.proxy_num | def proxy_num(self, protocol=None):
"""Get the number of proxies in the pool
Args:
protocol (str, optional): 'http' or 'https' or None. (default None)
Returns:
If protocol is None, return the total number of proxies, otherwise,
return the number of proxies o... | python | def proxy_num(self, protocol=None):
"""Get the number of proxies in the pool
Args:
protocol (str, optional): 'http' or 'https' or None. (default None)
Returns:
If protocol is None, return the total number of proxies, otherwise,
return the number of proxies o... | [
"def",
"proxy_num",
"(",
"self",
",",
"protocol",
"=",
"None",
")",
":",
"http_num",
"=",
"len",
"(",
"self",
".",
"proxies",
"[",
"'http'",
"]",
")",
"https_num",
"=",
"len",
"(",
"self",
".",
"proxies",
"[",
"'https'",
"]",
")",
"if",
"protocol",
... | Get the number of proxies in the pool
Args:
protocol (str, optional): 'http' or 'https' or None. (default None)
Returns:
If protocol is None, return the total number of proxies, otherwise,
return the number of proxies of corresponding protocol. | [
"Get",
"the",
"number",
"of",
"proxies",
"in",
"the",
"pool"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/proxy_pool.py#L104-L121 |
220,567 | hellock/icrawler | icrawler/utils/proxy_pool.py | ProxyPool.get_next | def get_next(self, protocol='http', format=False, policy='loop'):
"""Get the next proxy
Args:
protocol (str): 'http' or 'https'. (default 'http')
format (bool): Whether to format the proxy. (default False)
policy (str): Either 'loop' or 'random', indicating the polic... | python | def get_next(self, protocol='http', format=False, policy='loop'):
"""Get the next proxy
Args:
protocol (str): 'http' or 'https'. (default 'http')
format (bool): Whether to format the proxy. (default False)
policy (str): Either 'loop' or 'random', indicating the polic... | [
"def",
"get_next",
"(",
"self",
",",
"protocol",
"=",
"'http'",
",",
"format",
"=",
"False",
",",
"policy",
"=",
"'loop'",
")",
":",
"if",
"not",
"self",
".",
"proxies",
"[",
"protocol",
"]",
":",
"return",
"None",
"if",
"policy",
"==",
"'loop'",
":"... | Get the next proxy
Args:
protocol (str): 'http' or 'https'. (default 'http')
format (bool): Whether to format the proxy. (default False)
policy (str): Either 'loop' or 'random', indicating the policy of
getting the next proxy. If set to 'loop', will return pr... | [
"Get",
"the",
"next",
"proxy"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/proxy_pool.py#L123-L154 |
220,568 | hellock/icrawler | icrawler/utils/proxy_pool.py | ProxyPool.save | def save(self, filename):
"""Save proxies to file"""
proxies = {'http': [], 'https': []}
for protocol in ['http', 'https']:
for proxy in self.proxies[protocol]:
serializable_proxy = self.proxies[protocol][proxy].to_dict()
proxies[protocol].append(seria... | python | def save(self, filename):
"""Save proxies to file"""
proxies = {'http': [], 'https': []}
for protocol in ['http', 'https']:
for proxy in self.proxies[protocol]:
serializable_proxy = self.proxies[protocol][proxy].to_dict()
proxies[protocol].append(seria... | [
"def",
"save",
"(",
"self",
",",
"filename",
")",
":",
"proxies",
"=",
"{",
"'http'",
":",
"[",
"]",
",",
"'https'",
":",
"[",
"]",
"}",
"for",
"protocol",
"in",
"[",
"'http'",
",",
"'https'",
"]",
":",
"for",
"proxy",
"in",
"self",
".",
"proxies... | Save proxies to file | [
"Save",
"proxies",
"to",
"file"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/proxy_pool.py#L156-L164 |
220,569 | hellock/icrawler | icrawler/utils/proxy_pool.py | ProxyPool.load | def load(self, filename):
"""Load proxies from file"""
with open(filename, 'r') as fin:
proxies = json.load(fin)
for protocol in proxies:
for proxy in proxies[protocol]:
self.proxies[protocol][proxy['addr']] = Proxy(
proxy['addr'], prox... | python | def load(self, filename):
"""Load proxies from file"""
with open(filename, 'r') as fin:
proxies = json.load(fin)
for protocol in proxies:
for proxy in proxies[protocol]:
self.proxies[protocol][proxy['addr']] = Proxy(
proxy['addr'], prox... | [
"def",
"load",
"(",
"self",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"fin",
":",
"proxies",
"=",
"json",
".",
"load",
"(",
"fin",
")",
"for",
"protocol",
"in",
"proxies",
":",
"for",
"proxy",
"in",
"proxies... | Load proxies from file | [
"Load",
"proxies",
"from",
"file"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/proxy_pool.py#L166-L175 |
220,570 | hellock/icrawler | icrawler/utils/proxy_pool.py | ProxyPool.add_proxy | def add_proxy(self, proxy):
"""Add a valid proxy into pool
You must call `add_proxy` method to add a proxy into pool instead of
directly operate the `proxies` variable.
"""
protocol = proxy.protocol
addr = proxy.addr
if addr in self.proxies:
self.prox... | python | def add_proxy(self, proxy):
"""Add a valid proxy into pool
You must call `add_proxy` method to add a proxy into pool instead of
directly operate the `proxies` variable.
"""
protocol = proxy.protocol
addr = proxy.addr
if addr in self.proxies:
self.prox... | [
"def",
"add_proxy",
"(",
"self",
",",
"proxy",
")",
":",
"protocol",
"=",
"proxy",
".",
"protocol",
"addr",
"=",
"proxy",
".",
"addr",
"if",
"addr",
"in",
"self",
".",
"proxies",
":",
"self",
".",
"proxies",
"[",
"protocol",
"]",
"[",
"addr",
"]",
... | Add a valid proxy into pool
You must call `add_proxy` method to add a proxy into pool instead of
directly operate the `proxies` variable. | [
"Add",
"a",
"valid",
"proxy",
"into",
"pool"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/proxy_pool.py#L177-L189 |
220,571 | hellock/icrawler | icrawler/utils/proxy_pool.py | ProxyPool.remove_proxy | def remove_proxy(self, proxy):
"""Remove a proxy out of the pool"""
del self.search_flag[proxy.protocol][proxy.addr]
del self.addr_list[proxy.protocol][proxy.addr] | python | def remove_proxy(self, proxy):
"""Remove a proxy out of the pool"""
del self.search_flag[proxy.protocol][proxy.addr]
del self.addr_list[proxy.protocol][proxy.addr] | [
"def",
"remove_proxy",
"(",
"self",
",",
"proxy",
")",
":",
"del",
"self",
".",
"search_flag",
"[",
"proxy",
".",
"protocol",
"]",
"[",
"proxy",
".",
"addr",
"]",
"del",
"self",
".",
"addr_list",
"[",
"proxy",
".",
"protocol",
"]",
"[",
"proxy",
".",... | Remove a proxy out of the pool | [
"Remove",
"a",
"proxy",
"out",
"of",
"the",
"pool"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/proxy_pool.py#L191-L194 |
220,572 | hellock/icrawler | icrawler/utils/proxy_pool.py | ProxyPool.increase_weight | def increase_weight(self, proxy):
"""Increase the weight of a proxy by multiplying inc_ratio"""
new_weight = proxy.weight * self.inc_ratio
if new_weight < 1.0:
proxy.weight = new_weight
else:
proxy.weight = 1.0 | python | def increase_weight(self, proxy):
"""Increase the weight of a proxy by multiplying inc_ratio"""
new_weight = proxy.weight * self.inc_ratio
if new_weight < 1.0:
proxy.weight = new_weight
else:
proxy.weight = 1.0 | [
"def",
"increase_weight",
"(",
"self",
",",
"proxy",
")",
":",
"new_weight",
"=",
"proxy",
".",
"weight",
"*",
"self",
".",
"inc_ratio",
"if",
"new_weight",
"<",
"1.0",
":",
"proxy",
".",
"weight",
"=",
"new_weight",
"else",
":",
"proxy",
".",
"weight",
... | Increase the weight of a proxy by multiplying inc_ratio | [
"Increase",
"the",
"weight",
"of",
"a",
"proxy",
"by",
"multiplying",
"inc_ratio"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/proxy_pool.py#L196-L202 |
220,573 | hellock/icrawler | icrawler/utils/proxy_pool.py | ProxyPool.decrease_weight | def decrease_weight(self, proxy):
"""Decreasing the weight of a proxy by multiplying dec_ratio"""
new_weight = proxy.weight * self.dec_ratio
if new_weight < self.weight_thr:
self.remove_proxy(proxy)
else:
proxy.weight = new_weight | python | def decrease_weight(self, proxy):
"""Decreasing the weight of a proxy by multiplying dec_ratio"""
new_weight = proxy.weight * self.dec_ratio
if new_weight < self.weight_thr:
self.remove_proxy(proxy)
else:
proxy.weight = new_weight | [
"def",
"decrease_weight",
"(",
"self",
",",
"proxy",
")",
":",
"new_weight",
"=",
"proxy",
".",
"weight",
"*",
"self",
".",
"dec_ratio",
"if",
"new_weight",
"<",
"self",
".",
"weight_thr",
":",
"self",
".",
"remove_proxy",
"(",
"proxy",
")",
"else",
":",... | Decreasing the weight of a proxy by multiplying dec_ratio | [
"Decreasing",
"the",
"weight",
"of",
"a",
"proxy",
"by",
"multiplying",
"dec_ratio"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/proxy_pool.py#L204-L210 |
220,574 | hellock/icrawler | icrawler/utils/proxy_pool.py | ProxyPool.is_valid | def is_valid(self, addr, protocol='http', timeout=5):
"""Check if a proxy is valid
Args:
addr: A string in the form of 'ip:port'
protocol: Either 'http' or 'https', different test urls will be used
according to protocol.
timeout: A integer indic... | python | def is_valid(self, addr, protocol='http', timeout=5):
"""Check if a proxy is valid
Args:
addr: A string in the form of 'ip:port'
protocol: Either 'http' or 'https', different test urls will be used
according to protocol.
timeout: A integer indic... | [
"def",
"is_valid",
"(",
"self",
",",
"addr",
",",
"protocol",
"=",
"'http'",
",",
"timeout",
"=",
"5",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"try",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"test_url",
"[",
"protoc... | Check if a proxy is valid
Args:
addr: A string in the form of 'ip:port'
protocol: Either 'http' or 'https', different test urls will be used
according to protocol.
timeout: A integer indicating the timeout of connecting the test url.
Returns:
... | [
"Check",
"if",
"a",
"proxy",
"is",
"valid"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/proxy_pool.py#L212-L244 |
220,575 | hellock/icrawler | icrawler/utils/proxy_pool.py | ProxyPool.validate | def validate(self,
proxy_scanner,
expected_num=20,
queue_timeout=3,
val_timeout=5):
"""Target function of validation threads
Args:
proxy_scanner: A ProxyScanner object.
expected_num: Max number of valid proxies ... | python | def validate(self,
proxy_scanner,
expected_num=20,
queue_timeout=3,
val_timeout=5):
"""Target function of validation threads
Args:
proxy_scanner: A ProxyScanner object.
expected_num: Max number of valid proxies ... | [
"def",
"validate",
"(",
"self",
",",
"proxy_scanner",
",",
"expected_num",
"=",
"20",
",",
"queue_timeout",
"=",
"3",
",",
"val_timeout",
"=",
"5",
")",
":",
"while",
"self",
".",
"proxy_num",
"(",
")",
"<",
"expected_num",
":",
"try",
":",
"candidate_pr... | Target function of validation threads
Args:
proxy_scanner: A ProxyScanner object.
expected_num: Max number of valid proxies to be scanned.
queue_timeout: Timeout for getting a proxy from the queue.
val_timeout: An integer passed to `is_valid` as argument `timeout... | [
"Target",
"function",
"of",
"validation",
"threads"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/proxy_pool.py#L246-L280 |
220,576 | hellock/icrawler | icrawler/utils/proxy_pool.py | ProxyPool.scan | def scan(self,
proxy_scanner,
expected_num=20,
val_thr_num=4,
queue_timeout=3,
val_timeout=5,
out_file='proxies.json'):
"""Scan and validate proxies
Firstly, call the `scan` method of `proxy_scanner`, then using multiple
... | python | def scan(self,
proxy_scanner,
expected_num=20,
val_thr_num=4,
queue_timeout=3,
val_timeout=5,
out_file='proxies.json'):
"""Scan and validate proxies
Firstly, call the `scan` method of `proxy_scanner`, then using multiple
... | [
"def",
"scan",
"(",
"self",
",",
"proxy_scanner",
",",
"expected_num",
"=",
"20",
",",
"val_thr_num",
"=",
"4",
",",
"queue_timeout",
"=",
"3",
",",
"val_timeout",
"=",
"5",
",",
"out_file",
"=",
"'proxies.json'",
")",
":",
"try",
":",
"proxy_scanner",
"... | Scan and validate proxies
Firstly, call the `scan` method of `proxy_scanner`, then using multiple
threads to validate them.
Args:
proxy_scanner: A ProxyScanner object.
expected_num: Max number of valid proxies to be scanned.
val_thr_num: Number of threads us... | [
"Scan",
"and",
"validate",
"proxies"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/proxy_pool.py#L282-L327 |
220,577 | hellock/icrawler | icrawler/utils/proxy_pool.py | ProxyPool.default_scan | def default_scan(self,
region='mainland',
expected_num=20,
val_thr_num=4,
queue_timeout=3,
val_timeout=5,
out_file='proxies.json',
src_files=None):
"""Default scan m... | python | def default_scan(self,
region='mainland',
expected_num=20,
val_thr_num=4,
queue_timeout=3,
val_timeout=5,
out_file='proxies.json',
src_files=None):
"""Default scan m... | [
"def",
"default_scan",
"(",
"self",
",",
"region",
"=",
"'mainland'",
",",
"expected_num",
"=",
"20",
",",
"val_thr_num",
"=",
"4",
",",
"queue_timeout",
"=",
"3",
",",
"val_timeout",
"=",
"5",
",",
"out_file",
"=",
"'proxies.json'",
",",
"src_files",
"=",... | Default scan method, to simplify the usage of `scan` method.
It will register following scan functions:
1. scan_file
2. scan_cnproxy (if region is mainland)
3. scan_free_proxy_list (if region is overseas)
4. scan_ip84
5. scan_mimiip
After scanning, all the proxy ... | [
"Default",
"scan",
"method",
"to",
"simplify",
"the",
"usage",
"of",
"scan",
"method",
"."
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/proxy_pool.py#L329-L383 |
220,578 | hellock/icrawler | icrawler/utils/proxy_pool.py | ProxyScanner.register_func | def register_func(self, func_name, func_kwargs):
"""Register a scan function
Args:
func_name: The function name of a scan function.
func_kwargs: A dict containing arguments of the scan function.
"""
self.scan_funcs.append(func_name)
self.scan_kwargs.appen... | python | def register_func(self, func_name, func_kwargs):
"""Register a scan function
Args:
func_name: The function name of a scan function.
func_kwargs: A dict containing arguments of the scan function.
"""
self.scan_funcs.append(func_name)
self.scan_kwargs.appen... | [
"def",
"register_func",
"(",
"self",
",",
"func_name",
",",
"func_kwargs",
")",
":",
"self",
".",
"scan_funcs",
".",
"append",
"(",
"func_name",
")",
"self",
".",
"scan_kwargs",
".",
"append",
"(",
"func_kwargs",
")"
] | Register a scan function
Args:
func_name: The function name of a scan function.
func_kwargs: A dict containing arguments of the scan function. | [
"Register",
"a",
"scan",
"function"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/proxy_pool.py#L406-L414 |
220,579 | hellock/icrawler | icrawler/utils/proxy_pool.py | ProxyScanner.scan_file | def scan_file(self, src_file):
"""Scan candidate proxies from an existing file"""
self.logger.info('start scanning file {} for proxy list...'
.format(src_file))
with open(src_file, 'r') as fin:
proxies = json.load(fin)
for protocol in proxies.keys():
... | python | def scan_file(self, src_file):
"""Scan candidate proxies from an existing file"""
self.logger.info('start scanning file {} for proxy list...'
.format(src_file))
with open(src_file, 'r') as fin:
proxies = json.load(fin)
for protocol in proxies.keys():
... | [
"def",
"scan_file",
"(",
"self",
",",
"src_file",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'start scanning file {} for proxy list...'",
".",
"format",
"(",
"src_file",
")",
")",
"with",
"open",
"(",
"src_file",
",",
"'r'",
")",
"as",
"fin",
":",... | Scan candidate proxies from an existing file | [
"Scan",
"candidate",
"proxies",
"from",
"an",
"existing",
"file"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/proxy_pool.py#L499-L510 |
220,580 | hellock/icrawler | icrawler/utils/proxy_pool.py | ProxyScanner.scan | def scan(self):
"""Start a thread for each registered scan function to scan proxy lists"""
self.logger.info('{0} registered scan functions, starting {0} threads '
'to scan candidate proxy lists...'
.format(len(self.scan_funcs)))
for i in range(le... | python | def scan(self):
"""Start a thread for each registered scan function to scan proxy lists"""
self.logger.info('{0} registered scan functions, starting {0} threads '
'to scan candidate proxy lists...'
.format(len(self.scan_funcs)))
for i in range(le... | [
"def",
"scan",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'{0} registered scan functions, starting {0} threads '",
"'to scan candidate proxy lists...'",
".",
"format",
"(",
"len",
"(",
"self",
".",
"scan_funcs",
")",
")",
")",
"for",
"i",
"... | Start a thread for each registered scan function to scan proxy lists | [
"Start",
"a",
"thread",
"for",
"each",
"registered",
"scan",
"function",
"to",
"scan",
"proxy",
"lists"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/proxy_pool.py#L519-L531 |
220,581 | hellock/icrawler | icrawler/utils/cached_queue.py | CachedQueue.is_duplicated | def is_duplicated(self, item):
"""Check whether the item has been in the cache
If the item has not been seen before, then hash it and put it into
the cache, otherwise indicates the item is duplicated. When the cache
size exceeds capacity, discard the earliest items in the cache.
... | python | def is_duplicated(self, item):
"""Check whether the item has been in the cache
If the item has not been seen before, then hash it and put it into
the cache, otherwise indicates the item is duplicated. When the cache
size exceeds capacity, discard the earliest items in the cache.
... | [
"def",
"is_duplicated",
"(",
"self",
",",
"item",
")",
":",
"if",
"isinstance",
"(",
"item",
",",
"dict",
")",
":",
"hashable_item",
"=",
"json",
".",
"dumps",
"(",
"item",
",",
"sort_keys",
"=",
"True",
")",
"elif",
"isinstance",
"(",
"item",
",",
"... | Check whether the item has been in the cache
If the item has not been seen before, then hash it and put it into
the cache, otherwise indicates the item is duplicated. When the cache
size exceeds capacity, discard the earliest items in the cache.
Args:
item (object): The ite... | [
"Check",
"whether",
"the",
"item",
"has",
"been",
"in",
"the",
"cache"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/cached_queue.py#L27-L53 |
220,582 | hellock/icrawler | icrawler/utils/cached_queue.py | CachedQueue.put | def put(self, item, block=True, timeout=None, dup_callback=None):
"""Put an item to queue if it is not duplicated.
"""
if not self.is_duplicated(item):
super(CachedQueue, self).put(item, block, timeout)
else:
if dup_callback:
dup_callback(item) | python | def put(self, item, block=True, timeout=None, dup_callback=None):
"""Put an item to queue if it is not duplicated.
"""
if not self.is_duplicated(item):
super(CachedQueue, self).put(item, block, timeout)
else:
if dup_callback:
dup_callback(item) | [
"def",
"put",
"(",
"self",
",",
"item",
",",
"block",
"=",
"True",
",",
"timeout",
"=",
"None",
",",
"dup_callback",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"is_duplicated",
"(",
"item",
")",
":",
"super",
"(",
"CachedQueue",
",",
"self",
... | Put an item to queue if it is not duplicated. | [
"Put",
"an",
"item",
"to",
"queue",
"if",
"it",
"is",
"not",
"duplicated",
"."
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/cached_queue.py#L55-L62 |
220,583 | hellock/icrawler | icrawler/utils/signal.py | Signal.set | def set(self, **signals):
"""Set signals.
Args:
signals: A dict(key-value pairs) of all signals. For example
{'signal1': True, 'signal2': 10}
"""
for name in signals:
if name not in self._signals:
self._init_status[name] = sig... | python | def set(self, **signals):
"""Set signals.
Args:
signals: A dict(key-value pairs) of all signals. For example
{'signal1': True, 'signal2': 10}
"""
for name in signals:
if name not in self._signals:
self._init_status[name] = sig... | [
"def",
"set",
"(",
"self",
",",
"*",
"*",
"signals",
")",
":",
"for",
"name",
"in",
"signals",
":",
"if",
"name",
"not",
"in",
"self",
".",
"_signals",
":",
"self",
".",
"_init_status",
"[",
"name",
"]",
"=",
"signals",
"[",
"name",
"]",
"self",
... | Set signals.
Args:
signals: A dict(key-value pairs) of all signals. For example
{'signal1': True, 'signal2': 10} | [
"Set",
"signals",
"."
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/signal.py#L19-L29 |
220,584 | hellock/icrawler | icrawler/feeder.py | Feeder.worker_exec | def worker_exec(self, **kwargs):
"""Target function of workers"""
self.feed(**kwargs)
self.logger.info('thread {} exit'.format(current_thread().name)) | python | def worker_exec(self, **kwargs):
"""Target function of workers"""
self.feed(**kwargs)
self.logger.info('thread {} exit'.format(current_thread().name)) | [
"def",
"worker_exec",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"feed",
"(",
"*",
"*",
"kwargs",
")",
"self",
".",
"logger",
".",
"info",
"(",
"'thread {} exit'",
".",
"format",
"(",
"current_thread",
"(",
")",
".",
"name",
")",
... | Target function of workers | [
"Target",
"function",
"of",
"workers"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/feeder.py#L41-L44 |
220,585 | hellock/icrawler | icrawler/feeder.py | SimpleSEFeeder.feed | def feed(self, url_template, keyword, offset, max_num, page_step):
"""Feed urls once
Args:
url_template: A string with parameters replaced with "{}".
keyword: A string indicating the searching keyword.
offset: An integer indicating the starting index.
max... | python | def feed(self, url_template, keyword, offset, max_num, page_step):
"""Feed urls once
Args:
url_template: A string with parameters replaced with "{}".
keyword: A string indicating the searching keyword.
offset: An integer indicating the starting index.
max... | [
"def",
"feed",
"(",
"self",
",",
"url_template",
",",
"keyword",
",",
"offset",
",",
"max_num",
",",
"page_step",
")",
":",
"for",
"i",
"in",
"range",
"(",
"offset",
",",
"offset",
"+",
"max_num",
",",
"page_step",
")",
":",
"url",
"=",
"url_template",... | Feed urls once
Args:
url_template: A string with parameters replaced with "{}".
keyword: A string indicating the searching keyword.
offset: An integer indicating the starting index.
max_num: An integer indicating the max number of images to be crawled.
... | [
"Feed",
"urls",
"once"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/feeder.py#L79-L92 |
220,586 | hellock/icrawler | icrawler/utils/thread_pool.py | ThreadPool.connect | def connect(self, component):
"""Connect two ThreadPools.
The ``in_queue`` of the second pool will be set as the ``out_queue`` of
the current pool, thus all the output will be input to the second pool.
Args:
component (ThreadPool): the ThreadPool to be connected.
Re... | python | def connect(self, component):
"""Connect two ThreadPools.
The ``in_queue`` of the second pool will be set as the ``out_queue`` of
the current pool, thus all the output will be input to the second pool.
Args:
component (ThreadPool): the ThreadPool to be connected.
Re... | [
"def",
"connect",
"(",
"self",
",",
"component",
")",
":",
"if",
"not",
"isinstance",
"(",
"component",
",",
"ThreadPool",
")",
":",
"raise",
"TypeError",
"(",
"'\"component\" must be a ThreadPool object'",
")",
"component",
".",
"in_queue",
"=",
"self",
".",
... | Connect two ThreadPools.
The ``in_queue`` of the second pool will be set as the ``out_queue`` of
the current pool, thus all the output will be input to the second pool.
Args:
component (ThreadPool): the ThreadPool to be connected.
Returns:
ThreadPool: the modifi... | [
"Connect",
"two",
"ThreadPools",
"."
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/utils/thread_pool.py#L85-L99 |
220,587 | hellock/icrawler | icrawler/downloader.py | Downloader.set_file_idx_offset | def set_file_idx_offset(self, file_idx_offset=0):
"""Set offset of file index.
Args:
file_idx_offset: It can be either an integer or 'auto'. If set
to an integer, the filename will start from
``file_idx_offset`` + 1. If set to ``'auto'``, the filename
... | python | def set_file_idx_offset(self, file_idx_offset=0):
"""Set offset of file index.
Args:
file_idx_offset: It can be either an integer or 'auto'. If set
to an integer, the filename will start from
``file_idx_offset`` + 1. If set to ``'auto'``, the filename
... | [
"def",
"set_file_idx_offset",
"(",
"self",
",",
"file_idx_offset",
"=",
"0",
")",
":",
"if",
"isinstance",
"(",
"file_idx_offset",
",",
"int",
")",
":",
"self",
".",
"file_idx_offset",
"=",
"file_idx_offset",
"elif",
"file_idx_offset",
"==",
"'auto'",
":",
"se... | Set offset of file index.
Args:
file_idx_offset: It can be either an integer or 'auto'. If set
to an integer, the filename will start from
``file_idx_offset`` + 1. If set to ``'auto'``, the filename
will start from existing max file index plus 1. | [
"Set",
"offset",
"of",
"file",
"index",
"."
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/downloader.py#L45-L59 |
220,588 | hellock/icrawler | icrawler/downloader.py | Downloader.get_filename | def get_filename(self, task, default_ext):
"""Set the path where the image will be saved.
The default strategy is to use an increasing 6-digit number as
the filename. You can override this method if you want to set custom
naming rules. The file extension is kept if it can be obtained fr... | python | def get_filename(self, task, default_ext):
"""Set the path where the image will be saved.
The default strategy is to use an increasing 6-digit number as
the filename. You can override this method if you want to set custom
naming rules. The file extension is kept if it can be obtained fr... | [
"def",
"get_filename",
"(",
"self",
",",
"task",
",",
"default_ext",
")",
":",
"url_path",
"=",
"urlparse",
"(",
"task",
"[",
"'file_url'",
"]",
")",
"[",
"2",
"]",
"extension",
"=",
"url_path",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"1",
"]",
"i... | Set the path where the image will be saved.
The default strategy is to use an increasing 6-digit number as
the filename. You can override this method if you want to set custom
naming rules. The file extension is kept if it can be obtained from
the url, otherwise ``default_ext`` is used ... | [
"Set",
"the",
"path",
"where",
"the",
"image",
"will",
"be",
"saved",
"."
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/downloader.py#L61-L78 |
220,589 | hellock/icrawler | icrawler/downloader.py | Downloader.reach_max_num | def reach_max_num(self):
"""Check if downloaded images reached max num.
Returns:
bool: if downloaded images reached max num.
"""
if self.signal.get('reach_max_num'):
return True
if self.max_num > 0 and self.fetched_num >= self.max_num:
return ... | python | def reach_max_num(self):
"""Check if downloaded images reached max num.
Returns:
bool: if downloaded images reached max num.
"""
if self.signal.get('reach_max_num'):
return True
if self.max_num > 0 and self.fetched_num >= self.max_num:
return ... | [
"def",
"reach_max_num",
"(",
"self",
")",
":",
"if",
"self",
".",
"signal",
".",
"get",
"(",
"'reach_max_num'",
")",
":",
"return",
"True",
"if",
"self",
".",
"max_num",
">",
"0",
"and",
"self",
".",
"fetched_num",
">=",
"self",
".",
"max_num",
":",
... | Check if downloaded images reached max num.
Returns:
bool: if downloaded images reached max num. | [
"Check",
"if",
"downloaded",
"images",
"reached",
"max",
"num",
"."
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/downloader.py#L80-L91 |
220,590 | hellock/icrawler | icrawler/downloader.py | Downloader.download | def download(self,
task,
default_ext,
timeout=5,
max_retry=3,
overwrite=False,
**kwargs):
"""Download the image and save it to the corresponding path.
Args:
task (dict): The task dict got f... | python | def download(self,
task,
default_ext,
timeout=5,
max_retry=3,
overwrite=False,
**kwargs):
"""Download the image and save it to the corresponding path.
Args:
task (dict): The task dict got f... | [
"def",
"download",
"(",
"self",
",",
"task",
",",
"default_ext",
",",
"timeout",
"=",
"5",
",",
"max_retry",
"=",
"3",
",",
"overwrite",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"file_url",
"=",
"task",
"[",
"'file_url'",
"]",
"task",
"[",
... | Download the image and save it to the corresponding path.
Args:
task (dict): The task dict got from ``task_queue``.
timeout (int): Timeout of making requests for downloading images.
max_retry (int): the max retry times if the request fails.
**kwargs: reserved arg... | [
"Download",
"the",
"image",
"and",
"save",
"it",
"to",
"the",
"corresponding",
"path",
"."
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/downloader.py#L96-L151 |
220,591 | hellock/icrawler | icrawler/downloader.py | ImageDownloader.keep_file | def keep_file(self, task, response, min_size=None, max_size=None):
"""Decide whether to keep the image
Compare image size with ``min_size`` and ``max_size`` to decide.
Args:
response (Response): response of requests.
min_size (tuple or None): minimum size of required im... | python | def keep_file(self, task, response, min_size=None, max_size=None):
"""Decide whether to keep the image
Compare image size with ``min_size`` and ``max_size`` to decide.
Args:
response (Response): response of requests.
min_size (tuple or None): minimum size of required im... | [
"def",
"keep_file",
"(",
"self",
",",
"task",
",",
"response",
",",
"min_size",
"=",
"None",
",",
"max_size",
"=",
"None",
")",
":",
"try",
":",
"img",
"=",
"Image",
".",
"open",
"(",
"BytesIO",
"(",
"response",
".",
"content",
")",
")",
"except",
... | Decide whether to keep the image
Compare image size with ``min_size`` and ``max_size`` to decide.
Args:
response (Response): response of requests.
min_size (tuple or None): minimum size of required images.
max_size (tuple or None): maximum size of required images.
... | [
"Decide",
"whether",
"to",
"keep",
"the",
"image"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/downloader.py#L232-L253 |
220,592 | hellock/icrawler | icrawler/crawler.py | Crawler.set_logger | def set_logger(self, log_level=logging.INFO):
"""Configure the logger with log_level."""
logging.basicConfig(
format='%(asctime)s - %(levelname)s - %(name)s - %(message)s',
level=log_level,
stream=sys.stderr)
self.logger = logging.getLogger(__name__)
l... | python | def set_logger(self, log_level=logging.INFO):
"""Configure the logger with log_level."""
logging.basicConfig(
format='%(asctime)s - %(levelname)s - %(name)s - %(message)s',
level=log_level,
stream=sys.stderr)
self.logger = logging.getLogger(__name__)
l... | [
"def",
"set_logger",
"(",
"self",
",",
"log_level",
"=",
"logging",
".",
"INFO",
")",
":",
"logging",
".",
"basicConfig",
"(",
"format",
"=",
"'%(asctime)s - %(levelname)s - %(name)s - %(message)s'",
",",
"level",
"=",
"log_level",
",",
"stream",
"=",
"sys",
"."... | Configure the logger with log_level. | [
"Configure",
"the",
"logger",
"with",
"log_level",
"."
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/crawler.py#L76-L83 |
220,593 | hellock/icrawler | icrawler/crawler.py | Crawler.set_storage | def set_storage(self, storage):
"""Set storage backend for downloader
For full list of storage backend supported, please see :mod:`storage`.
Args:
storage (dict or BaseStorage): storage backend configuration or instance
"""
if isinstance(storage, BaseStorage):
... | python | def set_storage(self, storage):
"""Set storage backend for downloader
For full list of storage backend supported, please see :mod:`storage`.
Args:
storage (dict or BaseStorage): storage backend configuration or instance
"""
if isinstance(storage, BaseStorage):
... | [
"def",
"set_storage",
"(",
"self",
",",
"storage",
")",
":",
"if",
"isinstance",
"(",
"storage",
",",
"BaseStorage",
")",
":",
"self",
".",
"storage",
"=",
"storage",
"elif",
"isinstance",
"(",
"storage",
",",
"dict",
")",
":",
"if",
"'backend'",
"not",
... | Set storage backend for downloader
For full list of storage backend supported, please see :mod:`storage`.
Args:
storage (dict or BaseStorage): storage backend configuration or instance | [
"Set",
"storage",
"backend",
"for",
"downloader"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/crawler.py#L95-L122 |
220,594 | hellock/icrawler | icrawler/crawler.py | Crawler.set_session | def set_session(self, headers=None):
"""Init session with default or custom headers
Args:
headers: A dict of headers (default None, thus using the default
header to init the session)
"""
if headers is None:
headers = {
'User-A... | python | def set_session(self, headers=None):
"""Init session with default or custom headers
Args:
headers: A dict of headers (default None, thus using the default
header to init the session)
"""
if headers is None:
headers = {
'User-A... | [
"def",
"set_session",
"(",
"self",
",",
"headers",
"=",
"None",
")",
":",
"if",
"headers",
"is",
"None",
":",
"headers",
"=",
"{",
"'User-Agent'",
":",
"(",
"'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3)'",
"' AppleWebKit/537.36 (KHTML, like Gecko) '",
"'Chrome/48.0.... | Init session with default or custom headers
Args:
headers: A dict of headers (default None, thus using the default
header to init the session) | [
"Init",
"session",
"with",
"default",
"or",
"custom",
"headers"
] | 38c925758fd3d3e568d3ecc993f77bc0acfa4788 | https://github.com/hellock/icrawler/blob/38c925758fd3d3e568d3ecc993f77bc0acfa4788/icrawler/crawler.py#L134-L152 |
220,595 | pmorissette/bt | bt/core.py | Node.value | def value(self):
"""
Current value of the Node
"""
if self.root.stale:
self.root.update(self.root.now, None)
return self._value | python | def value(self):
"""
Current value of the Node
"""
if self.root.stale:
self.root.update(self.root.now, None)
return self._value | [
"def",
"value",
"(",
"self",
")",
":",
"if",
"self",
".",
"root",
".",
"stale",
":",
"self",
".",
"root",
".",
"update",
"(",
"self",
".",
"root",
".",
"now",
",",
"None",
")",
"return",
"self",
".",
"_value"
] | Current value of the Node | [
"Current",
"value",
"of",
"the",
"Node"
] | 0363e6fa100d9392dd18e32e3d8379d5e83c28fa | https://github.com/pmorissette/bt/blob/0363e6fa100d9392dd18e32e3d8379d5e83c28fa/bt/core.py#L175-L181 |
220,596 | pmorissette/bt | bt/core.py | Node.members | def members(self):
"""
Node members. Members include current node as well as Node's
children.
"""
res = [self]
for c in list(self.children.values()):
res.extend(c.members)
return res | python | def members(self):
"""
Node members. Members include current node as well as Node's
children.
"""
res = [self]
for c in list(self.children.values()):
res.extend(c.members)
return res | [
"def",
"members",
"(",
"self",
")",
":",
"res",
"=",
"[",
"self",
"]",
"for",
"c",
"in",
"list",
"(",
"self",
".",
"children",
".",
"values",
"(",
")",
")",
":",
"res",
".",
"extend",
"(",
"c",
".",
"members",
")",
"return",
"res"
] | Node members. Members include current node as well as Node's
children. | [
"Node",
"members",
".",
"Members",
"include",
"current",
"node",
"as",
"well",
"as",
"Node",
"s",
"children",
"."
] | 0363e6fa100d9392dd18e32e3d8379d5e83c28fa | https://github.com/pmorissette/bt/blob/0363e6fa100d9392dd18e32e3d8379d5e83c28fa/bt/core.py#L229-L237 |
220,597 | pmorissette/bt | bt/core.py | StrategyBase.universe | def universe(self):
"""
Data universe available at the current time.
Universe contains the data passed in when creating a Backtest.
Use this data to determine strategy logic.
"""
# avoid windowing every time
# if calling and on same date return
# cached va... | python | def universe(self):
"""
Data universe available at the current time.
Universe contains the data passed in when creating a Backtest.
Use this data to determine strategy logic.
"""
# avoid windowing every time
# if calling and on same date return
# cached va... | [
"def",
"universe",
"(",
"self",
")",
":",
"# avoid windowing every time",
"# if calling and on same date return",
"# cached value",
"if",
"self",
".",
"now",
"==",
"self",
".",
"_last_chk",
":",
"return",
"self",
".",
"_funiverse",
"else",
":",
"self",
".",
"_last... | Data universe available at the current time.
Universe contains the data passed in when creating a Backtest.
Use this data to determine strategy logic. | [
"Data",
"universe",
"available",
"at",
"the",
"current",
"time",
".",
"Universe",
"contains",
"the",
"data",
"passed",
"in",
"when",
"creating",
"a",
"Backtest",
".",
"Use",
"this",
"data",
"to",
"determine",
"strategy",
"logic",
"."
] | 0363e6fa100d9392dd18e32e3d8379d5e83c28fa | https://github.com/pmorissette/bt/blob/0363e6fa100d9392dd18e32e3d8379d5e83c28fa/bt/core.py#L374-L388 |
220,598 | pmorissette/bt | bt/core.py | StrategyBase.outlays | def outlays(self):
"""
Returns a DataFrame of outlays for each child SecurityBase
"""
return pd.DataFrame({x.name: x.outlays for x in self.securities}) | python | def outlays(self):
"""
Returns a DataFrame of outlays for each child SecurityBase
"""
return pd.DataFrame({x.name: x.outlays for x in self.securities}) | [
"def",
"outlays",
"(",
"self",
")",
":",
"return",
"pd",
".",
"DataFrame",
"(",
"{",
"x",
".",
"name",
":",
"x",
".",
"outlays",
"for",
"x",
"in",
"self",
".",
"securities",
"}",
")"
] | Returns a DataFrame of outlays for each child SecurityBase | [
"Returns",
"a",
"DataFrame",
"of",
"outlays",
"for",
"each",
"child",
"SecurityBase"
] | 0363e6fa100d9392dd18e32e3d8379d5e83c28fa | https://github.com/pmorissette/bt/blob/0363e6fa100d9392dd18e32e3d8379d5e83c28fa/bt/core.py#L398-L402 |
220,599 | pmorissette/bt | bt/core.py | StrategyBase.setup | def setup(self, universe):
"""
Setup strategy with universe. This will speed up future calculations
and updates.
"""
# save full universe in case we need it
self._original_data = universe
# determine if needs paper trading
# and setup if so
if sel... | python | def setup(self, universe):
"""
Setup strategy with universe. This will speed up future calculations
and updates.
"""
# save full universe in case we need it
self._original_data = universe
# determine if needs paper trading
# and setup if so
if sel... | [
"def",
"setup",
"(",
"self",
",",
"universe",
")",
":",
"# save full universe in case we need it",
"self",
".",
"_original_data",
"=",
"universe",
"# determine if needs paper trading",
"# and setup if so",
"if",
"self",
"is",
"not",
"self",
".",
"parent",
":",
"self",... | Setup strategy with universe. This will speed up future calculations
and updates. | [
"Setup",
"strategy",
"with",
"universe",
".",
"This",
"will",
"speed",
"up",
"future",
"calculations",
"and",
"updates",
"."
] | 0363e6fa100d9392dd18e32e3d8379d5e83c28fa | https://github.com/pmorissette/bt/blob/0363e6fa100d9392dd18e32e3d8379d5e83c28fa/bt/core.py#L418-L481 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.