repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
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", "." ]
train
https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L299-L319
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", "." ]
train
https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L321-L334
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", "." ]
train
https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L336-L342
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", "." ]
train
https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L344-L395
aiortc/aioice
aioice/ice.py
Connection.close
async def close(self): """ Close the connection. """ # stop consent freshness tests if self._query_consent_handle and not self._query_consent_handle.done(): self._query_consent_handle.cancel() try: await self._query_consent_handle ...
python
async def close(self): """ Close the connection. """ # stop consent freshness tests if self._query_consent_handle and not self._query_consent_handle.done(): self._query_consent_handle.cancel() try: await self._query_consent_handle ...
[ "async", "def", "close", "(", "self", ")", ":", "# stop consent freshness tests", "if", "self", ".", "_query_consent_handle", "and", "not", "self", ".", "_query_consent_handle", ".", "done", "(", ")", ":", "self", ".", "_query_consent_handle", ".", "cancel", "("...
Close the connection.
[ "Close", "the", "connection", "." ]
train
https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L397-L417
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", "." ]
train
https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L430-L446
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", "." ]
train
https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L456-L466
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", ")", ":", "# find local candidate", "protocol", "=", "None", "for", "p", "in", "self", ".", "_protocols", ":", "if", "(", "p", ".", "local_candidate", ...
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", "." ]
train
https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L468-L490
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", "# find remote candidate", "remote_candidate", "=", "None", "for", "c", "in", "self", ".", "_r...
Handle a succesful incoming check.
[ "Handle", "a", "succesful", "incoming", "check", "." ]
train
https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L554-L598
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", "." ]
train
https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L619-L654
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", "." ]
train
https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L656-L661
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", "." ]
train
https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L663-L670
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", "." ]
train
https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L740-L750
aiortc/aioice
aioice/ice.py
Connection.query_consent
async def query_consent(self): """ Periodically check consent (RFC 7675). """ failures = 0 while True: # randomize between 0.8 and 1.2 times CONSENT_INTERVAL await asyncio.sleep(CONSENT_INTERVAL * (0.8 + 0.4 * random.random())) for pair in sel...
python
async def query_consent(self): """ Periodically check consent (RFC 7675). """ failures = 0 while True: # randomize between 0.8 and 1.2 times CONSENT_INTERVAL await asyncio.sleep(CONSENT_INTERVAL * (0.8 + 0.4 * random.random())) for pair in sel...
[ "async", "def", "query_consent", "(", "self", ")", ":", "failures", "=", "0", "while", "True", ":", "# randomize between 0.8 and 1.2 times CONSENT_INTERVAL", "await", "asyncio", ".", "sleep", "(", "CONSENT_INTERVAL", "*", "(", "0.8", "+", "0.4", "*", "random", "...
Periodically check consent (RFC 7675).
[ "Periodically", "check", "consent", "(", "RFC", "7675", ")", "." ]
train
https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L752-L774
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", "." ]
train
https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/stun.py#L268-L306
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L50-L68
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L70-L109
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L111-L148
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L150-L160
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L162-L176
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L178-L190
cole/aiosmtplib
src/aiosmtplib/protocol.py
SMTPProtocol.starttls
async def starttls( self, tls_context: ssl.SSLContext, server_hostname: str = None, timeout: NumType = None, ) -> StartTLSResponse: """ Puts the connection to the SMTP server into TLS mode. """ if self._stream_reader is None or self._stream_writer is N...
python
async def starttls( self, tls_context: ssl.SSLContext, server_hostname: str = None, timeout: NumType = None, ) -> StartTLSResponse: """ Puts the connection to the SMTP server into TLS mode. """ if self._stream_reader is None or self._stream_writer is N...
[ "async", "def", "starttls", "(", "self", ",", "tls_context", ":", "ssl", ".", "SSLContext", ",", "server_hostname", ":", "str", "=", "None", ",", "timeout", ":", "NumType", "=", "None", ",", ")", "->", "StartTLSResponse", ":", "if", "self", ".", "_stream...
Puts the connection to the SMTP server into TLS mode.
[ "Puts", "the", "connection", "to", "the", "SMTP", "server", "into", "TLS", "mode", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L192-L222
cole/aiosmtplib
src/aiosmtplib/protocol.py
SMTPProtocol._drain_writer
async def _drain_writer(self, timeout: NumType = None) -> None: """ Wraps writer.drain() with error handling. """ if self._stream_writer is None: raise SMTPServerDisconnected("Client not connected") # Wrapping drain in a task makes mypy happy drain_task = asy...
python
async def _drain_writer(self, timeout: NumType = None) -> None: """ Wraps writer.drain() with error handling. """ if self._stream_writer is None: raise SMTPServerDisconnected("Client not connected") # Wrapping drain in a task makes mypy happy drain_task = asy...
[ "async", "def", "_drain_writer", "(", "self", ",", "timeout", ":", "NumType", "=", "None", ")", "->", "None", ":", "if", "self", ".", "_stream_writer", "is", "None", ":", "raise", "SMTPServerDisconnected", "(", "\"Client not connected\"", ")", "# Wrapping drain ...
Wraps writer.drain() with error handling.
[ "Wraps", "writer", ".", "drain", "()", "with", "error", "handling", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L224-L238
cole/aiosmtplib
src/aiosmtplib/protocol.py
SMTPProtocol._readline
async def _readline(self, timeout: NumType = None): """ Wraps reader.readuntil() with error handling. """ if self._stream_reader is None or self._stream_writer is None: raise SMTPServerDisconnected("Client not connected") read_task = asyncio.Task( self._s...
python
async def _readline(self, timeout: NumType = None): """ Wraps reader.readuntil() with error handling. """ if self._stream_reader is None or self._stream_writer is None: raise SMTPServerDisconnected("Client not connected") read_task = asyncio.Task( self._s...
[ "async", "def", "_readline", "(", "self", ",", "timeout", ":", "NumType", "=", "None", ")", ":", "if", "self", ".", "_stream_reader", "is", "None", "or", "self", ".", "_stream_writer", "is", "None", ":", "raise", "SMTPServerDisconnected", "(", "\"Client not ...
Wraps reader.readuntil() with error handling.
[ "Wraps", "reader", ".", "readuntil", "()", "with", "error", "handling", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/protocol.py#L240-L270
cole/aiosmtplib
src/aiosmtplib/esmtp.py
parse_esmtp_extensions
def parse_esmtp_extensions(message: str) -> Tuple[Dict[str, str], List[str]]: """ Parse an EHLO response from the server into a dict of {extension: params} and a list of auth method names. It might look something like: 220 size.does.matter.af.MIL (More ESMTP than Crappysoft!) EHLO he...
python
def parse_esmtp_extensions(message: str) -> Tuple[Dict[str, str], List[str]]: """ Parse an EHLO response from the server into a dict of {extension: params} and a list of auth method names. It might look something like: 220 size.does.matter.af.MIL (More ESMTP than Crappysoft!) EHLO he...
[ "def", "parse_esmtp_extensions", "(", "message", ":", "str", ")", "->", "Tuple", "[", "Dict", "[", "str", ",", "str", "]", ",", "List", "[", "str", "]", "]", ":", "esmtp_extensions", "=", "{", "}", "auth_types", "=", "[", "]", "# type: List[str]", "res...
Parse an EHLO response from the server into a dict of {extension: params} and a list of auth method names. It might look something like: 220 size.does.matter.af.MIL (More ESMTP than Crappysoft!) EHLO heaven.af.mil 250-size.does.matter.af.MIL offers FIFTEEN extensions: 250-8...
[ "Parse", "an", "EHLO", "response", "from", "the", "server", "into", "a", "dict", "of", "{", "extension", ":", "params", "}", "and", "a", "list", "of", "auth", "method", "names", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L471-L528
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L59-L68
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L86-L107
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L109-L127
cole/aiosmtplib
src/aiosmtplib/esmtp.py
ESMTP.rset
async def rset(self, timeout: DefaultNumType = _default) -> SMTPResponse: """ Send an SMTP RSET command, which resets the server's envelope (the envelope contains the sender, recipient, and mail data). :raises SMTPResponseException: on unexpected server response code """ ...
python
async def rset(self, timeout: DefaultNumType = _default) -> SMTPResponse: """ Send an SMTP RSET command, which resets the server's envelope (the envelope contains the sender, recipient, and mail data). :raises SMTPResponseException: on unexpected server response code """ ...
[ "async", "def", "rset", "(", "self", ",", "timeout", ":", "DefaultNumType", "=", "_default", ")", "->", "SMTPResponse", ":", "await", "self", ".", "_ehlo_or_helo_if_needed", "(", ")", "async", "with", "self", ".", "_command_lock", ":", "response", "=", "awai...
Send an SMTP RSET command, which resets the server's envelope (the envelope contains the sender, recipient, and mail data). :raises SMTPResponseException: on unexpected server response code
[ "Send", "an", "SMTP", "RSET", "command", "which", "resets", "the", "server", "s", "envelope", "(", "the", "envelope", "contains", "the", "sender", "recipient", "and", "mail", "data", ")", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L129-L143
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L145-L158
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L160-L187
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L189-L210
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", ":", "# Can't quit without HELO/EHLO", "await", "self", ".", "_ehlo_or_helo_if_needed", "(", ")", "async", "with", "self", ".", "_command_lock",...
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L212-L229
cole/aiosmtplib
src/aiosmtplib/esmtp.py
ESMTP.mail
async def mail( self, sender: str, options: Iterable[str] = None, timeout: DefaultNumType = _default, ) -> SMTPResponse: """ Send an SMTP MAIL command, which specifies the message sender and begins a new mail transfer session ("envelope"). :raises SMT...
python
async def mail( self, sender: str, options: Iterable[str] = None, timeout: DefaultNumType = _default, ) -> SMTPResponse: """ Send an SMTP MAIL command, which specifies the message sender and begins a new mail transfer session ("envelope"). :raises SMT...
[ "async", "def", "mail", "(", "self", ",", "sender", ":", "str", ",", "options", ":", "Iterable", "[", "str", "]", "=", "None", ",", "timeout", ":", "DefaultNumType", "=", "_default", ",", ")", "->", "SMTPResponse", ":", "await", "self", ".", "_ehlo_or_...
Send an SMTP MAIL command, which specifies the message sender and begins a new mail transfer session ("envelope"). :raises SMTPSenderRefused: on unexpected server response code
[ "Send", "an", "SMTP", "MAIL", "command", "which", "specifies", "the", "message", "sender", "and", "begins", "a", "new", "mail", "transfer", "session", "(", "envelope", ")", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L231-L259
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L261-L291
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", "(", ")", "# As data ...
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L293-L333
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L337-L359
cole/aiosmtplib
src/aiosmtplib/esmtp.py
ESMTP._ehlo_or_helo_if_needed
async def _ehlo_or_helo_if_needed(self) -> None: """ Call self.ehlo() and/or self.helo() if needed. If there has been no previous EHLO or HELO command this session, this method tries ESMTP EHLO first. """ async with self._ehlo_or_helo_lock: if self.is_ehlo_or...
python
async def _ehlo_or_helo_if_needed(self) -> None: """ Call self.ehlo() and/or self.helo() if needed. If there has been no previous EHLO or HELO command this session, this method tries ESMTP EHLO first. """ async with self._ehlo_or_helo_lock: if self.is_ehlo_or...
[ "async", "def", "_ehlo_or_helo_if_needed", "(", "self", ")", "->", "None", ":", "async", "with", "self", ".", "_ehlo_or_helo_lock", ":", "if", "self", ".", "is_ehlo_or_helo_needed", ":", "try", ":", "await", "self", ".", "ehlo", "(", ")", "except", "SMTPHelo...
Call self.ehlo() and/or self.helo() if needed. If there has been no previous EHLO or HELO command this session, this method tries ESMTP EHLO first.
[ "Call", "self", ".", "ehlo", "()", "and", "/", "or", "self", ".", "helo", "()", "if", "needed", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L367-L382
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L384-L392
cole/aiosmtplib
src/aiosmtplib/esmtp.py
ESMTP.starttls
async def starttls( self, server_hostname: str = None, validate_certs: bool = None, client_cert: DefaultStrType = _default, client_key: DefaultStrType = _default, cert_bundle: DefaultStrType = _default, tls_context: DefaultSSLContextType = _default, timeou...
python
async def starttls( self, server_hostname: str = None, validate_certs: bool = None, client_cert: DefaultStrType = _default, client_key: DefaultStrType = _default, cert_bundle: DefaultStrType = _default, tls_context: DefaultSSLContextType = _default, timeou...
[ "async", "def", "starttls", "(", "self", ",", "server_hostname", ":", "str", "=", "None", ",", "validate_certs", ":", "bool", "=", "None", ",", "client_cert", ":", "DefaultStrType", "=", "_default", ",", "client_key", ":", "DefaultStrType", "=", "_default", ...
Puts the connection to the SMTP server into TLS mode. If there has been no previous EHLO or HELO command this session, this method tries ESMTP EHLO first. If the server supports TLS, this will encrypt the rest of the SMTP session. If you provide the keyfile and certfile parameters, ...
[ "Puts", "the", "connection", "to", "the", "SMTP", "server", "into", "TLS", "mode", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L394-L468
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/auth.py#L40-L44
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/auth.py#L46-L82
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/auth.py#L84-L122
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/auth.py#L124-L151
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/auth.py#L153-L197
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/email.py#L16-L22
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/email.py#L25-L38
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/email.py#L62-L81
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", "=", "[", "]", "# type: List[str]", "...
Extract the recipients from the message object given.
[ "Extract", "the", "recipients", "from", "the", "message", "object", "given", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/email.py#L84-L105
cole/aiosmtplib
src/aiosmtplib/connection.py
SMTPConnection.source_address
def source_address(self) -> str: """ Get the system hostname to be sent to the SMTP server. Simply caches the result of :func:`socket.getfqdn`. """ if self._source_address is None: self._source_address = socket.getfqdn() return self._source_address
python
def source_address(self) -> str: """ Get the system hostname to be sent to the SMTP server. Simply caches the result of :func:`socket.getfqdn`. """ if self._source_address is None: self._source_address = socket.getfqdn() return self._source_address
[ "def", "source_address", "(", "self", ")", "->", "str", ":", "if", "self", ".", "_source_address", "is", "None", ":", "self", ".", "_source_address", "=", "socket", ".", "getfqdn", "(", ")", "return", "self", ".", "_source_address" ]
Get the system hostname to be sent to the SMTP server. Simply caches the result of :func:`socket.getfqdn`.
[ "Get", "the", "system", "hostname", "to", "be", "sent", "to", "the", "SMTP", "server", ".", "Simply", "caches", "the", "result", "of", ":", "func", ":", "socket", ".", "getfqdn", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/connection.py#L134-L142
cole/aiosmtplib
src/aiosmtplib/connection.py
SMTPConnection.connect
async def connect( self, hostname: str = None, port: int = None, source_address: DefaultStrType = _default, timeout: DefaultNumType = _default, loop: asyncio.AbstractEventLoop = None, use_tls: bool = None, validate_certs: bool = None, client_cert: ...
python
async def connect( self, hostname: str = None, port: int = None, source_address: DefaultStrType = _default, timeout: DefaultNumType = _default, loop: asyncio.AbstractEventLoop = None, use_tls: bool = None, validate_certs: bool = None, client_cert: ...
[ "async", "def", "connect", "(", "self", ",", "hostname", ":", "str", "=", "None", ",", "port", ":", "int", "=", "None", ",", "source_address", ":", "DefaultStrType", "=", "_default", ",", "timeout", ":", "DefaultNumType", "=", "_default", ",", "loop", ":...
Initialize a connection to the server. Options provided to :meth:`.connect` take precedence over those used to initialize the class. :keyword hostname: Server name (or IP) to connect to :keyword port: Server port. Defaults to 25 if ``use_tls`` is False, 465 if ``use_tls`` i...
[ "Initialize", "a", "connection", "to", "the", "server", ".", "Options", "provided", "to", ":", "meth", ":", ".", "connect", "take", "precedence", "over", "those", "used", "to", "initialize", "the", "class", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/connection.py#L144-L222
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", "# type:...
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/connection.py#L274-L301
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", ":", "# SERVER_AUTH is what we want for a client side socket", "contex...
Build an SSLContext object from the options we've been given.
[ "Build", "an", "SSLContext", "object", "from", "the", "options", "we", "ve", "been", "given", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/connection.py#L306-L327
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/connection.py#L329-L340
cole/aiosmtplib
src/aiosmtplib/connection.py
SMTPConnection.close
def close(self) -> None: """ Closes the connection. """ if self.transport is not None and not self.transport.is_closing(): self.transport.close() if self._connect_lock.locked(): self._connect_lock.release() self.protocol = None self.trans...
python
def close(self) -> None: """ Closes the connection. """ if self.transport is not None and not self.transport.is_closing(): self.transport.close() if self._connect_lock.locked(): self._connect_lock.release() self.protocol = None self.trans...
[ "def", "close", "(", "self", ")", "->", "None", ":", "if", "self", ".", "transport", "is", "not", "None", "and", "not", "self", ".", "transport", ".", "is_closing", "(", ")", ":", "self", ".", "transport", ".", "close", "(", ")", "if", "self", ".",...
Closes the connection.
[ "Closes", "the", "connection", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/connection.py#L342-L353
cole/aiosmtplib
src/aiosmtplib/connection.py
SMTPConnection.get_transport_info
def get_transport_info(self, key: str) -> Any: """ Get extra info from the transport. Supported keys: - ``peername`` - ``socket`` - ``sockname`` - ``compression`` - ``cipher`` - ``peercert`` - ``sslcontext`` ...
python
def get_transport_info(self, key: str) -> Any: """ Get extra info from the transport. Supported keys: - ``peername`` - ``socket`` - ``sockname`` - ``compression`` - ``cipher`` - ``peercert`` - ``sslcontext`` ...
[ "def", "get_transport_info", "(", "self", ",", "key", ":", "str", ")", "->", "Any", ":", "self", ".", "_raise_error_if_disconnected", "(", ")", "return", "self", ".", "transport", ".", "get_extra_info", "(", "key", ")" ]
Get extra info from the transport. Supported keys: - ``peername`` - ``socket`` - ``sockname`` - ``compression`` - ``cipher`` - ``peercert`` - ``sslcontext`` - ``sslobject`` :raises SMTPServerDisconnected: c...
[ "Get", "extra", "info", "from", "the", "transport", ".", "Supported", "keys", ":" ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/connection.py#L355-L373
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/smtp.py#L57-L166
cole/aiosmtplib
src/aiosmtplib/smtp.py
SMTP._send_recipients
async def _send_recipients( self, recipients: List[str], options: List[str] = None, timeout: DefaultNumType = _default, ) -> RecipientErrorsType: """ Send the recipients given to the server. Used as part of :meth:`.sendmail`. """ recipient_erro...
python
async def _send_recipients( self, recipients: List[str], options: List[str] = None, timeout: DefaultNumType = _default, ) -> RecipientErrorsType: """ Send the recipients given to the server. Used as part of :meth:`.sendmail`. """ recipient_erro...
[ "async", "def", "_send_recipients", "(", "self", ",", "recipients", ":", "List", "[", "str", "]", ",", "options", ":", "List", "[", "str", "]", "=", "None", ",", "timeout", ":", "DefaultNumType", "=", "_default", ",", ")", "->", "RecipientErrorsType", ":...
Send the recipients given to the server. Used as part of :meth:`.sendmail`.
[ "Send", "the", "recipients", "given", "to", "the", "server", ".", "Used", "as", "part", "of", ":", "meth", ":", ".", "sendmail", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/smtp.py#L168-L193
cole/aiosmtplib
src/aiosmtplib/smtp.py
SMTP.send_message
async def send_message( self, message: Message, sender: str = None, recipients: RecipientsType = None, mail_options: Iterable[str] = None, rcpt_options: Iterable[str] = None, timeout: DefaultNumType = _default, ) -> SendmailResponseType: r""" S...
python
async def send_message( self, message: Message, sender: str = None, recipients: RecipientsType = None, mail_options: Iterable[str] = None, rcpt_options: Iterable[str] = None, timeout: DefaultNumType = _default, ) -> SendmailResponseType: r""" S...
[ "async", "def", "send_message", "(", "self", ",", "message", ":", "Message", ",", "sender", ":", "str", "=", "None", ",", "recipients", ":", "RecipientsType", "=", "None", ",", "mail_options", ":", "Iterable", "[", "str", "]", "=", "None", ",", "rcpt_opt...
r""" Sends an :class:`email.message.Message` object. Arguments are as for :meth:`.sendmail`, except that message is an :class:`email.message.Message` object. If sender is None or recipients is None, these arguments are taken from the headers of the Message as described in RFC 2...
[ "r", "Sends", "an", ":", "class", ":", "email", ".", "message", ".", "Message", "object", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/smtp.py#L195-L235
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", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/smtp.py#L237-L252
cole/aiosmtplib
src/aiosmtplib/smtp.py
SMTP.sendmail_sync
def sendmail_sync( self, sender: str, recipients: RecipientsType, message: Union[str, bytes], mail_options: Iterable[str] = None, rcpt_options: Iterable[str] = None, timeout: DefaultNumType = _default, ) -> SendmailResponseType: """ Synchronous...
python
def sendmail_sync( self, sender: str, recipients: RecipientsType, message: Union[str, bytes], mail_options: Iterable[str] = None, rcpt_options: Iterable[str] = None, timeout: DefaultNumType = _default, ) -> SendmailResponseType: """ Synchronous...
[ "def", "sendmail_sync", "(", "self", ",", "sender", ":", "str", ",", "recipients", ":", "RecipientsType", ",", "message", ":", "Union", "[", "str", ",", "bytes", "]", ",", "mail_options", ":", "Iterable", "[", "str", "]", "=", "None", ",", "rcpt_options"...
Synchronous version of :meth:`.sendmail`. This method starts the event loop to connect, send the message, and disconnect.
[ "Synchronous", "version", "of", ":", "meth", ":", ".", "sendmail", ".", "This", "method", "starts", "the", "event", "loop", "to", "connect", "send", "the", "message", "and", "disconnect", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/smtp.py#L254-L275
cole/aiosmtplib
src/aiosmtplib/smtp.py
SMTP.send_message_sync
def send_message_sync( self, message: Message, sender: str = None, recipients: RecipientsType = None, mail_options: Iterable[str] = None, rcpt_options: Iterable[str] = None, timeout: DefaultNumType = _default, ) -> SendmailResponseType: """ Syn...
python
def send_message_sync( self, message: Message, sender: str = None, recipients: RecipientsType = None, mail_options: Iterable[str] = None, rcpt_options: Iterable[str] = None, timeout: DefaultNumType = _default, ) -> SendmailResponseType: """ Syn...
[ "def", "send_message_sync", "(", "self", ",", "message", ":", "Message", ",", "sender", ":", "str", "=", "None", ",", "recipients", ":", "RecipientsType", "=", "None", ",", "mail_options", ":", "Iterable", "[", "str", "]", "=", "None", ",", "rcpt_options",...
Synchronous version of :meth:`.send_message`. This method starts the event loop to connect, send the message, and disconnect.
[ "Synchronous", "version", "of", ":", "meth", ":", ".", "send_message", ".", "This", "method", "starts", "the", "event", "loop", "to", "connect", "send", "the", "message", "and", "disconnect", "." ]
train
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/smtp.py#L277-L298
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\"", ")", "# TODO change this to submit50.io!", "if", "res", ".", "status_code", "==", "200", "and", "res", ".", "text", ".", "strip", "(", ")...
Check for any announcements from cs50.me, raise Error if so.
[ "Check", "for", "any", "announcements", "from", "cs50", ".", "me", "raise", "Error", "if", "so", "." ]
train
https://github.com/cs50/submit50/blob/5f4c8b3675e8e261c8422f76eacd6a6330c23831/submit50/__main__.py#L28-L32
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", "(", ")", ":", "# Retrieve version info", "res", "=", "requests", ".", "get", "(", "\"https://cs50.me/versions/submit50\"", ")", "# TODO change this to submit50.io!", "if", "res", ".", "status_code", "!=", "200", ":", "raise", "Error", "(", "...
Check that submit50 is the latest version according to submit50.io.
[ "Check", "that", "submit50", "is", "the", "latest", "version", "according", "to", "submit50", ".", "io", "." ]
train
https://github.com/cs50/submit50/blob/5f4c8b3675e8e261c8422f76eacd6a6330c23831/submit50/__main__.py#L35-L44
cs50/submit50
submit50/__main__.py
cprint
def cprint(text="", color=None, on_color=None, attrs=None, **kwargs): """Colorizes text (and wraps to terminal's width).""" # Assume 80 in case not running in a terminal columns, lines = shutil.get_terminal_size() if columns == 0: columns = 80 # Because get_terminal_size's default fallback does...
python
def cprint(text="", color=None, on_color=None, attrs=None, **kwargs): """Colorizes text (and wraps to terminal's width).""" # Assume 80 in case not running in a terminal columns, lines = shutil.get_terminal_size() if columns == 0: columns = 80 # Because get_terminal_size's default fallback does...
[ "def", "cprint", "(", "text", "=", "\"\"", ",", "color", "=", "None", ",", "on_color", "=", "None", ",", "attrs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# Assume 80 in case not running in a terminal", "columns", ",", "lines", "=", "shutil", ".", ...
Colorizes text (and wraps to terminal's width).
[ "Colorizes", "text", "(", "and", "wraps", "to", "terminal", "s", "width", ")", "." ]
train
https://github.com/cs50/submit50/blob/5f4c8b3675e8e261c8422f76eacd6a6330c23831/submit50/__main__.py#L53-L62
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", "." ]
train
https://github.com/cs50/submit50/blob/5f4c8b3675e8e261c8422f76eacd6a6330c23831/submit50/__main__.py#L93-L104
kedder/ofxstatement
src/ofxstatement/plugin.py
list_plugins
def list_plugins(): """Return list of all plugin classes registered as a list of tuples: [(name, plugin_class)] """ plugin_eps = pkg_resources.iter_entry_points('ofxstatement') return sorted((ep.name, ep.load()) for ep in plugin_eps)
python
def list_plugins(): """Return list of all plugin classes registered as a list of tuples: [(name, plugin_class)] """ plugin_eps = pkg_resources.iter_entry_points('ofxstatement') return sorted((ep.name, ep.load()) for ep in plugin_eps)
[ "def", "list_plugins", "(", ")", ":", "plugin_eps", "=", "pkg_resources", ".", "iter_entry_points", "(", "'ofxstatement'", ")", "return", "sorted", "(", "(", "ep", ".", "name", ",", "ep", ".", "load", "(", ")", ")", "for", "ep", "in", "plugin_eps", ")" ]
Return list of all plugin classes registered as a list of tuples: [(name, plugin_class)]
[ "Return", "list", "of", "all", "plugin", "classes", "registered", "as", "a", "list", "of", "tuples", ":" ]
train
https://github.com/kedder/ofxstatement/blob/61f9dc1cfe6024874b859c8aec108b9d9acee57a/src/ofxstatement/plugin.py#L20-L26
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", "." ]
train
https://github.com/kedder/ofxstatement/blob/61f9dc1cfe6024874b859c8aec108b9d9acee57a/src/ofxstatement/statement.py#L155-L163
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", "." ]
train
https://github.com/kedder/ofxstatement/blob/61f9dc1cfe6024874b859c8aec108b9d9acee57a/src/ofxstatement/statement.py#L166-L180
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" ]
train
https://github.com/kedder/ofxstatement/blob/61f9dc1cfe6024874b859c8aec108b9d9acee57a/src/ofxstatement/statement.py#L113-L120
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" ]
train
https://github.com/kedder/ofxstatement/blob/61f9dc1cfe6024874b859c8aec108b9d9acee57a/src/ofxstatement/parser.py#L17-L33
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", "." ]
train
https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L53-L63
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", "." ]
train
https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L65-L75
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", "." ]
train
https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L77-L83
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...
Build an auth-token-protected CAS API url.
[ "Build", "an", "auth", "-", "token", "-", "protected", "CAS", "API", "url", "." ]
train
https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L85-L113
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", "." ]
train
https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L115-L141
discogs/python-cas-client
cas_client/cas_client.py
CASClient.get_destroy_other_sessions_url
def get_destroy_other_sessions_url(self, service_url=None): ''' Get the URL for a remote CAS `destroy-other-sessions` endpoint. :: >>> from cas_client import CASClient >>> client = CASClient('https://logmein.com') >>> service_url = 'http://myservice.net' ...
python
def get_destroy_other_sessions_url(self, service_url=None): ''' Get the URL for a remote CAS `destroy-other-sessions` endpoint. :: >>> from cas_client import CASClient >>> client = CASClient('https://logmein.com') >>> service_url = 'http://myservice.net' ...
[ "def", "get_destroy_other_sessions_url", "(", "self", ",", "service_url", "=", "None", ")", ":", "template", "=", "'{server_url}{auth_prefix}/destroy-other-sessions?service={service_url}'", "url", "=", "template", ".", "format", "(", "server_url", "=", "self", ".", "ser...
Get the URL for a remote CAS `destroy-other-sessions` endpoint. :: >>> from cas_client import CASClient >>> client = CASClient('https://logmein.com') >>> service_url = 'http://myservice.net' >>> client.get_destroy_other_sessions_url(service_url) 'http...
[ "Get", "the", "URL", "for", "a", "remote", "CAS", "destroy", "-", "other", "-", "sessions", "endpoint", ".", "::" ]
train
https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L143-L163
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", "." ]
train
https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L209-L254
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", "." ]
train
https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L256-L272
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", "." ]
train
https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L274-L284
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", "." ]
train
https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L286-L296
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", "." ]
train
https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L298-L309
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", "." ]
train
https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L311-L318
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", "." ]
train
https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L612-L618
CZ-NIC/python-rt
rt.py
Rt.__request
def __request(self, selector, get_params={}, post_data={}, files=[], without_login=False, text_response=True): """ General request for :term:`API`. :keyword selector: End part of URL which completes self.url parameter set during class initialization. ...
python
def __request(self, selector, get_params={}, post_data={}, files=[], without_login=False, text_response=True): """ General request for :term:`API`. :keyword selector: End part of URL which completes self.url parameter set during class initialization. ...
[ "def", "__request", "(", "self", ",", "selector", ",", "get_params", "=", "{", "}", ",", "post_data", "=", "{", "}", ",", "files", "=", "[", "]", ",", "without_login", "=", "False", ",", "text_response", "=", "True", ")", ":", "try", ":", "if", "("...
General request for :term:`API`. :keyword selector: End part of URL which completes self.url parameter set during class initialization. E.g.: ``ticket/123456/show`` :keyword post_data: Dictionary with POST method fields :keyword files: List ...
[ "General", "request", "for", ":", "term", ":", "API", "." ]
train
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L229-L299
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", "." ]
train
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L313-L331
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", "." ]
train
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L333-L337
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", "." ]
train
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L339-L380
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", "." ]
train
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L382-L394
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", "." ]
train
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L396-L406
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", "." ]
train
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L408-L419
CZ-NIC/python-rt
rt.py
Rt.search
def search(self, Queue=None, order=None, raw_query=None, Format='l', **kwargs): """ Search arbitrary needles in given fields and queue. Example:: >>> tracker = Rt('http://tracker.example.com/REST/1.0/', 'rt-username', 'top-secret') >>> tracker.login() >>> tickets = ...
python
def search(self, Queue=None, order=None, raw_query=None, Format='l', **kwargs): """ Search arbitrary needles in given fields and queue. Example:: >>> tracker = Rt('http://tracker.example.com/REST/1.0/', 'rt-username', 'top-secret') >>> tracker.login() >>> tickets = ...
[ "def", "search", "(", "self", ",", "Queue", "=", "None", ",", "order", "=", "None", ",", "raw_query", "=", "None", ",", "Format", "=", "'l'", ",", "*", "*", "kwargs", ")", ":", "get_params", "=", "{", "}", "query", "=", "[", "]", "url", "=", "'...
Search arbitrary needles in given fields and queue. Example:: >>> tracker = Rt('http://tracker.example.com/REST/1.0/', 'rt-username', 'top-secret') >>> tracker.login() >>> tickets = tracker.search(CF_Domain='example.com', Subject__like='warning') >>> tickets = t...
[ "Search", "arbitrary", "needles", "in", "given", "fields", "and", "queue", "." ]
train
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L421-L568
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", "." ]
train
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L570-L640
CZ-NIC/python-rt
rt.py
Rt.create_ticket
def create_ticket(self, Queue=None, files=[], **kwargs): """ Create new ticket and set given parameters. Example of message sended to ``http://tracker.example.com/REST/1.0/ticket/new``:: content=id: ticket/new Queue: General Owner: Nobody Requestors: som...
python
def create_ticket(self, Queue=None, files=[], **kwargs): """ Create new ticket and set given parameters. Example of message sended to ``http://tracker.example.com/REST/1.0/ticket/new``:: content=id: ticket/new Queue: General Owner: Nobody Requestors: som...
[ "def", "create_ticket", "(", "self", ",", "Queue", "=", "None", ",", "files", "=", "[", "]", ",", "*", "*", "kwargs", ")", ":", "post_data", "=", "'id: ticket/new\\nQueue: {}\\n'", ".", "format", "(", "Queue", "or", "self", ".", "default_queue", ",", ")"...
Create new ticket and set given parameters. Example of message sended to ``http://tracker.example.com/REST/1.0/ticket/new``:: content=id: ticket/new Queue: General Owner: Nobody Requestors: somebody@example.com Subject: Ticket created through REST AP...
[ "Create", "new", "ticket", "and", "set", "given", "parameters", "." ]
train
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L642-L700
CZ-NIC/python-rt
rt.py
Rt.edit_ticket
def edit_ticket(self, ticket_id, **kwargs): """ Edit ticket values. :param ticket_id: ID of ticket to edit :keyword kwargs: Other arguments possible to set: Requestors, Subject, Cc, AdminCc, Owner, Status, Priority, InitialPriority, FinalPriori...
python
def edit_ticket(self, ticket_id, **kwargs): """ Edit ticket values. :param ticket_id: ID of ticket to edit :keyword kwargs: Other arguments possible to set: Requestors, Subject, Cc, AdminCc, Owner, Status, Priority, InitialPriority, FinalPriori...
[ "def", "edit_ticket", "(", "self", ",", "ticket_id", ",", "*", "*", "kwargs", ")", ":", "post_data", "=", "''", "for", "key", ",", "value", "in", "iteritems", "(", "kwargs", ")", ":", "if", "isinstance", "(", "value", ",", "(", "list", ",", "tuple", ...
Edit ticket values. :param ticket_id: ID of ticket to edit :keyword kwargs: Other arguments possible to set: Requestors, Subject, Cc, AdminCc, Owner, Status, Priority, InitialPriority, FinalPriority, TimeEstimated, Starts, Due,...
[ "Edit", "ticket", "values", "." ]
train
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L702-L731
CZ-NIC/python-rt
rt.py
Rt.get_history
def get_history(self, ticket_id, transaction_id=None): """ Get set of history items. :param ticket_id: ID of ticket :keyword transaction_id: If set to None, all history items are returned, if set to ID of valid transaction just o...
python
def get_history(self, ticket_id, transaction_id=None): """ Get set of history items. :param ticket_id: ID of ticket :keyword transaction_id: If set to None, all history items are returned, if set to ID of valid transaction just o...
[ "def", "get_history", "(", "self", ",", "ticket_id", ",", "transaction_id", "=", "None", ")", ":", "if", "transaction_id", "is", "None", ":", "# We are using \"long\" format to get all history items at once.", "# Each history item is then separated by double dash.", "msgs", "...
Get set of history items. :param ticket_id: ID of ticket :keyword transaction_id: If set to None, all history items are returned, if set to ID of valid transaction just one history item is returned :returns: List of history item...
[ "Get", "set", "of", "history", "items", "." ]
train
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L733-L801
CZ-NIC/python-rt
rt.py
Rt.get_short_history
def get_short_history(self, ticket_id): """ Get set of short history items :param ticket_id: ID of ticket :returns: List of history items ordered increasingly by time of event. Each history item is a tuple containing (id, Description). Returns None if ticket ...
python
def get_short_history(self, ticket_id): """ Get set of short history items :param ticket_id: ID of ticket :returns: List of history items ordered increasingly by time of event. Each history item is a tuple containing (id, Description). Returns None if ticket ...
[ "def", "get_short_history", "(", "self", ",", "ticket_id", ")", ":", "msg", "=", "self", ".", "__request", "(", "'ticket/{}/history'", ".", "format", "(", "str", "(", "ticket_id", ")", ",", ")", ")", "items", "=", "[", "]", "lines", "=", "msg", ".", ...
Get set of short history items :param ticket_id: ID of ticket :returns: List of history items ordered increasingly by time of event. Each history item is a tuple containing (id, Description). Returns None if ticket does not exist.
[ "Get", "set", "of", "short", "history", "items" ]
train
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L803-L837
CZ-NIC/python-rt
rt.py
Rt.__correspond
def __correspond(self, ticket_id, text='', action='correspond', cc='', bcc='', content_type='text/plain', files=[]): """ Sends out the correspondence :param ticket_id: ID of ticket to which message belongs :keyword text: Content of email message :keyword action: correspond or comment ...
python
def __correspond(self, ticket_id, text='', action='correspond', cc='', bcc='', content_type='text/plain', files=[]): """ Sends out the correspondence :param ticket_id: ID of ticket to which message belongs :keyword text: Content of email message :keyword action: correspond or comment ...
[ "def", "__correspond", "(", "self", ",", "ticket_id", ",", "text", "=", "''", ",", "action", "=", "'correspond'", ",", "cc", "=", "''", ",", "bcc", "=", "''", ",", "content_type", "=", "'text/plain'", ",", "files", "=", "[", "]", ")", ":", "post_data...
Sends out the correspondence :param ticket_id: ID of ticket to which message belongs :keyword text: Content of email message :keyword action: correspond or comment :keyword content_type: Content type of email message, default to text/plain :keyword cc: Carbon copy just for this ...
[ "Sends", "out", "the", "correspondence" ]
train
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L839-L866
CZ-NIC/python-rt
rt.py
Rt.reply
def reply(self, ticket_id, text='', cc='', bcc='', content_type='text/plain', files=[]): """ Sends email message to the contacts in ``Requestors`` field of given ticket with subject as is set in ``Subject`` field. Form of message according to documentation:: id: <ticket-id> ...
python
def reply(self, ticket_id, text='', cc='', bcc='', content_type='text/plain', files=[]): """ Sends email message to the contacts in ``Requestors`` field of given ticket with subject as is set in ``Subject`` field. Form of message according to documentation:: id: <ticket-id> ...
[ "def", "reply", "(", "self", ",", "ticket_id", ",", "text", "=", "''", ",", "cc", "=", "''", ",", "bcc", "=", "''", ",", "content_type", "=", "'text/plain'", ",", "files", "=", "[", "]", ")", ":", "return", "self", ".", "__correspond", "(", "ticket...
Sends email message to the contacts in ``Requestors`` field of given ticket with subject as is set in ``Subject`` field. Form of message according to documentation:: id: <ticket-id> Action: correspond Text: the text comment second line starts with ...
[ "Sends", "email", "message", "to", "the", "contacts", "in", "Requestors", "field", "of", "given", "ticket", "with", "subject", "as", "is", "set", "in", "Subject", "field", "." ]
train
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L868-L896
CZ-NIC/python-rt
rt.py
Rt.get_attachments
def get_attachments(self, ticket_id): """ Get attachment list for a given ticket :param ticket_id: ID of ticket :returns: List of tuples for attachments belonging to given ticket. Tuple format: (id, name, content_type, size) Returns None if ticket does not ex...
python
def get_attachments(self, ticket_id): """ Get attachment list for a given ticket :param ticket_id: ID of ticket :returns: List of tuples for attachments belonging to given ticket. Tuple format: (id, name, content_type, size) Returns None if ticket does not ex...
[ "def", "get_attachments", "(", "self", ",", "ticket_id", ")", ":", "msg", "=", "self", ".", "__request", "(", "'ticket/{}/attachments'", ".", "format", "(", "str", "(", "ticket_id", ")", ",", ")", ")", "lines", "=", "msg", ".", "split", "(", "'\\n'", "...
Get attachment list for a given ticket :param ticket_id: ID of ticket :returns: List of tuples for attachments belonging to given ticket. Tuple format: (id, name, content_type, size) Returns None if ticket does not exist.
[ "Get", "attachment", "list", "for", "a", "given", "ticket" ]
train
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L933-L951