repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.new_binary_container | def new_binary_container(self, name):
"""Defines a new binary container to template.
Binary container can only contain binary fields defined with `Bin`
keyword.
Examples:
| New binary container | flags |
| bin | 2 | foo |
| bin | 6 | bar |
| End binary c... | python | def new_binary_container(self, name):
"""Defines a new binary container to template.
Binary container can only contain binary fields defined with `Bin`
keyword.
Examples:
| New binary container | flags |
| bin | 2 | foo |
| bin | 6 | bar |
| End binary c... | [
"def",
"new_binary_container",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"_message_stack",
".",
"append",
"(",
"BinaryContainerTemplate",
"(",
"name",
",",
"self",
".",
"_current_container",
")",
")"
] | Defines a new binary container to template.
Binary container can only contain binary fields defined with `Bin`
keyword.
Examples:
| New binary container | flags |
| bin | 2 | foo |
| bin | 6 | bar |
| End binary container | | [
"Defines",
"a",
"new",
"binary",
"container",
"to",
"template",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L784-L796 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.end_binary_container | def end_binary_container(self):
"""End binary container. See `New Binary Container`.
"""
binary_container = self._message_stack.pop()
binary_container.verify()
self._add_field(binary_container) | python | def end_binary_container(self):
"""End binary container. See `New Binary Container`.
"""
binary_container = self._message_stack.pop()
binary_container.verify()
self._add_field(binary_container) | [
"def",
"end_binary_container",
"(",
"self",
")",
":",
"binary_container",
"=",
"self",
".",
"_message_stack",
".",
"pop",
"(",
")",
"binary_container",
".",
"verify",
"(",
")",
"self",
".",
"_add_field",
"(",
"binary_container",
")"
] | End binary container. See `New Binary Container`. | [
"End",
"binary",
"container",
".",
"See",
"New",
"Binary",
"Container",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L801-L806 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.bin | def bin(self, size, name, value=None):
"""Add new binary field to template.
This keyword has to be called within a binary container. See `New Binary
Container`.
"""
self._add_field(Binary(size, name, value)) | python | def bin(self, size, name, value=None):
"""Add new binary field to template.
This keyword has to be called within a binary container. See `New Binary
Container`.
"""
self._add_field(Binary(size, name, value)) | [
"def",
"bin",
"(",
"self",
",",
"size",
",",
"name",
",",
"value",
"=",
"None",
")",
":",
"self",
".",
"_add_field",
"(",
"Binary",
"(",
"size",
",",
"name",
",",
"value",
")",
")"
] | Add new binary field to template.
This keyword has to be called within a binary container. See `New Binary
Container`. | [
"Add",
"new",
"binary",
"field",
"to",
"template",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L812-L818 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.new_union | def new_union(self, type, name):
"""Defines a new union to template of `type` and `name`.
Fields inside the union are alternatives and the length of the union is
the length of its longest field.
Example:
| New union | IntOrAddress | foo |
| Chars | 16 | ipAddress |
... | python | def new_union(self, type, name):
"""Defines a new union to template of `type` and `name`.
Fields inside the union are alternatives and the length of the union is
the length of its longest field.
Example:
| New union | IntOrAddress | foo |
| Chars | 16 | ipAddress |
... | [
"def",
"new_union",
"(",
"self",
",",
"type",
",",
"name",
")",
":",
"self",
".",
"_message_stack",
".",
"append",
"(",
"UnionTemplate",
"(",
"type",
",",
"name",
",",
"self",
".",
"_current_container",
")",
")"
] | Defines a new union to template of `type` and `name`.
Fields inside the union are alternatives and the length of the union is
the length of its longest field.
Example:
| New union | IntOrAddress | foo |
| Chars | 16 | ipAddress |
| u32 | int |
| End union | | [
"Defines",
"a",
"new",
"union",
"to",
"template",
"of",
"type",
"and",
"name",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L823-L835 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.start_bag | def start_bag(self, name):
"""Bags are sets of optional elements with an optional count.
The optional elements are given each as a `Case` with the accepted count
as first argument. The received elements are matched from the list of
cases in order. If the the received value does not vali... | python | def start_bag(self, name):
"""Bags are sets of optional elements with an optional count.
The optional elements are given each as a `Case` with the accepted count
as first argument. The received elements are matched from the list of
cases in order. If the the received value does not vali... | [
"def",
"start_bag",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"_message_stack",
".",
"append",
"(",
"BagTemplate",
"(",
"name",
",",
"self",
".",
"_current_container",
")",
")"
] | Bags are sets of optional elements with an optional count.
The optional elements are given each as a `Case` with the accepted count
as first argument. The received elements are matched from the list of
cases in order. If the the received value does not validate against the
case (for exa... | [
"Bags",
"are",
"sets",
"of",
"optional",
"elements",
"with",
"an",
"optional",
"count",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L843-L878 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.value | def value(self, name, value):
"""Defines a default `value` for a template field identified by `name`.
Default values for header fields can be set with header:field syntax.
Examples:
| Value | foo | 42 |
| Value | struct.sub_field | 0xcafe |
| Value | header:version | 0x... | python | def value(self, name, value):
"""Defines a default `value` for a template field identified by `name`.
Default values for header fields can be set with header:field syntax.
Examples:
| Value | foo | 42 |
| Value | struct.sub_field | 0xcafe |
| Value | header:version | 0x... | [
"def",
"value",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"_StructuredElement",
")",
":",
"self",
".",
"_struct_fields_as_values",
"(",
"name",
",",
"value",
")",
"elif",
"name",
".",
"startswith",
"(",
"'he... | Defines a default `value` for a template field identified by `name`.
Default values for header fields can be set with header:field syntax.
Examples:
| Value | foo | 42 |
| Value | struct.sub_field | 0xcafe |
| Value | header:version | 0x02 | | [
"Defines",
"a",
"default",
"value",
"for",
"a",
"template",
"field",
"identified",
"by",
"name",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L935-L950 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.conditional | def conditional(self, condition, name):
"""Defines a 'condition' when conditional element of 'name' exists if `condition` is true.
`condition` can contain multiple conditions combined together using Logical Expressions(&&,||).
Example:
| Conditional | mycondition == 1 | foo |
|... | python | def conditional(self, condition, name):
"""Defines a 'condition' when conditional element of 'name' exists if `condition` is true.
`condition` can contain multiple conditions combined together using Logical Expressions(&&,||).
Example:
| Conditional | mycondition == 1 | foo |
|... | [
"def",
"conditional",
"(",
"self",
",",
"condition",
",",
"name",
")",
":",
"self",
".",
"_message_stack",
".",
"append",
"(",
"ConditionalTemplate",
"(",
"condition",
",",
"name",
",",
"self",
".",
"_current_container",
")",
")"
] | Defines a 'condition' when conditional element of 'name' exists if `condition` is true.
`condition` can contain multiple conditions combined together using Logical Expressions(&&,||).
Example:
| Conditional | mycondition == 1 | foo |
| u8 | myelement | 42 |
| End conditional ... | [
"Defines",
"a",
"condition",
"when",
"conditional",
"element",
"of",
"name",
"exists",
"if",
"condition",
"is",
"true",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L999-L1013 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.get_client_unread_messages_count | def get_client_unread_messages_count(self, client_name=None):
"""Gets count of unread messages from client
"""
client = self._clients.get_with_name(client_name)[0]
return client.get_messages_count_in_buffer() | python | def get_client_unread_messages_count(self, client_name=None):
"""Gets count of unread messages from client
"""
client = self._clients.get_with_name(client_name)[0]
return client.get_messages_count_in_buffer() | [
"def",
"get_client_unread_messages_count",
"(",
"self",
",",
"client_name",
"=",
"None",
")",
":",
"client",
"=",
"self",
".",
"_clients",
".",
"get_with_name",
"(",
"client_name",
")",
"[",
"0",
"]",
"return",
"client",
".",
"get_messages_count_in_buffer",
"(",... | Gets count of unread messages from client | [
"Gets",
"count",
"of",
"unread",
"messages",
"from",
"client"
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L1021-L1025 | train |
robotframework/Rammbock | src/Rammbock/core.py | RammbockCore.get_server_unread_messages_count | def get_server_unread_messages_count(self, server_name=None):
"""Gets count of unread messages from server
"""
server = self._servers.get(server_name)
return server.get_messages_count_in_buffer() | python | def get_server_unread_messages_count(self, server_name=None):
"""Gets count of unread messages from server
"""
server = self._servers.get(server_name)
return server.get_messages_count_in_buffer() | [
"def",
"get_server_unread_messages_count",
"(",
"self",
",",
"server_name",
"=",
"None",
")",
":",
"server",
"=",
"self",
".",
"_servers",
".",
"get",
"(",
"server_name",
")",
"return",
"server",
".",
"get_messages_count_in_buffer",
"(",
")"
] | Gets count of unread messages from server | [
"Gets",
"count",
"of",
"unread",
"messages",
"from",
"server"
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/core.py#L1027-L1031 | train |
robotframework/Rammbock | src/Rammbock/binary_tools.py | to_twos_comp | def to_twos_comp(val, bits):
"""compute the 2's compliment of int value val"""
if not val.startswith('-'):
return to_int(val)
value = _invert(to_bin_str_from_int_string(bits, bin(to_int(val[1:]))))
return int(value, 2) + 1 | python | def to_twos_comp(val, bits):
"""compute the 2's compliment of int value val"""
if not val.startswith('-'):
return to_int(val)
value = _invert(to_bin_str_from_int_string(bits, bin(to_int(val[1:]))))
return int(value, 2) + 1 | [
"def",
"to_twos_comp",
"(",
"val",
",",
"bits",
")",
":",
"if",
"not",
"val",
".",
"startswith",
"(",
"'-'",
")",
":",
"return",
"to_int",
"(",
"val",
")",
"value",
"=",
"_invert",
"(",
"to_bin_str_from_int_string",
"(",
"bits",
",",
"bin",
"(",
"to_in... | compute the 2's compliment of int value val | [
"compute",
"the",
"2",
"s",
"compliment",
"of",
"int",
"value",
"val"
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/binary_tools.py#L119-L124 | train |
robotframework/Rammbock | src/Rammbock/rammbock.py | Rammbock.u8 | def u8(self, name, value=None, align=None):
"""Add an unsigned 1 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(1, name, value, align) | python | def u8(self, name, value=None, align=None):
"""Add an unsigned 1 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(1, name, value, align) | [
"def",
"u8",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
",",
"align",
"=",
"None",
")",
":",
"self",
".",
"uint",
"(",
"1",
",",
"name",
",",
"value",
",",
"align",
")"
] | Add an unsigned 1 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length. | [
"Add",
"an",
"unsigned",
"1",
"byte",
"integer",
"field",
"to",
"template",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/rammbock.py#L68-L72 | train |
robotframework/Rammbock | src/Rammbock/rammbock.py | Rammbock.u16 | def u16(self, name, value=None, align=None):
"""Add an unsigned 2 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(2, name, value, align) | python | def u16(self, name, value=None, align=None):
"""Add an unsigned 2 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(2, name, value, align) | [
"def",
"u16",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
",",
"align",
"=",
"None",
")",
":",
"self",
".",
"uint",
"(",
"2",
",",
"name",
",",
"value",
",",
"align",
")"
] | Add an unsigned 2 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length. | [
"Add",
"an",
"unsigned",
"2",
"byte",
"integer",
"field",
"to",
"template",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/rammbock.py#L74-L78 | train |
robotframework/Rammbock | src/Rammbock/rammbock.py | Rammbock.u24 | def u24(self, name, value=None, align=None):
"""Add an unsigned 3 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(3, name, value, align) | python | def u24(self, name, value=None, align=None):
"""Add an unsigned 3 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(3, name, value, align) | [
"def",
"u24",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
",",
"align",
"=",
"None",
")",
":",
"self",
".",
"uint",
"(",
"3",
",",
"name",
",",
"value",
",",
"align",
")"
] | Add an unsigned 3 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length. | [
"Add",
"an",
"unsigned",
"3",
"byte",
"integer",
"field",
"to",
"template",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/rammbock.py#L80-L84 | train |
robotframework/Rammbock | src/Rammbock/rammbock.py | Rammbock.u32 | def u32(self, name, value=None, align=None):
"""Add an unsigned 4 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(4, name, value, align) | python | def u32(self, name, value=None, align=None):
"""Add an unsigned 4 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(4, name, value, align) | [
"def",
"u32",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
",",
"align",
"=",
"None",
")",
":",
"self",
".",
"uint",
"(",
"4",
",",
"name",
",",
"value",
",",
"align",
")"
] | Add an unsigned 4 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length. | [
"Add",
"an",
"unsigned",
"4",
"byte",
"integer",
"field",
"to",
"template",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/rammbock.py#L86-L90 | train |
robotframework/Rammbock | src/Rammbock/rammbock.py | Rammbock.u40 | def u40(self, name, value=None, align=None):
"""Add an unsigned 5 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(5, name, value, align) | python | def u40(self, name, value=None, align=None):
"""Add an unsigned 5 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(5, name, value, align) | [
"def",
"u40",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
",",
"align",
"=",
"None",
")",
":",
"self",
".",
"uint",
"(",
"5",
",",
"name",
",",
"value",
",",
"align",
")"
] | Add an unsigned 5 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length. | [
"Add",
"an",
"unsigned",
"5",
"byte",
"integer",
"field",
"to",
"template",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/rammbock.py#L92-L96 | train |
robotframework/Rammbock | src/Rammbock/rammbock.py | Rammbock.u64 | def u64(self, name, value=None, align=None):
"""Add an unsigned 8 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(8, name, value, align) | python | def u64(self, name, value=None, align=None):
"""Add an unsigned 8 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(8, name, value, align) | [
"def",
"u64",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
",",
"align",
"=",
"None",
")",
":",
"self",
".",
"uint",
"(",
"8",
",",
"name",
",",
"value",
",",
"align",
")"
] | Add an unsigned 8 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length. | [
"Add",
"an",
"unsigned",
"8",
"byte",
"integer",
"field",
"to",
"template",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/rammbock.py#L98-L102 | train |
robotframework/Rammbock | src/Rammbock/rammbock.py | Rammbock.u128 | def u128(self, name, value=None, align=None):
"""Add an unsigned 16 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(16, name, value, align) | python | def u128(self, name, value=None, align=None):
"""Add an unsigned 16 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(16, name, value, align) | [
"def",
"u128",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
",",
"align",
"=",
"None",
")",
":",
"self",
".",
"uint",
"(",
"16",
",",
"name",
",",
"value",
",",
"align",
")"
] | Add an unsigned 16 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length. | [
"Add",
"an",
"unsigned",
"16",
"byte",
"integer",
"field",
"to",
"template",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/rammbock.py#L104-L108 | train |
robotframework/Rammbock | src/Rammbock/rammbock.py | Rammbock.i8 | def i8(self, name, value=None, align=None):
"""Add an 1 byte integer field to template.
This is an convenience method that simply calls `Int` keyword with predefined length."""
self.int(1, name, value, align) | python | def i8(self, name, value=None, align=None):
"""Add an 1 byte integer field to template.
This is an convenience method that simply calls `Int` keyword with predefined length."""
self.int(1, name, value, align) | [
"def",
"i8",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
",",
"align",
"=",
"None",
")",
":",
"self",
".",
"int",
"(",
"1",
",",
"name",
",",
"value",
",",
"align",
")"
] | Add an 1 byte integer field to template.
This is an convenience method that simply calls `Int` keyword with predefined length. | [
"Add",
"an",
"1",
"byte",
"integer",
"field",
"to",
"template",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/rammbock.py#L110-L114 | train |
robotframework/Rammbock | src/Rammbock/rammbock.py | Rammbock.i32 | def i32(self, name, value=None, align=None):
"""Add an 32 byte integer field to template.
This is an convenience method that simply calls `Int` keyword with predefined length."""
self.int(4, name, value, align) | python | def i32(self, name, value=None, align=None):
"""Add an 32 byte integer field to template.
This is an convenience method that simply calls `Int` keyword with predefined length."""
self.int(4, name, value, align) | [
"def",
"i32",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
",",
"align",
"=",
"None",
")",
":",
"self",
".",
"int",
"(",
"4",
",",
"name",
",",
"value",
",",
"align",
")"
] | Add an 32 byte integer field to template.
This is an convenience method that simply calls `Int` keyword with predefined length. | [
"Add",
"an",
"32",
"byte",
"integer",
"field",
"to",
"template",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/rammbock.py#L116-L120 | train |
robotframework/Rammbock | src/Rammbock/rammbock.py | Rammbock.array | def array(self, size, type, name, *parameters):
"""Define a new array of given `size` and containing fields of type `type`.
`name` if the name of this array element. The `type` is the name of keyword that is executed as the contents of
the array and optional extra parameters are passed as argum... | python | def array(self, size, type, name, *parameters):
"""Define a new array of given `size` and containing fields of type `type`.
`name` if the name of this array element. The `type` is the name of keyword that is executed as the contents of
the array and optional extra parameters are passed as argum... | [
"def",
"array",
"(",
"self",
",",
"size",
",",
"type",
",",
"name",
",",
"*",
"parameters",
")",
":",
"self",
".",
"_new_list",
"(",
"size",
",",
"name",
")",
"BuiltIn",
"(",
")",
".",
"run_keyword",
"(",
"type",
",",
"''",
",",
"*",
"parameters",
... | Define a new array of given `size` and containing fields of type `type`.
`name` if the name of this array element. The `type` is the name of keyword that is executed as the contents of
the array and optional extra parameters are passed as arguments to this keyword.
Examples:
| Array | ... | [
"Define",
"a",
"new",
"array",
"of",
"given",
"size",
"and",
"containing",
"fields",
"of",
"type",
"type",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/rammbock.py#L122-L136 | train |
robotframework/Rammbock | src/Rammbock/rammbock.py | Rammbock.container | def container(self, name, length, type, *parameters):
"""Define a container with given length.
This is a convenience method creating a `Struct` with `length` containing fields defined in `type`.
"""
self.new_struct('Container', name, 'length=%s' % length)
BuiltIn().run_keyword(t... | python | def container(self, name, length, type, *parameters):
"""Define a container with given length.
This is a convenience method creating a `Struct` with `length` containing fields defined in `type`.
"""
self.new_struct('Container', name, 'length=%s' % length)
BuiltIn().run_keyword(t... | [
"def",
"container",
"(",
"self",
",",
"name",
",",
"length",
",",
"type",
",",
"*",
"parameters",
")",
":",
"self",
".",
"new_struct",
"(",
"'Container'",
",",
"name",
",",
"'length=%s'",
"%",
"length",
")",
"BuiltIn",
"(",
")",
".",
"run_keyword",
"("... | Define a container with given length.
This is a convenience method creating a `Struct` with `length` containing fields defined in `type`. | [
"Define",
"a",
"container",
"with",
"given",
"length",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/rammbock.py#L138-L145 | train |
robotframework/Rammbock | src/Rammbock/rammbock.py | Rammbock.case | def case(self, size, kw, *parameters):
"""An element inside a bag started with `Start Bag`.
The first argument is size which can be absolute value like `1`, a range
like `0-3`, or just `*` to accept any number of elements.
Examples:
| Start bag | intBag |
| case | 0-1 |... | python | def case(self, size, kw, *parameters):
"""An element inside a bag started with `Start Bag`.
The first argument is size which can be absolute value like `1`, a range
like `0-3`, or just `*` to accept any number of elements.
Examples:
| Start bag | intBag |
| case | 0-1 |... | [
"def",
"case",
"(",
"self",
",",
"size",
",",
"kw",
",",
"*",
"parameters",
")",
":",
"self",
".",
"_start_bag_case",
"(",
"size",
")",
"BuiltIn",
"(",
")",
".",
"run_keyword",
"(",
"kw",
",",
"*",
"parameters",
")",
"self",
".",
"_end_bag_case",
"("... | An element inside a bag started with `Start Bag`.
The first argument is size which can be absolute value like `1`, a range
like `0-3`, or just `*` to accept any number of elements.
Examples:
| Start bag | intBag |
| case | 0-1 | u8 | foo | 42 |
| case | 0-2 | u8 | bar |... | [
"An",
"element",
"inside",
"a",
"bag",
"started",
"with",
"Start",
"Bag",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/rammbock.py#L147-L162 | train |
robotframework/Rammbock | src/Rammbock/rammbock.py | Rammbock.embed_seqdiag_sequence | def embed_seqdiag_sequence(self):
"""Create a message sequence diagram png file to output folder and embed the image to log file.
You need to have seqdiag installed to create the sequence diagram. See http://blockdiag.com/en/seqdiag/
"""
test_name = BuiltIn().replace_variables('${TEST N... | python | def embed_seqdiag_sequence(self):
"""Create a message sequence diagram png file to output folder and embed the image to log file.
You need to have seqdiag installed to create the sequence diagram. See http://blockdiag.com/en/seqdiag/
"""
test_name = BuiltIn().replace_variables('${TEST N... | [
"def",
"embed_seqdiag_sequence",
"(",
"self",
")",
":",
"test_name",
"=",
"BuiltIn",
"(",
")",
".",
"replace_variables",
"(",
"'${TEST NAME}'",
")",
"outputdir",
"=",
"BuiltIn",
"(",
")",
".",
"replace_variables",
"(",
"'${OUTPUTDIR}'",
")",
"path",
"=",
"os",... | Create a message sequence diagram png file to output folder and embed the image to log file.
You need to have seqdiag installed to create the sequence diagram. See http://blockdiag.com/en/seqdiag/ | [
"Create",
"a",
"message",
"sequence",
"diagram",
"png",
"file",
"to",
"output",
"folder",
"and",
"embed",
"the",
"image",
"to",
"log",
"file",
"."
] | c906058d055a6f7c68fe1a6096d78c2e3f642b1c | https://github.com/robotframework/Rammbock/blob/c906058d055a6f7c68fe1a6096d78c2e3f642b1c/src/Rammbock/rammbock.py#L164-L172 | train |
Duke-GCB/DukeDSClient | ddsc/ddsclient.py | DDSClient._check_pypi_version | def _check_pypi_version(self):
"""
When the version is out of date or we have trouble retrieving it print a error to stderr and pause.
"""
try:
check_version()
except VersionException as err:
print(str(err), file=sys.stderr)
time.sleep(TWO_SECO... | python | def _check_pypi_version(self):
"""
When the version is out of date or we have trouble retrieving it print a error to stderr and pause.
"""
try:
check_version()
except VersionException as err:
print(str(err), file=sys.stderr)
time.sleep(TWO_SECO... | [
"def",
"_check_pypi_version",
"(",
"self",
")",
":",
"try",
":",
"check_version",
"(",
")",
"except",
"VersionException",
"as",
"err",
":",
"print",
"(",
"str",
"(",
"err",
")",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"time",
".",
"sleep",
"(",
... | When the version is out of date or we have trouble retrieving it print a error to stderr and pause. | [
"When",
"the",
"version",
"is",
"out",
"of",
"date",
"or",
"we",
"have",
"trouble",
"retrieving",
"it",
"print",
"a",
"error",
"to",
"stderr",
"and",
"pause",
"."
] | 117f68fb9bae82e4c81ea487ad5d61ac350f3726 | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/ddsclient.py#L63-L71 | train |
twisted/txaws | txaws/client/ssl.py | get_ca_certs | def get_ca_certs(environ=os.environ):
"""
Retrieve a list of CAs at either the DEFAULT_CERTS_PATH or the env
override, TXAWS_CERTS_PATH.
In order to find .pem files, this function checks first for presence of the
TXAWS_CERTS_PATH environment variable that should point to a directory
containing ... | python | def get_ca_certs(environ=os.environ):
"""
Retrieve a list of CAs at either the DEFAULT_CERTS_PATH or the env
override, TXAWS_CERTS_PATH.
In order to find .pem files, this function checks first for presence of the
TXAWS_CERTS_PATH environment variable that should point to a directory
containing ... | [
"def",
"get_ca_certs",
"(",
"environ",
"=",
"os",
".",
"environ",
")",
":",
"cert_paths",
"=",
"environ",
".",
"get",
"(",
"\"TXAWS_CERTS_PATH\"",
",",
"DEFAULT_CERTS_PATH",
")",
".",
"split",
"(",
"\":\"",
")",
"certificate_authority_map",
"=",
"{",
"}",
"f... | Retrieve a list of CAs at either the DEFAULT_CERTS_PATH or the env
override, TXAWS_CERTS_PATH.
In order to find .pem files, this function checks first for presence of the
TXAWS_CERTS_PATH environment variable that should point to a directory
containing cert files. In the absense of this variable, the m... | [
"Retrieve",
"a",
"list",
"of",
"CAs",
"at",
"either",
"the",
"DEFAULT_CERTS_PATH",
"or",
"the",
"env",
"override",
"TXAWS_CERTS_PATH",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/client/ssl.py#L86-L119 | train |
twisted/txaws | txaws/util.py | iso8601time | def iso8601time(time_tuple):
"""Format time_tuple as a ISO8601 time string.
:param time_tuple: Either None, to use the current time, or a tuple tuple.
"""
if time_tuple:
return time.strftime("%Y-%m-%dT%H:%M:%SZ", time_tuple)
else:
return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmti... | python | def iso8601time(time_tuple):
"""Format time_tuple as a ISO8601 time string.
:param time_tuple: Either None, to use the current time, or a tuple tuple.
"""
if time_tuple:
return time.strftime("%Y-%m-%dT%H:%M:%SZ", time_tuple)
else:
return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmti... | [
"def",
"iso8601time",
"(",
"time_tuple",
")",
":",
"if",
"time_tuple",
":",
"return",
"time",
".",
"strftime",
"(",
"\"%Y-%m-%dT%H:%M:%SZ\"",
",",
"time_tuple",
")",
"else",
":",
"return",
"time",
".",
"strftime",
"(",
"\"%Y-%m-%dT%H:%M:%SZ\"",
",",
"time",
".... | Format time_tuple as a ISO8601 time string.
:param time_tuple: Either None, to use the current time, or a tuple tuple. | [
"Format",
"time_tuple",
"as",
"a",
"ISO8601",
"time",
"string",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/util.py#L39-L47 | train |
twisted/txaws | txaws/util.py | parse | def parse(url, defaultPort=True):
"""
Split the given URL into the scheme, host, port, and path.
@type url: C{str}
@param url: An URL to parse.
@type defaultPort: C{bool}
@param defaultPort: Whether to return the default port associated with the
scheme in the given url, when the url do... | python | def parse(url, defaultPort=True):
"""
Split the given URL into the scheme, host, port, and path.
@type url: C{str}
@param url: An URL to parse.
@type defaultPort: C{bool}
@param defaultPort: Whether to return the default port associated with the
scheme in the given url, when the url do... | [
"def",
"parse",
"(",
"url",
",",
"defaultPort",
"=",
"True",
")",
":",
"url",
"=",
"url",
".",
"strip",
"(",
")",
"parsed",
"=",
"urlparse",
"(",
"url",
")",
"scheme",
"=",
"parsed",
"[",
"0",
"]",
"path",
"=",
"urlunparse",
"(",
"(",
"\"\"",
","... | Split the given URL into the scheme, host, port, and path.
@type url: C{str}
@param url: An URL to parse.
@type defaultPort: C{bool}
@param defaultPort: Whether to return the default port associated with the
scheme in the given url, when the url doesn't specify one.
@return: A four-tuple ... | [
"Split",
"the",
"given",
"URL",
"into",
"the",
"scheme",
"host",
"port",
"and",
"path",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/util.py#L64-L103 | train |
Duke-GCB/DukeDSClient | ddsc/core/ddsapi.py | DataServiceAuth.claim_new_token | def claim_new_token(self):
"""
Update internal state to have a new token using a no authorization data service.
"""
# Intentionally doing this manually so we don't have a chicken and egg problem with DataServiceApi.
headers = {
'Content-Type': ContentType.json,
... | python | def claim_new_token(self):
"""
Update internal state to have a new token using a no authorization data service.
"""
# Intentionally doing this manually so we don't have a chicken and egg problem with DataServiceApi.
headers = {
'Content-Type': ContentType.json,
... | [
"def",
"claim_new_token",
"(",
"self",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"ContentType",
".",
"json",
",",
"'User-Agent'",
":",
"self",
".",
"user_agent_str",
",",
"}",
"data",
"=",
"{",
"\"agent_key\"",
":",
"self",
".",
"config",
".",
... | Update internal state to have a new token using a no authorization data service. | [
"Update",
"internal",
"state",
"to",
"have",
"a",
"new",
"token",
"using",
"a",
"no",
"authorization",
"data",
"service",
"."
] | 117f68fb9bae82e4c81ea487ad5d61ac350f3726 | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/ddsapi.py#L94-L121 | train |
twisted/txaws | txaws/server/resource.py | QueryAPI.handle | def handle(self, request):
"""Handle an HTTP request for executing an API call.
This method authenticates the request checking its signature, and then
calls the C{execute} method, passing it a L{Call} object set with the
principal for the authenticated user and the generic parameters
... | python | def handle(self, request):
"""Handle an HTTP request for executing an API call.
This method authenticates the request checking its signature, and then
calls the C{execute} method, passing it a L{Call} object set with the
principal for the authenticated user and the generic parameters
... | [
"def",
"handle",
"(",
"self",
",",
"request",
")",
":",
"request",
".",
"id",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"deferred",
"=",
"maybeDeferred",
"(",
"self",
".",
"_validate",
",",
"request",
")",
"deferred",
".",
"addCallback",
"(",
"self",
... | Handle an HTTP request for executing an API call.
This method authenticates the request checking its signature, and then
calls the C{execute} method, passing it a L{Call} object set with the
principal for the authenticated user and the generic parameters
extracted from the request.
... | [
"Handle",
"an",
"HTTP",
"request",
"for",
"executing",
"an",
"API",
"call",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/resource.py#L80-L130 | train |
twisted/txaws | txaws/server/resource.py | QueryAPI.get_call_arguments | def get_call_arguments(self, request):
"""
Get call arguments from a request. Override this if you want to use a
wire format different from AWS's.
The return value is a dictionary with three keys: 'transport_args',
'handler_args', and 'raw_args'.
The value of 'transport... | python | def get_call_arguments(self, request):
"""
Get call arguments from a request. Override this if you want to use a
wire format different from AWS's.
The return value is a dictionary with three keys: 'transport_args',
'handler_args', and 'raw_args'.
The value of 'transport... | [
"def",
"get_call_arguments",
"(",
"self",
",",
"request",
")",
":",
"params",
"=",
"dict",
"(",
"(",
"k",
",",
"v",
"[",
"-",
"1",
"]",
")",
"for",
"k",
",",
"v",
"in",
"request",
".",
"args",
".",
"iteritems",
"(",
")",
")",
"args",
",",
"rest... | Get call arguments from a request. Override this if you want to use a
wire format different from AWS's.
The return value is a dictionary with three keys: 'transport_args',
'handler_args', and 'raw_args'.
The value of 'transport_args' must be a dictionary with the following
keys... | [
"Get",
"call",
"arguments",
"from",
"a",
"request",
".",
"Override",
"this",
"if",
"you",
"want",
"to",
"use",
"a",
"wire",
"format",
"different",
"from",
"AWS",
"s",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/resource.py#L169-L214 | train |
twisted/txaws | txaws/server/resource.py | QueryAPI._validate_generic_parameters | def _validate_generic_parameters(self, args):
"""Validate the generic request parameters.
@param args: Parsed schema arguments.
@raises APIError: In the following cases:
- Action is not included in C{self.actions}
- SignatureVersion is not included in C{self.signature_ve... | python | def _validate_generic_parameters(self, args):
"""Validate the generic request parameters.
@param args: Parsed schema arguments.
@raises APIError: In the following cases:
- Action is not included in C{self.actions}
- SignatureVersion is not included in C{self.signature_ve... | [
"def",
"_validate_generic_parameters",
"(",
"self",
",",
"args",
")",
":",
"utc_now",
"=",
"self",
".",
"get_utc_time",
"(",
")",
"if",
"getattr",
"(",
"self",
",",
"\"actions\"",
",",
"None",
")",
"is",
"not",
"None",
":",
"if",
"not",
"args",
"[",
"\... | Validate the generic request parameters.
@param args: Parsed schema arguments.
@raises APIError: In the following cases:
- Action is not included in C{self.actions}
- SignatureVersion is not included in C{self.signature_versions}
- Expires and Timestamp are present
... | [
"Validate",
"the",
"generic",
"request",
"parameters",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/resource.py#L251-L290 | train |
twisted/txaws | txaws/server/resource.py | QueryAPI._validate_signature | def _validate_signature(self, request, principal, args, params):
"""Validate the signature."""
creds = AWSCredentials(principal.access_key, principal.secret_key)
endpoint = AWSServiceEndpoint()
endpoint.set_method(request.method)
endpoint.set_canonical_host(request.getHeader("Hos... | python | def _validate_signature(self, request, principal, args, params):
"""Validate the signature."""
creds = AWSCredentials(principal.access_key, principal.secret_key)
endpoint = AWSServiceEndpoint()
endpoint.set_method(request.method)
endpoint.set_canonical_host(request.getHeader("Hos... | [
"def",
"_validate_signature",
"(",
"self",
",",
"request",
",",
"principal",
",",
"args",
",",
"params",
")",
":",
"creds",
"=",
"AWSCredentials",
"(",
"principal",
".",
"access_key",
",",
"principal",
".",
"secret_key",
")",
"endpoint",
"=",
"AWSServiceEndpoi... | Validate the signature. | [
"Validate",
"the",
"signature",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/resource.py#L299-L317 | train |
twisted/txaws | txaws/server/resource.py | QueryAPI.render_GET | def render_GET(self, request):
"""Handle a GET request."""
if not request.args:
request.setHeader("Content-Type", "text/plain")
return self.get_status_text()
else:
self.handle(request)
return NOT_DONE_YET | python | def render_GET(self, request):
"""Handle a GET request."""
if not request.args:
request.setHeader("Content-Type", "text/plain")
return self.get_status_text()
else:
self.handle(request)
return NOT_DONE_YET | [
"def",
"render_GET",
"(",
"self",
",",
"request",
")",
":",
"if",
"not",
"request",
".",
"args",
":",
"request",
".",
"setHeader",
"(",
"\"Content-Type\"",
",",
"\"text/plain\"",
")",
"return",
"self",
".",
"get_status_text",
"(",
")",
"else",
":",
"self",... | Handle a GET request. | [
"Handle",
"a",
"GET",
"request",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/server/resource.py#L323-L330 | train |
twisted/txaws | txaws/_auth_v4.py | getSignatureKey | def getSignatureKey(key, dateStamp, regionName, serviceName):
"""
Generate the signing key for AWS V4 requests.
@param key: The secret key to use.
@type key: L{bytes}
@param dateStamp: The UTC date and time, serialized as an AWS date
stamp.
@type dateStamp: L{bytes}
@param regionN... | python | def getSignatureKey(key, dateStamp, regionName, serviceName):
"""
Generate the signing key for AWS V4 requests.
@param key: The secret key to use.
@type key: L{bytes}
@param dateStamp: The UTC date and time, serialized as an AWS date
stamp.
@type dateStamp: L{bytes}
@param regionN... | [
"def",
"getSignatureKey",
"(",
"key",
",",
"dateStamp",
",",
"regionName",
",",
"serviceName",
")",
":",
"kDate",
"=",
"sign",
"(",
"(",
"b'AWS4'",
"+",
"key",
")",
",",
"dateStamp",
")",
"kRegion",
"=",
"sign",
"(",
"kDate",
",",
"regionName",
")",
"k... | Generate the signing key for AWS V4 requests.
@param key: The secret key to use.
@type key: L{bytes}
@param dateStamp: The UTC date and time, serialized as an AWS date
stamp.
@type dateStamp: L{bytes}
@param regionName: The name of the region.
@type regionName: L{bytes}
@param se... | [
"Generate",
"the",
"signing",
"key",
"for",
"AWS",
"V4",
"requests",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/_auth_v4.py#L29-L54 | train |
twisted/txaws | txaws/_auth_v4.py | _make_canonical_uri | def _make_canonical_uri(parsed):
"""
Return the canonical URI for a parsed URL.
@param parsed: The parsed URL from which to extract the canonical
URI
@type parsed: L{urlparse.ParseResult}
@return: The canonical URI.
@rtype: L{str}
"""
path = urllib.quote(parsed.path)
canoni... | python | def _make_canonical_uri(parsed):
"""
Return the canonical URI for a parsed URL.
@param parsed: The parsed URL from which to extract the canonical
URI
@type parsed: L{urlparse.ParseResult}
@return: The canonical URI.
@rtype: L{str}
"""
path = urllib.quote(parsed.path)
canoni... | [
"def",
"_make_canonical_uri",
"(",
"parsed",
")",
":",
"path",
"=",
"urllib",
".",
"quote",
"(",
"parsed",
".",
"path",
")",
"canonical_parsed",
"=",
"parsed",
".",
"_replace",
"(",
"path",
"=",
"path",
",",
"params",
"=",
"''",
",",
"query",
"=",
"''"... | Return the canonical URI for a parsed URL.
@param parsed: The parsed URL from which to extract the canonical
URI
@type parsed: L{urlparse.ParseResult}
@return: The canonical URI.
@rtype: L{str} | [
"Return",
"the",
"canonical",
"URI",
"for",
"a",
"parsed",
"URL",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/_auth_v4.py#L86-L100 | train |
twisted/txaws | txaws/_auth_v4.py | _make_canonical_query_string | def _make_canonical_query_string(parsed):
"""
Return the canonical query string for a parsed URL.
@param parsed: The parsed URL from which to extract the canonical
query string.
@type parsed: L{urlparse.ParseResult}
@return: The canonical query string.
@rtype: L{str}
"""
query_... | python | def _make_canonical_query_string(parsed):
"""
Return the canonical query string for a parsed URL.
@param parsed: The parsed URL from which to extract the canonical
query string.
@type parsed: L{urlparse.ParseResult}
@return: The canonical query string.
@rtype: L{str}
"""
query_... | [
"def",
"_make_canonical_query_string",
"(",
"parsed",
")",
":",
"query_params",
"=",
"urlparse",
".",
"parse_qs",
"(",
"parsed",
".",
"query",
",",
"keep_blank_values",
"=",
"True",
")",
"sorted_query_params",
"=",
"sorted",
"(",
"(",
"k",
",",
"v",
")",
"fo... | Return the canonical query string for a parsed URL.
@param parsed: The parsed URL from which to extract the canonical
query string.
@type parsed: L{urlparse.ParseResult}
@return: The canonical query string.
@rtype: L{str} | [
"Return",
"the",
"canonical",
"query",
"string",
"for",
"a",
"parsed",
"URL",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/_auth_v4.py#L103-L118 | train |
twisted/txaws | txaws/_auth_v4.py | _make_canonical_headers | def _make_canonical_headers(headers, headers_to_sign):
"""
Return canonicalized headers.
@param headers: The request headers.
@type headers: L{dict}
@param headers_to_sign: A sequence of header names that should be
signed.
@type headers_to_sign: A sequence of L{bytes}
@return: The... | python | def _make_canonical_headers(headers, headers_to_sign):
"""
Return canonicalized headers.
@param headers: The request headers.
@type headers: L{dict}
@param headers_to_sign: A sequence of header names that should be
signed.
@type headers_to_sign: A sequence of L{bytes}
@return: The... | [
"def",
"_make_canonical_headers",
"(",
"headers",
",",
"headers_to_sign",
")",
":",
"pairs",
"=",
"[",
"]",
"for",
"name",
"in",
"headers_to_sign",
":",
"if",
"name",
"not",
"in",
"headers",
":",
"continue",
"values",
"=",
"headers",
"[",
"name",
"]",
"if"... | Return canonicalized headers.
@param headers: The request headers.
@type headers: L{dict}
@param headers_to_sign: A sequence of header names that should be
signed.
@type headers_to_sign: A sequence of L{bytes}
@return: The canonicalized headers.
@rtype: L{bytes} | [
"Return",
"canonicalized",
"headers",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/_auth_v4.py#L121-L149 | train |
twisted/txaws | txaws/_auth_v4.py | _make_signed_headers | def _make_signed_headers(headers, headers_to_sign):
"""
Return a semicolon-delimited list of headers to sign.
@param headers: The request headers.
@type headers: L{dict}
@param headers_to_sign: A sequence of header names that should be
signed.
@type headers_to_sign: L{bytes}
@retu... | python | def _make_signed_headers(headers, headers_to_sign):
"""
Return a semicolon-delimited list of headers to sign.
@param headers: The request headers.
@type headers: L{dict}
@param headers_to_sign: A sequence of header names that should be
signed.
@type headers_to_sign: L{bytes}
@retu... | [
"def",
"_make_signed_headers",
"(",
"headers",
",",
"headers_to_sign",
")",
":",
"return",
"b\";\"",
".",
"join",
"(",
"header",
".",
"lower",
"(",
")",
"for",
"header",
"in",
"sorted",
"(",
"headers_to_sign",
")",
"if",
"header",
"in",
"headers",
")"
] | Return a semicolon-delimited list of headers to sign.
@param headers: The request headers.
@type headers: L{dict}
@param headers_to_sign: A sequence of header names that should be
signed.
@type headers_to_sign: L{bytes}
@return: The semicolon-delimited list of headers.
@rtype: L{bytes... | [
"Return",
"a",
"semicolon",
"-",
"delimited",
"list",
"of",
"headers",
"to",
"sign",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/_auth_v4.py#L152-L167 | train |
T-002/pycast | pycast/common/helper.py | linear_interpolation | def linear_interpolation(first, last, steps):
"""Interpolates all missing values using linear interpolation.
:param numeric first: Start value for the interpolation.
:param numeric last: End Value for the interpolation
:param integer steps: Number of missing values that have to be calculated.
... | python | def linear_interpolation(first, last, steps):
"""Interpolates all missing values using linear interpolation.
:param numeric first: Start value for the interpolation.
:param numeric last: End Value for the interpolation
:param integer steps: Number of missing values that have to be calculated.
... | [
"def",
"linear_interpolation",
"(",
"first",
",",
"last",
",",
"steps",
")",
":",
"result",
"=",
"[",
"]",
"for",
"step",
"in",
"xrange",
"(",
"0",
",",
"steps",
")",
":",
"fpart",
"=",
"(",
"steps",
"-",
"step",
")",
"*",
"first",
"lpart",
"=",
... | Interpolates all missing values using linear interpolation.
:param numeric first: Start value for the interpolation.
:param numeric last: End Value for the interpolation
:param integer steps: Number of missing values that have to be calculated.
:return: Returns a list of floats containing ... | [
"Interpolates",
"all",
"missing",
"values",
"using",
"linear",
"interpolation",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/helper.py#L27-L47 | train |
Duke-GCB/DukeDSClient | ddsc/core/projectuploader.py | ProjectUploader.visit_file | def visit_file(self, item, parent):
"""
If file is large add it to the large items to be processed after small task list.
else file is small add it to the small task list.
"""
if self.is_large_file(item):
self.large_items.append((item, parent))
else:
... | python | def visit_file(self, item, parent):
"""
If file is large add it to the large items to be processed after small task list.
else file is small add it to the small task list.
"""
if self.is_large_file(item):
self.large_items.append((item, parent))
else:
... | [
"def",
"visit_file",
"(",
"self",
",",
"item",
",",
"parent",
")",
":",
"if",
"self",
".",
"is_large_file",
"(",
"item",
")",
":",
"self",
".",
"large_items",
".",
"append",
"(",
"(",
"item",
",",
"parent",
")",
")",
"else",
":",
"self",
".",
"smal... | If file is large add it to the large items to be processed after small task list.
else file is small add it to the small task list. | [
"If",
"file",
"is",
"large",
"add",
"it",
"to",
"the",
"large",
"items",
"to",
"be",
"processed",
"after",
"small",
"task",
"list",
".",
"else",
"file",
"is",
"small",
"add",
"it",
"to",
"the",
"small",
"task",
"list",
"."
] | 117f68fb9bae82e4c81ea487ad5d61ac350f3726 | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/projectuploader.py#L134-L142 | train |
Duke-GCB/DukeDSClient | ddsc/core/projectuploader.py | ProjectUploader.upload_large_items | def upload_large_items(self):
"""
Upload files that were too large.
"""
for local_file, parent in self.large_items:
if local_file.need_to_send:
self.process_large_file(local_file, parent) | python | def upload_large_items(self):
"""
Upload files that were too large.
"""
for local_file, parent in self.large_items:
if local_file.need_to_send:
self.process_large_file(local_file, parent) | [
"def",
"upload_large_items",
"(",
"self",
")",
":",
"for",
"local_file",
",",
"parent",
"in",
"self",
".",
"large_items",
":",
"if",
"local_file",
".",
"need_to_send",
":",
"self",
".",
"process_large_file",
"(",
"local_file",
",",
"parent",
")"
] | Upload files that were too large. | [
"Upload",
"files",
"that",
"were",
"too",
"large",
"."
] | 117f68fb9bae82e4c81ea487ad5d61ac350f3726 | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/projectuploader.py#L147-L153 | train |
Duke-GCB/DukeDSClient | ddsc/core/projectuploader.py | SmallItemUploadTaskBuilder.visit_project | def visit_project(self, item):
"""
Adds create project command to task runner if project doesn't already exist.
"""
if not item.remote_id:
command = CreateProjectCommand(self.settings, item)
self.task_runner_add(None, item, command)
else:
self.... | python | def visit_project(self, item):
"""
Adds create project command to task runner if project doesn't already exist.
"""
if not item.remote_id:
command = CreateProjectCommand(self.settings, item)
self.task_runner_add(None, item, command)
else:
self.... | [
"def",
"visit_project",
"(",
"self",
",",
"item",
")",
":",
"if",
"not",
"item",
".",
"remote_id",
":",
"command",
"=",
"CreateProjectCommand",
"(",
"self",
".",
"settings",
",",
"item",
")",
"self",
".",
"task_runner_add",
"(",
"None",
",",
"item",
",",... | Adds create project command to task runner if project doesn't already exist. | [
"Adds",
"create",
"project",
"command",
"to",
"task",
"runner",
"if",
"project",
"doesn",
"t",
"already",
"exist",
"."
] | 117f68fb9bae82e4c81ea487ad5d61ac350f3726 | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/projectuploader.py#L186-L194 | train |
Duke-GCB/DukeDSClient | ddsc/core/projectuploader.py | SmallItemUploadTaskBuilder.visit_folder | def visit_folder(self, item, parent):
"""
Adds create folder command to task runner if folder doesn't already exist.
"""
if not item.remote_id:
command = CreateFolderCommand(self.settings, item, parent)
self.task_runner_add(parent, item, command) | python | def visit_folder(self, item, parent):
"""
Adds create folder command to task runner if folder doesn't already exist.
"""
if not item.remote_id:
command = CreateFolderCommand(self.settings, item, parent)
self.task_runner_add(parent, item, command) | [
"def",
"visit_folder",
"(",
"self",
",",
"item",
",",
"parent",
")",
":",
"if",
"not",
"item",
".",
"remote_id",
":",
"command",
"=",
"CreateFolderCommand",
"(",
"self",
".",
"settings",
",",
"item",
",",
"parent",
")",
"self",
".",
"task_runner_add",
"(... | Adds create folder command to task runner if folder doesn't already exist. | [
"Adds",
"create",
"folder",
"command",
"to",
"task",
"runner",
"if",
"folder",
"doesn",
"t",
"already",
"exist",
"."
] | 117f68fb9bae82e4c81ea487ad5d61ac350f3726 | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/projectuploader.py#L196-L202 | train |
Duke-GCB/DukeDSClient | ddsc/core/projectuploader.py | SmallItemUploadTaskBuilder.visit_file | def visit_file(self, item, parent):
"""
If file is small add create small file command otherwise raise error.
Large files shouldn't be passed to SmallItemUploadTaskBuilder.
"""
if item.need_to_send:
if item.size > self.settings.config.upload_bytes_per_chunk:
... | python | def visit_file(self, item, parent):
"""
If file is small add create small file command otherwise raise error.
Large files shouldn't be passed to SmallItemUploadTaskBuilder.
"""
if item.need_to_send:
if item.size > self.settings.config.upload_bytes_per_chunk:
... | [
"def",
"visit_file",
"(",
"self",
",",
"item",
",",
"parent",
")",
":",
"if",
"item",
".",
"need_to_send",
":",
"if",
"item",
".",
"size",
">",
"self",
".",
"settings",
".",
"config",
".",
"upload_bytes_per_chunk",
":",
"msg",
"=",
"\"Programmer Error: Try... | If file is small add create small file command otherwise raise error.
Large files shouldn't be passed to SmallItemUploadTaskBuilder. | [
"If",
"file",
"is",
"small",
"add",
"create",
"small",
"file",
"command",
"otherwise",
"raise",
"error",
".",
"Large",
"files",
"shouldn",
"t",
"be",
"passed",
"to",
"SmallItemUploadTaskBuilder",
"."
] | 117f68fb9bae82e4c81ea487ad5d61ac350f3726 | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/projectuploader.py#L204-L216 | train |
pdkit/pdkit | pdkit/tremor_processor.py | TremorProcessor.bradykinesia | def bradykinesia(self, data_frame, method='fft'):
"""
This method calculates the bradykinesia amplitude of the data frame. It accepts two different methods, \
'fft' and 'welch'. First the signal gets re-sampled, dc removed and then high pass filtered.
:param data_frame: the ... | python | def bradykinesia(self, data_frame, method='fft'):
"""
This method calculates the bradykinesia amplitude of the data frame. It accepts two different methods, \
'fft' and 'welch'. First the signal gets re-sampled, dc removed and then high pass filtered.
:param data_frame: the ... | [
"def",
"bradykinesia",
"(",
"self",
",",
"data_frame",
",",
"method",
"=",
"'fft'",
")",
":",
"try",
":",
"data_frame_resampled",
"=",
"self",
".",
"resample_signal",
"(",
"data_frame",
")",
"data_frame_dc",
"=",
"self",
".",
"dc_remove_signal",
"(",
"data_fra... | This method calculates the bradykinesia amplitude of the data frame. It accepts two different methods, \
'fft' and 'welch'. First the signal gets re-sampled, dc removed and then high pass filtered.
:param data_frame: the data frame
:type data_frame: pandas.DataFrame
:par... | [
"This",
"method",
"calculates",
"the",
"bradykinesia",
"amplitude",
"of",
"the",
"data",
"frame",
".",
"It",
"accepts",
"two",
"different",
"methods",
"\\",
"fft",
"and",
"welch",
".",
"First",
"the",
"signal",
"gets",
"re",
"-",
"sampled",
"dc",
"removed",
... | c7120263da2071bb139815fbdb56ca77b544f340 | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/tremor_processor.py#L571-L599 | train |
twisted/txaws | txaws/client/gui/gtk.py | main | def main(argv, reactor=None):
"""Run the client GUI.
Typical use:
>>> sys.exit(main(sys.argv))
@param argv: The arguments to run it with, e.g. sys.argv.
@param reactor: The reactor to use. Must be compatible with gtk as this
module uses gtk API"s.
@return exitcode: The exit code it ret... | python | def main(argv, reactor=None):
"""Run the client GUI.
Typical use:
>>> sys.exit(main(sys.argv))
@param argv: The arguments to run it with, e.g. sys.argv.
@param reactor: The reactor to use. Must be compatible with gtk as this
module uses gtk API"s.
@return exitcode: The exit code it ret... | [
"def",
"main",
"(",
"argv",
",",
"reactor",
"=",
"None",
")",
":",
"if",
"reactor",
"is",
"None",
":",
"from",
"twisted",
".",
"internet",
"import",
"gtk2reactor",
"gtk2reactor",
".",
"install",
"(",
")",
"from",
"twisted",
".",
"internet",
"import",
"re... | Run the client GUI.
Typical use:
>>> sys.exit(main(sys.argv))
@param argv: The arguments to run it with, e.g. sys.argv.
@param reactor: The reactor to use. Must be compatible with gtk as this
module uses gtk API"s.
@return exitcode: The exit code it returned, as per sys.exit. | [
"Run",
"the",
"client",
"GUI",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/client/gui/gtk.py#L233-L254 | train |
twisted/txaws | txaws/client/discover/entry_point.py | main | def main(arguments, output=None, testing_mode=None):
"""
Entry point parses command-line arguments, runs the specified EC2 API
method and prints the response to the screen.
@param arguments: Command-line arguments, typically retrieved from
C{sys.argv}.
@param output: Optionally, a stream to... | python | def main(arguments, output=None, testing_mode=None):
"""
Entry point parses command-line arguments, runs the specified EC2 API
method and prints the response to the screen.
@param arguments: Command-line arguments, typically retrieved from
C{sys.argv}.
@param output: Optionally, a stream to... | [
"def",
"main",
"(",
"arguments",
",",
"output",
"=",
"None",
",",
"testing_mode",
"=",
"None",
")",
":",
"def",
"run_command",
"(",
"arguments",
",",
"output",
",",
"reactor",
")",
":",
"if",
"output",
"is",
"None",
":",
"output",
"=",
"sys",
".",
"s... | Entry point parses command-line arguments, runs the specified EC2 API
method and prints the response to the screen.
@param arguments: Command-line arguments, typically retrieved from
C{sys.argv}.
@param output: Optionally, a stream to write output to.
@param testing_mode: Optionally, a conditio... | [
"Entry",
"point",
"parses",
"command",
"-",
"line",
"arguments",
"runs",
"the",
"specified",
"EC2",
"API",
"method",
"and",
"prints",
"the",
"response",
"to",
"the",
"screen",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/client/discover/entry_point.py#L142-L178 | train |
T-002/pycast | pycast/methods/exponentialsmoothing.py | ExponentialSmoothing.execute | def execute(self, timeSeries):
"""Creates a new TimeSeries containing the smoothed and forcasted values.
:return: TimeSeries object containing the smoothed TimeSeries,
including the forecasted values.
:rtype: TimeSeries
:note: The first normalized value is chosen a... | python | def execute(self, timeSeries):
"""Creates a new TimeSeries containing the smoothed and forcasted values.
:return: TimeSeries object containing the smoothed TimeSeries,
including the forecasted values.
:rtype: TimeSeries
:note: The first normalized value is chosen a... | [
"def",
"execute",
"(",
"self",
",",
"timeSeries",
")",
":",
"self",
".",
"_calculate_values_to_forecast",
"(",
"timeSeries",
")",
"alpha",
"=",
"self",
".",
"_parameters",
"[",
"\"smoothingFactor\"",
"]",
"valuesToForecast",
"=",
"self",
".",
"_parameters",
"[",... | Creates a new TimeSeries containing the smoothed and forcasted values.
:return: TimeSeries object containing the smoothed TimeSeries,
including the forecasted values.
:rtype: TimeSeries
:note: The first normalized value is chosen as the starting point. | [
"Creates",
"a",
"new",
"TimeSeries",
"containing",
"the",
"smoothed",
"and",
"forcasted",
"values",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/exponentialsmoothing.py#L77-L148 | train |
T-002/pycast | pycast/methods/exponentialsmoothing.py | HoltMethod._get_parameter_intervals | def _get_parameter_intervals(self):
"""Returns the intervals for the methods parameter.
Only parameters with defined intervals can be used for optimization!
:return: Returns a dictionary containing the parameter intervals, using the parameter
name as key, while the value hast th... | python | def _get_parameter_intervals(self):
"""Returns the intervals for the methods parameter.
Only parameters with defined intervals can be used for optimization!
:return: Returns a dictionary containing the parameter intervals, using the parameter
name as key, while the value hast th... | [
"def",
"_get_parameter_intervals",
"(",
"self",
")",
":",
"parameterIntervals",
"=",
"{",
"}",
"parameterIntervals",
"[",
"\"smoothingFactor\"",
"]",
"=",
"[",
"0.0",
",",
"1.0",
",",
"False",
",",
"False",
"]",
"parameterIntervals",
"[",
"\"trendSmoothingFactor\"... | Returns the intervals for the methods parameter.
Only parameters with defined intervals can be used for optimization!
:return: Returns a dictionary containing the parameter intervals, using the parameter
name as key, while the value hast the following format:
[minValue, maxV... | [
"Returns",
"the",
"intervals",
"for",
"the",
"methods",
"parameter",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/exponentialsmoothing.py#L178-L204 | train |
T-002/pycast | pycast/methods/exponentialsmoothing.py | HoltWintersMethod._calculate_forecast | def _calculate_forecast(self, originalTimeSeries, smoothedData, seasonValues, lastSmoothingParams):
"""Calculates the actual forecasted based on the input data.
:param TimeSeries timeSeries: TimeSeries containing hte data.
:param list smoothedData: Contains the smoothed time series data.
... | python | def _calculate_forecast(self, originalTimeSeries, smoothedData, seasonValues, lastSmoothingParams):
"""Calculates the actual forecasted based on the input data.
:param TimeSeries timeSeries: TimeSeries containing hte data.
:param list smoothedData: Contains the smoothed time series data.
... | [
"def",
"_calculate_forecast",
"(",
"self",
",",
"originalTimeSeries",
",",
"smoothedData",
",",
"seasonValues",
",",
"lastSmoothingParams",
")",
":",
"forecastResults",
"=",
"[",
"]",
"lastEstimator",
",",
"lastSeasonValue",
",",
"lastTrend",
"=",
"lastSmoothingParams... | Calculates the actual forecasted based on the input data.
:param TimeSeries timeSeries: TimeSeries containing hte data.
:param list smoothedData: Contains the smoothed time series data.
:param list seasonValues: Contains the seasonal values for the forecast.
:param list lastSmoothingPar... | [
"Calculates",
"the",
"actual",
"forecasted",
"based",
"on",
"the",
"input",
"data",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/exponentialsmoothing.py#L395-L422 | train |
T-002/pycast | pycast/methods/exponentialsmoothing.py | HoltWintersMethod.initSeasonFactors | def initSeasonFactors(self, timeSeries):
""" Computes the initial season smoothing factors.
:return: Returns a list of season vectors of length "seasonLength".
:rtype: list
"""
seasonLength = self.get_parameter("seasonLength")
try:
seasonValues = self.get... | python | def initSeasonFactors(self, timeSeries):
""" Computes the initial season smoothing factors.
:return: Returns a list of season vectors of length "seasonLength".
:rtype: list
"""
seasonLength = self.get_parameter("seasonLength")
try:
seasonValues = self.get... | [
"def",
"initSeasonFactors",
"(",
"self",
",",
"timeSeries",
")",
":",
"seasonLength",
"=",
"self",
".",
"get_parameter",
"(",
"\"seasonLength\"",
")",
"try",
":",
"seasonValues",
"=",
"self",
".",
"get_parameter",
"(",
"\"seasonValues\"",
")",
"assert",
"seasonL... | Computes the initial season smoothing factors.
:return: Returns a list of season vectors of length "seasonLength".
:rtype: list | [
"Computes",
"the",
"initial",
"season",
"smoothing",
"factors",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/exponentialsmoothing.py#L424-L451 | train |
T-002/pycast | pycast/methods/exponentialsmoothing.py | HoltWintersMethod.initialTrendSmoothingFactors | def initialTrendSmoothingFactors(self, timeSeries):
""" Calculate the initial Trend smoothing Factor b0.
Explanation:
http://en.wikipedia.org/wiki/Exponential_smoothing#Triple_exponential_smoothing
:return: Returns the initial trend smoothing factor b0
"""
result... | python | def initialTrendSmoothingFactors(self, timeSeries):
""" Calculate the initial Trend smoothing Factor b0.
Explanation:
http://en.wikipedia.org/wiki/Exponential_smoothing#Triple_exponential_smoothing
:return: Returns the initial trend smoothing factor b0
"""
result... | [
"def",
"initialTrendSmoothingFactors",
"(",
"self",
",",
"timeSeries",
")",
":",
"result",
"=",
"0.0",
"seasonLength",
"=",
"self",
".",
"get_parameter",
"(",
"\"seasonLength\"",
")",
"k",
"=",
"min",
"(",
"len",
"(",
"timeSeries",
")",
"-",
"seasonLength",
... | Calculate the initial Trend smoothing Factor b0.
Explanation:
http://en.wikipedia.org/wiki/Exponential_smoothing#Triple_exponential_smoothing
:return: Returns the initial trend smoothing factor b0 | [
"Calculate",
"the",
"initial",
"Trend",
"smoothing",
"Factor",
"b0",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/exponentialsmoothing.py#L453-L467 | train |
T-002/pycast | pycast/methods/exponentialsmoothing.py | HoltWintersMethod.computeA | def computeA(self, j, timeSeries):
""" Calculates A_j. Aj is the average value of x in the jth cycle of your data
:return: A_j
:rtype: numeric
"""
seasonLength = self.get_parameter("seasonLength")
A_j = 0
for i in range(seasonLength):
A_j += ti... | python | def computeA(self, j, timeSeries):
""" Calculates A_j. Aj is the average value of x in the jth cycle of your data
:return: A_j
:rtype: numeric
"""
seasonLength = self.get_parameter("seasonLength")
A_j = 0
for i in range(seasonLength):
A_j += ti... | [
"def",
"computeA",
"(",
"self",
",",
"j",
",",
"timeSeries",
")",
":",
"seasonLength",
"=",
"self",
".",
"get_parameter",
"(",
"\"seasonLength\"",
")",
"A_j",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"seasonLength",
")",
":",
"A_j",
"+=",
"timeSeries",
... | Calculates A_j. Aj is the average value of x in the jth cycle of your data
:return: A_j
:rtype: numeric | [
"Calculates",
"A_j",
".",
"Aj",
"is",
"the",
"average",
"value",
"of",
"x",
"in",
"the",
"jth",
"cycle",
"of",
"your",
"data"
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/exponentialsmoothing.py#L470-L480 | train |
pdkit/pdkit | pdkit/gait_processor.py | GaitProcessor.frequency_of_peaks | def frequency_of_peaks(self, x, start_offset=100, end_offset=100):
"""
This method assess the frequency of the peaks on any given 1-dimensional time series.
:param x: The time series to assess freeze of gait on. This could be x, y, z or mag_sum_acc.
:type x: pandas.Series
... | python | def frequency_of_peaks(self, x, start_offset=100, end_offset=100):
"""
This method assess the frequency of the peaks on any given 1-dimensional time series.
:param x: The time series to assess freeze of gait on. This could be x, y, z or mag_sum_acc.
:type x: pandas.Series
... | [
"def",
"frequency_of_peaks",
"(",
"self",
",",
"x",
",",
"start_offset",
"=",
"100",
",",
"end_offset",
"=",
"100",
")",
":",
"peaks_data",
"=",
"x",
"[",
"start_offset",
":",
"-",
"end_offset",
"]",
".",
"values",
"maxtab",
",",
"mintab",
"=",
"peakdet"... | This method assess the frequency of the peaks on any given 1-dimensional time series.
:param x: The time series to assess freeze of gait on. This could be x, y, z or mag_sum_acc.
:type x: pandas.Series
:param start_offset: Signal to leave out (of calculations) from the begining of t... | [
"This",
"method",
"assess",
"the",
"frequency",
"of",
"the",
"peaks",
"on",
"any",
"given",
"1",
"-",
"dimensional",
"time",
"series",
"."
] | c7120263da2071bb139815fbdb56ca77b544f340 | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/gait_processor.py#L178-L199 | train |
pdkit/pdkit | pdkit/gait_processor.py | GaitProcessor.walk_regularity_symmetry | def walk_regularity_symmetry(self, data_frame):
"""
This method extracts the step and stride regularity and also walk symmetry.
:param data_frame: The data frame. It should have x, y, and z columns.
:type data_frame: pandas.DataFrame
:return step_regularity: Reg... | python | def walk_regularity_symmetry(self, data_frame):
"""
This method extracts the step and stride regularity and also walk symmetry.
:param data_frame: The data frame. It should have x, y, and z columns.
:type data_frame: pandas.DataFrame
:return step_regularity: Reg... | [
"def",
"walk_regularity_symmetry",
"(",
"self",
",",
"data_frame",
")",
":",
"def",
"_symmetry",
"(",
"v",
")",
":",
"maxtab",
",",
"_",
"=",
"peakdet",
"(",
"v",
",",
"self",
".",
"delta",
")",
"return",
"maxtab",
"[",
"1",
"]",
"[",
"1",
"]",
","... | This method extracts the step and stride regularity and also walk symmetry.
:param data_frame: The data frame. It should have x, y, and z columns.
:type data_frame: pandas.DataFrame
:return step_regularity: Regularity of steps on [x, y, z] coordinates, defined as the consistency of ... | [
"This",
"method",
"extracts",
"the",
"step",
"and",
"stride",
"regularity",
"and",
"also",
"walk",
"symmetry",
"."
] | c7120263da2071bb139815fbdb56ca77b544f340 | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/gait_processor.py#L235-L265 | train |
pdkit/pdkit | pdkit/gait_processor.py | GaitProcessor.heel_strikes | def heel_strikes(self, x):
""" Estimate heel strike times between sign changes in accelerometer data.
:param x: The time series to assess freeze of gait on. This could be x, y, z or mag_sum_acc.
:type x: pandas.Series
:return strikes: Heel strike timings measured in seconds.... | python | def heel_strikes(self, x):
""" Estimate heel strike times between sign changes in accelerometer data.
:param x: The time series to assess freeze of gait on. This could be x, y, z or mag_sum_acc.
:type x: pandas.Series
:return strikes: Heel strike timings measured in seconds.... | [
"def",
"heel_strikes",
"(",
"self",
",",
"x",
")",
":",
"data",
"=",
"x",
".",
"values",
"data",
"-=",
"data",
".",
"mean",
"(",
")",
"filtered",
"=",
"butter_lowpass_filter",
"(",
"data",
",",
"self",
".",
"sampling_frequency",
",",
"self",
".",
"cuto... | Estimate heel strike times between sign changes in accelerometer data.
:param x: The time series to assess freeze of gait on. This could be x, y, z or mag_sum_acc.
:type x: pandas.Series
:return strikes: Heel strike timings measured in seconds.
:rtype striles: numpy.ndar... | [
"Estimate",
"heel",
"strike",
"times",
"between",
"sign",
"changes",
"in",
"accelerometer",
"data",
"."
] | c7120263da2071bb139815fbdb56ca77b544f340 | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/gait_processor.py#L314-L364 | train |
pdkit/pdkit | pdkit/gait_processor.py | GaitProcessor.gait_regularity_symmetry | def gait_regularity_symmetry(self, x, average_step_duration='autodetect', average_stride_duration='autodetect', unbias=1, normalize=2):
"""
Compute step and stride regularity and symmetry from accelerometer data with the help of steps and strides.
:param x: The time series to assess fr... | python | def gait_regularity_symmetry(self, x, average_step_duration='autodetect', average_stride_duration='autodetect', unbias=1, normalize=2):
"""
Compute step and stride regularity and symmetry from accelerometer data with the help of steps and strides.
:param x: The time series to assess fr... | [
"def",
"gait_regularity_symmetry",
"(",
"self",
",",
"x",
",",
"average_step_duration",
"=",
"'autodetect'",
",",
"average_stride_duration",
"=",
"'autodetect'",
",",
"unbias",
"=",
"1",
",",
"normalize",
"=",
"2",
")",
":",
"if",
"(",
"average_step_duration",
"... | Compute step and stride regularity and symmetry from accelerometer data with the help of steps and strides.
:param x: The time series to assess freeze of gait on. This could be x, y, z or mag_sum_acc.
:type x: pandas.Series
:param average_step_duration: Average duration of each step... | [
"Compute",
"step",
"and",
"stride",
"regularity",
"and",
"symmetry",
"from",
"accelerometer",
"data",
"with",
"the",
"help",
"of",
"steps",
"and",
"strides",
"."
] | c7120263da2071bb139815fbdb56ca77b544f340 | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/gait_processor.py#L366-L428 | train |
pdkit/pdkit | pdkit/gait_processor.py | GaitProcessor.gait | def gait(self, x):
"""
Extract gait features from estimated heel strikes and accelerometer data.
:param x: The time series to assess freeze of gait on. This could be x, y, z or mag_sum_acc.
:type x: pandas.Series
:return number_of_steps: Estimated number of step... | python | def gait(self, x):
"""
Extract gait features from estimated heel strikes and accelerometer data.
:param x: The time series to assess freeze of gait on. This could be x, y, z or mag_sum_acc.
:type x: pandas.Series
:return number_of_steps: Estimated number of step... | [
"def",
"gait",
"(",
"self",
",",
"x",
")",
":",
"data",
"=",
"x",
"strikes",
",",
"_",
"=",
"self",
".",
"heel_strikes",
"(",
"data",
")",
"step_durations",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"np",
".",
"size",
"(",
"strik... | Extract gait features from estimated heel strikes and accelerometer data.
:param x: The time series to assess freeze of gait on. This could be x, y, z or mag_sum_acc.
:type x: pandas.Series
:return number_of_steps: Estimated number of steps based on heel strikes [number of steps].
... | [
"Extract",
"gait",
"features",
"from",
"estimated",
"heel",
"strikes",
"and",
"accelerometer",
"data",
"."
] | c7120263da2071bb139815fbdb56ca77b544f340 | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/gait_processor.py#L431-L539 | train |
pdkit/pdkit | pdkit/gait_processor.py | GaitProcessor.add_manual_segmentation_to_data_frame | def add_manual_segmentation_to_data_frame(self, data_frame, segmentation_dictionary):
"""
Utility method to store manual segmentation of gait time series.
:param data_frame: The data frame. It should have x, y, and z columns.
:type data_frame: pandas.DataFrame
:... | python | def add_manual_segmentation_to_data_frame(self, data_frame, segmentation_dictionary):
"""
Utility method to store manual segmentation of gait time series.
:param data_frame: The data frame. It should have x, y, and z columns.
:type data_frame: pandas.DataFrame
:... | [
"def",
"add_manual_segmentation_to_data_frame",
"(",
"self",
",",
"data_frame",
",",
"segmentation_dictionary",
")",
":",
"data_frame",
"[",
"'segmentation'",
"]",
"=",
"'unknown'",
"for",
"i",
",",
"(",
"k",
",",
"v",
")",
"in",
"enumerate",
"(",
"segmentation_... | Utility method to store manual segmentation of gait time series.
:param data_frame: The data frame. It should have x, y, and z columns.
:type data_frame: pandas.DataFrame
:param segmentation_dictionary: A dictionary of the form {'signal_type': [(from, to), (from, to)], ..., 'signal_... | [
"Utility",
"method",
"to",
"store",
"manual",
"segmentation",
"of",
"gait",
"time",
"series",
"."
] | c7120263da2071bb139815fbdb56ca77b544f340 | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/gait_processor.py#L615-L642 | train |
twisted/txaws | txaws/client/base.py | error_wrapper | def error_wrapper(error, errorClass):
"""
We want to see all error messages from cloud services. Amazon's EC2 says
that their errors are accompanied either by a 400-series or 500-series HTTP
response code. As such, the first thing we want to do is check to see if
the error is in that range. If it is... | python | def error_wrapper(error, errorClass):
"""
We want to see all error messages from cloud services. Amazon's EC2 says
that their errors are accompanied either by a 400-series or 500-series HTTP
response code. As such, the first thing we want to do is check to see if
the error is in that range. If it is... | [
"def",
"error_wrapper",
"(",
"error",
",",
"errorClass",
")",
":",
"http_status",
"=",
"0",
"if",
"error",
".",
"check",
"(",
"TwistedWebError",
")",
":",
"xml_payload",
"=",
"error",
".",
"value",
".",
"response",
"if",
"error",
".",
"value",
".",
"stat... | We want to see all error messages from cloud services. Amazon's EC2 says
that their errors are accompanied either by a 400-series or 500-series HTTP
response code. As such, the first thing we want to do is check to see if
the error is in that range. If it is, we then need to see if the error
message is ... | [
"We",
"want",
"to",
"see",
"all",
"error",
"messages",
"from",
"cloud",
"services",
".",
"Amazon",
"s",
"EC2",
"says",
"that",
"their",
"errors",
"are",
"accompanied",
"either",
"by",
"a",
"400",
"-",
"series",
"or",
"500",
"-",
"series",
"HTTP",
"respon... | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/client/base.py#L46-L79 | train |
twisted/txaws | txaws/client/base.py | BaseQuery._headers | def _headers(self, headers_dict):
"""
Convert dictionary of headers into twisted.web.client.Headers object.
"""
return Headers(dict((k,[v]) for (k,v) in headers_dict.items())) | python | def _headers(self, headers_dict):
"""
Convert dictionary of headers into twisted.web.client.Headers object.
"""
return Headers(dict((k,[v]) for (k,v) in headers_dict.items())) | [
"def",
"_headers",
"(",
"self",
",",
"headers_dict",
")",
":",
"return",
"Headers",
"(",
"dict",
"(",
"(",
"k",
",",
"[",
"v",
"]",
")",
"for",
"(",
"k",
",",
"v",
")",
"in",
"headers_dict",
".",
"items",
"(",
")",
")",
")"
] | Convert dictionary of headers into twisted.web.client.Headers object. | [
"Convert",
"dictionary",
"of",
"headers",
"into",
"twisted",
".",
"web",
".",
"client",
".",
"Headers",
"object",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/client/base.py#L692-L696 | train |
twisted/txaws | txaws/client/base.py | BaseQuery._unpack_headers | def _unpack_headers(self, headers):
"""
Unpack twisted.web.client.Headers object to dict. This is to provide
backwards compatability.
"""
return dict((k,v[0]) for (k,v) in headers.getAllRawHeaders()) | python | def _unpack_headers(self, headers):
"""
Unpack twisted.web.client.Headers object to dict. This is to provide
backwards compatability.
"""
return dict((k,v[0]) for (k,v) in headers.getAllRawHeaders()) | [
"def",
"_unpack_headers",
"(",
"self",
",",
"headers",
")",
":",
"return",
"dict",
"(",
"(",
"k",
",",
"v",
"[",
"0",
"]",
")",
"for",
"(",
"k",
",",
"v",
")",
"in",
"headers",
".",
"getAllRawHeaders",
"(",
")",
")"
] | Unpack twisted.web.client.Headers object to dict. This is to provide
backwards compatability. | [
"Unpack",
"twisted",
".",
"web",
".",
"client",
".",
"Headers",
"object",
"to",
"dict",
".",
"This",
"is",
"to",
"provide",
"backwards",
"compatability",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/client/base.py#L698-L703 | train |
twisted/txaws | txaws/client/base.py | BaseQuery.get_request_headers | def get_request_headers(self, *args, **kwds):
"""
A convenience method for obtaining the headers that were sent to the
S3 server.
The AWS S3 API depends upon setting headers. This method is provided as
a convenience for debugging issues with the S3 communications.
"""
... | python | def get_request_headers(self, *args, **kwds):
"""
A convenience method for obtaining the headers that were sent to the
S3 server.
The AWS S3 API depends upon setting headers. This method is provided as
a convenience for debugging issues with the S3 communications.
"""
... | [
"def",
"get_request_headers",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwds",
")",
":",
"if",
"self",
".",
"request_headers",
":",
"return",
"self",
".",
"_unpack_headers",
"(",
"self",
".",
"request_headers",
")"
] | A convenience method for obtaining the headers that were sent to the
S3 server.
The AWS S3 API depends upon setting headers. This method is provided as
a convenience for debugging issues with the S3 communications. | [
"A",
"convenience",
"method",
"for",
"obtaining",
"the",
"headers",
"that",
"were",
"sent",
"to",
"the",
"S3",
"server",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/client/base.py#L705-L714 | train |
twisted/txaws | txaws/client/base.py | BaseQuery._handle_response | def _handle_response(self, response):
"""
Handle the HTTP response by memoing the headers and then delivering
bytes.
"""
self.client.status = response.code
self.response_headers = response.headers
# XXX This workaround (which needs to be improved at that) for poss... | python | def _handle_response(self, response):
"""
Handle the HTTP response by memoing the headers and then delivering
bytes.
"""
self.client.status = response.code
self.response_headers = response.headers
# XXX This workaround (which needs to be improved at that) for poss... | [
"def",
"_handle_response",
"(",
"self",
",",
"response",
")",
":",
"self",
".",
"client",
".",
"status",
"=",
"response",
".",
"code",
"self",
".",
"response_headers",
"=",
"response",
".",
"headers",
"if",
"self",
".",
"_method",
".",
"upper",
"(",
")",... | Handle the HTTP response by memoing the headers and then delivering
bytes. | [
"Handle",
"the",
"HTTP",
"response",
"by",
"memoing",
"the",
"headers",
"and",
"then",
"delivering",
"bytes",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/client/base.py#L716-L734 | train |
twisted/txaws | txaws/client/base.py | BaseQuery.get_response_headers | def get_response_headers(self, *args, **kwargs):
"""
A convenience method for obtaining the headers that were sent from the
S3 server.
The AWS S3 API depends upon setting headers. This method is used by the
head_object API call for getting a S3 object's metadata.
"""
... | python | def get_response_headers(self, *args, **kwargs):
"""
A convenience method for obtaining the headers that were sent from the
S3 server.
The AWS S3 API depends upon setting headers. This method is used by the
head_object API call for getting a S3 object's metadata.
"""
... | [
"def",
"get_response_headers",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"self",
".",
"response_headers",
":",
"return",
"self",
".",
"_unpack_headers",
"(",
"self",
".",
"response_headers",
")"
] | A convenience method for obtaining the headers that were sent from the
S3 server.
The AWS S3 API depends upon setting headers. This method is used by the
head_object API call for getting a S3 object's metadata. | [
"A",
"convenience",
"method",
"for",
"obtaining",
"the",
"headers",
"that",
"were",
"sent",
"from",
"the",
"S3",
"server",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/client/base.py#L740-L749 | train |
alphagov/notifications-python-client | notifications_python_client/authentication.py | create_jwt_token | def create_jwt_token(secret, client_id):
"""
Create JWT token for GOV.UK Notify
Tokens have standard header:
{
"typ": "JWT",
"alg": "HS256"
}
Claims consist of:
iss: identifier for the client
iat: issued at in epoch seconds (UTC)
:param secret: Application signing ... | python | def create_jwt_token(secret, client_id):
"""
Create JWT token for GOV.UK Notify
Tokens have standard header:
{
"typ": "JWT",
"alg": "HS256"
}
Claims consist of:
iss: identifier for the client
iat: issued at in epoch seconds (UTC)
:param secret: Application signing ... | [
"def",
"create_jwt_token",
"(",
"secret",
",",
"client_id",
")",
":",
"assert",
"secret",
",",
"\"Missing secret key\"",
"assert",
"client_id",
",",
"\"Missing client id\"",
"headers",
"=",
"{",
"\"typ\"",
":",
"__type__",
",",
"\"alg\"",
":",
"__algorithm__",
"}"... | Create JWT token for GOV.UK Notify
Tokens have standard header:
{
"typ": "JWT",
"alg": "HS256"
}
Claims consist of:
iss: identifier for the client
iat: issued at in epoch seconds (UTC)
:param secret: Application signing secret
:param client_id: Identifier for the clien... | [
"Create",
"JWT",
"token",
"for",
"GOV",
".",
"UK",
"Notify"
] | b397aed212acf15b1b1e049da2654d9a230f72d2 | https://github.com/alphagov/notifications-python-client/blob/b397aed212acf15b1b1e049da2654d9a230f72d2/notifications_python_client/authentication.py#L25-L56 | train |
alphagov/notifications-python-client | notifications_python_client/authentication.py | decode_jwt_token | def decode_jwt_token(token, secret):
"""
Validates and decodes the JWT token
Token checked for
- signature of JWT token
- token issued date is valid
:param token: jwt token
:param secret: client specific secret
:return boolean: True if valid token, False otherwise
:raises To... | python | def decode_jwt_token(token, secret):
"""
Validates and decodes the JWT token
Token checked for
- signature of JWT token
- token issued date is valid
:param token: jwt token
:param secret: client specific secret
:return boolean: True if valid token, False otherwise
:raises To... | [
"def",
"decode_jwt_token",
"(",
"token",
",",
"secret",
")",
":",
"try",
":",
"decoded_token",
"=",
"jwt",
".",
"decode",
"(",
"token",
",",
"key",
"=",
"secret",
".",
"encode",
"(",
")",
",",
"verify",
"=",
"True",
",",
"algorithms",
"=",
"[",
"__al... | Validates and decodes the JWT token
Token checked for
- signature of JWT token
- token issued date is valid
:param token: jwt token
:param secret: client specific secret
:return boolean: True if valid token, False otherwise
:raises TokenIssuerError: if iss field not present
:rai... | [
"Validates",
"and",
"decodes",
"the",
"JWT",
"token",
"Token",
"checked",
"for",
"-",
"signature",
"of",
"JWT",
"token",
"-",
"token",
"issued",
"date",
"is",
"valid"
] | b397aed212acf15b1b1e049da2654d9a230f72d2 | https://github.com/alphagov/notifications-python-client/blob/b397aed212acf15b1b1e049da2654d9a230f72d2/notifications_python_client/authentication.py#L80-L121 | train |
apertium/streamparser | streamparser.py | parse | def parse(stream, with_text=False): # type: (Iterator[str], bool) -> Iterator[Union[Tuple[str, LexicalUnit], LexicalUnit]]
"""Generates lexical units from a character stream.
Args:
stream (Iterator[str]): A character stream containing lexical units, superblanks and other text.
with_text (Optio... | python | def parse(stream, with_text=False): # type: (Iterator[str], bool) -> Iterator[Union[Tuple[str, LexicalUnit], LexicalUnit]]
"""Generates lexical units from a character stream.
Args:
stream (Iterator[str]): A character stream containing lexical units, superblanks and other text.
with_text (Optio... | [
"def",
"parse",
"(",
"stream",
",",
"with_text",
"=",
"False",
")",
":",
"buffer",
"=",
"''",
"text_buffer",
"=",
"''",
"in_lexical_unit",
"=",
"False",
"in_superblank",
"=",
"False",
"for",
"char",
"in",
"stream",
":",
"if",
"in_superblank",
":",
"if",
... | Generates lexical units from a character stream.
Args:
stream (Iterator[str]): A character stream containing lexical units, superblanks and other text.
with_text (Optional[bool]): A boolean defining whether to output preceding text with each lexical unit.
Yields:
:class:`LexicalUnit`: ... | [
"Generates",
"lexical",
"units",
"from",
"a",
"character",
"stream",
"."
] | dd9d1566af47b8b2babbc172b42706579d52e422 | https://github.com/apertium/streamparser/blob/dd9d1566af47b8b2babbc172b42706579d52e422/streamparser.py#L187-L239 | train |
T-002/pycast | pycast/common/timeseries.py | TimeSeries.from_twodim_list | def from_twodim_list(cls, datalist, tsformat=None):
"""Creates a new TimeSeries instance from the data stored inside a two dimensional list.
:param list datalist: List containing multiple iterables with at least two values.
The first item will always be used as timestamp in the predefine... | python | def from_twodim_list(cls, datalist, tsformat=None):
"""Creates a new TimeSeries instance from the data stored inside a two dimensional list.
:param list datalist: List containing multiple iterables with at least two values.
The first item will always be used as timestamp in the predefine... | [
"def",
"from_twodim_list",
"(",
"cls",
",",
"datalist",
",",
"tsformat",
"=",
"None",
")",
":",
"ts",
"=",
"TimeSeries",
"(",
")",
"ts",
".",
"set_timeformat",
"(",
"tsformat",
")",
"for",
"entry",
"in",
"datalist",
":",
"ts",
".",
"add_entry",
"(",
"*... | Creates a new TimeSeries instance from the data stored inside a two dimensional list.
:param list datalist: List containing multiple iterables with at least two values.
The first item will always be used as timestamp in the predefined format,
the second represents the value. All othe... | [
"Creates",
"a",
"new",
"TimeSeries",
"instance",
"from",
"the",
"data",
"stored",
"inside",
"a",
"two",
"dimensional",
"list",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/timeseries.py#L170-L194 | train |
T-002/pycast | pycast/common/timeseries.py | TimeSeries.initialize_from_sql_cursor | def initialize_from_sql_cursor(self, sqlcursor):
"""Initializes the TimeSeries's data from the given SQL cursor.
You need to set the time stamp format using :py:meth:`TimeSeries.set_timeformat`.
:param SQLCursor sqlcursor: Cursor that was holds the SQL result for any given
"SELE... | python | def initialize_from_sql_cursor(self, sqlcursor):
"""Initializes the TimeSeries's data from the given SQL cursor.
You need to set the time stamp format using :py:meth:`TimeSeries.set_timeformat`.
:param SQLCursor sqlcursor: Cursor that was holds the SQL result for any given
"SELE... | [
"def",
"initialize_from_sql_cursor",
"(",
"self",
",",
"sqlcursor",
")",
":",
"tuples",
"=",
"0",
"data",
"=",
"sqlcursor",
".",
"fetchmany",
"(",
")",
"while",
"0",
"<",
"len",
"(",
"data",
")",
":",
"for",
"entry",
"in",
"data",
":",
"self",
".",
"... | Initializes the TimeSeries's data from the given SQL cursor.
You need to set the time stamp format using :py:meth:`TimeSeries.set_timeformat`.
:param SQLCursor sqlcursor: Cursor that was holds the SQL result for any given
"SELECT timestamp, value, ... FROM ..." SQL query.
On... | [
"Initializes",
"the",
"TimeSeries",
"s",
"data",
"from",
"the",
"given",
"SQL",
"cursor",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/timeseries.py#L196-L223 | train |
T-002/pycast | pycast/common/timeseries.py | TimeSeries.convert_timestamp_to_epoch | def convert_timestamp_to_epoch(cls, timestamp, tsformat):
"""Converts the given timestamp into a float representing UNIX-epochs.
:param string timestamp: Timestamp in the defined format.
:param string tsformat: Format of the given timestamp. This is used to convert the
timestamp ... | python | def convert_timestamp_to_epoch(cls, timestamp, tsformat):
"""Converts the given timestamp into a float representing UNIX-epochs.
:param string timestamp: Timestamp in the defined format.
:param string tsformat: Format of the given timestamp. This is used to convert the
timestamp ... | [
"def",
"convert_timestamp_to_epoch",
"(",
"cls",
",",
"timestamp",
",",
"tsformat",
")",
":",
"return",
"time",
".",
"mktime",
"(",
"time",
".",
"strptime",
"(",
"timestamp",
",",
"tsformat",
")",
")"
] | Converts the given timestamp into a float representing UNIX-epochs.
:param string timestamp: Timestamp in the defined format.
:param string tsformat: Format of the given timestamp. This is used to convert the
timestamp into UNIX epochs. For valid examples take a look into
the... | [
"Converts",
"the",
"given",
"timestamp",
"into",
"a",
"float",
"representing",
"UNIX",
"-",
"epochs",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/timeseries.py#L323-L335 | train |
T-002/pycast | pycast/common/timeseries.py | TimeSeries.convert_epoch_to_timestamp | def convert_epoch_to_timestamp(cls, timestamp, tsformat):
"""Converts the given float representing UNIX-epochs into an actual timestamp.
:param float timestamp: Timestamp as UNIX-epochs.
:param string tsformat: Format of the given timestamp. This is used to convert the
timesta... | python | def convert_epoch_to_timestamp(cls, timestamp, tsformat):
"""Converts the given float representing UNIX-epochs into an actual timestamp.
:param float timestamp: Timestamp as UNIX-epochs.
:param string tsformat: Format of the given timestamp. This is used to convert the
timesta... | [
"def",
"convert_epoch_to_timestamp",
"(",
"cls",
",",
"timestamp",
",",
"tsformat",
")",
":",
"return",
"time",
".",
"strftime",
"(",
"tsformat",
",",
"time",
".",
"gmtime",
"(",
"timestamp",
")",
")"
] | Converts the given float representing UNIX-epochs into an actual timestamp.
:param float timestamp: Timestamp as UNIX-epochs.
:param string tsformat: Format of the given timestamp. This is used to convert the
timestamp from UNIX epochs. For valid examples take a look into the
... | [
"Converts",
"the",
"given",
"float",
"representing",
"UNIX",
"-",
"epochs",
"into",
"an",
"actual",
"timestamp",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/timeseries.py#L338-L349 | train |
T-002/pycast | pycast/common/timeseries.py | TimeSeries.sort_timeseries | def sort_timeseries(self, ascending=True):
"""Sorts the data points within the TimeSeries according to their occurrence inline.
:param boolean ascending: Determines if the TimeSeries will be ordered ascending or
descending. If this is set to descending once, the ordered parameter defined in... | python | def sort_timeseries(self, ascending=True):
"""Sorts the data points within the TimeSeries according to their occurrence inline.
:param boolean ascending: Determines if the TimeSeries will be ordered ascending or
descending. If this is set to descending once, the ordered parameter defined in... | [
"def",
"sort_timeseries",
"(",
"self",
",",
"ascending",
"=",
"True",
")",
":",
"if",
"ascending",
"and",
"self",
".",
"_sorted",
":",
"return",
"sortorder",
"=",
"1",
"if",
"not",
"ascending",
":",
"sortorder",
"=",
"-",
"1",
"self",
".",
"_predefinedSo... | Sorts the data points within the TimeSeries according to their occurrence inline.
:param boolean ascending: Determines if the TimeSeries will be ordered ascending or
descending. If this is set to descending once, the ordered parameter defined in
:py:meth:`TimeSeries.__init__` will be se... | [
"Sorts",
"the",
"data",
"points",
"within",
"the",
"TimeSeries",
"according",
"to",
"their",
"occurrence",
"inline",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/timeseries.py#L368-L391 | train |
T-002/pycast | pycast/common/timeseries.py | TimeSeries.sorted_timeseries | def sorted_timeseries(self, ascending=True):
"""Returns a sorted copy of the TimeSeries, preserving the original one.
As an assumption this new TimeSeries is not ordered anymore if a new value is added.
:param boolean ascending: Determines if the TimeSeries will be ordered ascending
... | python | def sorted_timeseries(self, ascending=True):
"""Returns a sorted copy of the TimeSeries, preserving the original one.
As an assumption this new TimeSeries is not ordered anymore if a new value is added.
:param boolean ascending: Determines if the TimeSeries will be ordered ascending
... | [
"def",
"sorted_timeseries",
"(",
"self",
",",
"ascending",
"=",
"True",
")",
":",
"sortorder",
"=",
"1",
"if",
"not",
"ascending",
":",
"sortorder",
"=",
"-",
"1",
"data",
"=",
"sorted",
"(",
"self",
".",
"_timeseriesData",
",",
"key",
"=",
"lambda",
"... | Returns a sorted copy of the TimeSeries, preserving the original one.
As an assumption this new TimeSeries is not ordered anymore if a new value is added.
:param boolean ascending: Determines if the TimeSeries will be ordered ascending
or descending.
:return: Returns a new T... | [
"Returns",
"a",
"sorted",
"copy",
"of",
"the",
"TimeSeries",
"preserving",
"the",
"original",
"one",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/timeseries.py#L393-L416 | train |
T-002/pycast | pycast/common/timeseries.py | TimeSeries.normalize | def normalize(self, normalizationLevel="minute", fusionMethod="mean", interpolationMethod="linear"):
"""Normalizes the TimeSeries data points.
If this function is called, the TimeSeries gets ordered ascending
automatically. The new timestamps will represent the center of each time
bucke... | python | def normalize(self, normalizationLevel="minute", fusionMethod="mean", interpolationMethod="linear"):
"""Normalizes the TimeSeries data points.
If this function is called, the TimeSeries gets ordered ascending
automatically. The new timestamps will represent the center of each time
bucke... | [
"def",
"normalize",
"(",
"self",
",",
"normalizationLevel",
"=",
"\"minute\"",
",",
"fusionMethod",
"=",
"\"mean\"",
",",
"interpolationMethod",
"=",
"\"linear\"",
")",
":",
"if",
"self",
".",
"_normalizationLevel",
"==",
"normalizationLevel",
":",
"if",
"self",
... | Normalizes the TimeSeries data points.
If this function is called, the TimeSeries gets ordered ascending
automatically. The new timestamps will represent the center of each time
bucket. Within a normalized TimeSeries, the temporal distance between two consecutive data points is constant.
... | [
"Normalizes",
"the",
"TimeSeries",
"data",
"points",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/timeseries.py#L418-L529 | train |
T-002/pycast | pycast/common/timeseries.py | TimeSeries._check_normalization | def _check_normalization(self):
"""Checks, if the TimeSeries is normalized.
:return: Returns :py:const:`True` if all data entries of the TimeSeries have an equal temporal
distance, :py:const:`False` otherwise.
"""
lastDistance = None
distance = None
fo... | python | def _check_normalization(self):
"""Checks, if the TimeSeries is normalized.
:return: Returns :py:const:`True` if all data entries of the TimeSeries have an equal temporal
distance, :py:const:`False` otherwise.
"""
lastDistance = None
distance = None
fo... | [
"def",
"_check_normalization",
"(",
"self",
")",
":",
"lastDistance",
"=",
"None",
"distance",
"=",
"None",
"for",
"idx",
"in",
"xrange",
"(",
"len",
"(",
"self",
")",
"-",
"1",
")",
":",
"distance",
"=",
"self",
"[",
"idx",
"+",
"1",
"]",
"[",
"0"... | Checks, if the TimeSeries is normalized.
:return: Returns :py:const:`True` if all data entries of the TimeSeries have an equal temporal
distance, :py:const:`False` otherwise. | [
"Checks",
"if",
"the",
"TimeSeries",
"is",
"normalized",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/timeseries.py#L542-L563 | train |
T-002/pycast | pycast/common/timeseries.py | TimeSeries.sample | def sample(self, percentage):
"""Samples with replacement from the TimeSeries. Returns the sample and the remaining timeseries.
The original timeseries is not changed.
:param float percentage: How many percent of the original timeseries should be in the sample
:return: A tuple conta... | python | def sample(self, percentage):
"""Samples with replacement from the TimeSeries. Returns the sample and the remaining timeseries.
The original timeseries is not changed.
:param float percentage: How many percent of the original timeseries should be in the sample
:return: A tuple conta... | [
"def",
"sample",
"(",
"self",
",",
"percentage",
")",
":",
"if",
"not",
"(",
"0.0",
"<",
"percentage",
"<",
"1.0",
")",
":",
"raise",
"ValueError",
"(",
"\"Parameter percentage has to be in (0.0, 1.0).\"",
")",
"cls",
"=",
"self",
".",
"__class__",
"value_coun... | Samples with replacement from the TimeSeries. Returns the sample and the remaining timeseries.
The original timeseries is not changed.
:param float percentage: How many percent of the original timeseries should be in the sample
:return: A tuple containing (sample, rest) as two TimeSeries.
... | [
"Samples",
"with",
"replacement",
"from",
"the",
"TimeSeries",
".",
"Returns",
"the",
"sample",
"and",
"the",
"remaining",
"timeseries",
".",
"The",
"original",
"timeseries",
"is",
"not",
"changed",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/timeseries.py#L592-L618 | train |
T-002/pycast | pycast/common/timeseries.py | MultiDimensionalTimeSeries.from_twodim_list | def from_twodim_list(cls, datalist, tsformat=None, dimensions=1):
"""Creates a new MultiDimensionalTimeSeries instance from the data stored inside a two dimensional list.
:param list datalist: List containing multiple iterables with at least two values.
The first item will always be used... | python | def from_twodim_list(cls, datalist, tsformat=None, dimensions=1):
"""Creates a new MultiDimensionalTimeSeries instance from the data stored inside a two dimensional list.
:param list datalist: List containing multiple iterables with at least two values.
The first item will always be used... | [
"def",
"from_twodim_list",
"(",
"cls",
",",
"datalist",
",",
"tsformat",
"=",
"None",
",",
"dimensions",
"=",
"1",
")",
":",
"ts",
"=",
"MultiDimensionalTimeSeries",
"(",
"dimensions",
"=",
"dimensions",
")",
"ts",
".",
"set_timeformat",
"(",
"tsformat",
")"... | Creates a new MultiDimensionalTimeSeries instance from the data stored inside a two dimensional list.
:param list datalist: List containing multiple iterables with at least two values.
The first item will always be used as timestamp in the predefined format,
the second is a list, con... | [
"Creates",
"a",
"new",
"MultiDimensionalTimeSeries",
"instance",
"from",
"the",
"data",
"stored",
"inside",
"a",
"two",
"dimensional",
"list",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/timeseries.py#L725-L750 | train |
twisted/txaws | txaws/client/_producers.py | FileBodyProducer._writeloop | def _writeloop(self, consumer):
"""
Return an iterator which reads one chunk of bytes from the input file
and writes them to the consumer for each time it is iterated.
"""
while True:
bytes = self._inputFile.read(self._readSize)
if not bytes:
... | python | def _writeloop(self, consumer):
"""
Return an iterator which reads one chunk of bytes from the input file
and writes them to the consumer for each time it is iterated.
"""
while True:
bytes = self._inputFile.read(self._readSize)
if not bytes:
... | [
"def",
"_writeloop",
"(",
"self",
",",
"consumer",
")",
":",
"while",
"True",
":",
"bytes",
"=",
"self",
".",
"_inputFile",
".",
"read",
"(",
"self",
".",
"_readSize",
")",
"if",
"not",
"bytes",
":",
"self",
".",
"_inputFile",
".",
"close",
"(",
")",... | Return an iterator which reads one chunk of bytes from the input file
and writes them to the consumer for each time it is iterated. | [
"Return",
"an",
"iterator",
"which",
"reads",
"one",
"chunk",
"of",
"bytes",
"from",
"the",
"input",
"file",
"and",
"writes",
"them",
"to",
"the",
"consumer",
"for",
"each",
"time",
"it",
"is",
"iterated",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/client/_producers.py#L93-L104 | train |
Duke-GCB/DukeDSClient | ddsc/core/upload.py | ProjectUpload.run | def run(self):
"""
Upload different items within local_project to remote store showing a progress bar.
"""
progress_printer = ProgressPrinter(self.different_items.total_items(), msg_verb='sending')
upload_settings = UploadSettings(self.config, self.remote_store.data_service, prog... | python | def run(self):
"""
Upload different items within local_project to remote store showing a progress bar.
"""
progress_printer = ProgressPrinter(self.different_items.total_items(), msg_verb='sending')
upload_settings = UploadSettings(self.config, self.remote_store.data_service, prog... | [
"def",
"run",
"(",
"self",
")",
":",
"progress_printer",
"=",
"ProgressPrinter",
"(",
"self",
".",
"different_items",
".",
"total_items",
"(",
")",
",",
"msg_verb",
"=",
"'sending'",
")",
"upload_settings",
"=",
"UploadSettings",
"(",
"self",
".",
"config",
... | Upload different items within local_project to remote store showing a progress bar. | [
"Upload",
"different",
"items",
"within",
"local_project",
"to",
"remote",
"store",
"showing",
"a",
"progress",
"bar",
"."
] | 117f68fb9bae82e4c81ea487ad5d61ac350f3726 | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/upload.py#L53-L62 | train |
Duke-GCB/DukeDSClient | ddsc/core/upload.py | ProjectUpload.get_upload_report | def get_upload_report(self):
"""
Generate and print a report onto stdout.
"""
project = self.remote_store.fetch_remote_project(self.project_name_or_id,
must_exist=True,
inclu... | python | def get_upload_report(self):
"""
Generate and print a report onto stdout.
"""
project = self.remote_store.fetch_remote_project(self.project_name_or_id,
must_exist=True,
inclu... | [
"def",
"get_upload_report",
"(",
"self",
")",
":",
"project",
"=",
"self",
".",
"remote_store",
".",
"fetch_remote_project",
"(",
"self",
".",
"project_name_or_id",
",",
"must_exist",
"=",
"True",
",",
"include_children",
"=",
"False",
")",
"report",
"=",
"Upl... | Generate and print a report onto stdout. | [
"Generate",
"and",
"print",
"a",
"report",
"onto",
"stdout",
"."
] | 117f68fb9bae82e4c81ea487ad5d61ac350f3726 | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/upload.py#L89-L98 | train |
Duke-GCB/DukeDSClient | ddsc/core/upload.py | ProjectUpload.get_url_msg | def get_url_msg(self):
"""
Print url to view the project via dds portal.
"""
msg = 'URL to view project'
project_id = self.local_project.remote_id
url = '{}: https://{}/#/project/{}'.format(msg, self.config.get_portal_url_base(), project_id)
return url | python | def get_url_msg(self):
"""
Print url to view the project via dds portal.
"""
msg = 'URL to view project'
project_id = self.local_project.remote_id
url = '{}: https://{}/#/project/{}'.format(msg, self.config.get_portal_url_base(), project_id)
return url | [
"def",
"get_url_msg",
"(",
"self",
")",
":",
"msg",
"=",
"'URL to view project'",
"project_id",
"=",
"self",
".",
"local_project",
".",
"remote_id",
"url",
"=",
"'{}: https://{}/#/project/{}'",
".",
"format",
"(",
"msg",
",",
"self",
".",
"config",
".",
"get_p... | Print url to view the project via dds portal. | [
"Print",
"url",
"to",
"view",
"the",
"project",
"via",
"dds",
"portal",
"."
] | 117f68fb9bae82e4c81ea487ad5d61ac350f3726 | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/upload.py#L100-L107 | train |
Duke-GCB/DukeDSClient | ddsc/core/fileuploader.py | FileUploadOperations._send_file_external_with_retry | def _send_file_external_with_retry(self, http_verb, host, url, http_headers, chunk):
"""
Send chunk to host, url using http_verb. If http_verb is PUT and a connection error occurs
retry a few times. Pauses between retries. Raises if unsuccessful.
"""
count = 0
retry_times... | python | def _send_file_external_with_retry(self, http_verb, host, url, http_headers, chunk):
"""
Send chunk to host, url using http_verb. If http_verb is PUT and a connection error occurs
retry a few times. Pauses between retries. Raises if unsuccessful.
"""
count = 0
retry_times... | [
"def",
"_send_file_external_with_retry",
"(",
"self",
",",
"http_verb",
",",
"host",
",",
"url",
",",
"http_headers",
",",
"chunk",
")",
":",
"count",
"=",
"0",
"retry_times",
"=",
"1",
"if",
"http_verb",
"==",
"'PUT'",
":",
"retry_times",
"=",
"SEND_EXTERNA... | Send chunk to host, url using http_verb. If http_verb is PUT and a connection error occurs
retry a few times. Pauses between retries. Raises if unsuccessful. | [
"Send",
"chunk",
"to",
"host",
"url",
"using",
"http_verb",
".",
"If",
"http_verb",
"is",
"PUT",
"and",
"a",
"connection",
"error",
"occurs",
"retry",
"a",
"few",
"times",
".",
"Pauses",
"between",
"retries",
".",
"Raises",
"if",
"unsuccessful",
"."
] | 117f68fb9bae82e4c81ea487ad5d61ac350f3726 | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/fileuploader.py#L192-L212 | train |
Duke-GCB/DukeDSClient | ddsc/core/fileuploader.py | ParallelChunkProcessor.run | def run(self):
"""
Sends contents of a local file to a remote data service.
"""
processes = []
progress_queue = ProgressQueue(Queue())
num_chunks = ParallelChunkProcessor.determine_num_chunks(self.config.upload_bytes_per_chunk,
... | python | def run(self):
"""
Sends contents of a local file to a remote data service.
"""
processes = []
progress_queue = ProgressQueue(Queue())
num_chunks = ParallelChunkProcessor.determine_num_chunks(self.config.upload_bytes_per_chunk,
... | [
"def",
"run",
"(",
"self",
")",
":",
"processes",
"=",
"[",
"]",
"progress_queue",
"=",
"ProgressQueue",
"(",
"Queue",
"(",
")",
")",
"num_chunks",
"=",
"ParallelChunkProcessor",
".",
"determine_num_chunks",
"(",
"self",
".",
"config",
".",
"upload_bytes_per_c... | Sends contents of a local file to a remote data service. | [
"Sends",
"contents",
"of",
"a",
"local",
"file",
"to",
"a",
"remote",
"data",
"service",
"."
] | 117f68fb9bae82e4c81ea487ad5d61ac350f3726 | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/fileuploader.py#L256-L267 | train |
Duke-GCB/DukeDSClient | ddsc/core/fileuploader.py | ChunkSender.send | def send(self):
"""
For each chunk we need to send, create upload url and send bytes. Raises exception on error.
"""
sent_chunks = 0
chunk_num = self.index
with open(self.filename, 'rb') as infile:
infile.seek(self.index * self.chunk_size)
while se... | python | def send(self):
"""
For each chunk we need to send, create upload url and send bytes. Raises exception on error.
"""
sent_chunks = 0
chunk_num = self.index
with open(self.filename, 'rb') as infile:
infile.seek(self.index * self.chunk_size)
while se... | [
"def",
"send",
"(",
"self",
")",
":",
"sent_chunks",
"=",
"0",
"chunk_num",
"=",
"self",
".",
"index",
"with",
"open",
"(",
"self",
".",
"filename",
",",
"'rb'",
")",
"as",
"infile",
":",
"infile",
".",
"seek",
"(",
"self",
".",
"index",
"*",
"self... | For each chunk we need to send, create upload url and send bytes. Raises exception on error. | [
"For",
"each",
"chunk",
"we",
"need",
"to",
"send",
"create",
"upload",
"url",
"and",
"send",
"bytes",
".",
"Raises",
"exception",
"on",
"error",
"."
] | 117f68fb9bae82e4c81ea487ad5d61ac350f3726 | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/fileuploader.py#L369-L382 | train |
T-002/pycast | pycast/methods/basemethod.py | BaseMethod._in_valid_interval | def _in_valid_interval(self, parameter, value):
"""Returns if the parameter is within its valid interval.
:param string parameter: Name of the parameter that has to be checked.
:param numeric value: Value of the parameter.
:return: Returns :py:const:`True` it the value for t... | python | def _in_valid_interval(self, parameter, value):
"""Returns if the parameter is within its valid interval.
:param string parameter: Name of the parameter that has to be checked.
:param numeric value: Value of the parameter.
:return: Returns :py:const:`True` it the value for t... | [
"def",
"_in_valid_interval",
"(",
"self",
",",
"parameter",
",",
"value",
")",
":",
"if",
"parameter",
"not",
"in",
"self",
".",
"_parameterIntervals",
":",
"return",
"True",
"interval",
"=",
"self",
".",
"_parameterIntervals",
"[",
"parameter",
"]",
"if",
"... | Returns if the parameter is within its valid interval.
:param string parameter: Name of the parameter that has to be checked.
:param numeric value: Value of the parameter.
:return: Returns :py:const:`True` it the value for the given parameter is valid,
:py:const:`False` ... | [
"Returns",
"if",
"the",
"parameter",
"is",
"within",
"its",
"valid",
"interval",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/basemethod.py#L118-L144 | train |
T-002/pycast | pycast/methods/basemethod.py | BaseMethod._get_value_error_message_for_invalid_prarameter | def _get_value_error_message_for_invalid_prarameter(self, parameter, value):
"""Returns the ValueError message for the given parameter.
:param string parameter: Name of the parameter the message has to be created for.
:param numeric value: Value outside the parameters interval.
:... | python | def _get_value_error_message_for_invalid_prarameter(self, parameter, value):
"""Returns the ValueError message for the given parameter.
:param string parameter: Name of the parameter the message has to be created for.
:param numeric value: Value outside the parameters interval.
:... | [
"def",
"_get_value_error_message_for_invalid_prarameter",
"(",
"self",
",",
"parameter",
",",
"value",
")",
":",
"if",
"parameter",
"not",
"in",
"self",
".",
"_parameterIntervals",
":",
"return",
"interval",
"=",
"self",
".",
"_parameterIntervals",
"[",
"parameter",... | Returns the ValueError message for the given parameter.
:param string parameter: Name of the parameter the message has to be created for.
:param numeric value: Value outside the parameters interval.
:return: Returns a string containing hte message.
:rtype: string | [
"Returns",
"the",
"ValueError",
"message",
"for",
"the",
"given",
"parameter",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/basemethod.py#L146-L166 | train |
T-002/pycast | pycast/methods/basemethod.py | BaseMethod.set_parameter | def set_parameter(self, name, value):
"""Sets a parameter for the BaseMethod.
:param string name: Name of the parameter that has to be checked.
:param numeric value: Value of the parameter.
"""
if not self._in_valid_interval(name, value):
raise ValueError(sel... | python | def set_parameter(self, name, value):
"""Sets a parameter for the BaseMethod.
:param string name: Name of the parameter that has to be checked.
:param numeric value: Value of the parameter.
"""
if not self._in_valid_interval(name, value):
raise ValueError(sel... | [
"def",
"set_parameter",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"if",
"not",
"self",
".",
"_in_valid_interval",
"(",
"name",
",",
"value",
")",
":",
"raise",
"ValueError",
"(",
"self",
".",
"_get_value_error_message_for_invalid_prarameter",
"(",
"nam... | Sets a parameter for the BaseMethod.
:param string name: Name of the parameter that has to be checked.
:param numeric value: Value of the parameter. | [
"Sets",
"a",
"parameter",
"for",
"the",
"BaseMethod",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/basemethod.py#L168-L180 | train |
T-002/pycast | pycast/methods/basemethod.py | BaseMethod.can_be_executed | def can_be_executed(self):
"""Returns if the method can already be executed.
:return: Returns :py:const:`True` if all required parameters where already set, False otherwise.
:rtype: boolean
"""
missingParams = filter(lambda rp: rp not in self._parameters, self._requiredParame... | python | def can_be_executed(self):
"""Returns if the method can already be executed.
:return: Returns :py:const:`True` if all required parameters where already set, False otherwise.
:rtype: boolean
"""
missingParams = filter(lambda rp: rp not in self._parameters, self._requiredParame... | [
"def",
"can_be_executed",
"(",
"self",
")",
":",
"missingParams",
"=",
"filter",
"(",
"lambda",
"rp",
":",
"rp",
"not",
"in",
"self",
".",
"_parameters",
",",
"self",
".",
"_requiredParameters",
")",
"return",
"len",
"(",
"missingParams",
")",
"==",
"0"
] | Returns if the method can already be executed.
:return: Returns :py:const:`True` if all required parameters where already set, False otherwise.
:rtype: boolean | [
"Returns",
"if",
"the",
"method",
"can",
"already",
"be",
"executed",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/basemethod.py#L210-L217 | train |
T-002/pycast | pycast/methods/basemethod.py | BaseForecastingMethod.set_parameter | def set_parameter(self, name, value):
"""Sets a parameter for the BaseForecastingMethod.
:param string name: Name of the parameter.
:param numeric value: Value of the parameter.
"""
# set the furecast until variable to None if necessary
if name == "valuesToForecast... | python | def set_parameter(self, name, value):
"""Sets a parameter for the BaseForecastingMethod.
:param string name: Name of the parameter.
:param numeric value: Value of the parameter.
"""
# set the furecast until variable to None if necessary
if name == "valuesToForecast... | [
"def",
"set_parameter",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"if",
"name",
"==",
"\"valuesToForecast\"",
":",
"self",
".",
"_forecastUntil",
"=",
"None",
"return",
"super",
"(",
"BaseForecastingMethod",
",",
"self",
")",
".",
"set_parameter",
"(... | Sets a parameter for the BaseForecastingMethod.
:param string name: Name of the parameter.
:param numeric value: Value of the parameter. | [
"Sets",
"a",
"parameter",
"for",
"the",
"BaseForecastingMethod",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/basemethod.py#L272-L283 | train |
T-002/pycast | pycast/methods/basemethod.py | BaseForecastingMethod._calculate_values_to_forecast | def _calculate_values_to_forecast(self, timeSeries):
"""Calculates the number of values, that need to be forecasted to match the goal set in forecast_until.
This sets the parameter "valuesToForecast" and should be called at the beginning of the :py:meth:`BaseMethod.execute` implementation.
:pa... | python | def _calculate_values_to_forecast(self, timeSeries):
"""Calculates the number of values, that need to be forecasted to match the goal set in forecast_until.
This sets the parameter "valuesToForecast" and should be called at the beginning of the :py:meth:`BaseMethod.execute` implementation.
:pa... | [
"def",
"_calculate_values_to_forecast",
"(",
"self",
",",
"timeSeries",
")",
":",
"if",
"self",
".",
"_forecastUntil",
"is",
"None",
":",
"return",
"if",
"not",
"timeSeries",
".",
"is_sorted",
"(",
")",
":",
"raise",
"ValueError",
"(",
"\"timeSeries has to be so... | Calculates the number of values, that need to be forecasted to match the goal set in forecast_until.
This sets the parameter "valuesToForecast" and should be called at the beginning of the :py:meth:`BaseMethod.execute` implementation.
:param TimeSeries timeSeries: Should be a sorted and normalized ... | [
"Calculates",
"the",
"number",
"of",
"values",
"that",
"need",
"to",
"be",
"forecasted",
"to",
"match",
"the",
"goal",
"set",
"in",
"forecast_until",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/basemethod.py#L300-L322 | train |
T-002/pycast | pycast/methods/simplemovingaverage.py | SimpleMovingAverage.execute | def execute(self, timeSeries):
"""Creates a new TimeSeries containing the SMA values for the predefined windowsize.
:param TimeSeries timeSeries: The TimeSeries used to calculate the simple moving average values.
:return: TimeSeries object containing the smooth moving average.
:r... | python | def execute(self, timeSeries):
"""Creates a new TimeSeries containing the SMA values for the predefined windowsize.
:param TimeSeries timeSeries: The TimeSeries used to calculate the simple moving average values.
:return: TimeSeries object containing the smooth moving average.
:r... | [
"def",
"execute",
"(",
"self",
",",
"timeSeries",
")",
":",
"windowsize",
"=",
"self",
".",
"_parameters",
"[",
"\"windowsize\"",
"]",
"if",
"len",
"(",
"timeSeries",
")",
"<",
"windowsize",
":",
"raise",
"ValueError",
"(",
"\"windowsize is larger than the numbe... | Creates a new TimeSeries containing the SMA values for the predefined windowsize.
:param TimeSeries timeSeries: The TimeSeries used to calculate the simple moving average values.
:return: TimeSeries object containing the smooth moving average.
:rtype: TimeSeries
:raise: Ra... | [
"Creates",
"a",
"new",
"TimeSeries",
"containing",
"the",
"SMA",
"values",
"for",
"the",
"predefined",
"windowsize",
"."
] | 8a53505c6d8367e0ea572e8af768e80b29e1cc41 | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/simplemovingaverage.py#L79-L111 | train |
twisted/txaws | txaws/wsdl.py | NodeItem._create_child | def _create_child(self, tag):
"""Create a new child element with the given tag."""
return etree.SubElement(self._root, self._get_namespace_tag(tag)) | python | def _create_child(self, tag):
"""Create a new child element with the given tag."""
return etree.SubElement(self._root, self._get_namespace_tag(tag)) | [
"def",
"_create_child",
"(",
"self",
",",
"tag",
")",
":",
"return",
"etree",
".",
"SubElement",
"(",
"self",
".",
"_root",
",",
"self",
".",
"_get_namespace_tag",
"(",
"tag",
")",
")"
] | Create a new child element with the given tag. | [
"Create",
"a",
"new",
"child",
"element",
"with",
"the",
"given",
"tag",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/wsdl.py#L243-L245 | train |
twisted/txaws | txaws/wsdl.py | SequenceSchema.create | def create(self, root=None, namespace=None):
"""Create a sequence element with the given root.
@param root: The C{etree.Element} to root the sequence at, if C{None} a
new one will be created..
@result: A L{SequenceItem} with the given root.
@raises L{ECResponseError}: If the... | python | def create(self, root=None, namespace=None):
"""Create a sequence element with the given root.
@param root: The C{etree.Element} to root the sequence at, if C{None} a
new one will be created..
@result: A L{SequenceItem} with the given root.
@raises L{ECResponseError}: If the... | [
"def",
"create",
"(",
"self",
",",
"root",
"=",
"None",
",",
"namespace",
"=",
"None",
")",
":",
"if",
"root",
"is",
"not",
"None",
":",
"tag",
"=",
"root",
".",
"tag",
"if",
"root",
".",
"nsmap",
":",
"namespace",
"=",
"root",
".",
"nsmap",
"[",... | Create a sequence element with the given root.
@param root: The C{etree.Element} to root the sequence at, if C{None} a
new one will be created..
@result: A L{SequenceItem} with the given root.
@raises L{ECResponseError}: If the given C{root} has a bad tag. | [
"Create",
"a",
"sequence",
"element",
"with",
"the",
"given",
"root",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/wsdl.py#L316-L332 | train |
twisted/txaws | txaws/wsdl.py | SequenceSchema.set | def set(self, child, min_occurs=1, max_occurs=1):
"""Set the schema for the sequence children.
@param child: The schema that children must match.
@param min_occurs: The minimum number of children the sequence
must have.
@param max_occurs: The maximum number of children the s... | python | def set(self, child, min_occurs=1, max_occurs=1):
"""Set the schema for the sequence children.
@param child: The schema that children must match.
@param min_occurs: The minimum number of children the sequence
must have.
@param max_occurs: The maximum number of children the s... | [
"def",
"set",
"(",
"self",
",",
"child",
",",
"min_occurs",
"=",
"1",
",",
"max_occurs",
"=",
"1",
")",
":",
"if",
"isinstance",
"(",
"child",
",",
"LeafSchema",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Sequence can't have leaf children\"",
")",
"if",
"s... | Set the schema for the sequence children.
@param child: The schema that children must match.
@param min_occurs: The minimum number of children the sequence
must have.
@param max_occurs: The maximum number of children the sequence
can have. | [
"Set",
"the",
"schema",
"for",
"the",
"sequence",
"children",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/wsdl.py#L341-L364 | train |
twisted/txaws | txaws/wsdl.py | SequenceItem.append | def append(self):
"""Append a new item to the sequence, appending it to the end.
@return: The newly created item.
@raises L{WSDLParseError}: If the operation would result in having
more child elements than the allowed max.
"""
tag = self._schema.tag
children... | python | def append(self):
"""Append a new item to the sequence, appending it to the end.
@return: The newly created item.
@raises L{WSDLParseError}: If the operation would result in having
more child elements than the allowed max.
"""
tag = self._schema.tag
children... | [
"def",
"append",
"(",
"self",
")",
":",
"tag",
"=",
"self",
".",
"_schema",
".",
"tag",
"children",
"=",
"self",
".",
"_root",
".",
"getchildren",
"(",
")",
"if",
"len",
"(",
"children",
")",
">=",
"self",
".",
"_schema",
".",
"max_occurs",
":",
"r... | Append a new item to the sequence, appending it to the end.
@return: The newly created item.
@raises L{WSDLParseError}: If the operation would result in having
more child elements than the allowed max. | [
"Append",
"a",
"new",
"item",
"to",
"the",
"sequence",
"appending",
"it",
"to",
"the",
"end",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/wsdl.py#L397-L413 | train |
twisted/txaws | txaws/wsdl.py | SequenceItem._get_child | def _get_child(self, children, index):
"""Return the child with the given index."""
try:
return children[index]
except IndexError:
raise WSDLParseError("Non existing item in tag '%s'" %
self._schema.tag) | python | def _get_child(self, children, index):
"""Return the child with the given index."""
try:
return children[index]
except IndexError:
raise WSDLParseError("Non existing item in tag '%s'" %
self._schema.tag) | [
"def",
"_get_child",
"(",
"self",
",",
"children",
",",
"index",
")",
":",
"try",
":",
"return",
"children",
"[",
"index",
"]",
"except",
"IndexError",
":",
"raise",
"WSDLParseError",
"(",
"\"Non existing item in tag '%s'\"",
"%",
"self",
".",
"_schema",
".",
... | Return the child with the given index. | [
"Return",
"the",
"child",
"with",
"the",
"given",
"index",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/wsdl.py#L452-L458 | train |
twisted/txaws | txaws/wsdl.py | WSDLParser._parse_type | def _parse_type(self, element, types):
"""Parse a 'complexType' element.
@param element: The top-level complexType element
@param types: A map of the elements of all available complexType's.
@return: The schema for the complexType.
"""
name = element.attrib["name"]
... | python | def _parse_type(self, element, types):
"""Parse a 'complexType' element.
@param element: The top-level complexType element
@param types: A map of the elements of all available complexType's.
@return: The schema for the complexType.
"""
name = element.attrib["name"]
... | [
"def",
"_parse_type",
"(",
"self",
",",
"element",
",",
"types",
")",
":",
"name",
"=",
"element",
".",
"attrib",
"[",
"\"name\"",
"]",
"type",
"=",
"element",
".",
"attrib",
"[",
"\"type\"",
"]",
"if",
"not",
"type",
".",
"startswith",
"(",
"\"tns:\""... | Parse a 'complexType' element.
@param element: The top-level complexType element
@param types: A map of the elements of all available complexType's.
@return: The schema for the complexType. | [
"Parse",
"a",
"complexType",
"element",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/wsdl.py#L508-L562 | train |
twisted/txaws | txaws/wsdl.py | WSDLParser._parse_child | def _parse_child(self, child):
"""Parse a single child element.
@param child: The child C{etree.Element} to parse.
@return: A tuple C{(name, type, min_occurs, max_occurs)} with the
details about the given child.
"""
if set(child.attrib) - set(["name", "type", "minOcc... | python | def _parse_child(self, child):
"""Parse a single child element.
@param child: The child C{etree.Element} to parse.
@return: A tuple C{(name, type, min_occurs, max_occurs)} with the
details about the given child.
"""
if set(child.attrib) - set(["name", "type", "minOcc... | [
"def",
"_parse_child",
"(",
"self",
",",
"child",
")",
":",
"if",
"set",
"(",
"child",
".",
"attrib",
")",
"-",
"set",
"(",
"[",
"\"name\"",
",",
"\"type\"",
",",
"\"minOccurs\"",
",",
"\"maxOccurs\"",
"]",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Un... | Parse a single child element.
@param child: The child C{etree.Element} to parse.
@return: A tuple C{(name, type, min_occurs, max_occurs)} with the
details about the given child. | [
"Parse",
"a",
"single",
"child",
"element",
"."
] | 5c3317376cd47e536625027e38c3b37840175ce0 | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/wsdl.py#L564-L584 | train |
Duke-GCB/DukeDSClient | ddsc/core/d4s2.py | CopyActivity.finished | def finished(self):
"""
Mark the activity as finished
"""
self.data_service.update_activity(self.id, self.name, self.desc,
started_on=self.started,
ended_on=self._current_timestamp_str()) | python | def finished(self):
"""
Mark the activity as finished
"""
self.data_service.update_activity(self.id, self.name, self.desc,
started_on=self.started,
ended_on=self._current_timestamp_str()) | [
"def",
"finished",
"(",
"self",
")",
":",
"self",
".",
"data_service",
".",
"update_activity",
"(",
"self",
".",
"id",
",",
"self",
".",
"name",
",",
"self",
".",
"desc",
",",
"started_on",
"=",
"self",
".",
"started",
",",
"ended_on",
"=",
"self",
"... | Mark the activity as finished | [
"Mark",
"the",
"activity",
"as",
"finished"
] | 117f68fb9bae82e4c81ea487ad5d61ac350f3726 | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/d4s2.py#L413-L419 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.