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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ethereum/eth-abi | eth_abi/decoding.py | ContextFramesBytesIO.seek_in_frame | def seek_in_frame(self, pos, *args, **kwargs):
"""
Seeks relative to the total offset of the current contextual frames.
"""
super().seek(self._total_offset + pos, *args, **kwargs) | python | def seek_in_frame(self, pos, *args, **kwargs):
"""
Seeks relative to the total offset of the current contextual frames.
"""
super().seek(self._total_offset + pos, *args, **kwargs) | [
"def",
"seek_in_frame",
"(",
"self",
",",
"pos",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"super",
"(",
")",
".",
"seek",
"(",
"self",
".",
"_total_offset",
"+",
"pos",
",",
"*",
"args",
",",
"**",
"kwargs",
")"
] | Seeks relative to the total offset of the current contextual frames. | [
"Seeks",
"relative",
"to",
"the",
"total",
"offset",
"of",
"the",
"current",
"contextual",
"frames",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/decoding.py#L80-L84 | train |
ethereum/eth-abi | eth_abi/decoding.py | ContextFramesBytesIO.push_frame | def push_frame(self, offset):
"""
Pushes a new contextual frame onto the stack with the given offset and a
return position at the current cursor position then seeks to the new
total offset.
"""
self._frames.append((offset, self.tell()))
self._total_offset += offse... | python | def push_frame(self, offset):
"""
Pushes a new contextual frame onto the stack with the given offset and a
return position at the current cursor position then seeks to the new
total offset.
"""
self._frames.append((offset, self.tell()))
self._total_offset += offse... | [
"def",
"push_frame",
"(",
"self",
",",
"offset",
")",
":",
"self",
".",
"_frames",
".",
"append",
"(",
"(",
"offset",
",",
"self",
".",
"tell",
"(",
")",
")",
")",
"self",
".",
"_total_offset",
"+=",
"offset",
"self",
".",
"seek_in_frame",
"(",
"0",
... | Pushes a new contextual frame onto the stack with the given offset and a
return position at the current cursor position then seeks to the new
total offset. | [
"Pushes",
"a",
"new",
"contextual",
"frame",
"onto",
"the",
"stack",
"with",
"the",
"given",
"offset",
"and",
"a",
"return",
"position",
"at",
"the",
"current",
"cursor",
"position",
"then",
"seeks",
"to",
"the",
"new",
"total",
"offset",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/decoding.py#L86-L95 | train |
ethereum/eth-abi | eth_abi/decoding.py | ContextFramesBytesIO.pop_frame | def pop_frame(self):
"""
Pops the current contextual frame off of the stack and returns the
cursor to the frame's return position.
"""
try:
offset, return_pos = self._frames.pop()
except IndexError:
raise IndexError('no frames to pop')
self... | python | def pop_frame(self):
"""
Pops the current contextual frame off of the stack and returns the
cursor to the frame's return position.
"""
try:
offset, return_pos = self._frames.pop()
except IndexError:
raise IndexError('no frames to pop')
self... | [
"def",
"pop_frame",
"(",
"self",
")",
":",
"try",
":",
"offset",
",",
"return_pos",
"=",
"self",
".",
"_frames",
".",
"pop",
"(",
")",
"except",
"IndexError",
":",
"raise",
"IndexError",
"(",
"'no frames to pop'",
")",
"self",
".",
"_total_offset",
"-=",
... | Pops the current contextual frame off of the stack and returns the
cursor to the frame's return position. | [
"Pops",
"the",
"current",
"contextual",
"frame",
"off",
"of",
"the",
"stack",
"and",
"returns",
"the",
"cursor",
"to",
"the",
"frame",
"s",
"return",
"position",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/decoding.py#L97-L108 | train |
ethereum/eth-abi | eth_abi/registry.py | has_arrlist | def has_arrlist(type_str):
"""
A predicate that matches a type string with an array dimension list.
"""
try:
abi_type = grammar.parse(type_str)
except exceptions.ParseError:
return False
return abi_type.arrlist is not None | python | def has_arrlist(type_str):
"""
A predicate that matches a type string with an array dimension list.
"""
try:
abi_type = grammar.parse(type_str)
except exceptions.ParseError:
return False
return abi_type.arrlist is not None | [
"def",
"has_arrlist",
"(",
"type_str",
")",
":",
"try",
":",
"abi_type",
"=",
"grammar",
".",
"parse",
"(",
"type_str",
")",
"except",
"exceptions",
".",
"ParseError",
":",
"return",
"False",
"return",
"abi_type",
".",
"arrlist",
"is",
"not",
"None"
] | A predicate that matches a type string with an array dimension list. | [
"A",
"predicate",
"that",
"matches",
"a",
"type",
"string",
"with",
"an",
"array",
"dimension",
"list",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/registry.py#L258-L267 | train |
ethereum/eth-abi | eth_abi/registry.py | is_base_tuple | def is_base_tuple(type_str):
"""
A predicate that matches a tuple type with no array dimension list.
"""
try:
abi_type = grammar.parse(type_str)
except exceptions.ParseError:
return False
return isinstance(abi_type, grammar.TupleType) and abi_type.arrlist is None | python | def is_base_tuple(type_str):
"""
A predicate that matches a tuple type with no array dimension list.
"""
try:
abi_type = grammar.parse(type_str)
except exceptions.ParseError:
return False
return isinstance(abi_type, grammar.TupleType) and abi_type.arrlist is None | [
"def",
"is_base_tuple",
"(",
"type_str",
")",
":",
"try",
":",
"abi_type",
"=",
"grammar",
".",
"parse",
"(",
"type_str",
")",
"except",
"exceptions",
".",
"ParseError",
":",
"return",
"False",
"return",
"isinstance",
"(",
"abi_type",
",",
"grammar",
".",
... | A predicate that matches a tuple type with no array dimension list. | [
"A",
"predicate",
"that",
"matches",
"a",
"tuple",
"type",
"with",
"no",
"array",
"dimension",
"list",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/registry.py#L270-L279 | train |
ethereum/eth-abi | eth_abi/registry.py | ABIRegistry.register | def register(self, lookup: Lookup, encoder: Encoder, decoder: Decoder, label: str=None) -> None:
"""
Registers the given ``encoder`` and ``decoder`` under the given
``lookup``. A unique string label may be optionally provided that can
be used to refer to the registration by name.
... | python | def register(self, lookup: Lookup, encoder: Encoder, decoder: Decoder, label: str=None) -> None:
"""
Registers the given ``encoder`` and ``decoder`` under the given
``lookup``. A unique string label may be optionally provided that can
be used to refer to the registration by name.
... | [
"def",
"register",
"(",
"self",
",",
"lookup",
":",
"Lookup",
",",
"encoder",
":",
"Encoder",
",",
"decoder",
":",
"Decoder",
",",
"label",
":",
"str",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"register_encoder",
"(",
"lookup",
",",
"encoder",... | Registers the given ``encoder`` and ``decoder`` under the given
``lookup``. A unique string label may be optionally provided that can
be used to refer to the registration by name.
:param lookup: A type string or type string matcher function
(predicate). When the registry is querie... | [
"Registers",
"the",
"given",
"encoder",
"and",
"decoder",
"under",
"the",
"given",
"lookup",
".",
"A",
"unique",
"string",
"label",
"may",
"be",
"optionally",
"provided",
"that",
"can",
"be",
"used",
"to",
"refer",
"to",
"the",
"registration",
"by",
"name",
... | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/registry.py#L395-L431 | train |
ethereum/eth-abi | eth_abi/registry.py | ABIRegistry.unregister | def unregister(self, label: str) -> None:
"""
Unregisters the entries in the encoder and decoder registries which
have the label ``label``.
"""
self.unregister_encoder(label)
self.unregister_decoder(label) | python | def unregister(self, label: str) -> None:
"""
Unregisters the entries in the encoder and decoder registries which
have the label ``label``.
"""
self.unregister_encoder(label)
self.unregister_decoder(label) | [
"def",
"unregister",
"(",
"self",
",",
"label",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"unregister_encoder",
"(",
"label",
")",
"self",
".",
"unregister_decoder",
"(",
"label",
")"
] | Unregisters the entries in the encoder and decoder registries which
have the label ``label``. | [
"Unregisters",
"the",
"entries",
"in",
"the",
"encoder",
"and",
"decoder",
"registries",
"which",
"have",
"the",
"label",
"label",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/registry.py#L433-L439 | train |
ethereum/eth-abi | eth_abi/registry.py | ABIRegistry.copy | def copy(self):
"""
Copies a registry such that new registrations can be made or existing
registrations can be unregistered without affecting any instance from
which a copy was obtained. This is useful if an existing registry
fulfills most of a user's needs but requires one or t... | python | def copy(self):
"""
Copies a registry such that new registrations can be made or existing
registrations can be unregistered without affecting any instance from
which a copy was obtained. This is useful if an existing registry
fulfills most of a user's needs but requires one or t... | [
"def",
"copy",
"(",
"self",
")",
":",
"cpy",
"=",
"type",
"(",
"self",
")",
"(",
")",
"cpy",
".",
"_encoders",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"_encoders",
")",
"cpy",
".",
"_decoders",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"_... | Copies a registry such that new registrations can be made or existing
registrations can be unregistered without affecting any instance from
which a copy was obtained. This is useful if an existing registry
fulfills most of a user's needs but requires one or two modifications.
In that ca... | [
"Copies",
"a",
"registry",
"such",
"that",
"new",
"registrations",
"can",
"be",
"made",
"or",
"existing",
"registrations",
"can",
"be",
"unregistered",
"without",
"affecting",
"any",
"instance",
"from",
"which",
"a",
"copy",
"was",
"obtained",
".",
"This",
"is... | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/registry.py#L463-L477 | train |
ethereum/eth-abi | eth_abi/codec.py | ABIEncoder.encode_single | def encode_single(self, typ: TypeStr, arg: Any) -> bytes:
"""
Encodes the python value ``arg`` as a binary value of the ABI type
``typ``.
:param typ: The string representation of the ABI type that will be used
for encoding e.g. ``'uint256'``, ``'bytes[]'``, ``'(int,int)'``,
... | python | def encode_single(self, typ: TypeStr, arg: Any) -> bytes:
"""
Encodes the python value ``arg`` as a binary value of the ABI type
``typ``.
:param typ: The string representation of the ABI type that will be used
for encoding e.g. ``'uint256'``, ``'bytes[]'``, ``'(int,int)'``,
... | [
"def",
"encode_single",
"(",
"self",
",",
"typ",
":",
"TypeStr",
",",
"arg",
":",
"Any",
")",
"->",
"bytes",
":",
"encoder",
"=",
"self",
".",
"_registry",
".",
"get_encoder",
"(",
"typ",
")",
"return",
"encoder",
"(",
"arg",
")"
] | Encodes the python value ``arg`` as a binary value of the ABI type
``typ``.
:param typ: The string representation of the ABI type that will be used
for encoding e.g. ``'uint256'``, ``'bytes[]'``, ``'(int,int)'``,
etc.
:param arg: The python value to be encoded.
... | [
"Encodes",
"the",
"python",
"value",
"arg",
"as",
"a",
"binary",
"value",
"of",
"the",
"ABI",
"type",
"typ",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/codec.py#L50-L65 | train |
ethereum/eth-abi | eth_abi/codec.py | ABIEncoder.encode_abi | def encode_abi(self, types: Iterable[TypeStr], args: Iterable[Any]) -> bytes:
"""
Encodes the python values in ``args`` as a sequence of binary values of
the ABI types in ``types`` via the head-tail mechanism.
:param types: An iterable of string representations of the ABI types
... | python | def encode_abi(self, types: Iterable[TypeStr], args: Iterable[Any]) -> bytes:
"""
Encodes the python values in ``args`` as a sequence of binary values of
the ABI types in ``types`` via the head-tail mechanism.
:param types: An iterable of string representations of the ABI types
... | [
"def",
"encode_abi",
"(",
"self",
",",
"types",
":",
"Iterable",
"[",
"TypeStr",
"]",
",",
"args",
":",
"Iterable",
"[",
"Any",
"]",
")",
"->",
"bytes",
":",
"encoders",
"=",
"[",
"self",
".",
"_registry",
".",
"get_encoder",
"(",
"type_str",
")",
"f... | Encodes the python values in ``args`` as a sequence of binary values of
the ABI types in ``types`` via the head-tail mechanism.
:param types: An iterable of string representations of the ABI types
that will be used for encoding e.g. ``('uint256', 'bytes[]',
'(int,int)')``
... | [
"Encodes",
"the",
"python",
"values",
"in",
"args",
"as",
"a",
"sequence",
"of",
"binary",
"values",
"of",
"the",
"ABI",
"types",
"in",
"types",
"via",
"the",
"head",
"-",
"tail",
"mechanism",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/codec.py#L67-L87 | train |
ethereum/eth-abi | eth_abi/codec.py | ABIEncoder.is_encodable | def is_encodable(self, typ: TypeStr, arg: Any) -> bool:
"""
Determines if the python value ``arg`` is encodable as a value of the
ABI type ``typ``.
:param typ: A string representation for the ABI type against which the
python value ``arg`` will be checked e.g. ``'uint256'``,... | python | def is_encodable(self, typ: TypeStr, arg: Any) -> bool:
"""
Determines if the python value ``arg`` is encodable as a value of the
ABI type ``typ``.
:param typ: A string representation for the ABI type against which the
python value ``arg`` will be checked e.g. ``'uint256'``,... | [
"def",
"is_encodable",
"(",
"self",
",",
"typ",
":",
"TypeStr",
",",
"arg",
":",
"Any",
")",
"->",
"bool",
":",
"encoder",
"=",
"self",
".",
"_registry",
".",
"get_encoder",
"(",
"typ",
")",
"try",
":",
"encoder",
".",
"validate_value",
"(",
"arg",
"... | Determines if the python value ``arg`` is encodable as a value of the
ABI type ``typ``.
:param typ: A string representation for the ABI type against which the
python value ``arg`` will be checked e.g. ``'uint256'``,
``'bytes[]'``, ``'(int,int)'``, etc.
:param arg: The py... | [
"Determines",
"if",
"the",
"python",
"value",
"arg",
"is",
"encodable",
"as",
"a",
"value",
"of",
"the",
"ABI",
"type",
"typ",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/codec.py#L89-L114 | train |
ethereum/eth-abi | eth_abi/codec.py | ABIDecoder.decode_single | def decode_single(self, typ: TypeStr, data: Decodable) -> Any:
"""
Decodes the binary value ``data`` of the ABI type ``typ`` into its
equivalent python value.
:param typ: The string representation of the ABI type that will be used for
decoding e.g. ``'uint256'``, ``'bytes[]'... | python | def decode_single(self, typ: TypeStr, data: Decodable) -> Any:
"""
Decodes the binary value ``data`` of the ABI type ``typ`` into its
equivalent python value.
:param typ: The string representation of the ABI type that will be used for
decoding e.g. ``'uint256'``, ``'bytes[]'... | [
"def",
"decode_single",
"(",
"self",
",",
"typ",
":",
"TypeStr",
",",
"data",
":",
"Decodable",
")",
"->",
"Any",
":",
"if",
"not",
"is_bytes",
"(",
"data",
")",
":",
"raise",
"TypeError",
"(",
"\"The `data` value must be of bytes type. Got {0}\"",
".",
"form... | Decodes the binary value ``data`` of the ABI type ``typ`` into its
equivalent python value.
:param typ: The string representation of the ABI type that will be used for
decoding e.g. ``'uint256'``, ``'bytes[]'``, ``'(int,int)'``, etc.
:param data: The binary value to be decoded.
... | [
"Decodes",
"the",
"binary",
"value",
"data",
"of",
"the",
"ABI",
"type",
"typ",
"into",
"its",
"equivalent",
"python",
"value",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/codec.py#L135-L153 | train |
ethereum/eth-abi | eth_abi/codec.py | ABIDecoder.decode_abi | def decode_abi(self, types: Iterable[TypeStr], data: Decodable) -> Tuple[Any, ...]:
"""
Decodes the binary value ``data`` as a sequence of values of the ABI types
in ``types`` via the head-tail mechanism into a tuple of equivalent python
values.
:param types: An iterable of stri... | python | def decode_abi(self, types: Iterable[TypeStr], data: Decodable) -> Tuple[Any, ...]:
"""
Decodes the binary value ``data`` as a sequence of values of the ABI types
in ``types`` via the head-tail mechanism into a tuple of equivalent python
values.
:param types: An iterable of stri... | [
"def",
"decode_abi",
"(",
"self",
",",
"types",
":",
"Iterable",
"[",
"TypeStr",
"]",
",",
"data",
":",
"Decodable",
")",
"->",
"Tuple",
"[",
"Any",
",",
"...",
"]",
":",
"if",
"not",
"is_bytes",
"(",
"data",
")",
":",
"raise",
"TypeError",
"(",
"\... | Decodes the binary value ``data`` as a sequence of values of the ABI types
in ``types`` via the head-tail mechanism into a tuple of equivalent python
values.
:param types: An iterable of string representations of the ABI types that
will be used for decoding e.g. ``('uint256', 'bytes... | [
"Decodes",
"the",
"binary",
"value",
"data",
"as",
"a",
"sequence",
"of",
"values",
"of",
"the",
"ABI",
"types",
"in",
"types",
"via",
"the",
"head",
"-",
"tail",
"mechanism",
"into",
"a",
"tuple",
"of",
"equivalent",
"python",
"values",
"."
] | 0a5cab0bdeae30b77efa667379427581784f1707 | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/codec.py#L155-L179 | train |
aiortc/aioice | aioice/turn.py | create_turn_endpoint | async def create_turn_endpoint(protocol_factory, server_addr, username, password,
lifetime=600, ssl=False, transport='udp'):
"""
Create datagram connection relayed over TURN.
"""
loop = asyncio.get_event_loop()
if transport == 'tcp':
_, inner_protocol = await l... | python | async def create_turn_endpoint(protocol_factory, server_addr, username, password,
lifetime=600, ssl=False, transport='udp'):
"""
Create datagram connection relayed over TURN.
"""
loop = asyncio.get_event_loop()
if transport == 'tcp':
_, inner_protocol = await l... | [
"async",
"def",
"create_turn_endpoint",
"(",
"protocol_factory",
",",
"server_addr",
",",
"username",
",",
"password",
",",
"lifetime",
"=",
"600",
",",
"ssl",
"=",
"False",
",",
"transport",
"=",
"'udp'",
")",
":",
"loop",
"=",
"asyncio",
".",
"get_event_lo... | Create datagram connection relayed over TURN. | [
"Create",
"datagram",
"connection",
"relayed",
"over",
"TURN",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/turn.py#L276-L303 | train |
aiortc/aioice | aioice/turn.py | TurnClientMixin.connect | async def connect(self):
"""
Create a TURN allocation.
"""
request = stun.Message(message_method=stun.Method.ALLOCATE,
message_class=stun.Class.REQUEST)
request.attributes['LIFETIME'] = self.lifetime
request.attributes['REQUESTED-TRANSPORT']... | python | async def connect(self):
"""
Create a TURN allocation.
"""
request = stun.Message(message_method=stun.Method.ALLOCATE,
message_class=stun.Class.REQUEST)
request.attributes['LIFETIME'] = self.lifetime
request.attributes['REQUESTED-TRANSPORT']... | [
"async",
"def",
"connect",
"(",
"self",
")",
":",
"request",
"=",
"stun",
".",
"Message",
"(",
"message_method",
"=",
"stun",
".",
"Method",
".",
"ALLOCATE",
",",
"message_class",
"=",
"stun",
".",
"Class",
".",
"REQUEST",
")",
"request",
".",
"attribute... | Create a TURN allocation. | [
"Create",
"a",
"TURN",
"allocation",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/turn.py#L70-L99 | train |
aiortc/aioice | aioice/turn.py | TurnClientMixin.delete | async def delete(self):
"""
Delete the TURN allocation.
"""
if self.refresh_handle:
self.refresh_handle.cancel()
self.refresh_handle = None
request = stun.Message(message_method=stun.Method.REFRESH,
message_class=stun.Class.... | python | async def delete(self):
"""
Delete the TURN allocation.
"""
if self.refresh_handle:
self.refresh_handle.cancel()
self.refresh_handle = None
request = stun.Message(message_method=stun.Method.REFRESH,
message_class=stun.Class.... | [
"async",
"def",
"delete",
"(",
"self",
")",
":",
"if",
"self",
".",
"refresh_handle",
":",
"self",
".",
"refresh_handle",
".",
"cancel",
"(",
")",
"self",
".",
"refresh_handle",
"=",
"None",
"request",
"=",
"stun",
".",
"Message",
"(",
"message_method",
... | Delete the TURN allocation. | [
"Delete",
"the",
"TURN",
"allocation",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/turn.py#L130-L145 | train |
aiortc/aioice | aioice/turn.py | TurnClientMixin.refresh | async def refresh(self):
"""
Periodically refresh the TURN allocation.
"""
while True:
await asyncio.sleep(5/6 * self.lifetime)
request = stun.Message(message_method=stun.Method.REFRESH,
message_class=stun.Class.REQUEST)
... | python | async def refresh(self):
"""
Periodically refresh the TURN allocation.
"""
while True:
await asyncio.sleep(5/6 * self.lifetime)
request = stun.Message(message_method=stun.Method.REFRESH,
message_class=stun.Class.REQUEST)
... | [
"async",
"def",
"refresh",
"(",
"self",
")",
":",
"while",
"True",
":",
"await",
"asyncio",
".",
"sleep",
"(",
"5",
"/",
"6",
"*",
"self",
".",
"lifetime",
")",
"request",
"=",
"stun",
".",
"Message",
"(",
"message_method",
"=",
"stun",
".",
"Method"... | Periodically refresh the TURN allocation. | [
"Periodically",
"refresh",
"the",
"TURN",
"allocation",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/turn.py#L147-L159 | train |
aiortc/aioice | aioice/turn.py | TurnClientMixin.send_data | async def send_data(self, data, addr):
"""
Send data to a remote host via the TURN server.
"""
channel = self.peer_to_channel.get(addr)
if channel is None:
channel = self.channel_number
self.channel_number += 1
self.channel_to_peer[channel] = a... | python | async def send_data(self, data, addr):
"""
Send data to a remote host via the TURN server.
"""
channel = self.peer_to_channel.get(addr)
if channel is None:
channel = self.channel_number
self.channel_number += 1
self.channel_to_peer[channel] = a... | [
"async",
"def",
"send_data",
"(",
"self",
",",
"data",
",",
"addr",
")",
":",
"channel",
"=",
"self",
".",
"peer_to_channel",
".",
"get",
"(",
"addr",
")",
"if",
"channel",
"is",
"None",
":",
"channel",
"=",
"self",
".",
"channel_number",
"self",
".",
... | Send data to a remote host via the TURN server. | [
"Send",
"data",
"to",
"a",
"remote",
"host",
"via",
"the",
"TURN",
"server",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/turn.py#L177-L192 | train |
aiortc/aioice | aioice/turn.py | TurnClientMixin.send_stun | def send_stun(self, message, addr):
"""
Send a STUN message to the TURN server.
"""
logger.debug('%s > %s %s', self, addr, message)
self._send(bytes(message)) | python | def send_stun(self, message, addr):
"""
Send a STUN message to the TURN server.
"""
logger.debug('%s > %s %s', self, addr, message)
self._send(bytes(message)) | [
"def",
"send_stun",
"(",
"self",
",",
"message",
",",
"addr",
")",
":",
"logger",
".",
"debug",
"(",
"'%s > %s %s'",
",",
"self",
",",
"addr",
",",
"message",
")",
"self",
".",
"_send",
"(",
"bytes",
"(",
"message",
")",
")"
] | Send a STUN message to the TURN server. | [
"Send",
"a",
"STUN",
"message",
"to",
"the",
"TURN",
"server",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/turn.py#L194-L199 | train |
aiortc/aioice | aioice/turn.py | TurnTransport.get_extra_info | def get_extra_info(self, name, default=None):
"""
Return optional transport information.
- `'related_address'`: the related address
- `'sockname'`: the relayed address
"""
if name == 'related_address':
return self.__inner_protocol.transport.get_extra_info('so... | python | def get_extra_info(self, name, default=None):
"""
Return optional transport information.
- `'related_address'`: the related address
- `'sockname'`: the relayed address
"""
if name == 'related_address':
return self.__inner_protocol.transport.get_extra_info('so... | [
"def",
"get_extra_info",
"(",
"self",
",",
"name",
",",
"default",
"=",
"None",
")",
":",
"if",
"name",
"==",
"'related_address'",
":",
"return",
"self",
".",
"__inner_protocol",
".",
"transport",
".",
"get_extra_info",
"(",
"'sockname'",
")",
"elif",
"name"... | Return optional transport information.
- `'related_address'`: the related address
- `'sockname'`: the relayed address | [
"Return",
"optional",
"transport",
"information",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/turn.py#L250-L261 | train |
aiortc/aioice | aioice/turn.py | TurnTransport.sendto | def sendto(self, data, addr):
"""
Sends the `data` bytes to the remote peer given `addr`.
This will bind a TURN channel as necessary.
"""
asyncio.ensure_future(self.__inner_protocol.send_data(data, addr)) | python | def sendto(self, data, addr):
"""
Sends the `data` bytes to the remote peer given `addr`.
This will bind a TURN channel as necessary.
"""
asyncio.ensure_future(self.__inner_protocol.send_data(data, addr)) | [
"def",
"sendto",
"(",
"self",
",",
"data",
",",
"addr",
")",
":",
"asyncio",
".",
"ensure_future",
"(",
"self",
".",
"__inner_protocol",
".",
"send_data",
"(",
"data",
",",
"addr",
")",
")"
] | Sends the `data` bytes to the remote peer given `addr`.
This will bind a TURN channel as necessary. | [
"Sends",
"the",
"data",
"bytes",
"to",
"the",
"remote",
"peer",
"given",
"addr",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/turn.py#L263-L269 | train |
aiortc/aioice | aioice/candidate.py | candidate_foundation | def candidate_foundation(candidate_type, candidate_transport, base_address):
"""
See RFC 5245 - 4.1.1.3. Computing Foundations
"""
key = '%s|%s|%s' % (candidate_type, candidate_transport, base_address)
return hashlib.md5(key.encode('ascii')).hexdigest() | python | def candidate_foundation(candidate_type, candidate_transport, base_address):
"""
See RFC 5245 - 4.1.1.3. Computing Foundations
"""
key = '%s|%s|%s' % (candidate_type, candidate_transport, base_address)
return hashlib.md5(key.encode('ascii')).hexdigest() | [
"def",
"candidate_foundation",
"(",
"candidate_type",
",",
"candidate_transport",
",",
"base_address",
")",
":",
"key",
"=",
"'%s|%s|%s'",
"%",
"(",
"candidate_type",
",",
"candidate_transport",
",",
"base_address",
")",
"return",
"hashlib",
".",
"md5",
"(",
"key"... | See RFC 5245 - 4.1.1.3. Computing Foundations | [
"See",
"RFC",
"5245",
"-",
"4",
".",
"1",
".",
"1",
".",
"3",
".",
"Computing",
"Foundations"
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/candidate.py#L5-L10 | train |
aiortc/aioice | aioice/candidate.py | candidate_priority | def candidate_priority(candidate_component, candidate_type, local_pref=65535):
"""
See RFC 5245 - 4.1.2.1. Recommended Formula
"""
if candidate_type == 'host':
type_pref = 126
elif candidate_type == 'prflx':
type_pref = 110
elif candidate_type == 'srflx':
type_pref = 100
... | python | def candidate_priority(candidate_component, candidate_type, local_pref=65535):
"""
See RFC 5245 - 4.1.2.1. Recommended Formula
"""
if candidate_type == 'host':
type_pref = 126
elif candidate_type == 'prflx':
type_pref = 110
elif candidate_type == 'srflx':
type_pref = 100
... | [
"def",
"candidate_priority",
"(",
"candidate_component",
",",
"candidate_type",
",",
"local_pref",
"=",
"65535",
")",
":",
"if",
"candidate_type",
"==",
"'host'",
":",
"type_pref",
"=",
"126",
"elif",
"candidate_type",
"==",
"'prflx'",
":",
"type_pref",
"=",
"11... | See RFC 5245 - 4.1.2.1. Recommended Formula | [
"See",
"RFC",
"5245",
"-",
"4",
".",
"1",
".",
"2",
".",
"1",
".",
"Recommended",
"Formula"
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/candidate.py#L13-L28 | train |
aiortc/aioice | aioice/candidate.py | Candidate.to_sdp | def to_sdp(self):
"""
Return a string representation suitable for SDP.
"""
sdp = '%s %d %s %d %s %d typ %s' % (
self.foundation,
self.component,
self.transport,
self.priority,
self.host,
self.port,
self.t... | python | def to_sdp(self):
"""
Return a string representation suitable for SDP.
"""
sdp = '%s %d %s %d %s %d typ %s' % (
self.foundation,
self.component,
self.transport,
self.priority,
self.host,
self.port,
self.t... | [
"def",
"to_sdp",
"(",
"self",
")",
":",
"sdp",
"=",
"'%s %d %s %d %s %d typ %s'",
"%",
"(",
"self",
".",
"foundation",
",",
"self",
".",
"component",
",",
"self",
".",
"transport",
",",
"self",
".",
"priority",
",",
"self",
".",
"host",
",",
"self",
".... | Return a string representation suitable for SDP. | [
"Return",
"a",
"string",
"representation",
"suitable",
"for",
"SDP",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/candidate.py#L85-L105 | train |
aiortc/aioice | aioice/candidate.py | Candidate.can_pair_with | def can_pair_with(self, other):
"""
A local candidate is paired with a remote candidate if and only if
the two candidates have the same component ID and have the same IP
address version.
"""
a = ipaddress.ip_address(self.host)
b = ipaddress.ip_address(other.host)
... | python | def can_pair_with(self, other):
"""
A local candidate is paired with a remote candidate if and only if
the two candidates have the same component ID and have the same IP
address version.
"""
a = ipaddress.ip_address(self.host)
b = ipaddress.ip_address(other.host)
... | [
"def",
"can_pair_with",
"(",
"self",
",",
"other",
")",
":",
"a",
"=",
"ipaddress",
".",
"ip_address",
"(",
"self",
".",
"host",
")",
"b",
"=",
"ipaddress",
".",
"ip_address",
"(",
"other",
".",
"host",
")",
"return",
"(",
"self",
".",
"component",
"... | A local candidate is paired with a remote candidate if and only if
the two candidates have the same component ID and have the same IP
address version. | [
"A",
"local",
"candidate",
"is",
"paired",
"with",
"a",
"remote",
"candidate",
"if",
"and",
"only",
"if",
"the",
"two",
"candidates",
"have",
"the",
"same",
"component",
"ID",
"and",
"have",
"the",
"same",
"IP",
"address",
"version",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/candidate.py#L107-L119 | train |
aiortc/aioice | aioice/ice.py | candidate_pair_priority | def candidate_pair_priority(local, remote, ice_controlling):
"""
See RFC 5245 - 5.7.2. Computing Pair Priority and Ordering Pairs
"""
G = ice_controlling and local.priority or remote.priority
D = ice_controlling and remote.priority or local.priority
return (1 << 32) * min(G, D) + 2 * max(G, D) +... | python | def candidate_pair_priority(local, remote, ice_controlling):
"""
See RFC 5245 - 5.7.2. Computing Pair Priority and Ordering Pairs
"""
G = ice_controlling and local.priority or remote.priority
D = ice_controlling and remote.priority or local.priority
return (1 << 32) * min(G, D) + 2 * max(G, D) +... | [
"def",
"candidate_pair_priority",
"(",
"local",
",",
"remote",
",",
"ice_controlling",
")",
":",
"G",
"=",
"ice_controlling",
"and",
"local",
".",
"priority",
"or",
"remote",
".",
"priority",
"D",
"=",
"ice_controlling",
"and",
"remote",
".",
"priority",
"or",... | See RFC 5245 - 5.7.2. Computing Pair Priority and Ordering Pairs | [
"See",
"RFC",
"5245",
"-",
"5",
".",
"7",
".",
"2",
".",
"Computing",
"Pair",
"Priority",
"and",
"Ordering",
"Pairs"
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L24-L30 | train |
aiortc/aioice | aioice/ice.py | get_host_addresses | def get_host_addresses(use_ipv4, use_ipv6):
"""
Get local IP addresses.
"""
addresses = []
for interface in netifaces.interfaces():
ifaddresses = netifaces.ifaddresses(interface)
for address in ifaddresses.get(socket.AF_INET, []):
if use_ipv4 and address['addr'] != '127.0... | python | def get_host_addresses(use_ipv4, use_ipv6):
"""
Get local IP addresses.
"""
addresses = []
for interface in netifaces.interfaces():
ifaddresses = netifaces.ifaddresses(interface)
for address in ifaddresses.get(socket.AF_INET, []):
if use_ipv4 and address['addr'] != '127.0... | [
"def",
"get_host_addresses",
"(",
"use_ipv4",
",",
"use_ipv6",
")",
":",
"addresses",
"=",
"[",
"]",
"for",
"interface",
"in",
"netifaces",
".",
"interfaces",
"(",
")",
":",
"ifaddresses",
"=",
"netifaces",
".",
"ifaddresses",
"(",
"interface",
")",
"for",
... | Get local IP addresses. | [
"Get",
"local",
"IP",
"addresses",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L33-L46 | train |
aiortc/aioice | aioice/ice.py | server_reflexive_candidate | async def server_reflexive_candidate(protocol, stun_server):
"""
Query STUN server to obtain a server-reflexive candidate.
"""
# lookup address
loop = asyncio.get_event_loop()
stun_server = (
await loop.run_in_executor(None, socket.gethostbyname, stun_server[0]),
stun_server[1])
... | python | async def server_reflexive_candidate(protocol, stun_server):
"""
Query STUN server to obtain a server-reflexive candidate.
"""
# lookup address
loop = asyncio.get_event_loop()
stun_server = (
await loop.run_in_executor(None, socket.gethostbyname, stun_server[0]),
stun_server[1])
... | [
"async",
"def",
"server_reflexive_candidate",
"(",
"protocol",
",",
"stun_server",
")",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"stun_server",
"=",
"(",
"await",
"loop",
".",
"run_in_executor",
"(",
"None",
",",
"socket",
".",
"gethostbyn... | Query STUN server to obtain a server-reflexive candidate. | [
"Query",
"STUN",
"server",
"to",
"obtain",
"a",
"server",
"-",
"reflexive",
"candidate",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L49-L74 | train |
aiortc/aioice | aioice/ice.py | sort_candidate_pairs | def sort_candidate_pairs(pairs, ice_controlling):
"""
Sort a list of candidate pairs.
"""
def pair_priority(pair):
return -candidate_pair_priority(pair.local_candidate,
pair.remote_candidate,
ice_controlling)
pa... | python | def sort_candidate_pairs(pairs, ice_controlling):
"""
Sort a list of candidate pairs.
"""
def pair_priority(pair):
return -candidate_pair_priority(pair.local_candidate,
pair.remote_candidate,
ice_controlling)
pa... | [
"def",
"sort_candidate_pairs",
"(",
"pairs",
",",
"ice_controlling",
")",
":",
"def",
"pair_priority",
"(",
"pair",
")",
":",
"return",
"-",
"candidate_pair_priority",
"(",
"pair",
".",
"local_candidate",
",",
"pair",
".",
"remote_candidate",
",",
"ice_controlling... | Sort a list of candidate pairs. | [
"Sort",
"a",
"list",
"of",
"candidate",
"pairs",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L77-L86 | train |
aiortc/aioice | aioice/ice.py | StunProtocol.send_stun | def send_stun(self, message, addr):
"""
Send a STUN message.
"""
self.__log_debug('> %s %s', addr, message)
self.transport.sendto(bytes(message), addr) | python | def send_stun(self, message, addr):
"""
Send a STUN message.
"""
self.__log_debug('> %s %s', addr, message)
self.transport.sendto(bytes(message), addr) | [
"def",
"send_stun",
"(",
"self",
",",
"message",
",",
"addr",
")",
":",
"self",
".",
"__log_debug",
"(",
"'> %s %s'",
",",
"addr",
",",
"message",
")",
"self",
".",
"transport",
".",
"sendto",
"(",
"bytes",
"(",
"message",
")",
",",
"addr",
")"
] | Send a STUN message. | [
"Send",
"a",
"STUN",
"message",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L200-L205 | train |
aiortc/aioice | aioice/ice.py | Connection.add_remote_candidate | def add_remote_candidate(self, remote_candidate):
"""
Add a remote candidate or signal end-of-candidates.
To signal end-of-candidates, pass `None`.
"""
if self._remote_candidates_end:
raise ValueError('Cannot add remote candidate after end-of-candidates.')
i... | python | def add_remote_candidate(self, remote_candidate):
"""
Add a remote candidate or signal end-of-candidates.
To signal end-of-candidates, pass `None`.
"""
if self._remote_candidates_end:
raise ValueError('Cannot add remote candidate after end-of-candidates.')
i... | [
"def",
"add_remote_candidate",
"(",
"self",
",",
"remote_candidate",
")",
":",
"if",
"self",
".",
"_remote_candidates_end",
":",
"raise",
"ValueError",
"(",
"'Cannot add remote candidate after end-of-candidates.'",
")",
"if",
"remote_candidate",
"is",
"None",
":",
"self... | Add a remote candidate or signal end-of-candidates.
To signal end-of-candidates, pass `None`. | [
"Add",
"a",
"remote",
"candidate",
"or",
"signal",
"end",
"-",
"of",
"-",
"candidates",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L299-L319 | train |
aiortc/aioice | aioice/ice.py | Connection.gather_candidates | async def gather_candidates(self):
"""
Gather local candidates.
You **must** call this coroutine before calling :meth:`connect`.
"""
if not self._local_candidates_start:
self._local_candidates_start = True
addresses = get_host_addresses(use_ipv4=self._use... | python | async def gather_candidates(self):
"""
Gather local candidates.
You **must** call this coroutine before calling :meth:`connect`.
"""
if not self._local_candidates_start:
self._local_candidates_start = True
addresses = get_host_addresses(use_ipv4=self._use... | [
"async",
"def",
"gather_candidates",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_local_candidates_start",
":",
"self",
".",
"_local_candidates_start",
"=",
"True",
"addresses",
"=",
"get_host_addresses",
"(",
"use_ipv4",
"=",
"self",
".",
"_use_ipv4",
","... | Gather local candidates.
You **must** call this coroutine before calling :meth:`connect`. | [
"Gather",
"local",
"candidates",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L321-L334 | train |
aiortc/aioice | aioice/ice.py | Connection.get_default_candidate | def get_default_candidate(self, component):
"""
Gets the default local candidate for the specified component.
"""
for candidate in sorted(self._local_candidates, key=lambda x: x.priority):
if candidate.component == component:
return candidate | python | def get_default_candidate(self, component):
"""
Gets the default local candidate for the specified component.
"""
for candidate in sorted(self._local_candidates, key=lambda x: x.priority):
if candidate.component == component:
return candidate | [
"def",
"get_default_candidate",
"(",
"self",
",",
"component",
")",
":",
"for",
"candidate",
"in",
"sorted",
"(",
"self",
".",
"_local_candidates",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
".",
"priority",
")",
":",
"if",
"candidate",
".",
"component",
... | Gets the default local candidate for the specified component. | [
"Gets",
"the",
"default",
"local",
"candidate",
"for",
"the",
"specified",
"component",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L336-L342 | train |
aiortc/aioice | aioice/ice.py | Connection.connect | async def connect(self):
"""
Perform ICE handshake.
This coroutine returns if a candidate pair was successfuly nominated
and raises an exception otherwise.
"""
if not self._local_candidates_end:
raise ConnectionError('Local candidates gathering was not perfor... | python | async def connect(self):
"""
Perform ICE handshake.
This coroutine returns if a candidate pair was successfuly nominated
and raises an exception otherwise.
"""
if not self._local_candidates_end:
raise ConnectionError('Local candidates gathering was not perfor... | [
"async",
"def",
"connect",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_local_candidates_end",
":",
"raise",
"ConnectionError",
"(",
"'Local candidates gathering was not performed'",
")",
"if",
"(",
"self",
".",
"remote_username",
"is",
"None",
"or",
"self",... | Perform ICE handshake.
This coroutine returns if a candidate pair was successfuly nominated
and raises an exception otherwise. | [
"Perform",
"ICE",
"handshake",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L344-L395 | train |
aiortc/aioice | aioice/ice.py | Connection.recvfrom | async def recvfrom(self):
"""
Receive the next datagram.
The return value is a `(bytes, component)` tuple where `bytes` is a
bytes object representing the data received and `component` is the
component on which the data was received.
If the connection is not established... | python | async def recvfrom(self):
"""
Receive the next datagram.
The return value is a `(bytes, component)` tuple where `bytes` is a
bytes object representing the data received and `component` is the
component on which the data was received.
If the connection is not established... | [
"async",
"def",
"recvfrom",
"(",
"self",
")",
":",
"if",
"not",
"len",
"(",
"self",
".",
"_nominated",
")",
":",
"raise",
"ConnectionError",
"(",
"'Cannot receive data, not connected'",
")",
"result",
"=",
"await",
"self",
".",
"_queue",
".",
"get",
"(",
"... | Receive the next datagram.
The return value is a `(bytes, component)` tuple where `bytes` is a
bytes object representing the data received and `component` is the
component on which the data was received.
If the connection is not established, a `ConnectionError` is raised. | [
"Receive",
"the",
"next",
"datagram",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L430-L446 | train |
aiortc/aioice | aioice/ice.py | Connection.sendto | async def sendto(self, data, component):
"""
Send a datagram on the specified component.
If the connection is not established, a `ConnectionError` is raised.
"""
active_pair = self._nominated.get(component)
if active_pair:
await active_pair.protocol.send_data... | python | async def sendto(self, data, component):
"""
Send a datagram on the specified component.
If the connection is not established, a `ConnectionError` is raised.
"""
active_pair = self._nominated.get(component)
if active_pair:
await active_pair.protocol.send_data... | [
"async",
"def",
"sendto",
"(",
"self",
",",
"data",
",",
"component",
")",
":",
"active_pair",
"=",
"self",
".",
"_nominated",
".",
"get",
"(",
"component",
")",
"if",
"active_pair",
":",
"await",
"active_pair",
".",
"protocol",
".",
"send_data",
"(",
"d... | Send a datagram on the specified component.
If the connection is not established, a `ConnectionError` is raised. | [
"Send",
"a",
"datagram",
"on",
"the",
"specified",
"component",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L456-L466 | train |
aiortc/aioice | aioice/ice.py | Connection.set_selected_pair | def set_selected_pair(self, component, local_foundation, remote_foundation):
"""
Force the selected candidate pair.
If the remote party does not support ICE, you should using this
instead of calling :meth:`connect`.
"""
# find local candidate
protocol = None
... | python | def set_selected_pair(self, component, local_foundation, remote_foundation):
"""
Force the selected candidate pair.
If the remote party does not support ICE, you should using this
instead of calling :meth:`connect`.
"""
# find local candidate
protocol = None
... | [
"def",
"set_selected_pair",
"(",
"self",
",",
"component",
",",
"local_foundation",
",",
"remote_foundation",
")",
":",
"protocol",
"=",
"None",
"for",
"p",
"in",
"self",
".",
"_protocols",
":",
"if",
"(",
"p",
".",
"local_candidate",
".",
"component",
"==",... | Force the selected candidate pair.
If the remote party does not support ICE, you should using this
instead of calling :meth:`connect`. | [
"Force",
"the",
"selected",
"candidate",
"pair",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L468-L490 | train |
aiortc/aioice | aioice/ice.py | Connection.check_incoming | def check_incoming(self, message, addr, protocol):
"""
Handle a succesful incoming check.
"""
component = protocol.local_candidate.component
# find remote candidate
remote_candidate = None
for c in self._remote_candidates:
if c.host == addr[0] and c.p... | python | def check_incoming(self, message, addr, protocol):
"""
Handle a succesful incoming check.
"""
component = protocol.local_candidate.component
# find remote candidate
remote_candidate = None
for c in self._remote_candidates:
if c.host == addr[0] and c.p... | [
"def",
"check_incoming",
"(",
"self",
",",
"message",
",",
"addr",
",",
"protocol",
")",
":",
"component",
"=",
"protocol",
".",
"local_candidate",
".",
"component",
"remote_candidate",
"=",
"None",
"for",
"c",
"in",
"self",
".",
"_remote_candidates",
":",
"... | Handle a succesful incoming check. | [
"Handle",
"a",
"succesful",
"incoming",
"check",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L554-L598 | train |
aiortc/aioice | aioice/ice.py | Connection.check_start | async def check_start(self, pair):
"""
Starts a check.
"""
self.check_state(pair, CandidatePair.State.IN_PROGRESS)
request = self.build_request(pair)
try:
response, addr = await pair.protocol.request(
request, pair.remote_addr,
... | python | async def check_start(self, pair):
"""
Starts a check.
"""
self.check_state(pair, CandidatePair.State.IN_PROGRESS)
request = self.build_request(pair)
try:
response, addr = await pair.protocol.request(
request, pair.remote_addr,
... | [
"async",
"def",
"check_start",
"(",
"self",
",",
"pair",
")",
":",
"self",
".",
"check_state",
"(",
"pair",
",",
"CandidatePair",
".",
"State",
".",
"IN_PROGRESS",
")",
"request",
"=",
"self",
".",
"build_request",
"(",
"pair",
")",
"try",
":",
"response... | Starts a check. | [
"Starts",
"a",
"check",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L619-L654 | train |
aiortc/aioice | aioice/ice.py | Connection.check_state | def check_state(self, pair, state):
"""
Updates the state of a check.
"""
self.__log_info('Check %s %s -> %s', pair, pair.state, state)
pair.state = state | python | def check_state(self, pair, state):
"""
Updates the state of a check.
"""
self.__log_info('Check %s %s -> %s', pair, pair.state, state)
pair.state = state | [
"def",
"check_state",
"(",
"self",
",",
"pair",
",",
"state",
")",
":",
"self",
".",
"__log_info",
"(",
"'Check %s %s -> %s'",
",",
"pair",
",",
"pair",
".",
"state",
",",
"state",
")",
"pair",
".",
"state",
"=",
"state"
] | Updates the state of a check. | [
"Updates",
"the",
"state",
"of",
"a",
"check",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L656-L661 | train |
aiortc/aioice | aioice/ice.py | Connection._find_pair | def _find_pair(self, protocol, remote_candidate):
"""
Find a candidate pair in the check list.
"""
for pair in self._check_list:
if (pair.protocol == protocol and pair.remote_candidate == remote_candidate):
return pair
return None | python | def _find_pair(self, protocol, remote_candidate):
"""
Find a candidate pair in the check list.
"""
for pair in self._check_list:
if (pair.protocol == protocol and pair.remote_candidate == remote_candidate):
return pair
return None | [
"def",
"_find_pair",
"(",
"self",
",",
"protocol",
",",
"remote_candidate",
")",
":",
"for",
"pair",
"in",
"self",
".",
"_check_list",
":",
"if",
"(",
"pair",
".",
"protocol",
"==",
"protocol",
"and",
"pair",
".",
"remote_candidate",
"==",
"remote_candidate"... | Find a candidate pair in the check list. | [
"Find",
"a",
"candidate",
"pair",
"in",
"the",
"check",
"list",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L663-L670 | train |
aiortc/aioice | aioice/ice.py | Connection._prune_components | def _prune_components(self):
"""
Remove components for which the remote party did not provide any candidates.
This can only be determined after end-of-candidates.
"""
seen_components = set(map(lambda x: x.component, self._remote_candidates))
missing_components = self._co... | python | def _prune_components(self):
"""
Remove components for which the remote party did not provide any candidates.
This can only be determined after end-of-candidates.
"""
seen_components = set(map(lambda x: x.component, self._remote_candidates))
missing_components = self._co... | [
"def",
"_prune_components",
"(",
"self",
")",
":",
"seen_components",
"=",
"set",
"(",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"component",
",",
"self",
".",
"_remote_candidates",
")",
")",
"missing_components",
"=",
"self",
".",
"_components",
"-",
"see... | Remove components for which the remote party did not provide any candidates.
This can only be determined after end-of-candidates. | [
"Remove",
"components",
"for",
"which",
"the",
"remote",
"party",
"did",
"not",
"provide",
"any",
"candidates",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L740-L750 | train |
aiortc/aioice | aioice/stun.py | parse_message | def parse_message(data, integrity_key=None):
"""
Parses a STUN message.
If the ``integrity_key`` parameter is given, the message's HMAC will be verified.
"""
if len(data) < HEADER_LENGTH:
raise ValueError('STUN message length is less than 20 bytes')
message_type, length, cookie, transac... | python | def parse_message(data, integrity_key=None):
"""
Parses a STUN message.
If the ``integrity_key`` parameter is given, the message's HMAC will be verified.
"""
if len(data) < HEADER_LENGTH:
raise ValueError('STUN message length is less than 20 bytes')
message_type, length, cookie, transac... | [
"def",
"parse_message",
"(",
"data",
",",
"integrity_key",
"=",
"None",
")",
":",
"if",
"len",
"(",
"data",
")",
"<",
"HEADER_LENGTH",
":",
"raise",
"ValueError",
"(",
"'STUN message length is less than 20 bytes'",
")",
"message_type",
",",
"length",
",",
"cooki... | Parses a STUN message.
If the ``integrity_key`` parameter is given, the message's HMAC will be verified. | [
"Parses",
"a",
"STUN",
"message",
"."
] | a04d810d94ec2d00eca9ce01eacca74b3b086616 | https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/stun.py#L268-L306 | train |
cole/aiosmtplib | src/aiosmtplib/protocol.py | SMTPProtocol.connection_made | def connection_made(self, transport: asyncio.BaseTransport) -> None:
"""
Modified ``connection_made`` that supports upgrading our transport in
place using STARTTLS.
We set the _transport directly on the StreamReader, rather than calling
set_transport (which will raise an Asserti... | python | def connection_made(self, transport: asyncio.BaseTransport) -> None:
"""
Modified ``connection_made`` that supports upgrading our transport in
place using STARTTLS.
We set the _transport directly on the StreamReader, rather than calling
set_transport (which will raise an Asserti... | [
"def",
"connection_made",
"(",
"self",
",",
"transport",
":",
"asyncio",
".",
"BaseTransport",
")",
"->",
"None",
":",
"if",
"self",
".",
"_stream_reader",
"is",
"None",
":",
"raise",
"SMTPServerDisconnected",
"(",
"\"Client not connected\"",
")",
"self",
".",
... | Modified ``connection_made`` that supports upgrading our transport in
place using STARTTLS.
We set the _transport directly on the StreamReader, rather than calling
set_transport (which will raise an AssertionError on upgrade). | [
"Modified",
"connection_made",
"that",
"supports",
"upgrading",
"our",
"transport",
"in",
"place",
"using",
"STARTTLS",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L50-L68 | train |
cole/aiosmtplib | src/aiosmtplib/protocol.py | SMTPProtocol.upgrade_transport | def upgrade_transport(
self,
context: ssl.SSLContext,
server_hostname: str = None,
waiter: Awaitable = None,
) -> SSLProtocol:
"""
Upgrade our transport to TLS in place.
"""
if self._over_ssl:
raise RuntimeError("Already using TLS.")
... | python | def upgrade_transport(
self,
context: ssl.SSLContext,
server_hostname: str = None,
waiter: Awaitable = None,
) -> SSLProtocol:
"""
Upgrade our transport to TLS in place.
"""
if self._over_ssl:
raise RuntimeError("Already using TLS.")
... | [
"def",
"upgrade_transport",
"(",
"self",
",",
"context",
":",
"ssl",
".",
"SSLContext",
",",
"server_hostname",
":",
"str",
"=",
"None",
",",
"waiter",
":",
"Awaitable",
"=",
"None",
",",
")",
"->",
"SSLProtocol",
":",
"if",
"self",
".",
"_over_ssl",
":"... | Upgrade our transport to TLS in place. | [
"Upgrade",
"our",
"transport",
"to",
"TLS",
"in",
"place",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L70-L109 | train |
cole/aiosmtplib | src/aiosmtplib/protocol.py | SMTPProtocol.read_response | async def read_response(self, timeout: NumType = None) -> SMTPResponse:
"""
Get a status reponse from the server.
Returns an SMTPResponse namedtuple consisting of:
- server response code (e.g. 250, or such, if all goes well)
- server response string corresponding to response... | python | async def read_response(self, timeout: NumType = None) -> SMTPResponse:
"""
Get a status reponse from the server.
Returns an SMTPResponse namedtuple consisting of:
- server response code (e.g. 250, or such, if all goes well)
- server response string corresponding to response... | [
"async",
"def",
"read_response",
"(",
"self",
",",
"timeout",
":",
"NumType",
"=",
"None",
")",
"->",
"SMTPResponse",
":",
"if",
"self",
".",
"_stream_reader",
"is",
"None",
":",
"raise",
"SMTPServerDisconnected",
"(",
"\"Client not connected\"",
")",
"code",
... | Get a status reponse from the server.
Returns an SMTPResponse namedtuple consisting of:
- server response code (e.g. 250, or such, if all goes well)
- server response string corresponding to response code (multiline
responses are converted to a single, multiline string). | [
"Get",
"a",
"status",
"reponse",
"from",
"the",
"server",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L111-L148 | train |
cole/aiosmtplib | src/aiosmtplib/protocol.py | SMTPProtocol.write_and_drain | async def write_and_drain(self, data: bytes, timeout: NumType = None) -> None:
"""
Format a command and send it to the server.
"""
if self._stream_writer is None:
raise SMTPServerDisconnected("Client not connected")
self._stream_writer.write(data)
async with... | python | async def write_and_drain(self, data: bytes, timeout: NumType = None) -> None:
"""
Format a command and send it to the server.
"""
if self._stream_writer is None:
raise SMTPServerDisconnected("Client not connected")
self._stream_writer.write(data)
async with... | [
"async",
"def",
"write_and_drain",
"(",
"self",
",",
"data",
":",
"bytes",
",",
"timeout",
":",
"NumType",
"=",
"None",
")",
"->",
"None",
":",
"if",
"self",
".",
"_stream_writer",
"is",
"None",
":",
"raise",
"SMTPServerDisconnected",
"(",
"\"Client not conn... | Format a command and send it to the server. | [
"Format",
"a",
"command",
"and",
"send",
"it",
"to",
"the",
"server",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L150-L160 | train |
cole/aiosmtplib | src/aiosmtplib/protocol.py | SMTPProtocol.write_message_data | async def write_message_data(self, data: bytes, timeout: NumType = None) -> None:
"""
Encode and write email message data.
Automatically quotes lines beginning with a period per RFC821.
Lone \\\\r and \\\\n characters are converted to \\\\r\\\\n
characters.
"""
d... | python | async def write_message_data(self, data: bytes, timeout: NumType = None) -> None:
"""
Encode and write email message data.
Automatically quotes lines beginning with a period per RFC821.
Lone \\\\r and \\\\n characters are converted to \\\\r\\\\n
characters.
"""
d... | [
"async",
"def",
"write_message_data",
"(",
"self",
",",
"data",
":",
"bytes",
",",
"timeout",
":",
"NumType",
"=",
"None",
")",
"->",
"None",
":",
"data",
"=",
"LINE_ENDINGS_REGEX",
".",
"sub",
"(",
"b\"\\r\\n\"",
",",
"data",
")",
"data",
"=",
"PERIOD_R... | Encode and write email message data.
Automatically quotes lines beginning with a period per RFC821.
Lone \\\\r and \\\\n characters are converted to \\\\r\\\\n
characters. | [
"Encode",
"and",
"write",
"email",
"message",
"data",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L162-L176 | train |
cole/aiosmtplib | src/aiosmtplib/protocol.py | SMTPProtocol.execute_command | async def execute_command(
self, *args: bytes, timeout: NumType = None
) -> SMTPResponse:
"""
Sends an SMTP command along with any args to the server, and returns
a response.
"""
command = b" ".join(args) + b"\r\n"
await self.write_and_drain(command, timeout=... | python | async def execute_command(
self, *args: bytes, timeout: NumType = None
) -> SMTPResponse:
"""
Sends an SMTP command along with any args to the server, and returns
a response.
"""
command = b" ".join(args) + b"\r\n"
await self.write_and_drain(command, timeout=... | [
"async",
"def",
"execute_command",
"(",
"self",
",",
"*",
"args",
":",
"bytes",
",",
"timeout",
":",
"NumType",
"=",
"None",
")",
"->",
"SMTPResponse",
":",
"command",
"=",
"b\" \"",
".",
"join",
"(",
"args",
")",
"+",
"b\"\\r\\n\"",
"await",
"self",
"... | Sends an SMTP command along with any args to the server, and returns
a response. | [
"Sends",
"an",
"SMTP",
"command",
"along",
"with",
"any",
"args",
"to",
"the",
"server",
"and",
"returns",
"a",
"response",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L178-L190 | train |
cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.last_ehlo_response | def last_ehlo_response(self, response: SMTPResponse) -> None:
"""
When setting the last EHLO response, parse the message for supported
extensions and auth methods.
"""
extensions, auth_methods = parse_esmtp_extensions(response.message)
self._last_ehlo_response = response
... | python | def last_ehlo_response(self, response: SMTPResponse) -> None:
"""
When setting the last EHLO response, parse the message for supported
extensions and auth methods.
"""
extensions, auth_methods = parse_esmtp_extensions(response.message)
self._last_ehlo_response = response
... | [
"def",
"last_ehlo_response",
"(",
"self",
",",
"response",
":",
"SMTPResponse",
")",
"->",
"None",
":",
"extensions",
",",
"auth_methods",
"=",
"parse_esmtp_extensions",
"(",
"response",
".",
"message",
")",
"self",
".",
"_last_ehlo_response",
"=",
"response",
"... | When setting the last EHLO response, parse the message for supported
extensions and auth methods. | [
"When",
"setting",
"the",
"last",
"EHLO",
"response",
"parse",
"the",
"message",
"for",
"supported",
"extensions",
"and",
"auth",
"methods",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L59-L68 | train |
cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.helo | async def helo(
self, hostname: str = None, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send the SMTP HELO command.
Hostname to send for this command defaults to the FQDN of the local
host.
:raises SMTPHeloError: on unexpected server response code
... | python | async def helo(
self, hostname: str = None, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send the SMTP HELO command.
Hostname to send for this command defaults to the FQDN of the local
host.
:raises SMTPHeloError: on unexpected server response code
... | [
"async",
"def",
"helo",
"(",
"self",
",",
"hostname",
":",
"str",
"=",
"None",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"if",
"hostname",
"is",
"None",
":",
"hostname",
"=",
"self",
".",
"source_address",
"a... | Send the SMTP HELO command.
Hostname to send for this command defaults to the FQDN of the local
host.
:raises SMTPHeloError: on unexpected server response code | [
"Send",
"the",
"SMTP",
"HELO",
"command",
".",
"Hostname",
"to",
"send",
"for",
"this",
"command",
"defaults",
"to",
"the",
"FQDN",
"of",
"the",
"local",
"host",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L86-L107 | train |
cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.help | async def help(self, timeout: DefaultNumType = _default) -> str:
"""
Send the SMTP HELP command, which responds with help text.
:raises SMTPResponseException: on unexpected server response code
"""
await self._ehlo_or_helo_if_needed()
async with self._command_lock:
... | python | async def help(self, timeout: DefaultNumType = _default) -> str:
"""
Send the SMTP HELP command, which responds with help text.
:raises SMTPResponseException: on unexpected server response code
"""
await self._ehlo_or_helo_if_needed()
async with self._command_lock:
... | [
"async",
"def",
"help",
"(",
"self",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"str",
":",
"await",
"self",
".",
"_ehlo_or_helo_if_needed",
"(",
")",
"async",
"with",
"self",
".",
"_command_lock",
":",
"response",
"=",
"await",
"se... | Send the SMTP HELP command, which responds with help text.
:raises SMTPResponseException: on unexpected server response code | [
"Send",
"the",
"SMTP",
"HELP",
"command",
"which",
"responds",
"with",
"help",
"text",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L109-L127 | train |
cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.noop | async def noop(self, timeout: DefaultNumType = _default) -> SMTPResponse:
"""
Send an SMTP NOOP command, which does nothing.
:raises SMTPResponseException: on unexpected server response code
"""
await self._ehlo_or_helo_if_needed()
async with self._command_lock:
... | python | async def noop(self, timeout: DefaultNumType = _default) -> SMTPResponse:
"""
Send an SMTP NOOP command, which does nothing.
:raises SMTPResponseException: on unexpected server response code
"""
await self._ehlo_or_helo_if_needed()
async with self._command_lock:
... | [
"async",
"def",
"noop",
"(",
"self",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"await",
"self",
".",
"_ehlo_or_helo_if_needed",
"(",
")",
"async",
"with",
"self",
".",
"_command_lock",
":",
"response",
"=",
"awai... | Send an SMTP NOOP command, which does nothing.
:raises SMTPResponseException: on unexpected server response code | [
"Send",
"an",
"SMTP",
"NOOP",
"command",
"which",
"does",
"nothing",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L145-L158 | train |
cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.vrfy | async def vrfy(
self, address: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send an SMTP VRFY command, which tests an address for validity.
Not many servers support this command.
:raises SMTPResponseException: on unexpected server response code
"""
... | python | async def vrfy(
self, address: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send an SMTP VRFY command, which tests an address for validity.
Not many servers support this command.
:raises SMTPResponseException: on unexpected server response code
"""
... | [
"async",
"def",
"vrfy",
"(",
"self",
",",
"address",
":",
"str",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"await",
"self",
".",
"_ehlo_or_helo_if_needed",
"(",
")",
"parsed_address",
"=",
"parse_address",
"(",
"... | Send an SMTP VRFY command, which tests an address for validity.
Not many servers support this command.
:raises SMTPResponseException: on unexpected server response code | [
"Send",
"an",
"SMTP",
"VRFY",
"command",
"which",
"tests",
"an",
"address",
"for",
"validity",
".",
"Not",
"many",
"servers",
"support",
"this",
"command",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L160-L187 | train |
cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.expn | async def expn(
self, address: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send an SMTP EXPN command, which expands a mailing list.
Not many servers support this command.
:raises SMTPResponseException: on unexpected server response code
"""
... | python | async def expn(
self, address: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send an SMTP EXPN command, which expands a mailing list.
Not many servers support this command.
:raises SMTPResponseException: on unexpected server response code
"""
... | [
"async",
"def",
"expn",
"(",
"self",
",",
"address",
":",
"str",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"await",
"self",
".",
"_ehlo_or_helo_if_needed",
"(",
")",
"parsed_address",
"=",
"parse_address",
"(",
"... | Send an SMTP EXPN command, which expands a mailing list.
Not many servers support this command.
:raises SMTPResponseException: on unexpected server response code | [
"Send",
"an",
"SMTP",
"EXPN",
"command",
"which",
"expands",
"a",
"mailing",
"list",
".",
"Not",
"many",
"servers",
"support",
"this",
"command",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L189-L210 | train |
cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.quit | async def quit(self, timeout: DefaultNumType = _default) -> SMTPResponse:
"""
Send the SMTP QUIT command, which closes the connection.
Also closes the connection from our side after a response is received.
:raises SMTPResponseException: on unexpected server response code
"""
... | python | async def quit(self, timeout: DefaultNumType = _default) -> SMTPResponse:
"""
Send the SMTP QUIT command, which closes the connection.
Also closes the connection from our side after a response is received.
:raises SMTPResponseException: on unexpected server response code
"""
... | [
"async",
"def",
"quit",
"(",
"self",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"await",
"self",
".",
"_ehlo_or_helo_if_needed",
"(",
")",
"async",
"with",
"self",
".",
"_command_lock",
":",
"response",
"=",
"awai... | Send the SMTP QUIT command, which closes the connection.
Also closes the connection from our side after a response is received.
:raises SMTPResponseException: on unexpected server response code | [
"Send",
"the",
"SMTP",
"QUIT",
"command",
"which",
"closes",
"the",
"connection",
".",
"Also",
"closes",
"the",
"connection",
"from",
"our",
"side",
"after",
"a",
"response",
"is",
"received",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L212-L229 | train |
cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.rcpt | async def rcpt(
self,
recipient: str,
options: Iterable[str] = None,
timeout: DefaultNumType = _default,
) -> SMTPResponse:
"""
Send an SMTP RCPT command, which specifies a single recipient for
the message. This command is sent once per recipient and must be
... | python | async def rcpt(
self,
recipient: str,
options: Iterable[str] = None,
timeout: DefaultNumType = _default,
) -> SMTPResponse:
"""
Send an SMTP RCPT command, which specifies a single recipient for
the message. This command is sent once per recipient and must be
... | [
"async",
"def",
"rcpt",
"(",
"self",
",",
"recipient",
":",
"str",
",",
"options",
":",
"Iterable",
"[",
"str",
"]",
"=",
"None",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
",",
")",
"->",
"SMTPResponse",
":",
"await",
"self",
".",
"_ehlo_... | Send an SMTP RCPT command, which specifies a single recipient for
the message. This command is sent once per recipient and must be
preceded by 'MAIL'.
:raises SMTPRecipientRefused: on unexpected server response code | [
"Send",
"an",
"SMTP",
"RCPT",
"command",
"which",
"specifies",
"a",
"single",
"recipient",
"for",
"the",
"message",
".",
"This",
"command",
"is",
"sent",
"once",
"per",
"recipient",
"and",
"must",
"be",
"preceded",
"by",
"MAIL",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L261-L291 | train |
cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.data | async def data(
self, message: Union[str, bytes], timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send an SMTP DATA command, followed by the message given.
This method transfers the actual email content to the server.
:raises SMTPDataError: on unexpected server res... | python | async def data(
self, message: Union[str, bytes], timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send an SMTP DATA command, followed by the message given.
This method transfers the actual email content to the server.
:raises SMTPDataError: on unexpected server res... | [
"async",
"def",
"data",
"(",
"self",
",",
"message",
":",
"Union",
"[",
"str",
",",
"bytes",
"]",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"await",
"self",
".",
"_ehlo_or_helo_if_needed",
"(",
")",
"self",
"... | Send an SMTP DATA command, followed by the message given.
This method transfers the actual email content to the server.
:raises SMTPDataError: on unexpected server response code
:raises SMTPServerDisconnected: connection lost | [
"Send",
"an",
"SMTP",
"DATA",
"command",
"followed",
"by",
"the",
"message",
"given",
".",
"This",
"method",
"transfers",
"the",
"actual",
"email",
"content",
"to",
"the",
"server",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L293-L333 | train |
cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.ehlo | async def ehlo(
self, hostname: str = None, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send the SMTP EHLO command.
Hostname to send for this command defaults to the FQDN of the local
host.
:raises SMTPHeloError: on unexpected server response code
... | python | async def ehlo(
self, hostname: str = None, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send the SMTP EHLO command.
Hostname to send for this command defaults to the FQDN of the local
host.
:raises SMTPHeloError: on unexpected server response code
... | [
"async",
"def",
"ehlo",
"(",
"self",
",",
"hostname",
":",
"str",
"=",
"None",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"if",
"hostname",
"is",
"None",
":",
"hostname",
"=",
"self",
".",
"source_address",
"a... | Send the SMTP EHLO command.
Hostname to send for this command defaults to the FQDN of the local
host.
:raises SMTPHeloError: on unexpected server response code | [
"Send",
"the",
"SMTP",
"EHLO",
"command",
".",
"Hostname",
"to",
"send",
"for",
"this",
"command",
"defaults",
"to",
"the",
"FQDN",
"of",
"the",
"local",
"host",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L337-L359 | train |
cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP._reset_server_state | def _reset_server_state(self) -> None:
"""
Clear stored information about the server.
"""
self.last_helo_response = None
self._last_ehlo_response = None
self.esmtp_extensions = {}
self.supports_esmtp = False
self.server_auth_methods = [] | python | def _reset_server_state(self) -> None:
"""
Clear stored information about the server.
"""
self.last_helo_response = None
self._last_ehlo_response = None
self.esmtp_extensions = {}
self.supports_esmtp = False
self.server_auth_methods = [] | [
"def",
"_reset_server_state",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"last_helo_response",
"=",
"None",
"self",
".",
"_last_ehlo_response",
"=",
"None",
"self",
".",
"esmtp_extensions",
"=",
"{",
"}",
"self",
".",
"supports_esmtp",
"=",
"False",
"... | Clear stored information about the server. | [
"Clear",
"stored",
"information",
"about",
"the",
"server",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L384-L392 | train |
cole/aiosmtplib | src/aiosmtplib/auth.py | SMTPAuth.supported_auth_methods | def supported_auth_methods(self) -> List[str]:
"""
Get all AUTH methods supported by the both server and by us.
"""
return [auth for auth in self.AUTH_METHODS if auth in self.server_auth_methods] | python | def supported_auth_methods(self) -> List[str]:
"""
Get all AUTH methods supported by the both server and by us.
"""
return [auth for auth in self.AUTH_METHODS if auth in self.server_auth_methods] | [
"def",
"supported_auth_methods",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"[",
"auth",
"for",
"auth",
"in",
"self",
".",
"AUTH_METHODS",
"if",
"auth",
"in",
"self",
".",
"server_auth_methods",
"]"
] | Get all AUTH methods supported by the both server and by us. | [
"Get",
"all",
"AUTH",
"methods",
"supported",
"by",
"the",
"both",
"server",
"and",
"by",
"us",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/auth.py#L40-L44 | train |
cole/aiosmtplib | src/aiosmtplib/auth.py | SMTPAuth.login | async def login(
self, username: str, password: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Tries to login with supported auth methods.
Some servers advertise authentication methods they don't really
support, so if authentication fails, we continue until w... | python | async def login(
self, username: str, password: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Tries to login with supported auth methods.
Some servers advertise authentication methods they don't really
support, so if authentication fails, we continue until w... | [
"async",
"def",
"login",
"(",
"self",
",",
"username",
":",
"str",
",",
"password",
":",
"str",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"await",
"self",
".",
"_ehlo_or_helo_if_needed",
"(",
")",
"if",
"not",
... | Tries to login with supported auth methods.
Some servers advertise authentication methods they don't really
support, so if authentication fails, we continue until we've tried
all methods. | [
"Tries",
"to",
"login",
"with",
"supported",
"auth",
"methods",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/auth.py#L46-L82 | train |
cole/aiosmtplib | src/aiosmtplib/auth.py | SMTPAuth.auth_crammd5 | async def auth_crammd5(
self, username: str, password: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
CRAM-MD5 auth uses the password as a shared secret to MD5 the server's
response.
Example::
250 AUTH CRAM-MD5
auth cram-md5
... | python | async def auth_crammd5(
self, username: str, password: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
CRAM-MD5 auth uses the password as a shared secret to MD5 the server's
response.
Example::
250 AUTH CRAM-MD5
auth cram-md5
... | [
"async",
"def",
"auth_crammd5",
"(",
"self",
",",
"username",
":",
"str",
",",
"password",
":",
"str",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"async",
"with",
"self",
".",
"_command_lock",
":",
"initial_respon... | CRAM-MD5 auth uses the password as a shared secret to MD5 the server's
response.
Example::
250 AUTH CRAM-MD5
auth cram-md5
334 PDI0NjA5LjEwNDc5MTQwNDZAcG9wbWFpbC5TcGFjZS5OZXQ+
dGltIGI5MTNhNjAyYzdlZGE3YTQ5NWI0ZTZlNzMzNGQzODkw | [
"CRAM",
"-",
"MD5",
"auth",
"uses",
"the",
"password",
"as",
"a",
"shared",
"secret",
"to",
"MD5",
"the",
"server",
"s",
"response",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/auth.py#L84-L122 | train |
cole/aiosmtplib | src/aiosmtplib/auth.py | SMTPAuth.auth_plain | async def auth_plain(
self, username: str, password: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
PLAIN auth encodes the username and password in one Base64 encoded
string. No verification message is required.
Example::
220-esmtp.example.com
... | python | async def auth_plain(
self, username: str, password: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
PLAIN auth encodes the username and password in one Base64 encoded
string. No verification message is required.
Example::
220-esmtp.example.com
... | [
"async",
"def",
"auth_plain",
"(",
"self",
",",
"username",
":",
"str",
",",
"password",
":",
"str",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"username_bytes",
"=",
"username",
".",
"encode",
"(",
"\"ascii\"",
... | PLAIN auth encodes the username and password in one Base64 encoded
string. No verification message is required.
Example::
220-esmtp.example.com
AUTH PLAIN dGVzdAB0ZXN0AHRlc3RwYXNz
235 ok, go ahead (#2.0.0) | [
"PLAIN",
"auth",
"encodes",
"the",
"username",
"and",
"password",
"in",
"one",
"Base64",
"encoded",
"string",
".",
"No",
"verification",
"message",
"is",
"required",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/auth.py#L124-L151 | train |
cole/aiosmtplib | src/aiosmtplib/auth.py | SMTPAuth.auth_login | async def auth_login(
self, username: str, password: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
LOGIN auth sends the Base64 encoded username and password in sequence.
Example::
250 AUTH LOGIN PLAIN CRAM-MD5
auth login avlsdkfj
... | python | async def auth_login(
self, username: str, password: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
LOGIN auth sends the Base64 encoded username and password in sequence.
Example::
250 AUTH LOGIN PLAIN CRAM-MD5
auth login avlsdkfj
... | [
"async",
"def",
"auth_login",
"(",
"self",
",",
"username",
":",
"str",
",",
"password",
":",
"str",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"encoded_username",
"=",
"base64",
".",
"b64encode",
"(",
"username",... | LOGIN auth sends the Base64 encoded username and password in sequence.
Example::
250 AUTH LOGIN PLAIN CRAM-MD5
auth login avlsdkfj
334 UGFzc3dvcmQ6
avlsdkfj
Note that there is an alternate version sends the username
as a separate command::
... | [
"LOGIN",
"auth",
"sends",
"the",
"Base64",
"encoded",
"username",
"and",
"password",
"in",
"sequence",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/auth.py#L153-L197 | train |
cole/aiosmtplib | src/aiosmtplib/email.py | parse_address | def parse_address(address: str) -> str:
"""
Parse an email address, falling back to the raw string given.
"""
display_name, parsed_address = email.utils.parseaddr(address)
return parsed_address or address | python | def parse_address(address: str) -> str:
"""
Parse an email address, falling back to the raw string given.
"""
display_name, parsed_address = email.utils.parseaddr(address)
return parsed_address or address | [
"def",
"parse_address",
"(",
"address",
":",
"str",
")",
"->",
"str",
":",
"display_name",
",",
"parsed_address",
"=",
"email",
".",
"utils",
".",
"parseaddr",
"(",
"address",
")",
"return",
"parsed_address",
"or",
"address"
] | Parse an email address, falling back to the raw string given. | [
"Parse",
"an",
"email",
"address",
"falling",
"back",
"to",
"the",
"raw",
"string",
"given",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/email.py#L16-L22 | train |
cole/aiosmtplib | src/aiosmtplib/email.py | quote_address | def quote_address(address: str) -> str:
"""
Quote a subset of the email addresses defined by RFC 821.
Should be able to handle anything email.utils.parseaddr can handle.
"""
display_name, parsed_address = email.utils.parseaddr(address)
if parsed_address:
quoted_address = "<{}>".format(p... | python | def quote_address(address: str) -> str:
"""
Quote a subset of the email addresses defined by RFC 821.
Should be able to handle anything email.utils.parseaddr can handle.
"""
display_name, parsed_address = email.utils.parseaddr(address)
if parsed_address:
quoted_address = "<{}>".format(p... | [
"def",
"quote_address",
"(",
"address",
":",
"str",
")",
"->",
"str",
":",
"display_name",
",",
"parsed_address",
"=",
"email",
".",
"utils",
".",
"parseaddr",
"(",
"address",
")",
"if",
"parsed_address",
":",
"quoted_address",
"=",
"\"<{}>\"",
".",
"format"... | Quote a subset of the email addresses defined by RFC 821.
Should be able to handle anything email.utils.parseaddr can handle. | [
"Quote",
"a",
"subset",
"of",
"the",
"email",
"addresses",
"defined",
"by",
"RFC",
"821",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/email.py#L25-L38 | train |
cole/aiosmtplib | src/aiosmtplib/email.py | _extract_sender | def _extract_sender(
message: Message, resent_dates: List[Union[str, Header]] = None
) -> str:
"""
Extract the sender from the message object given.
"""
if resent_dates:
sender_header = "Resent-Sender"
from_header = "Resent-From"
else:
sender_header = "Sender"
fro... | python | def _extract_sender(
message: Message, resent_dates: List[Union[str, Header]] = None
) -> str:
"""
Extract the sender from the message object given.
"""
if resent_dates:
sender_header = "Resent-Sender"
from_header = "Resent-From"
else:
sender_header = "Sender"
fro... | [
"def",
"_extract_sender",
"(",
"message",
":",
"Message",
",",
"resent_dates",
":",
"List",
"[",
"Union",
"[",
"str",
",",
"Header",
"]",
"]",
"=",
"None",
")",
"->",
"str",
":",
"if",
"resent_dates",
":",
"sender_header",
"=",
"\"Resent-Sender\"",
"from_h... | Extract the sender from the message object given. | [
"Extract",
"the",
"sender",
"from",
"the",
"message",
"object",
"given",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/email.py#L62-L81 | train |
cole/aiosmtplib | src/aiosmtplib/email.py | _extract_recipients | def _extract_recipients(
message: Message, resent_dates: List[Union[str, Header]] = None
) -> List[str]:
"""
Extract the recipients from the message object given.
"""
recipients = [] # type: List[str]
if resent_dates:
recipient_headers = ("Resent-To", "Resent-Cc", "Resent-Bcc")
els... | python | def _extract_recipients(
message: Message, resent_dates: List[Union[str, Header]] = None
) -> List[str]:
"""
Extract the recipients from the message object given.
"""
recipients = [] # type: List[str]
if resent_dates:
recipient_headers = ("Resent-To", "Resent-Cc", "Resent-Bcc")
els... | [
"def",
"_extract_recipients",
"(",
"message",
":",
"Message",
",",
"resent_dates",
":",
"List",
"[",
"Union",
"[",
"str",
",",
"Header",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"str",
"]",
":",
"recipients",
"=",
"[",
"]",
"if",
"resent_dates",
... | Extract the recipients from the message object given. | [
"Extract",
"the",
"recipients",
"from",
"the",
"message",
"object",
"given",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/email.py#L84-L105 | train |
cole/aiosmtplib | src/aiosmtplib/connection.py | SMTPConnection.execute_command | async def execute_command(
self, *args: bytes, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Check that we're connected, if we got a timeout value, and then
pass the command to the protocol.
:raises SMTPServerDisconnected: connection lost
"""
if t... | python | async def execute_command(
self, *args: bytes, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Check that we're connected, if we got a timeout value, and then
pass the command to the protocol.
:raises SMTPServerDisconnected: connection lost
"""
if t... | [
"async",
"def",
"execute_command",
"(",
"self",
",",
"*",
"args",
":",
"bytes",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"if",
"timeout",
"is",
"_default",
":",
"timeout",
"=",
"self",
".",
"timeout",
"self",
... | Check that we're connected, if we got a timeout value, and then
pass the command to the protocol.
:raises SMTPServerDisconnected: connection lost | [
"Check",
"that",
"we",
"re",
"connected",
"if",
"we",
"got",
"a",
"timeout",
"value",
"and",
"then",
"pass",
"the",
"command",
"to",
"the",
"protocol",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/connection.py#L274-L301 | train |
cole/aiosmtplib | src/aiosmtplib/connection.py | SMTPConnection._get_tls_context | def _get_tls_context(self) -> ssl.SSLContext:
"""
Build an SSLContext object from the options we've been given.
"""
if self.tls_context is not None:
context = self.tls_context
else:
# SERVER_AUTH is what we want for a client side socket
context... | python | def _get_tls_context(self) -> ssl.SSLContext:
"""
Build an SSLContext object from the options we've been given.
"""
if self.tls_context is not None:
context = self.tls_context
else:
# SERVER_AUTH is what we want for a client side socket
context... | [
"def",
"_get_tls_context",
"(",
"self",
")",
"->",
"ssl",
".",
"SSLContext",
":",
"if",
"self",
".",
"tls_context",
"is",
"not",
"None",
":",
"context",
"=",
"self",
".",
"tls_context",
"else",
":",
"context",
"=",
"ssl",
".",
"create_default_context",
"("... | Build an SSLContext object from the options we've been given. | [
"Build",
"an",
"SSLContext",
"object",
"from",
"the",
"options",
"we",
"ve",
"been",
"given",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/connection.py#L306-L327 | train |
cole/aiosmtplib | src/aiosmtplib/connection.py | SMTPConnection._raise_error_if_disconnected | def _raise_error_if_disconnected(self) -> None:
"""
See if we're still connected, and if not, raise
``SMTPServerDisconnected``.
"""
if (
self.transport is None
or self.protocol is None
or self.transport.is_closing()
):
self.... | python | def _raise_error_if_disconnected(self) -> None:
"""
See if we're still connected, and if not, raise
``SMTPServerDisconnected``.
"""
if (
self.transport is None
or self.protocol is None
or self.transport.is_closing()
):
self.... | [
"def",
"_raise_error_if_disconnected",
"(",
"self",
")",
"->",
"None",
":",
"if",
"(",
"self",
".",
"transport",
"is",
"None",
"or",
"self",
".",
"protocol",
"is",
"None",
"or",
"self",
".",
"transport",
".",
"is_closing",
"(",
")",
")",
":",
"self",
"... | See if we're still connected, and if not, raise
``SMTPServerDisconnected``. | [
"See",
"if",
"we",
"re",
"still",
"connected",
"and",
"if",
"not",
"raise",
"SMTPServerDisconnected",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/connection.py#L329-L340 | train |
cole/aiosmtplib | src/aiosmtplib/smtp.py | SMTP.sendmail | async def sendmail(
self,
sender: str,
recipients: RecipientsType,
message: Union[str, bytes],
mail_options: Iterable[str] = None,
rcpt_options: Iterable[str] = None,
timeout: DefaultNumType = _default,
) -> SendmailResponseType:
"""
This comma... | python | async def sendmail(
self,
sender: str,
recipients: RecipientsType,
message: Union[str, bytes],
mail_options: Iterable[str] = None,
rcpt_options: Iterable[str] = None,
timeout: DefaultNumType = _default,
) -> SendmailResponseType:
"""
This comma... | [
"async",
"def",
"sendmail",
"(",
"self",
",",
"sender",
":",
"str",
",",
"recipients",
":",
"RecipientsType",
",",
"message",
":",
"Union",
"[",
"str",
",",
"bytes",
"]",
",",
"mail_options",
":",
"Iterable",
"[",
"str",
"]",
"=",
"None",
",",
"rcpt_op... | This command performs an entire mail transaction.
The arguments are:
- sender: The address sending this mail.
- recipients: A list of addresses to send this mail to. A bare
string will be treated as a list with 1 address.
- message: The message string to sen... | [
"This",
"command",
"performs",
"an",
"entire",
"mail",
"transaction",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/smtp.py#L57-L166 | train |
cole/aiosmtplib | src/aiosmtplib/smtp.py | SMTP._run_sync | def _run_sync(self, method: Callable, *args, **kwargs) -> Any:
"""
Utility method to run commands synchronously for testing.
"""
if self.loop.is_running():
raise RuntimeError("Event loop is already running.")
if not self.is_connected:
self.loop.run_until_... | python | def _run_sync(self, method: Callable, *args, **kwargs) -> Any:
"""
Utility method to run commands synchronously for testing.
"""
if self.loop.is_running():
raise RuntimeError("Event loop is already running.")
if not self.is_connected:
self.loop.run_until_... | [
"def",
"_run_sync",
"(",
"self",
",",
"method",
":",
"Callable",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
"->",
"Any",
":",
"if",
"self",
".",
"loop",
".",
"is_running",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Event loop is already running.\"",
... | Utility method to run commands synchronously for testing. | [
"Utility",
"method",
"to",
"run",
"commands",
"synchronously",
"for",
"testing",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/smtp.py#L237-L252 | train |
cs50/submit50 | submit50/__main__.py | check_announcements | def check_announcements():
"""Check for any announcements from cs50.me, raise Error if so."""
res = requests.get("https://cs50.me/status/submit50") # TODO change this to submit50.io!
if res.status_code == 200 and res.text.strip():
raise Error(res.text.strip()) | python | def check_announcements():
"""Check for any announcements from cs50.me, raise Error if so."""
res = requests.get("https://cs50.me/status/submit50") # TODO change this to submit50.io!
if res.status_code == 200 and res.text.strip():
raise Error(res.text.strip()) | [
"def",
"check_announcements",
"(",
")",
":",
"res",
"=",
"requests",
".",
"get",
"(",
"\"https://cs50.me/status/submit50\"",
")",
"if",
"res",
".",
"status_code",
"==",
"200",
"and",
"res",
".",
"text",
".",
"strip",
"(",
")",
":",
"raise",
"Error",
"(",
... | Check for any announcements from cs50.me, raise Error if so. | [
"Check",
"for",
"any",
"announcements",
"from",
"cs50",
".",
"me",
"raise",
"Error",
"if",
"so",
"."
] | 5f4c8b3675e8e261c8422f76eacd6a6330c23831 | https://github.com/cs50/submit50/blob/5f4c8b3675e8e261c8422f76eacd6a6330c23831/submit50/__main__.py#L28-L32 | train |
cs50/submit50 | submit50/__main__.py | check_version | def check_version():
"""Check that submit50 is the latest version according to submit50.io."""
# Retrieve version info
res = requests.get("https://cs50.me/versions/submit50") # TODO change this to submit50.io!
if res.status_code != 200:
raise Error(_("You have an unknown version of submit50. "
... | python | def check_version():
"""Check that submit50 is the latest version according to submit50.io."""
# Retrieve version info
res = requests.get("https://cs50.me/versions/submit50") # TODO change this to submit50.io!
if res.status_code != 200:
raise Error(_("You have an unknown version of submit50. "
... | [
"def",
"check_version",
"(",
")",
":",
"res",
"=",
"requests",
".",
"get",
"(",
"\"https://cs50.me/versions/submit50\"",
")",
"if",
"res",
".",
"status_code",
"!=",
"200",
":",
"raise",
"Error",
"(",
"_",
"(",
"\"You have an unknown version of submit50. \"",
"\"Em... | Check that submit50 is the latest version according to submit50.io. | [
"Check",
"that",
"submit50",
"is",
"the",
"latest",
"version",
"according",
"to",
"submit50",
".",
"io",
"."
] | 5f4c8b3675e8e261c8422f76eacd6a6330c23831 | https://github.com/cs50/submit50/blob/5f4c8b3675e8e261c8422f76eacd6a6330c23831/submit50/__main__.py#L35-L44 | train |
cs50/submit50 | submit50/__main__.py | excepthook | def excepthook(type, value, tb):
"""Report an exception."""
if (issubclass(type, Error) or issubclass(type, lib50.Error)) and str(value):
for line in str(value).split("\n"):
cprint(str(line), "yellow")
else:
cprint(_("Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!... | python | def excepthook(type, value, tb):
"""Report an exception."""
if (issubclass(type, Error) or issubclass(type, lib50.Error)) and str(value):
for line in str(value).split("\n"):
cprint(str(line), "yellow")
else:
cprint(_("Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!... | [
"def",
"excepthook",
"(",
"type",
",",
"value",
",",
"tb",
")",
":",
"if",
"(",
"issubclass",
"(",
"type",
",",
"Error",
")",
"or",
"issubclass",
"(",
"type",
",",
"lib50",
".",
"Error",
")",
")",
"and",
"str",
"(",
"value",
")",
":",
"for",
"lin... | Report an exception. | [
"Report",
"an",
"exception",
"."
] | 5f4c8b3675e8e261c8422f76eacd6a6330c23831 | https://github.com/cs50/submit50/blob/5f4c8b3675e8e261c8422f76eacd6a6330c23831/submit50/__main__.py#L93-L104 | train |
kedder/ofxstatement | src/ofxstatement/statement.py | generate_transaction_id | def generate_transaction_id(stmt_line):
"""Generate pseudo-unique id for given statement line.
This function can be used in statement parsers when real transaction id is
not available in source statement.
"""
return str(abs(hash((stmt_line.date,
stmt_line.memo,
... | python | def generate_transaction_id(stmt_line):
"""Generate pseudo-unique id for given statement line.
This function can be used in statement parsers when real transaction id is
not available in source statement.
"""
return str(abs(hash((stmt_line.date,
stmt_line.memo,
... | [
"def",
"generate_transaction_id",
"(",
"stmt_line",
")",
":",
"return",
"str",
"(",
"abs",
"(",
"hash",
"(",
"(",
"stmt_line",
".",
"date",
",",
"stmt_line",
".",
"memo",
",",
"stmt_line",
".",
"amount",
")",
")",
")",
")"
] | Generate pseudo-unique id for given statement line.
This function can be used in statement parsers when real transaction id is
not available in source statement. | [
"Generate",
"pseudo",
"-",
"unique",
"id",
"for",
"given",
"statement",
"line",
"."
] | 61f9dc1cfe6024874b859c8aec108b9d9acee57a | https://github.com/kedder/ofxstatement/blob/61f9dc1cfe6024874b859c8aec108b9d9acee57a/src/ofxstatement/statement.py#L155-L163 | train |
kedder/ofxstatement | src/ofxstatement/statement.py | recalculate_balance | def recalculate_balance(stmt):
"""Recalculate statement starting and ending dates and balances.
When starting balance is not available, it will be assumed to be 0.
This function can be used in statement parsers when balance information is
not available in source statement.
"""
total_amount = ... | python | def recalculate_balance(stmt):
"""Recalculate statement starting and ending dates and balances.
When starting balance is not available, it will be assumed to be 0.
This function can be used in statement parsers when balance information is
not available in source statement.
"""
total_amount = ... | [
"def",
"recalculate_balance",
"(",
"stmt",
")",
":",
"total_amount",
"=",
"sum",
"(",
"sl",
".",
"amount",
"for",
"sl",
"in",
"stmt",
".",
"lines",
")",
"stmt",
".",
"start_balance",
"=",
"stmt",
".",
"start_balance",
"or",
"D",
"(",
"0",
")",
"stmt",
... | Recalculate statement starting and ending dates and balances.
When starting balance is not available, it will be assumed to be 0.
This function can be used in statement parsers when balance information is
not available in source statement. | [
"Recalculate",
"statement",
"starting",
"and",
"ending",
"dates",
"and",
"balances",
"."
] | 61f9dc1cfe6024874b859c8aec108b9d9acee57a | https://github.com/kedder/ofxstatement/blob/61f9dc1cfe6024874b859c8aec108b9d9acee57a/src/ofxstatement/statement.py#L166-L180 | train |
kedder/ofxstatement | src/ofxstatement/statement.py | StatementLine.assert_valid | def assert_valid(self):
"""Ensure that fields have valid values
"""
assert self.trntype in TRANSACTION_TYPES, \
"trntype must be one of %s" % TRANSACTION_TYPES
if self.bank_account_to:
self.bank_account_to.assert_valid() | python | def assert_valid(self):
"""Ensure that fields have valid values
"""
assert self.trntype in TRANSACTION_TYPES, \
"trntype must be one of %s" % TRANSACTION_TYPES
if self.bank_account_to:
self.bank_account_to.assert_valid() | [
"def",
"assert_valid",
"(",
"self",
")",
":",
"assert",
"self",
".",
"trntype",
"in",
"TRANSACTION_TYPES",
",",
"\"trntype must be one of %s\"",
"%",
"TRANSACTION_TYPES",
"if",
"self",
".",
"bank_account_to",
":",
"self",
".",
"bank_account_to",
".",
"assert_valid",... | Ensure that fields have valid values | [
"Ensure",
"that",
"fields",
"have",
"valid",
"values"
] | 61f9dc1cfe6024874b859c8aec108b9d9acee57a | https://github.com/kedder/ofxstatement/blob/61f9dc1cfe6024874b859c8aec108b9d9acee57a/src/ofxstatement/statement.py#L113-L120 | train |
kedder/ofxstatement | src/ofxstatement/parser.py | StatementParser.parse | def parse(self):
"""Read and parse statement
Return Statement object
May raise exceptions.ParseException on malformed input.
"""
reader = self.split_records()
for line in reader:
self.cur_record += 1
if not line:
continue
... | python | def parse(self):
"""Read and parse statement
Return Statement object
May raise exceptions.ParseException on malformed input.
"""
reader = self.split_records()
for line in reader:
self.cur_record += 1
if not line:
continue
... | [
"def",
"parse",
"(",
"self",
")",
":",
"reader",
"=",
"self",
".",
"split_records",
"(",
")",
"for",
"line",
"in",
"reader",
":",
"self",
".",
"cur_record",
"+=",
"1",
"if",
"not",
"line",
":",
"continue",
"stmt_line",
"=",
"self",
".",
"parse_record",... | Read and parse statement
Return Statement object
May raise exceptions.ParseException on malformed input. | [
"Read",
"and",
"parse",
"statement"
] | 61f9dc1cfe6024874b859c8aec108b9d9acee57a | https://github.com/kedder/ofxstatement/blob/61f9dc1cfe6024874b859c8aec108b9d9acee57a/src/ofxstatement/parser.py#L17-L33 | train |
discogs/python-cas-client | cas_client/cas_client.py | CASClient.acquire_auth_token_ticket | def acquire_auth_token_ticket(self, headers=None):
'''
Acquire an auth token from the CAS server.
'''
logging.debug('[CAS] Acquiring Auth token ticket')
url = self._get_auth_token_tickets_url()
text = self._perform_post(url, headers=headers)
auth_token_ticket = js... | python | def acquire_auth_token_ticket(self, headers=None):
'''
Acquire an auth token from the CAS server.
'''
logging.debug('[CAS] Acquiring Auth token ticket')
url = self._get_auth_token_tickets_url()
text = self._perform_post(url, headers=headers)
auth_token_ticket = js... | [
"def",
"acquire_auth_token_ticket",
"(",
"self",
",",
"headers",
"=",
"None",
")",
":",
"logging",
".",
"debug",
"(",
"'[CAS] Acquiring Auth token ticket'",
")",
"url",
"=",
"self",
".",
"_get_auth_token_tickets_url",
"(",
")",
"text",
"=",
"self",
".",
"_perfor... | Acquire an auth token from the CAS server. | [
"Acquire",
"an",
"auth",
"token",
"from",
"the",
"CAS",
"server",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L53-L63 | train |
discogs/python-cas-client | cas_client/cas_client.py | CASClient.create_session | def create_session(self, ticket, payload=None, expires=None):
'''
Create a session record from a service ticket.
'''
assert isinstance(self.session_storage_adapter, CASSessionAdapter)
logging.debug('[CAS] Creating session for ticket {}'.format(ticket))
self.session_storag... | python | def create_session(self, ticket, payload=None, expires=None):
'''
Create a session record from a service ticket.
'''
assert isinstance(self.session_storage_adapter, CASSessionAdapter)
logging.debug('[CAS] Creating session for ticket {}'.format(ticket))
self.session_storag... | [
"def",
"create_session",
"(",
"self",
",",
"ticket",
",",
"payload",
"=",
"None",
",",
"expires",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"self",
".",
"session_storage_adapter",
",",
"CASSessionAdapter",
")",
"logging",
".",
"debug",
"(",
"'[CAS]... | Create a session record from a service ticket. | [
"Create",
"a",
"session",
"record",
"from",
"a",
"service",
"ticket",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L65-L75 | train |
discogs/python-cas-client | cas_client/cas_client.py | CASClient.delete_session | def delete_session(self, ticket):
'''
Delete a session record associated with a service ticket.
'''
assert isinstance(self.session_storage_adapter, CASSessionAdapter)
logging.debug('[CAS] Deleting session for ticket {}'.format(ticket))
self.session_storage_adapter.delete(... | python | def delete_session(self, ticket):
'''
Delete a session record associated with a service ticket.
'''
assert isinstance(self.session_storage_adapter, CASSessionAdapter)
logging.debug('[CAS] Deleting session for ticket {}'.format(ticket))
self.session_storage_adapter.delete(... | [
"def",
"delete_session",
"(",
"self",
",",
"ticket",
")",
":",
"assert",
"isinstance",
"(",
"self",
".",
"session_storage_adapter",
",",
"CASSessionAdapter",
")",
"logging",
".",
"debug",
"(",
"'[CAS] Deleting session for ticket {}'",
".",
"format",
"(",
"ticket",
... | Delete a session record associated with a service ticket. | [
"Delete",
"a",
"session",
"record",
"associated",
"with",
"a",
"service",
"ticket",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L77-L83 | train |
discogs/python-cas-client | cas_client/cas_client.py | CASClient.get_api_url | def get_api_url(
self,
api_resource,
auth_token_ticket,
authenticator,
private_key,
service_url=None,
**kwargs
):
'''
Build an auth-token-protected CAS API url.
'''
auth_token, auth_token_signature = self._build_auth_token_data(... | python | def get_api_url(
self,
api_resource,
auth_token_ticket,
authenticator,
private_key,
service_url=None,
**kwargs
):
'''
Build an auth-token-protected CAS API url.
'''
auth_token, auth_token_signature = self._build_auth_token_data(... | [
"def",
"get_api_url",
"(",
"self",
",",
"api_resource",
",",
"auth_token_ticket",
",",
"authenticator",
",",
"private_key",
",",
"service_url",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"auth_token",
",",
"auth_token_signature",
"=",
"self",
".",
"_build_auth_... | Build an auth-token-protected CAS API url. | [
"Build",
"an",
"auth",
"-",
"token",
"-",
"protected",
"CAS",
"API",
"url",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L85-L113 | train |
discogs/python-cas-client | cas_client/cas_client.py | CASClient.get_auth_token_login_url | def get_auth_token_login_url(
self,
auth_token_ticket,
authenticator,
private_key,
service_url,
username,
):
'''
Build an auth token login URL.
See https://github.com/rbCAS/CASino/wiki/Auth-Token-Login for details.
'''
auth_tok... | python | def get_auth_token_login_url(
self,
auth_token_ticket,
authenticator,
private_key,
service_url,
username,
):
'''
Build an auth token login URL.
See https://github.com/rbCAS/CASino/wiki/Auth-Token-Login for details.
'''
auth_tok... | [
"def",
"get_auth_token_login_url",
"(",
"self",
",",
"auth_token_ticket",
",",
"authenticator",
",",
"private_key",
",",
"service_url",
",",
"username",
",",
")",
":",
"auth_token",
",",
"auth_token_signature",
"=",
"self",
".",
"_build_auth_token_data",
"(",
"auth_... | Build an auth token login URL.
See https://github.com/rbCAS/CASino/wiki/Auth-Token-Login for details. | [
"Build",
"an",
"auth",
"token",
"login",
"URL",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L115-L141 | train |
discogs/python-cas-client | cas_client/cas_client.py | CASClient.parse_logout_request | def parse_logout_request(self, message_text):
'''
Parse the contents of a CAS `LogoutRequest` XML message.
::
>>> from cas_client import CASClient
>>> client = CASClient('https://logmein.com')
>>> message_text = """
... <samlp:LogoutRequest
... | python | def parse_logout_request(self, message_text):
'''
Parse the contents of a CAS `LogoutRequest` XML message.
::
>>> from cas_client import CASClient
>>> client = CASClient('https://logmein.com')
>>> message_text = """
... <samlp:LogoutRequest
... | [
"def",
"parse_logout_request",
"(",
"self",
",",
"message_text",
")",
":",
"result",
"=",
"{",
"}",
"xml_document",
"=",
"parseString",
"(",
"message_text",
")",
"for",
"node",
"in",
"xml_document",
".",
"getElementsByTagName",
"(",
"'saml:NameId'",
")",
":",
... | Parse the contents of a CAS `LogoutRequest` XML message.
::
>>> from cas_client import CASClient
>>> client = CASClient('https://logmein.com')
>>> message_text = """
... <samlp:LogoutRequest
... xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
... | [
"Parse",
"the",
"contents",
"of",
"a",
"CAS",
"LogoutRequest",
"XML",
"message",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L209-L254 | train |
discogs/python-cas-client | cas_client/cas_client.py | CASClient.perform_api_request | def perform_api_request(
self,
url,
method='POST',
headers=None,
body=None,
**kwargs
):
'''
Perform an auth-token-protected request against a CAS API endpoint.
'''
assert method in ('GET', 'POST')
if method == 'GET':
... | python | def perform_api_request(
self,
url,
method='POST',
headers=None,
body=None,
**kwargs
):
'''
Perform an auth-token-protected request against a CAS API endpoint.
'''
assert method in ('GET', 'POST')
if method == 'GET':
... | [
"def",
"perform_api_request",
"(",
"self",
",",
"url",
",",
"method",
"=",
"'POST'",
",",
"headers",
"=",
"None",
",",
"body",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"assert",
"method",
"in",
"(",
"'GET'",
",",
"'POST'",
")",
"if",
"method",
"==... | Perform an auth-token-protected request against a CAS API endpoint. | [
"Perform",
"an",
"auth",
"-",
"token",
"-",
"protected",
"request",
"against",
"a",
"CAS",
"API",
"endpoint",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L256-L272 | train |
discogs/python-cas-client | cas_client/cas_client.py | CASClient.perform_proxy | def perform_proxy(self, proxy_ticket, headers=None):
'''
Fetch a response from the remote CAS `proxy` endpoint.
'''
url = self._get_proxy_url(ticket=proxy_ticket)
logging.debug('[CAS] Proxy URL: {}'.format(url))
return self._perform_cas_call(
url,
... | python | def perform_proxy(self, proxy_ticket, headers=None):
'''
Fetch a response from the remote CAS `proxy` endpoint.
'''
url = self._get_proxy_url(ticket=proxy_ticket)
logging.debug('[CAS] Proxy URL: {}'.format(url))
return self._perform_cas_call(
url,
... | [
"def",
"perform_proxy",
"(",
"self",
",",
"proxy_ticket",
",",
"headers",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"_get_proxy_url",
"(",
"ticket",
"=",
"proxy_ticket",
")",
"logging",
".",
"debug",
"(",
"'[CAS] Proxy URL: {}'",
".",
"format",
"(",
... | Fetch a response from the remote CAS `proxy` endpoint. | [
"Fetch",
"a",
"response",
"from",
"the",
"remote",
"CAS",
"proxy",
"endpoint",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L274-L284 | train |
discogs/python-cas-client | cas_client/cas_client.py | CASClient.perform_proxy_validate | def perform_proxy_validate(self, proxied_service_ticket, headers=None):
'''
Fetch a response from the remote CAS `proxyValidate` endpoint.
'''
url = self._get_proxy_validate_url(ticket=proxied_service_ticket)
logging.debug('[CAS] ProxyValidate URL: {}'.format(url))
return... | python | def perform_proxy_validate(self, proxied_service_ticket, headers=None):
'''
Fetch a response from the remote CAS `proxyValidate` endpoint.
'''
url = self._get_proxy_validate_url(ticket=proxied_service_ticket)
logging.debug('[CAS] ProxyValidate URL: {}'.format(url))
return... | [
"def",
"perform_proxy_validate",
"(",
"self",
",",
"proxied_service_ticket",
",",
"headers",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"_get_proxy_validate_url",
"(",
"ticket",
"=",
"proxied_service_ticket",
")",
"logging",
".",
"debug",
"(",
"'[CAS] ProxyVa... | Fetch a response from the remote CAS `proxyValidate` endpoint. | [
"Fetch",
"a",
"response",
"from",
"the",
"remote",
"CAS",
"proxyValidate",
"endpoint",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L286-L296 | train |
discogs/python-cas-client | cas_client/cas_client.py | CASClient.perform_service_validate | def perform_service_validate(
self,
ticket=None,
service_url=None,
headers=None,
):
'''
Fetch a response from the remote CAS `serviceValidate` endpoint.
'''
url = self._get_service_validate_url(ticket, service_url=service_url)
logging.debug... | python | def perform_service_validate(
self,
ticket=None,
service_url=None,
headers=None,
):
'''
Fetch a response from the remote CAS `serviceValidate` endpoint.
'''
url = self._get_service_validate_url(ticket, service_url=service_url)
logging.debug... | [
"def",
"perform_service_validate",
"(",
"self",
",",
"ticket",
"=",
"None",
",",
"service_url",
"=",
"None",
",",
"headers",
"=",
"None",
",",
")",
":",
"url",
"=",
"self",
".",
"_get_service_validate_url",
"(",
"ticket",
",",
"service_url",
"=",
"service_ur... | Fetch a response from the remote CAS `serviceValidate` endpoint. | [
"Fetch",
"a",
"response",
"from",
"the",
"remote",
"CAS",
"serviceValidate",
"endpoint",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L298-L309 | train |
discogs/python-cas-client | cas_client/cas_client.py | CASClient.session_exists | def session_exists(self, ticket):
'''
Test if a session records exists for a service ticket.
'''
assert isinstance(self.session_storage_adapter, CASSessionAdapter)
exists = self.session_storage_adapter.exists(ticket)
logging.debug('[CAS] Session [{}] exists: {}'.format(ti... | python | def session_exists(self, ticket):
'''
Test if a session records exists for a service ticket.
'''
assert isinstance(self.session_storage_adapter, CASSessionAdapter)
exists = self.session_storage_adapter.exists(ticket)
logging.debug('[CAS] Session [{}] exists: {}'.format(ti... | [
"def",
"session_exists",
"(",
"self",
",",
"ticket",
")",
":",
"assert",
"isinstance",
"(",
"self",
".",
"session_storage_adapter",
",",
"CASSessionAdapter",
")",
"exists",
"=",
"self",
".",
"session_storage_adapter",
".",
"exists",
"(",
"ticket",
")",
"logging"... | Test if a session records exists for a service ticket. | [
"Test",
"if",
"a",
"session",
"records",
"exists",
"for",
"a",
"service",
"ticket",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L311-L318 | train |
discogs/python-cas-client | cas_client/cas_client.py | MemcachedCASSessionAdapter.create | def create(self, ticket, payload=None, expires=None):
'''
Create a session identifier in memcache associated with ``ticket``.
'''
if not payload:
payload = True
self._client.set(str(ticket), payload, expires) | python | def create(self, ticket, payload=None, expires=None):
'''
Create a session identifier in memcache associated with ``ticket``.
'''
if not payload:
payload = True
self._client.set(str(ticket), payload, expires) | [
"def",
"create",
"(",
"self",
",",
"ticket",
",",
"payload",
"=",
"None",
",",
"expires",
"=",
"None",
")",
":",
"if",
"not",
"payload",
":",
"payload",
"=",
"True",
"self",
".",
"_client",
".",
"set",
"(",
"str",
"(",
"ticket",
")",
",",
"payload"... | Create a session identifier in memcache associated with ``ticket``. | [
"Create",
"a",
"session",
"identifier",
"in",
"memcache",
"associated",
"with",
"ticket",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L612-L618 | train |
CZ-NIC/python-rt | rt.py | Rt.__check_response | def __check_response(self, msg):
""" Search general errors in server response and raise exceptions when found.
:keyword msg: Result message
:raises NotAllowed: Exception raised when operation was called with
insufficient privileges
:raises AuthorizationError:... | python | def __check_response(self, msg):
""" Search general errors in server response and raise exceptions when found.
:keyword msg: Result message
:raises NotAllowed: Exception raised when operation was called with
insufficient privileges
:raises AuthorizationError:... | [
"def",
"__check_response",
"(",
"self",
",",
"msg",
")",
":",
"if",
"not",
"isinstance",
"(",
"msg",
",",
"list",
")",
":",
"msg",
"=",
"msg",
".",
"split",
"(",
"\"\\n\"",
")",
"if",
"(",
"len",
"(",
"msg",
")",
">",
"2",
")",
"and",
"self",
"... | Search general errors in server response and raise exceptions when found.
:keyword msg: Result message
:raises NotAllowed: Exception raised when operation was called with
insufficient privileges
:raises AuthorizationError: Credentials are invalid or missing
:... | [
"Search",
"general",
"errors",
"in",
"server",
"response",
"and",
"raise",
"exceptions",
"when",
"found",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L313-L331 | train |
CZ-NIC/python-rt | rt.py | Rt.__normalize_list | def __normalize_list(self, msg):
"""Split message to list by commas and trim whitespace."""
if isinstance(msg, list):
msg = "".join(msg)
return list(map(lambda x: x.strip(), msg.split(","))) | python | def __normalize_list(self, msg):
"""Split message to list by commas and trim whitespace."""
if isinstance(msg, list):
msg = "".join(msg)
return list(map(lambda x: x.strip(), msg.split(","))) | [
"def",
"__normalize_list",
"(",
"self",
",",
"msg",
")",
":",
"if",
"isinstance",
"(",
"msg",
",",
"list",
")",
":",
"msg",
"=",
"\"\"",
".",
"join",
"(",
"msg",
")",
"return",
"list",
"(",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"strip",
"(",
... | Split message to list by commas and trim whitespace. | [
"Split",
"message",
"to",
"list",
"by",
"commas",
"and",
"trim",
"whitespace",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L333-L337 | train |
CZ-NIC/python-rt | rt.py | Rt.login | def login(self, login=None, password=None):
""" Login with default or supplied credetials.
.. note::
Calling this method is not necessary when HTTP basic or HTTP
digest_auth authentication is used and RT accepts it as external
authentication method, because the logi... | python | def login(self, login=None, password=None):
""" Login with default or supplied credetials.
.. note::
Calling this method is not necessary when HTTP basic or HTTP
digest_auth authentication is used and RT accepts it as external
authentication method, because the logi... | [
"def",
"login",
"(",
"self",
",",
"login",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"if",
"(",
"login",
"is",
"not",
"None",
")",
"and",
"(",
"password",
"is",
"not",
"None",
")",
":",
"login_data",
"=",
"{",
"'user'",
":",
"login",
"... | Login with default or supplied credetials.
.. note::
Calling this method is not necessary when HTTP basic or HTTP
digest_auth authentication is used and RT accepts it as external
authentication method, because the login in this case is done
transparently by requ... | [
"Login",
"with",
"default",
"or",
"supplied",
"credetials",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L339-L380 | train |
CZ-NIC/python-rt | rt.py | Rt.logout | def logout(self):
""" Logout of user.
:returns: ``True``
Successful logout
``False``
Logout failed (mainly because user was not login)
"""
ret = False
if self.login_result is True:
ret = self.__get_status_... | python | def logout(self):
""" Logout of user.
:returns: ``True``
Successful logout
``False``
Logout failed (mainly because user was not login)
"""
ret = False
if self.login_result is True:
ret = self.__get_status_... | [
"def",
"logout",
"(",
"self",
")",
":",
"ret",
"=",
"False",
"if",
"self",
".",
"login_result",
"is",
"True",
":",
"ret",
"=",
"self",
".",
"__get_status_code",
"(",
"self",
".",
"__request",
"(",
"'logout'",
")",
")",
"==",
"200",
"self",
".",
"logi... | Logout of user.
:returns: ``True``
Successful logout
``False``
Logout failed (mainly because user was not login) | [
"Logout",
"of",
"user",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L382-L394 | train |
CZ-NIC/python-rt | rt.py | Rt.new_correspondence | def new_correspondence(self, queue=None):
""" Obtains tickets changed by other users than the system one.
:keyword queue: Queue where to search
:returns: List of tickets which were last updated by other user than
the system one ordered in decreasing order by LastUpdated.
... | python | def new_correspondence(self, queue=None):
""" Obtains tickets changed by other users than the system one.
:keyword queue: Queue where to search
:returns: List of tickets which were last updated by other user than
the system one ordered in decreasing order by LastUpdated.
... | [
"def",
"new_correspondence",
"(",
"self",
",",
"queue",
"=",
"None",
")",
":",
"return",
"self",
".",
"search",
"(",
"Queue",
"=",
"queue",
",",
"order",
"=",
"'-LastUpdated'",
",",
"LastUpdatedBy__notexact",
"=",
"self",
".",
"default_login",
")"
] | Obtains tickets changed by other users than the system one.
:keyword queue: Queue where to search
:returns: List of tickets which were last updated by other user than
the system one ordered in decreasing order by LastUpdated.
Each ticket is dictionary, the same as i... | [
"Obtains",
"tickets",
"changed",
"by",
"other",
"users",
"than",
"the",
"system",
"one",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L396-L406 | train |
CZ-NIC/python-rt | rt.py | Rt.last_updated | def last_updated(self, since, queue=None):
""" Obtains tickets changed after given date.
:param since: Date as string in form '2011-02-24'
:keyword queue: Queue where to search
:returns: List of tickets with LastUpdated parameter later than
*since* ordered in decreasi... | python | def last_updated(self, since, queue=None):
""" Obtains tickets changed after given date.
:param since: Date as string in form '2011-02-24'
:keyword queue: Queue where to search
:returns: List of tickets with LastUpdated parameter later than
*since* ordered in decreasi... | [
"def",
"last_updated",
"(",
"self",
",",
"since",
",",
"queue",
"=",
"None",
")",
":",
"return",
"self",
".",
"search",
"(",
"Queue",
"=",
"queue",
",",
"order",
"=",
"'-LastUpdated'",
",",
"LastUpdatedBy__notexact",
"=",
"self",
".",
"default_login",
",",... | Obtains tickets changed after given date.
:param since: Date as string in form '2011-02-24'
:keyword queue: Queue where to search
:returns: List of tickets with LastUpdated parameter later than
*since* ordered in decreasing order by LastUpdated.
Each tickets... | [
"Obtains",
"tickets",
"changed",
"after",
"given",
"date",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L408-L419 | train |
CZ-NIC/python-rt | rt.py | Rt.get_ticket | def get_ticket(self, ticket_id):
""" Fetch ticket by its ID.
:param ticket_id: ID of demanded ticket
:returns: Dictionary with key, value pairs for ticket with
*ticket_id* or None if ticket does not exist. List of keys:
* id
* nume... | python | def get_ticket(self, ticket_id):
""" Fetch ticket by its ID.
:param ticket_id: ID of demanded ticket
:returns: Dictionary with key, value pairs for ticket with
*ticket_id* or None if ticket does not exist. List of keys:
* id
* nume... | [
"def",
"get_ticket",
"(",
"self",
",",
"ticket_id",
")",
":",
"msg",
"=",
"self",
".",
"__request",
"(",
"'ticket/{}/show'",
".",
"format",
"(",
"str",
"(",
"ticket_id",
")",
",",
")",
")",
"status_code",
"=",
"self",
".",
"__get_status_code",
"(",
"msg"... | Fetch ticket by its ID.
:param ticket_id: ID of demanded ticket
:returns: Dictionary with key, value pairs for ticket with
*ticket_id* or None if ticket does not exist. List of keys:
* id
* numerical_id
* Queue
... | [
"Fetch",
"ticket",
"by",
"its",
"ID",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L570-L640 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.