repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
FulcrumTechnologies/pyconfluence
pyconfluence/actions.py
edit_page
def edit_page(id, name, space, content): """Update a page in Confluence. Parameters: - id: ID of the page you wish to edit. - name: name you would like to give to the page (usually the same name). - space: space where the page lives. - content: XHTML content to be written to the page. Notes:...
python
def edit_page(id, name, space, content): """Update a page in Confluence. Parameters: - id: ID of the page you wish to edit. - name: name you would like to give to the page (usually the same name). - space: space where the page lives. - content: XHTML content to be written to the page. Notes:...
[ "def", "edit_page", "(", "id", ",", "name", ",", "space", ",", "content", ")", ":", "data", "=", "{", "}", "data", "[", "\"id\"", "]", "=", "str", "(", "id", ")", "data", "[", "\"type\"", "]", "=", "\"page\"", "data", "[", "\"title\"", "]", "=", ...
Update a page in Confluence. Parameters: - id: ID of the page you wish to edit. - name: name you would like to give to the page (usually the same name). - space: space where the page lives. - content: XHTML content to be written to the page. Notes: it is required to try an initial update to find...
[ "Update", "a", "page", "in", "Confluence", ".", "Parameters", ":", "-", "id", ":", "ID", "of", "the", "page", "you", "wish", "to", "edit", ".", "-", "name", ":", "name", "you", "would", "like", "to", "give", "to", "the", "page", "(", "usually", "th...
a999726dbc1cbdd3d9062234698eeae799ce84ce
https://github.com/FulcrumTechnologies/pyconfluence/blob/a999726dbc1cbdd3d9062234698eeae799ce84ce/pyconfluence/actions.py#L247-L268
train
Edit a page in Confluence.
FulcrumTechnologies/pyconfluence
pyconfluence/actions.py
delete_page_full
def delete_page_full(id): """Delete a page from Confluence, along with its children. Parameters: - id: id of a Confluence page. Notes: - Getting a 204 error is expected! It means the page can no longer be found. """ children = _json.loads(get_page_children(id)) for i in children["resul...
python
def delete_page_full(id): """Delete a page from Confluence, along with its children. Parameters: - id: id of a Confluence page. Notes: - Getting a 204 error is expected! It means the page can no longer be found. """ children = _json.loads(get_page_children(id)) for i in children["resul...
[ "def", "delete_page_full", "(", "id", ")", ":", "children", "=", "_json", ".", "loads", "(", "get_page_children", "(", "id", ")", ")", "for", "i", "in", "children", "[", "\"results\"", "]", ":", "delete_page_full", "(", "i", "[", "\"id\"", "]", ")", "r...
Delete a page from Confluence, along with its children. Parameters: - id: id of a Confluence page. Notes: - Getting a 204 error is expected! It means the page can no longer be found.
[ "Delete", "a", "page", "from", "Confluence", "along", "with", "its", "children", ".", "Parameters", ":", "-", "id", ":", "id", "of", "a", "Confluence", "page", ".", "Notes", ":", "-", "Getting", "a", "204", "error", "is", "expected!", "It", "means", "t...
a999726dbc1cbdd3d9062234698eeae799ce84ce
https://github.com/FulcrumTechnologies/pyconfluence/blob/a999726dbc1cbdd3d9062234698eeae799ce84ce/pyconfluence/actions.py#L281-L294
train
Delete a page from Confluence along with its children.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.fqdn
def fqdn(self): """ Returns the string used to identify the client when initiating a SMTP session. RFC 5321 `§ 4.1.1.1`_ and `§ 4.1.3`_ tell us what to do: - Use the client FQDN ; - If it isn't available, we SHOULD fall back to an address literal. Returns: ...
python
def fqdn(self): """ Returns the string used to identify the client when initiating a SMTP session. RFC 5321 `§ 4.1.1.1`_ and `§ 4.1.3`_ tell us what to do: - Use the client FQDN ; - If it isn't available, we SHOULD fall back to an address literal. Returns: ...
[ "def", "fqdn", "(", "self", ")", ":", "if", "self", ".", "_fqdn", "is", "None", ":", "# Let's try to retrieve it:", "self", ".", "_fqdn", "=", "socket", ".", "getfqdn", "(", ")", "if", "\".\"", "not", "in", "self", ".", "_fqdn", ":", "try", ":", "inf...
Returns the string used to identify the client when initiating a SMTP session. RFC 5321 `§ 4.1.1.1`_ and `§ 4.1.3`_ tell us what to do: - Use the client FQDN ; - If it isn't available, we SHOULD fall back to an address literal. Returns: str: The value that should b...
[ "Returns", "the", "string", "used", "to", "identify", "the", "client", "when", "initiating", "a", "SMTP", "session", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L132-L166
train
Returns the FQDN of the client when initiating a SMTP session.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.reset_state
def reset_state(self): """ Resets some attributes to their default values. This is especially useful when initializing a newly created :class:`SMTP` instance and when closing an existing SMTP session. It allows us to use the same SMTP instance and connect several times. ...
python
def reset_state(self): """ Resets some attributes to their default values. This is especially useful when initializing a newly created :class:`SMTP` instance and when closing an existing SMTP session. It allows us to use the same SMTP instance and connect several times. ...
[ "def", "reset_state", "(", "self", ")", ":", "self", ".", "last_helo_response", "=", "(", "None", ",", "None", ")", "self", ".", "last_ehlo_response", "=", "(", "None", ",", "None", ")", "self", ".", "supports_esmtp", "=", "False", "self", ".", "esmtp_ex...
Resets some attributes to their default values. This is especially useful when initializing a newly created :class:`SMTP` instance and when closing an existing SMTP session. It allows us to use the same SMTP instance and connect several times.
[ "Resets", "some", "attributes", "to", "their", "default", "values", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L168-L189
train
Resets some attributes to their default values.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.connect
async def connect(self): """ Connects to the server. .. note:: This method is automatically invoked by :meth:`SMTP.__aenter__`. The code is mostly borrowed from the :func:`asyncio.streams.open_connection` source code. Raises: ConnectionError subclass...
python
async def connect(self): """ Connects to the server. .. note:: This method is automatically invoked by :meth:`SMTP.__aenter__`. The code is mostly borrowed from the :func:`asyncio.streams.open_connection` source code. Raises: ConnectionError subclass...
[ "async", "def", "connect", "(", "self", ")", ":", "# First build the reader:", "self", ".", "reader", "=", "SMTPStreamReader", "(", "loop", "=", "self", ".", "loop", ")", "# Then build the protocol:", "protocol", "=", "asyncio", ".", "StreamReaderProtocol", "(", ...
Connects to the server. .. note:: This method is automatically invoked by :meth:`SMTP.__aenter__`. The code is mostly borrowed from the :func:`asyncio.streams.open_connection` source code. Raises: ConnectionError subclass: If the connection between client and ...
[ "Connects", "to", "the", "server", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L217-L277
train
Connects to the server and returns a tuple containing the server s response.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.do_cmd
async def do_cmd(self, *args, success=None): """ Sends the given command to the server. Args: *args: Command and arguments to be sent to the server. Raises: ConnectionResetError: If the connection with the server is unexpectedely lost. ...
python
async def do_cmd(self, *args, success=None): """ Sends the given command to the server. Args: *args: Command and arguments to be sent to the server. Raises: ConnectionResetError: If the connection with the server is unexpectedely lost. ...
[ "async", "def", "do_cmd", "(", "self", ",", "*", "args", ",", "success", "=", "None", ")", ":", "if", "success", "is", "None", ":", "success", "=", "(", "250", ",", ")", "cmd", "=", "\" \"", ".", "join", "(", "args", ")", "await", "self", ".", ...
Sends the given command to the server. Args: *args: Command and arguments to be sent to the server. Raises: ConnectionResetError: If the connection with the server is unexpectedely lost. SMTPCommandFailedError: If the command fails. Returns:...
[ "Sends", "the", "given", "command", "to", "the", "server", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L279-L306
train
Sends a command to the server and returns the response.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.helo
async def helo(self, from_host=None): """ Sends a SMTP 'HELO' command. - Identifies the client and starts the session. If given ``from_host`` is None, defaults to the client FQDN. For further details, please check out `RFC 5321 § 4.1.1.1`_. Args: from_host ...
python
async def helo(self, from_host=None): """ Sends a SMTP 'HELO' command. - Identifies the client and starts the session. If given ``from_host`` is None, defaults to the client FQDN. For further details, please check out `RFC 5321 § 4.1.1.1`_. Args: from_host ...
[ "async", "def", "helo", "(", "self", ",", "from_host", "=", "None", ")", ":", "if", "from_host", "is", "None", ":", "from_host", "=", "self", ".", "fqdn", "code", ",", "message", "=", "await", "self", ".", "do_cmd", "(", "\"HELO\"", ",", "from_host", ...
Sends a SMTP 'HELO' command. - Identifies the client and starts the session. If given ``from_host`` is None, defaults to the client FQDN. For further details, please check out `RFC 5321 § 4.1.1.1`_. Args: from_host (str or None): Name to use to identify the client. ...
[ "Sends", "a", "SMTP", "HELO", "command", ".", "-", "Identifies", "the", "client", "and", "starts", "the", "session", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L308-L338
train
Sends a SMTP HELO command to identify the client and starts the session.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.ehlo
async def ehlo(self, from_host=None): """ Sends a SMTP 'EHLO' command. - Identifies the client and starts the session. If given ``from`_host`` is None, defaults to the client FQDN. For further details, please check out `RFC 5321 § 4.1.1.1`_. Args: from_host...
python
async def ehlo(self, from_host=None): """ Sends a SMTP 'EHLO' command. - Identifies the client and starts the session. If given ``from`_host`` is None, defaults to the client FQDN. For further details, please check out `RFC 5321 § 4.1.1.1`_. Args: from_host...
[ "async", "def", "ehlo", "(", "self", ",", "from_host", "=", "None", ")", ":", "if", "from_host", "is", "None", ":", "from_host", "=", "self", ".", "fqdn", "code", ",", "message", "=", "await", "self", ".", "do_cmd", "(", "\"EHLO\"", ",", "from_host", ...
Sends a SMTP 'EHLO' command. - Identifies the client and starts the session. If given ``from`_host`` is None, defaults to the client FQDN. For further details, please check out `RFC 5321 § 4.1.1.1`_. Args: from_host (str or None): Name to use to identify the client. ...
[ "Sends", "a", "SMTP", "EHLO", "command", ".", "-", "Identifies", "the", "client", "and", "starts", "the", "session", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L340-L375
train
Sends an SMTP EHLO command to the server and starts the session.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.help
async def help(self, command_name=None): """ Sends a SMTP 'HELP' command. For further details please check out `RFC 5321 § 4.1.1.8`_. Args: command_name (str or None, optional): Name of a command for which you want help. For example, if you want to get help ...
python
async def help(self, command_name=None): """ Sends a SMTP 'HELP' command. For further details please check out `RFC 5321 § 4.1.1.8`_. Args: command_name (str or None, optional): Name of a command for which you want help. For example, if you want to get help ...
[ "async", "def", "help", "(", "self", ",", "command_name", "=", "None", ")", ":", "if", "command_name", "is", "None", ":", "command_name", "=", "\"\"", "code", ",", "message", "=", "await", "self", ".", "do_cmd", "(", "\"HELP\"", ",", "command_name", ")",...
Sends a SMTP 'HELP' command. For further details please check out `RFC 5321 § 4.1.1.8`_. Args: command_name (str or None, optional): Name of a command for which you want help. For example, if you want to get help about the '*RSET*' command, you'd call ``help...
[ "Sends", "a", "SMTP", "HELP", "command", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L377-L403
train
Sends a SMTP HELP command.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.mail
async def mail(self, sender, options=None): """ Sends a SMTP 'MAIL' command. - Starts the mail transfer session. For further details, please check out `RFC 5321 § 4.1.1.2`_ and `§ 3.3`_. Args: sender (str): Sender mailbox (used as reverse-path). options ...
python
async def mail(self, sender, options=None): """ Sends a SMTP 'MAIL' command. - Starts the mail transfer session. For further details, please check out `RFC 5321 § 4.1.1.2`_ and `§ 3.3`_. Args: sender (str): Sender mailbox (used as reverse-path). options ...
[ "async", "def", "mail", "(", "self", ",", "sender", ",", "options", "=", "None", ")", ":", "if", "options", "is", "None", ":", "options", "=", "[", "]", "from_addr", "=", "\"FROM:{}\"", ".", "format", "(", "quoteaddr", "(", "sender", ")", ")", "code"...
Sends a SMTP 'MAIL' command. - Starts the mail transfer session. For further details, please check out `RFC 5321 § 4.1.1.2`_ and `§ 3.3`_. Args: sender (str): Sender mailbox (used as reverse-path). options (list of str or None, optional): Additional options to send ...
[ "Sends", "a", "SMTP", "MAIL", "command", ".", "-", "Starts", "the", "mail", "transfer", "session", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L487-L517
train
Sends a SMTP MAIL command.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.rcpt
async def rcpt(self, recipient, options=None): """ Sends a SMTP 'RCPT' command. - Indicates a recipient for the e-mail. For further details, please check out `RFC 5321 § 4.1.1.3`_ and `§ 3.3`_. Args: recipient (str): E-mail address of one recipient. opti...
python
async def rcpt(self, recipient, options=None): """ Sends a SMTP 'RCPT' command. - Indicates a recipient for the e-mail. For further details, please check out `RFC 5321 § 4.1.1.3`_ and `§ 3.3`_. Args: recipient (str): E-mail address of one recipient. opti...
[ "async", "def", "rcpt", "(", "self", ",", "recipient", ",", "options", "=", "None", ")", ":", "if", "options", "is", "None", ":", "options", "=", "[", "]", "to_addr", "=", "\"TO:{}\"", ".", "format", "(", "quoteaddr", "(", "recipient", ")", ")", "cod...
Sends a SMTP 'RCPT' command. - Indicates a recipient for the e-mail. For further details, please check out `RFC 5321 § 4.1.1.3`_ and `§ 3.3`_. Args: recipient (str): E-mail address of one recipient. options (list of str or None, optional): Additional options to send ...
[ "Sends", "a", "SMTP", "RCPT", "command", ".", "-", "Indicates", "a", "recipient", "for", "the", "e", "-", "mail", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L519-L549
train
Sends an SMTP RCPT command to the specified e - mail address.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.quit
async def quit(self): """ Sends a SMTP 'QUIT' command. - Ends the session. For further details, please check out `RFC 5321 § 4.1.1.10`_. Returns: (int, str): A (code, message) 2-tuple containing the server response. If the connection is already closed when c...
python
async def quit(self): """ Sends a SMTP 'QUIT' command. - Ends the session. For further details, please check out `RFC 5321 § 4.1.1.10`_. Returns: (int, str): A (code, message) 2-tuple containing the server response. If the connection is already closed when c...
[ "async", "def", "quit", "(", "self", ")", ":", "code", "=", "-", "1", "message", "=", "None", "try", ":", "code", ",", "message", "=", "await", "self", ".", "do_cmd", "(", "\"QUIT\"", ")", "except", "ConnectionError", ":", "# We voluntarily ignore this kin...
Sends a SMTP 'QUIT' command. - Ends the session. For further details, please check out `RFC 5321 § 4.1.1.10`_. Returns: (int, str): A (code, message) 2-tuple containing the server response. If the connection is already closed when calling this method, return...
[ "Sends", "a", "SMTP", "QUIT", "command", ".", "-", "Ends", "the", "session", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L551-L578
train
Sends a SMTP QUIT command to the server and closes the connection.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.data
async def data(self, email_message): """ Sends a SMTP 'DATA' command. - Transmits the message to the server. If ``email_message`` is a bytes object, sends it as it is. Else, makes all the required changes so it can be safely trasmitted to the SMTP server.` For further d...
python
async def data(self, email_message): """ Sends a SMTP 'DATA' command. - Transmits the message to the server. If ``email_message`` is a bytes object, sends it as it is. Else, makes all the required changes so it can be safely trasmitted to the SMTP server.` For further d...
[ "async", "def", "data", "(", "self", ",", "email_message", ")", ":", "code", ",", "message", "=", "await", "self", ".", "do_cmd", "(", "\"DATA\"", ",", "success", "=", "(", "354", ",", ")", ")", "email_message", "=", "SMTP", ".", "prepare_message", "("...
Sends a SMTP 'DATA' command. - Transmits the message to the server. If ``email_message`` is a bytes object, sends it as it is. Else, makes all the required changes so it can be safely trasmitted to the SMTP server.` For further details, please check out `RFC 5321 § 4.1.1.4`_. ...
[ "Sends", "a", "SMTP", "DATA", "command", ".", "-", "Transmits", "the", "message", "to", "the", "server", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L580-L616
train
Sends an SMTP DATA command to the server.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.auth
async def auth(self, username, password): """ Tries to authenticate user against the SMTP server. Args: username (str): Username to authenticate with. password (str): Password to use along with the given ``username``. Raises: ConnectionResetError: If...
python
async def auth(self, username, password): """ Tries to authenticate user against the SMTP server. Args: username (str): Username to authenticate with. password (str): Password to use along with the given ``username``. Raises: ConnectionResetError: If...
[ "async", "def", "auth", "(", "self", ",", "username", ",", "password", ")", ":", "# EHLO/HELO is required:", "await", "self", ".", "ehlo_or_helo_if_needed", "(", ")", "errors", "=", "[", "]", "# To store SMTPAuthenticationErrors", "code", "=", "message", "=", "N...
Tries to authenticate user against the SMTP server. Args: username (str): Username to authenticate with. password (str): Password to use along with the given ``username``. Raises: ConnectionResetError: If the connection with the server is unexpectede...
[ "Tries", "to", "authenticate", "user", "against", "the", "SMTP", "server", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L618-L664
train
Attempts to authenticate user against the server.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.starttls
async def starttls(self, context=None): """ Upgrades 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 SSL/TLS, this will encrypt the rest of the SMTP ...
python
async def starttls(self, context=None): """ Upgrades 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 SSL/TLS, this will encrypt the rest of the SMTP ...
[ "async", "def", "starttls", "(", "self", ",", "context", "=", "None", ")", ":", "if", "not", "self", ".", "use_aioopenssl", ":", "raise", "BadImplementationError", "(", "\"This connection does not use aioopenssl\"", ")", "import", "aioopenssl", "import", "OpenSSL", ...
Upgrades 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 SSL/TLS, this will encrypt the rest of the SMTP session. Raises: SMTPCommandNotSupp...
[ "Upgrades", "the", "connection", "to", "the", "SMTP", "server", "into", "TLS", "mode", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L666-L721
train
Start TLS negotiation.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.sendmail
async def sendmail( self, sender, recipients, message, mail_options=None, rcpt_options=None ): """ Performs an entire e-mail transaction. Example: >>> try: >>> with SMTP() as client: >>> try: >>> r = client.sen...
python
async def sendmail( self, sender, recipients, message, mail_options=None, rcpt_options=None ): """ Performs an entire e-mail transaction. Example: >>> try: >>> with SMTP() as client: >>> try: >>> r = client.sen...
[ "async", "def", "sendmail", "(", "self", ",", "sender", ",", "recipients", ",", "message", ",", "mail_options", "=", "None", ",", "rcpt_options", "=", "None", ")", ":", "# Make sure `recipients` is a list:", "if", "isinstance", "(", "recipients", ",", "str", "...
Performs an entire e-mail transaction. Example: >>> try: >>> with SMTP() as client: >>> try: >>> r = client.sendmail(sender, recipients, message) >>> except SMTPException: >>> print("Error while...
[ "Performs", "an", "entire", "e", "-", "mail", "transaction", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L723-L810
train
Sends an e - mail to the specified recipients and message.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.send_mail
async def send_mail( self, sender, recipients, message, mail_options=None, rcpt_options=None ): """ Alias for :meth:`SMTP.sendmail`. """ return await self.sendmail( sender, recipients, message, mail_options, rcpt_options )
python
async def send_mail( self, sender, recipients, message, mail_options=None, rcpt_options=None ): """ Alias for :meth:`SMTP.sendmail`. """ return await self.sendmail( sender, recipients, message, mail_options, rcpt_options )
[ "async", "def", "send_mail", "(", "self", ",", "sender", ",", "recipients", ",", "message", ",", "mail_options", "=", "None", ",", "rcpt_options", "=", "None", ")", ":", "return", "await", "self", ".", "sendmail", "(", "sender", ",", "recipients", ",", "...
Alias for :meth:`SMTP.sendmail`.
[ "Alias", "for", ":", "meth", ":", "SMTP", ".", "sendmail", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L812-L820
train
Send an email using the specified options.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.ehlo_or_helo_if_needed
async def ehlo_or_helo_if_needed(self): """ Calls :meth:`SMTP.ehlo` and/or :meth:`SMTP.helo` if needed. If there hasn't been any previous *EHLO* or *HELO* command this session, tries to initiate the session. *EHLO* is tried first. Raises: ConnectionResetError: If th...
python
async def ehlo_or_helo_if_needed(self): """ Calls :meth:`SMTP.ehlo` and/or :meth:`SMTP.helo` if needed. If there hasn't been any previous *EHLO* or *HELO* command this session, tries to initiate the session. *EHLO* is tried first. Raises: ConnectionResetError: If th...
[ "async", "def", "ehlo_or_helo_if_needed", "(", "self", ")", ":", "no_helo", "=", "self", ".", "last_helo_response", "==", "(", "None", ",", "None", ")", "no_ehlo", "=", "self", ".", "last_ehlo_response", "==", "(", "None", ",", "None", ")", "if", "no_helo"...
Calls :meth:`SMTP.ehlo` and/or :meth:`SMTP.helo` if needed. If there hasn't been any previous *EHLO* or *HELO* command this session, tries to initiate the session. *EHLO* is tried first. Raises: ConnectionResetError: If the connection with the server is unexpectedel...
[ "Calls", ":", "meth", ":", "SMTP", ".", "ehlo", "and", "/", "or", ":", "meth", ":", "SMTP", ".", "helo", "if", "needed", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L822-L844
train
Attempts to initiate the session if needed.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.close
async def close(self): """ Cleans up after the connection to the SMTP server has been closed (voluntarily or not). """ if self.writer is not None: # Close the transport: try: self.writer.close() except OSError as exc: ...
python
async def close(self): """ Cleans up after the connection to the SMTP server has been closed (voluntarily or not). """ if self.writer is not None: # Close the transport: try: self.writer.close() except OSError as exc: ...
[ "async", "def", "close", "(", "self", ")", ":", "if", "self", ".", "writer", "is", "not", "None", ":", "# Close the transport:", "try", ":", "self", ".", "writer", ".", "close", "(", ")", "except", "OSError", "as", "exc", ":", "if", "exc", ".", "errn...
Cleans up after the connection to the SMTP server has been closed (voluntarily or not).
[ "Cleans", "up", "after", "the", "connection", "to", "the", "SMTP", "server", "has", "been", "closed", "(", "voluntarily", "or", "not", ")", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L846-L859
train
Closes the connection to the SMTP server.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP._auth_cram_md5
async def _auth_cram_md5(self, username, password): """ Performs an authentication attemps using the CRAM-MD5 mechanism. Protocol: 1. Send 'AUTH CRAM-MD5' to server ; 2. If the server replies with a 334 return code, we can go on: 1) The challenge (sent ...
python
async def _auth_cram_md5(self, username, password): """ Performs an authentication attemps using the CRAM-MD5 mechanism. Protocol: 1. Send 'AUTH CRAM-MD5' to server ; 2. If the server replies with a 334 return code, we can go on: 1) The challenge (sent ...
[ "async", "def", "_auth_cram_md5", "(", "self", ",", "username", ",", "password", ")", ":", "mechanism", "=", "\"CRAM-MD5\"", "code", ",", "message", "=", "await", "self", ".", "do_cmd", "(", "\"AUTH\"", ",", "mechanism", ",", "success", "=", "(", "334", ...
Performs an authentication attemps using the CRAM-MD5 mechanism. Protocol: 1. Send 'AUTH CRAM-MD5' to server ; 2. If the server replies with a 334 return code, we can go on: 1) The challenge (sent by the server) is base64-decoded ; 2) The decoded challe...
[ "Performs", "an", "authentication", "attemps", "using", "the", "CRAM", "-", "MD5", "mechanism", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L861-L913
train
Performs an authentication attempt using the CRAM - MD5 mechanism.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP._auth_login
async def _auth_login(self, username, password): """ Performs an authentication attempt using the LOGIN mechanism. Protocol: 1. The username is base64-encoded ; 2. The string 'AUTH LOGIN' and a space character are prepended to the base64-encoded username ...
python
async def _auth_login(self, username, password): """ Performs an authentication attempt using the LOGIN mechanism. Protocol: 1. The username is base64-encoded ; 2. The string 'AUTH LOGIN' and a space character are prepended to the base64-encoded username ...
[ "async", "def", "_auth_login", "(", "self", ",", "username", ",", "password", ")", ":", "mechanism", "=", "\"LOGIN\"", "code", ",", "message", "=", "await", "self", ".", "do_cmd", "(", "\"AUTH\"", ",", "mechanism", ",", "SMTP", ".", "b64enc", "(", "usern...
Performs an authentication attempt using the LOGIN mechanism. Protocol: 1. The username is base64-encoded ; 2. The string 'AUTH LOGIN' and a space character are prepended to the base64-encoded username and sent to the server ; 3. If the server replies with a ...
[ "Performs", "an", "authentication", "attempt", "using", "the", "LOGIN", "mechanism", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L915-L954
train
Performs an authentication attempt using the LOGIN mechanism.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP._auth_plain
async def _auth_plain(self, username, password): """ Performs an authentication attempt using the PLAIN mechanism. Protocol: 1. Format the username and password in a suitable way ; 2. The formatted string is base64-encoded ; 3. The string 'AUTH PLAIN' and a ...
python
async def _auth_plain(self, username, password): """ Performs an authentication attempt using the PLAIN mechanism. Protocol: 1. Format the username and password in a suitable way ; 2. The formatted string is base64-encoded ; 3. The string 'AUTH PLAIN' and a ...
[ "async", "def", "_auth_plain", "(", "self", ",", "username", ",", "password", ")", ":", "mechanism", "=", "\"PLAIN\"", "credentials", "=", "\"\\0{}\\0{}\"", ".", "format", "(", "username", ",", "password", ")", "encoded_credentials", "=", "SMTP", ".", "b64enc"...
Performs an authentication attempt using the PLAIN mechanism. Protocol: 1. Format the username and password in a suitable way ; 2. The formatted string is base64-encoded ; 3. The string 'AUTH PLAIN' and a space character are prepended to the base64-encoded us...
[ "Performs", "an", "authentication", "attempt", "using", "the", "PLAIN", "mechanism", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L956-L995
train
Performs an authentication using the PLAIN mechanism.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.parse_esmtp_extensions
def parse_esmtp_extensions(message): """ Parses the response given by an ESMTP server after a *EHLO* command. The response is parsed to build: - A dict of supported ESMTP extensions (with parameters, if any). - A list of supported authentication methods. Returns: ...
python
def parse_esmtp_extensions(message): """ Parses the response given by an ESMTP server after a *EHLO* command. The response is parsed to build: - A dict of supported ESMTP extensions (with parameters, if any). - A list of supported authentication methods. Returns: ...
[ "def", "parse_esmtp_extensions", "(", "message", ")", ":", "extns", "=", "{", "}", "auths", "=", "[", "]", "oldstyle_auth_regex", "=", "re", ".", "compile", "(", "r\"auth=(?P<auth>.*)\"", ",", "re", ".", "IGNORECASE", ")", "extension_regex", "=", "re", ".", ...
Parses the response given by an ESMTP server after a *EHLO* command. The response is parsed to build: - A dict of supported ESMTP extensions (with parameters, if any). - A list of supported authentication methods. Returns: (dict, list): A (extensions, auth_mechanisms) 2-tu...
[ "Parses", "the", "response", "given", "by", "an", "ESMTP", "server", "after", "a", "*", "EHLO", "*", "command", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L998-L1049
train
Parses the response from an ESMTP server after a EHLO command.
hwmrocker/smtplibaio
smtplibaio/smtp.py
SMTP.prepare_message
def prepare_message(message): """ Returns the given message encoded in ascii with a format suitable for SMTP transmission: - Makes sure the message is ASCII encoded ; - Normalizes line endings to '\r\n' ; - Adds a (second) period at the beginning of lines that start ...
python
def prepare_message(message): """ Returns the given message encoded in ascii with a format suitable for SMTP transmission: - Makes sure the message is ASCII encoded ; - Normalizes line endings to '\r\n' ; - Adds a (second) period at the beginning of lines that start ...
[ "def", "prepare_message", "(", "message", ")", ":", "if", "isinstance", "(", "message", ",", "bytes", ")", ":", "bytes_message", "=", "message", "else", ":", "bytes_message", "=", "message", ".", "encode", "(", "\"ascii\"", ")", "# The original algorithm uses re...
Returns the given message encoded in ascii with a format suitable for SMTP transmission: - Makes sure the message is ASCII encoded ; - Normalizes line endings to '\r\n' ; - Adds a (second) period at the beginning of lines that start with a period ; - Makes sure the mes...
[ "Returns", "the", "given", "message", "encoded", "in", "ascii", "with", "a", "format", "suitable", "for", "SMTP", "transmission", ":" ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/smtp.py#L1052-L1108
train
Prepares the given message for SMTP transmission.
OnroerendErfgoed/language-tags
language_tags/Tag.py
Tag.format
def format(self): """ Get format according to algorithm defined in RFC 5646 section 2.1.1. :return: formatted tag string. """ tag = self.data['tag'] subtags = tag.split('-') if len(subtags) == 1: return subtags[0] formatted_tag = subtags[0] ...
python
def format(self): """ Get format according to algorithm defined in RFC 5646 section 2.1.1. :return: formatted tag string. """ tag = self.data['tag'] subtags = tag.split('-') if len(subtags) == 1: return subtags[0] formatted_tag = subtags[0] ...
[ "def", "format", "(", "self", ")", ":", "tag", "=", "self", ".", "data", "[", "'tag'", "]", "subtags", "=", "tag", ".", "split", "(", "'-'", ")", "if", "len", "(", "subtags", ")", "==", "1", ":", "return", "subtags", "[", "0", "]", "formatted_tag...
Get format according to algorithm defined in RFC 5646 section 2.1.1. :return: formatted tag string.
[ "Get", "format", "according", "to", "algorithm", "defined", "in", "RFC", "5646", "section", "2", ".", "1", ".", "1", "." ]
acb91e5458d22617f344e2eefaba9a9865373fdd
https://github.com/OnroerendErfgoed/language-tags/blob/acb91e5458d22617f344e2eefaba9a9865373fdd/language_tags/Tag.py#L118-L146
train
Returns the formatted version of the tag string according to RFC 5646 section 2. 1. 1.
OnroerendErfgoed/language-tags
language_tags/Tag.py
Tag.subtags
def subtags(self): """ Get the :class:`language_tags.Subtag.Subtag` objects of the tag. :return: list of :class:`language_tags.Subtag.Subtag` objects that are part of the tag. The return list can be empty. """ data = self.data subtags = [] # if tag i...
python
def subtags(self): """ Get the :class:`language_tags.Subtag.Subtag` objects of the tag. :return: list of :class:`language_tags.Subtag.Subtag` objects that are part of the tag. The return list can be empty. """ data = self.data subtags = [] # if tag i...
[ "def", "subtags", "(", "self", ")", ":", "data", "=", "self", ".", "data", "subtags", "=", "[", "]", "# if tag is grandfathered return no subtags", "if", "'record'", "in", "data", "and", "self", ".", "data", "[", "'record'", "]", "[", "'Type'", "]", "==", ...
Get the :class:`language_tags.Subtag.Subtag` objects of the tag. :return: list of :class:`language_tags.Subtag.Subtag` objects that are part of the tag. The return list can be empty.
[ "Get", "the", ":", "class", ":", "language_tags", ".", "Subtag", ".", "Subtag", "objects", "of", "the", "tag", "." ]
acb91e5458d22617f344e2eefaba9a9865373fdd
https://github.com/OnroerendErfgoed/language-tags/blob/acb91e5458d22617f344e2eefaba9a9865373fdd/language_tags/Tag.py#L149-L212
train
Get the list of subtags of the tag.
OnroerendErfgoed/language-tags
language_tags/Tag.py
Tag.language
def language(self): """ Get the language :class:`language_tags.Subtag.Subtag` of the tag. :return: language :class:`language_tags.Subtag.Subtag` that is part of the tag. The return can be None. """ language_item = [subtag for subtag in self.subtags if subtag.type ==...
python
def language(self): """ Get the language :class:`language_tags.Subtag.Subtag` of the tag. :return: language :class:`language_tags.Subtag.Subtag` that is part of the tag. The return can be None. """ language_item = [subtag for subtag in self.subtags if subtag.type ==...
[ "def", "language", "(", "self", ")", ":", "language_item", "=", "[", "subtag", "for", "subtag", "in", "self", ".", "subtags", "if", "subtag", ".", "type", "==", "'language'", "]", "return", "language_item", "[", "0", "]", "if", "len", "(", "language_item...
Get the language :class:`language_tags.Subtag.Subtag` of the tag. :return: language :class:`language_tags.Subtag.Subtag` that is part of the tag. The return can be None.
[ "Get", "the", "language", ":", "class", ":", "language_tags", ".", "Subtag", ".", "Subtag", "of", "the", "tag", "." ]
acb91e5458d22617f344e2eefaba9a9865373fdd
https://github.com/OnroerendErfgoed/language-tags/blob/acb91e5458d22617f344e2eefaba9a9865373fdd/language_tags/Tag.py#L215-L225
train
Get the language of the tag.
OnroerendErfgoed/language-tags
language_tags/Tag.py
Tag.region
def region(self): """ Get the region :class:`language_tags.Subtag.Subtag` of the tag. :return: region :class:`language_tags.Subtag.Subtag` that is part of the tag. The return can be None. """ region_item = [subtag for subtag in self.subtags if subtag.type == 'region...
python
def region(self): """ Get the region :class:`language_tags.Subtag.Subtag` of the tag. :return: region :class:`language_tags.Subtag.Subtag` that is part of the tag. The return can be None. """ region_item = [subtag for subtag in self.subtags if subtag.type == 'region...
[ "def", "region", "(", "self", ")", ":", "region_item", "=", "[", "subtag", "for", "subtag", "in", "self", ".", "subtags", "if", "subtag", ".", "type", "==", "'region'", "]", "return", "region_item", "[", "0", "]", "if", "len", "(", "region_item", ")", ...
Get the region :class:`language_tags.Subtag.Subtag` of the tag. :return: region :class:`language_tags.Subtag.Subtag` that is part of the tag. The return can be None.
[ "Get", "the", "region", ":", "class", ":", "language_tags", ".", "Subtag", ".", "Subtag", "of", "the", "tag", "." ]
acb91e5458d22617f344e2eefaba9a9865373fdd
https://github.com/OnroerendErfgoed/language-tags/blob/acb91e5458d22617f344e2eefaba9a9865373fdd/language_tags/Tag.py#L228-L238
train
Get the region of the tag.
OnroerendErfgoed/language-tags
language_tags/Tag.py
Tag.script
def script(self): """ Get the script :class:`language_tags.Subtag.Subtag` of the tag. :return: script :class:`language_tags.Subtag.Subtag` that is part of the tag. The return can be None. """ script_item = [subtag for subtag in self.subtags if subtag.type == 'script'...
python
def script(self): """ Get the script :class:`language_tags.Subtag.Subtag` of the tag. :return: script :class:`language_tags.Subtag.Subtag` that is part of the tag. The return can be None. """ script_item = [subtag for subtag in self.subtags if subtag.type == 'script'...
[ "def", "script", "(", "self", ")", ":", "script_item", "=", "[", "subtag", "for", "subtag", "in", "self", ".", "subtags", "if", "subtag", ".", "type", "==", "'script'", "]", "return", "script_item", "[", "0", "]", "if", "len", "(", "script_item", ")", ...
Get the script :class:`language_tags.Subtag.Subtag` of the tag. :return: script :class:`language_tags.Subtag.Subtag` that is part of the tag. The return can be None.
[ "Get", "the", "script", ":", "class", ":", "language_tags", ".", "Subtag", ".", "Subtag", "of", "the", "tag", "." ]
acb91e5458d22617f344e2eefaba9a9865373fdd
https://github.com/OnroerendErfgoed/language-tags/blob/acb91e5458d22617f344e2eefaba9a9865373fdd/language_tags/Tag.py#L242-L251
train
Get the script of the tag.
OnroerendErfgoed/language-tags
language_tags/Tag.py
Tag.errors
def errors(self): """ Get the errors of the tag. If invalid then the list will consist of errors containing each a code and message explaining the error. Each error also refers to the respective (sub)tag(s). :return: list of errors of the tag. If the tag is valid, it returns an ...
python
def errors(self): """ Get the errors of the tag. If invalid then the list will consist of errors containing each a code and message explaining the error. Each error also refers to the respective (sub)tag(s). :return: list of errors of the tag. If the tag is valid, it returns an ...
[ "def", "errors", "(", "self", ")", ":", "errors", "=", "[", "]", "data", "=", "self", ".", "data", "error", "=", "self", ".", "error", "# Check if the tag is grandfathered and if the grandfathered tag is deprecated (e.g. no-nyn).", "if", "'record'", "in", "data", ":...
Get the errors of the tag. If invalid then the list will consist of errors containing each a code and message explaining the error. Each error also refers to the respective (sub)tag(s). :return: list of errors of the tag. If the tag is valid, it returns an empty list.
[ "Get", "the", "errors", "of", "the", "tag", ".", "If", "invalid", "then", "the", "list", "will", "consist", "of", "errors", "containing", "each", "a", "code", "and", "message", "explaining", "the", "error", ".", "Each", "error", "also", "refers", "to", "...
acb91e5458d22617f344e2eefaba9a9865373fdd
https://github.com/OnroerendErfgoed/language-tags/blob/acb91e5458d22617f344e2eefaba9a9865373fdd/language_tags/Tag.py#L263-L352
train
Returns a list of all the errors that are found in the tag.
OnroerendErfgoed/language-tags
language_tags/Tag.py
Tag.error
def error(self, code, subtag=None): """ Get the :class:`language_tags.Tag.Tag.Error` of a specific Tag error code. The error creates a message explaining the error. It also refers to the respective (sub)tag(s). :param int code: a Tag error error: * 1 = Tag.ERR_DEPRE...
python
def error(self, code, subtag=None): """ Get the :class:`language_tags.Tag.Tag.Error` of a specific Tag error code. The error creates a message explaining the error. It also refers to the respective (sub)tag(s). :param int code: a Tag error error: * 1 = Tag.ERR_DEPRE...
[ "def", "error", "(", "self", ",", "code", ",", "subtag", "=", "None", ")", ":", "message", "=", "\"\"", "data", "=", "self", ".", "data", "if", "code", "==", "self", ".", "ERR_DEPRECATED", ":", "message", "=", "'The tag %s is deprecated.'", "%", "data", ...
Get the :class:`language_tags.Tag.Tag.Error` of a specific Tag error code. The error creates a message explaining the error. It also refers to the respective (sub)tag(s). :param int code: a Tag error error: * 1 = Tag.ERR_DEPRECATED * 2 = Tag.ERR_NO_LANGUAGE ...
[ "Get", "the", ":", "class", ":", "language_tags", ".", "Tag", ".", "Tag", ".", "Error", "of", "a", "specific", "Tag", "error", "code", ".", "The", "error", "creates", "a", "message", "explaining", "the", "error", ".", "It", "also", "refers", "to", "the...
acb91e5458d22617f344e2eefaba9a9865373fdd
https://github.com/OnroerendErfgoed/language-tags/blob/acb91e5458d22617f344e2eefaba9a9865373fdd/language_tags/Tag.py#L354-L430
train
Return an exception class containing a specific Tag. Error.
happyleavesaoc/aoc-mgz
mgz/enums.py
ObjectEnum
def ObjectEnum(ctx): """Object Enumeration. Should export the whole list from the game for the best accuracy. """ return Enum( ctx, villager_male=83, villager_female=293, scout_cavalry=448, eagle_warrior=751, king=434, flare=332, relic=285...
python
def ObjectEnum(ctx): """Object Enumeration. Should export the whole list from the game for the best accuracy. """ return Enum( ctx, villager_male=83, villager_female=293, scout_cavalry=448, eagle_warrior=751, king=434, flare=332, relic=285...
[ "def", "ObjectEnum", "(", "ctx", ")", ":", "return", "Enum", "(", "ctx", ",", "villager_male", "=", "83", ",", "villager_female", "=", "293", ",", "scout_cavalry", "=", "448", ",", "eagle_warrior", "=", "751", ",", "king", "=", "434", ",", "flare", "="...
Object Enumeration. Should export the whole list from the game for the best accuracy.
[ "Object", "Enumeration", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/enums.py#L8-L81
train
Object Enumeration.
happyleavesaoc/aoc-mgz
mgz/enums.py
GameTypeEnum
def GameTypeEnum(ctx): """Game Type Enumeration.""" return Enum( ctx, RM=0, Regicide=1, DM=2, Scenario=3, Campaign=4, KingOfTheHill=5, WonderRace=6, DefendTheWonder=7, TurboRandom=8 )
python
def GameTypeEnum(ctx): """Game Type Enumeration.""" return Enum( ctx, RM=0, Regicide=1, DM=2, Scenario=3, Campaign=4, KingOfTheHill=5, WonderRace=6, DefendTheWonder=7, TurboRandom=8 )
[ "def", "GameTypeEnum", "(", "ctx", ")", ":", "return", "Enum", "(", "ctx", ",", "RM", "=", "0", ",", "Regicide", "=", "1", ",", "DM", "=", "2", ",", "Scenario", "=", "3", ",", "Campaign", "=", "4", ",", "KingOfTheHill", "=", "5", ",", "WonderRace...
Game Type Enumeration.
[ "Game", "Type", "Enumeration", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/enums.py#L92-L105
train
Game Type Enumeration.
happyleavesaoc/aoc-mgz
mgz/enums.py
ObjectTypeEnum
def ObjectTypeEnum(ctx): """Object Type Enumeration.""" return Enum( ctx, static=10, animated=20, doppelganger=25, moving=30, action=40, base=50, missile=60, combat=70, building=80, tree=90, default=Pass )
python
def ObjectTypeEnum(ctx): """Object Type Enumeration.""" return Enum( ctx, static=10, animated=20, doppelganger=25, moving=30, action=40, base=50, missile=60, combat=70, building=80, tree=90, default=Pass )
[ "def", "ObjectTypeEnum", "(", "ctx", ")", ":", "return", "Enum", "(", "ctx", ",", "static", "=", "10", ",", "animated", "=", "20", ",", "doppelganger", "=", "25", ",", "moving", "=", "30", ",", "action", "=", "40", ",", "base", "=", "50", ",", "m...
Object Type Enumeration.
[ "Object", "Type", "Enumeration", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/enums.py#L107-L122
train
Object Type Enumeration.
happyleavesaoc/aoc-mgz
mgz/enums.py
PlayerTypeEnum
def PlayerTypeEnum(ctx): """Player Type Enumeration.""" return Enum( ctx, absent=0, closed=1, human=2, eliminated=3, computer=4, cyborg=5, spectator=6 )
python
def PlayerTypeEnum(ctx): """Player Type Enumeration.""" return Enum( ctx, absent=0, closed=1, human=2, eliminated=3, computer=4, cyborg=5, spectator=6 )
[ "def", "PlayerTypeEnum", "(", "ctx", ")", ":", "return", "Enum", "(", "ctx", ",", "absent", "=", "0", ",", "closed", "=", "1", ",", "human", "=", "2", ",", "eliminated", "=", "3", ",", "computer", "=", "4", ",", "cyborg", "=", "5", ",", "spectato...
Player Type Enumeration.
[ "Player", "Type", "Enumeration", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/enums.py#L124-L135
train
Player Type Enumeration.
happyleavesaoc/aoc-mgz
mgz/enums.py
ResourceEnum
def ResourceEnum(ctx): """Resource Type Enumeration.""" return Enum( ctx, food=0, wood=1, stone=2, gold=3, decay=12, fish=17, default=Pass # lots of resource types exist )
python
def ResourceEnum(ctx): """Resource Type Enumeration.""" return Enum( ctx, food=0, wood=1, stone=2, gold=3, decay=12, fish=17, default=Pass # lots of resource types exist )
[ "def", "ResourceEnum", "(", "ctx", ")", ":", "return", "Enum", "(", "ctx", ",", "food", "=", "0", ",", "wood", "=", "1", ",", "stone", "=", "2", ",", "gold", "=", "3", ",", "decay", "=", "12", ",", "fish", "=", "17", ",", "default", "=", "Pas...
Resource Type Enumeration.
[ "Resource", "Type", "Enumeration", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/enums.py#L167-L178
train
Resource Type Enumeration.
happyleavesaoc/aoc-mgz
mgz/enums.py
VictoryEnum
def VictoryEnum(ctx): """Victory Type Enumeration.""" return Enum( ctx, standard=0, conquest=1, exploration=2, ruins=3, artifacts=4, discoveries=5, gold=6, time_limit=7, score=8, standard2=9, regicide=10, las...
python
def VictoryEnum(ctx): """Victory Type Enumeration.""" return Enum( ctx, standard=0, conquest=1, exploration=2, ruins=3, artifacts=4, discoveries=5, gold=6, time_limit=7, score=8, standard2=9, regicide=10, las...
[ "def", "VictoryEnum", "(", "ctx", ")", ":", "return", "Enum", "(", "ctx", ",", "standard", "=", "0", ",", "conquest", "=", "1", ",", "exploration", "=", "2", ",", "ruins", "=", "3", ",", "artifacts", "=", "4", ",", "discoveries", "=", "5", ",", "...
Victory Type Enumeration.
[ "Victory", "Type", "Enumeration", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/enums.py#L180-L196
train
Victory Type Enumeration.
happyleavesaoc/aoc-mgz
mgz/enums.py
StartingAgeEnum
def StartingAgeEnum(ctx): """Starting Age Enumeration.""" return Enum( ctx, what=-2, unset=-1, dark=0, feudal=1, castle=2, imperial=3, postimperial=4, dmpostimperial=6 )
python
def StartingAgeEnum(ctx): """Starting Age Enumeration.""" return Enum( ctx, what=-2, unset=-1, dark=0, feudal=1, castle=2, imperial=3, postimperial=4, dmpostimperial=6 )
[ "def", "StartingAgeEnum", "(", "ctx", ")", ":", "return", "Enum", "(", "ctx", ",", "what", "=", "-", "2", ",", "unset", "=", "-", "1", ",", "dark", "=", "0", ",", "feudal", "=", "1", ",", "castle", "=", "2", ",", "imperial", "=", "3", ",", "p...
Starting Age Enumeration.
[ "Starting", "Age", "Enumeration", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/enums.py#L219-L231
train
Starting Age Enumeration.
happyleavesaoc/aoc-mgz
mgz/enums.py
GameActionModeEnum
def GameActionModeEnum(ctx): """Game Action Modes.""" return Enum( ctx, diplomacy=0, speed=1, instant_build=2, quick_build=4, allied_victory=5, cheat=6, unk0=9, spy=10, unk1=11, farm_queue=13, farm_unqueue=14, ...
python
def GameActionModeEnum(ctx): """Game Action Modes.""" return Enum( ctx, diplomacy=0, speed=1, instant_build=2, quick_build=4, allied_victory=5, cheat=6, unk0=9, spy=10, unk1=11, farm_queue=13, farm_unqueue=14, ...
[ "def", "GameActionModeEnum", "(", "ctx", ")", ":", "return", "Enum", "(", "ctx", ",", "diplomacy", "=", "0", ",", "speed", "=", "1", ",", "instant_build", "=", "2", ",", "quick_build", "=", "4", ",", "allied_victory", "=", "5", ",", "cheat", "=", "6"...
Game Action Modes.
[ "Game", "Action", "Modes", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/enums.py#L250-L266
train
Game Action Mode Enumeration.
happyleavesaoc/aoc-mgz
mgz/enums.py
ReleaseTypeEnum
def ReleaseTypeEnum(ctx): """Types of Releases.""" return Enum( ctx, all=0, selected=3, sametype=4, notselected=5, inversetype=6, default=Pass )
python
def ReleaseTypeEnum(ctx): """Types of Releases.""" return Enum( ctx, all=0, selected=3, sametype=4, notselected=5, inversetype=6, default=Pass )
[ "def", "ReleaseTypeEnum", "(", "ctx", ")", ":", "return", "Enum", "(", "ctx", ",", "all", "=", "0", ",", "selected", "=", "3", ",", "sametype", "=", "4", ",", "notselected", "=", "5", ",", "inversetype", "=", "6", ",", "default", "=", "Pass", ")" ]
Types of Releases.
[ "Types", "of", "Releases", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/enums.py#L278-L288
train
Types of Releases.
happyleavesaoc/aoc-mgz
mgz/enums.py
MyDiplomacyEnum
def MyDiplomacyEnum(ctx): """Player's Diplomacy Enumeration.""" return Enum( ctx, gaia=0, self=1, ally=2, neutral=3, enemy=4, invalid_player=-1 )
python
def MyDiplomacyEnum(ctx): """Player's Diplomacy Enumeration.""" return Enum( ctx, gaia=0, self=1, ally=2, neutral=3, enemy=4, invalid_player=-1 )
[ "def", "MyDiplomacyEnum", "(", "ctx", ")", ":", "return", "Enum", "(", "ctx", ",", "gaia", "=", "0", ",", "self", "=", "1", ",", "ally", "=", "2", ",", "neutral", "=", "3", ",", "enemy", "=", "4", ",", "invalid_player", "=", "-", "1", ")" ]
Player's Diplomacy Enumeration.
[ "Player", "s", "Diplomacy", "Enumeration", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/enums.py#L310-L320
train
Player s Diplomacy Enumeration.
happyleavesaoc/aoc-mgz
mgz/enums.py
ActionEnum
def ActionEnum(ctx): """Action Enumeration.""" return Enum( ctx, interact=0, stop=1, ai_interact=2, move=3, add_attribute=5, give_attribute=6, ai_move=10, resign=11, spec=15, waypoint=16, stance=18, guard=19,...
python
def ActionEnum(ctx): """Action Enumeration.""" return Enum( ctx, interact=0, stop=1, ai_interact=2, move=3, add_attribute=5, give_attribute=6, ai_move=10, resign=11, spec=15, waypoint=16, stance=18, guard=19,...
[ "def", "ActionEnum", "(", "ctx", ")", ":", "return", "Enum", "(", "ctx", ",", "interact", "=", "0", ",", "stop", "=", "1", ",", "ai_interact", "=", "2", ",", "move", "=", "3", ",", "add_attribute", "=", "5", ",", "give_attribute", "=", "6", ",", ...
Action Enumeration.
[ "Action", "Enumeration", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/enums.py#L322-L368
train
Action Enumeration.
bollwyvl/nosebook
nosebook.py
NosebookThree.newKernel
def newKernel(self, nb): """ generate a new kernel """ manager, kernel = utils.start_new_kernel( kernel_name=nb.metadata.kernelspec.name ) return kernel
python
def newKernel(self, nb): """ generate a new kernel """ manager, kernel = utils.start_new_kernel( kernel_name=nb.metadata.kernelspec.name ) return kernel
[ "def", "newKernel", "(", "self", ",", "nb", ")", ":", "manager", ",", "kernel", "=", "utils", ".", "start_new_kernel", "(", "kernel_name", "=", "nb", ".", "metadata", ".", "kernelspec", ".", "name", ")", "return", "kernel" ]
generate a new kernel
[ "generate", "a", "new", "kernel" ]
6a79104b9be4b5acf1ff06cbf745f220a54a4613
https://github.com/bollwyvl/nosebook/blob/6a79104b9be4b5acf1ff06cbf745f220a54a4613/nosebook.py#L65-L72
train
generate a new kernel
bollwyvl/nosebook
nosebook.py
Nosebook.options
def options(self, parser, env=os.environ): """ advertise options """ self.testMatchPat = env.get('NOSEBOOK_TESTMATCH', r'.*[Tt]est.*\.ipynb$') self.testMatchCellPat = env.get('NOSEBOOK_CELLMATCH', r'.*'...
python
def options(self, parser, env=os.environ): """ advertise options """ self.testMatchPat = env.get('NOSEBOOK_TESTMATCH', r'.*[Tt]est.*\.ipynb$') self.testMatchCellPat = env.get('NOSEBOOK_CELLMATCH', r'.*'...
[ "def", "options", "(", "self", ",", "parser", ",", "env", "=", "os", ".", "environ", ")", ":", "self", ".", "testMatchPat", "=", "env", ".", "get", "(", "'NOSEBOOK_TESTMATCH'", ",", "r'.*[Tt]est.*\\.ipynb$'", ")", "self", ".", "testMatchCellPat", "=", "env...
advertise options
[ "advertise", "options" ]
6a79104b9be4b5acf1ff06cbf745f220a54a4613
https://github.com/bollwyvl/nosebook/blob/6a79104b9be4b5acf1ff06cbf745f220a54a4613/nosebook.py#L92-L134
train
Advertise options from environment variables.
bollwyvl/nosebook
nosebook.py
Nosebook.configure
def configure(self, options, conf): """ apply configured options """ super(Nosebook, self).configure(options, conf) self.testMatch = re.compile(options.nosebookTestMatch).match self.testMatchCell = re.compile(options.nosebookTestMatchCell).match scrubs = [] ...
python
def configure(self, options, conf): """ apply configured options """ super(Nosebook, self).configure(options, conf) self.testMatch = re.compile(options.nosebookTestMatch).match self.testMatchCell = re.compile(options.nosebookTestMatchCell).match scrubs = [] ...
[ "def", "configure", "(", "self", ",", "options", ",", "conf", ")", ":", "super", "(", "Nosebook", ",", "self", ")", ".", "configure", "(", "options", ",", "conf", ")", "self", ".", "testMatch", "=", "re", ".", "compile", "(", "options", ".", "noseboo...
apply configured options
[ "apply", "configured", "options" ]
6a79104b9be4b5acf1ff06cbf745f220a54a4613
https://github.com/bollwyvl/nosebook/blob/6a79104b9be4b5acf1ff06cbf745f220a54a4613/nosebook.py#L136-L165
train
apply configured options
bollwyvl/nosebook
nosebook.py
Nosebook.wantFile
def wantFile(self, filename): """ filter files to those that match nosebook-match """ log.info("considering %s", filename) if self.testMatch(filename) is None: return False nb = self.readnb(filename) for cell in self.codeCells(nb): retu...
python
def wantFile(self, filename): """ filter files to those that match nosebook-match """ log.info("considering %s", filename) if self.testMatch(filename) is None: return False nb = self.readnb(filename) for cell in self.codeCells(nb): retu...
[ "def", "wantFile", "(", "self", ",", "filename", ")", ":", "log", ".", "info", "(", "\"considering %s\"", ",", "filename", ")", "if", "self", ".", "testMatch", "(", "filename", ")", "is", "None", ":", "return", "False", "nb", "=", "self", ".", "readnb"...
filter files to those that match nosebook-match
[ "filter", "files", "to", "those", "that", "match", "nosebook", "-", "match" ]
6a79104b9be4b5acf1ff06cbf745f220a54a4613
https://github.com/bollwyvl/nosebook/blob/6a79104b9be4b5acf1ff06cbf745f220a54a4613/nosebook.py#L193-L210
train
Return True if the file filename should be considered to be considered as nosebook - match.
rhjdjong/SlipLib
sliplib/slipsocket.py
SlipSocket.create_connection
def create_connection(cls, address, timeout=None, source_address=None): """Create a SlipSocket connection. This convenience method creates a connection to the the specified address using the :func:`socket.create_connection` function. The socket that is returned from that call is automat...
python
def create_connection(cls, address, timeout=None, source_address=None): """Create a SlipSocket connection. This convenience method creates a connection to the the specified address using the :func:`socket.create_connection` function. The socket that is returned from that call is automat...
[ "def", "create_connection", "(", "cls", ",", "address", ",", "timeout", "=", "None", ",", "source_address", "=", "None", ")", ":", "sock", "=", "socket", ".", "create_connection", "(", "address", ",", "timeout", ",", "source_address", ")", "return", "cls", ...
Create a SlipSocket connection. This convenience method creates a connection to the the specified address using the :func:`socket.create_connection` function. The socket that is returned from that call is automatically wrapped in a :class:`SlipSocket` object. .. note:: ...
[ "Create", "a", "SlipSocket", "connection", "." ]
8300dba3e512bca282380f234be34d75f4a73ce1
https://github.com/rhjdjong/SlipLib/blob/8300dba3e512bca282380f234be34d75f4a73ce1/sliplib/slipsocket.py#L94-L110
train
Create a new connection to the specified address.
rhjdjong/SlipLib
sliplib/slipwrapper.py
SlipWrapper.send_msg
def send_msg(self, message): """Send a SLIP-encoded message over the stream. :param bytes message: The message to encode and send """ packet = self.driver.send(message) self.send_bytes(packet)
python
def send_msg(self, message): """Send a SLIP-encoded message over the stream. :param bytes message: The message to encode and send """ packet = self.driver.send(message) self.send_bytes(packet)
[ "def", "send_msg", "(", "self", ",", "message", ")", ":", "packet", "=", "self", ".", "driver", ".", "send", "(", "message", ")", "self", ".", "send_bytes", "(", "packet", ")" ]
Send a SLIP-encoded message over the stream. :param bytes message: The message to encode and send
[ "Send", "a", "SLIP", "-", "encoded", "message", "over", "the", "stream", "." ]
8300dba3e512bca282380f234be34d75f4a73ce1
https://github.com/rhjdjong/SlipLib/blob/8300dba3e512bca282380f234be34d75f4a73ce1/sliplib/slipwrapper.py#L65-L71
train
Send a SLIP - encoded message over the stream.
rhjdjong/SlipLib
sliplib/slipwrapper.py
SlipWrapper.recv_msg
def recv_msg(self): """Receive a single message from the stream. :return: A SLIP-decoded message :rtype: bytes :raises ProtocolError: when a SLIP protocol error has been encountered. A subsequent call to :meth:`recv_msg` (after handling the exception) will return t...
python
def recv_msg(self): """Receive a single message from the stream. :return: A SLIP-decoded message :rtype: bytes :raises ProtocolError: when a SLIP protocol error has been encountered. A subsequent call to :meth:`recv_msg` (after handling the exception) will return t...
[ "def", "recv_msg", "(", "self", ")", ":", "# First check if there are any pending messages", "if", "self", ".", "_messages", ":", "return", "self", ".", "_messages", ".", "popleft", "(", ")", "# No pending messages left. If a ProtocolError has occurred", "# it must be re-ra...
Receive a single message from the stream. :return: A SLIP-decoded message :rtype: bytes :raises ProtocolError: when a SLIP protocol error has been encountered. A subsequent call to :meth:`recv_msg` (after handling the exception) will return the message from the next packet...
[ "Receive", "a", "single", "message", "from", "the", "stream", "." ]
8300dba3e512bca282380f234be34d75f4a73ce1
https://github.com/rhjdjong/SlipLib/blob/8300dba3e512bca282380f234be34d75f4a73ce1/sliplib/slipwrapper.py#L73-L117
train
Receive a single message from the stream.
kstaniek/condoor
condoor/drivers/NX-OS.py
Driver.reload
def reload(self, save_config=True): """Reload the device. !!!WARNING! there is unsaved configuration!!! This command will reboot the system. (y/n)? [n] """ if save_config: self.device.send("copy running-config startup-config") self.device("reload", wait_for_...
python
def reload(self, save_config=True): """Reload the device. !!!WARNING! there is unsaved configuration!!! This command will reboot the system. (y/n)? [n] """ if save_config: self.device.send("copy running-config startup-config") self.device("reload", wait_for_...
[ "def", "reload", "(", "self", ",", "save_config", "=", "True", ")", ":", "if", "save_config", ":", "self", ".", "device", ".", "send", "(", "\"copy running-config startup-config\"", ")", "self", ".", "device", "(", "\"reload\"", ",", "wait_for_string", "=", ...
Reload the device. !!!WARNING! there is unsaved configuration!!! This command will reboot the system. (y/n)? [n]
[ "Reload", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/NX-OS.py#L43-L52
train
Reload the device.
kstaniek/condoor
condoor/connection.py
Connection.finalize
def finalize(self): """Clean up the object. After calling this method the object can't be used anymore. This will be reworked when changing the logging model. """ self.pause_session_logging() self._disable_logging() self._msg_callback = None self._error_m...
python
def finalize(self): """Clean up the object. After calling this method the object can't be used anymore. This will be reworked when changing the logging model. """ self.pause_session_logging() self._disable_logging() self._msg_callback = None self._error_m...
[ "def", "finalize", "(", "self", ")", ":", "self", ".", "pause_session_logging", "(", ")", "self", ".", "_disable_logging", "(", ")", "self", ".", "_msg_callback", "=", "None", "self", ".", "_error_msg_callback", "=", "None", "self", ".", "_warning_msg_callback...
Clean up the object. After calling this method the object can't be used anymore. This will be reworked when changing the logging model.
[ "Clean", "up", "the", "object", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L100-L111
train
Finalize the object.
kstaniek/condoor
condoor/connection.py
Connection._chain_indices
def _chain_indices(self): """Get the deque of chain indices starting with last successful index.""" chain_indices = deque(range(len(self.connection_chains))) chain_indices.rotate(self._last_chain_index) return chain_indices
python
def _chain_indices(self): """Get the deque of chain indices starting with last successful index.""" chain_indices = deque(range(len(self.connection_chains))) chain_indices.rotate(self._last_chain_index) return chain_indices
[ "def", "_chain_indices", "(", "self", ")", ":", "chain_indices", "=", "deque", "(", "range", "(", "len", "(", "self", ".", "connection_chains", ")", ")", ")", "chain_indices", ".", "rotate", "(", "self", ".", "_last_chain_index", ")", "return", "chain_indice...
Get the deque of chain indices starting with last successful index.
[ "Get", "the", "deque", "of", "chain", "indices", "starting", "with", "last", "successful", "index", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L226-L230
train
Get the deque of chain indices starting with last successful index.
kstaniek/condoor
condoor/connection.py
Connection.connect
def connect(self, logfile=None, force_discovery=False, tracefile=None): """Connect to the device. Args: logfile (file): Optional file descriptor for session logging. The file must be open for write. The session is logged only if ``log_session=True`` was passed to the constru...
python
def connect(self, logfile=None, force_discovery=False, tracefile=None): """Connect to the device. Args: logfile (file): Optional file descriptor for session logging. The file must be open for write. The session is logged only if ``log_session=True`` was passed to the constru...
[ "def", "connect", "(", "self", ",", "logfile", "=", "None", ",", "force_discovery", "=", "False", ",", "tracefile", "=", "None", ")", ":", "self", ".", "reconnect", "(", "logfile", "=", "logfile", ",", "max_timeout", "=", "120", ",", "force_discovery", "...
Connect to the device. Args: logfile (file): Optional file descriptor for session logging. The file must be open for write. The session is logged only if ``log_session=True`` was passed to the constructor. If *None* then the default *session.log* file is created in `...
[ "Connect", "to", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L232-L254
train
Connects to the device.
kstaniek/condoor
condoor/connection.py
Connection.reconnect
def reconnect(self, logfile=None, max_timeout=360, force_discovery=False, tracefile=None, retry=True): """Reconnect to the device. It can be called when after device reloads or the session was disconnected either by device or jumphost. If multiple jumphosts are used then `reconnect` starts from...
python
def reconnect(self, logfile=None, max_timeout=360, force_discovery=False, tracefile=None, retry=True): """Reconnect to the device. It can be called when after device reloads or the session was disconnected either by device or jumphost. If multiple jumphosts are used then `reconnect` starts from...
[ "def", "reconnect", "(", "self", ",", "logfile", "=", "None", ",", "max_timeout", "=", "360", ",", "force_discovery", "=", "False", ",", "tracefile", "=", "None", ",", "retry", "=", "True", ")", ":", "self", ".", "_enable_logging", "(", "logfile", ",", ...
Reconnect to the device. It can be called when after device reloads or the session was disconnected either by device or jumphost. If multiple jumphosts are used then `reconnect` starts from the last valid connection. Args: logfile (file): Optional file descriptor for sessio...
[ "Reconnect", "to", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L256-L364
train
Reconnect to the device.
kstaniek/condoor
condoor/connection.py
Connection.resume_session_logging
def resume_session_logging(self): """Resume session logging.""" self._chain.ctrl.set_session_log(self.session_fd) self.log("Session logging resumed")
python
def resume_session_logging(self): """Resume session logging.""" self._chain.ctrl.set_session_log(self.session_fd) self.log("Session logging resumed")
[ "def", "resume_session_logging", "(", "self", ")", ":", "self", ".", "_chain", ".", "ctrl", ".", "set_session_log", "(", "self", ".", "session_fd", ")", "self", ".", "log", "(", "\"Session logging resumed\"", ")" ]
Resume session logging.
[ "Resume", "session", "logging", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L371-L374
train
Resume session logging.
kstaniek/condoor
condoor/connection.py
Connection.send
def send(self, cmd="", timeout=300, wait_for_string=None, password=False): """Send the command to the device and return the output. Args: cmd (str): Command string for execution. Defaults to empty string. timeout (int): Timeout in seconds. Defaults to 300 sec (5 min) ...
python
def send(self, cmd="", timeout=300, wait_for_string=None, password=False): """Send the command to the device and return the output. Args: cmd (str): Command string for execution. Defaults to empty string. timeout (int): Timeout in seconds. Defaults to 300 sec (5 min) ...
[ "def", "send", "(", "self", ",", "cmd", "=", "\"\"", ",", "timeout", "=", "300", ",", "wait_for_string", "=", "None", ",", "password", "=", "False", ")", ":", "return", "self", ".", "_chain", ".", "send", "(", "cmd", ",", "timeout", ",", "wait_for_st...
Send the command to the device and return the output. Args: cmd (str): Command string for execution. Defaults to empty string. timeout (int): Timeout in seconds. Defaults to 300 sec (5 min) wait_for_string (str): This is optional string that driver waits for afte...
[ "Send", "the", "command", "to", "the", "device", "and", "return", "the", "output", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L376-L397
train
Send a command to the device and return the output.
kstaniek/condoor
condoor/connection.py
Connection.config
def config(self, configlet=None, plane='sdr', **attributes): """Configure the device. This method applies configuration to the device. Args: configlet (text): The configuration template. plane (text): sdr or admin attributes (dict): The dictionary of attribu...
python
def config(self, configlet=None, plane='sdr', **attributes): """Configure the device. This method applies configuration to the device. Args: configlet (text): The configuration template. plane (text): sdr or admin attributes (dict): The dictionary of attribu...
[ "def", "config", "(", "self", ",", "configlet", "=", "None", ",", "plane", "=", "'sdr'", ",", "*", "*", "attributes", ")", ":", "begin", "=", "time", ".", "time", "(", ")", "label", "=", "self", ".", "_chain", ".", "target_device", ".", "config", "...
Configure the device. This method applies configuration to the device. Args: configlet (text): The configuration template. plane (text): sdr or admin attributes (dict): The dictionary of attributes used in template. Returns: A string with commit...
[ "Configure", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L399-L422
train
Configure the device.
kstaniek/condoor
condoor/connection.py
Connection.rollback
def rollback(self, label=None, plane='sdr'): """Rollback the configuration. This method rolls back the configuration on the device. Args: label (text): The configuration label ID plane: (text): sdr or admin Returns: A string with commit label or Non...
python
def rollback(self, label=None, plane='sdr'): """Rollback the configuration. This method rolls back the configuration on the device. Args: label (text): The configuration label ID plane: (text): sdr or admin Returns: A string with commit label or Non...
[ "def", "rollback", "(", "self", ",", "label", "=", "None", ",", "plane", "=", "'sdr'", ")", ":", "begin", "=", "time", ".", "time", "(", ")", "rb_label", "=", "self", ".", "_chain", ".", "target_device", ".", "rollback", "(", "label", "=", "label", ...
Rollback the configuration. This method rolls back the configuration on the device. Args: label (text): The configuration label ID plane: (text): sdr or admin Returns: A string with commit label or None
[ "Rollback", "the", "configuration", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L424-L446
train
This method rolls back the configuration on the device.
kstaniek/condoor
condoor/connection.py
Connection.discovery
def discovery(self, logfile=None, tracefile=None): """Discover the device details. This method discover several device attributes. Args: logfile (file): Optional file descriptor for session logging. The file must be open for write. The session is logged only if ``lo...
python
def discovery(self, logfile=None, tracefile=None): """Discover the device details. This method discover several device attributes. Args: logfile (file): Optional file descriptor for session logging. The file must be open for write. The session is logged only if ``lo...
[ "def", "discovery", "(", "self", ",", "logfile", "=", "None", ",", "tracefile", "=", "None", ")", ":", "self", ".", "_enable_logging", "(", "logfile", "=", "logfile", ",", "tracefile", "=", "tracefile", ")", "self", ".", "log", "(", "\"'discovery' method i...
Discover the device details. This method discover several device attributes. Args: logfile (file): Optional file descriptor for session logging. The file must be open for write. The session is logged only if ``log_session=True`` was passed to the constructor. ...
[ "Discover", "the", "device", "details", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L453-L469
train
Discover the device details.
kstaniek/condoor
condoor/connection.py
Connection.reload
def reload(self, reload_timeout=300, save_config=True, no_reload_cmd=False): """Reload the device and wait for device to boot up. Returns False if reload was not successful. """ begin = time.time() self._chain.target_device.clear_info() result = False try: ...
python
def reload(self, reload_timeout=300, save_config=True, no_reload_cmd=False): """Reload the device and wait for device to boot up. Returns False if reload was not successful. """ begin = time.time() self._chain.target_device.clear_info() result = False try: ...
[ "def", "reload", "(", "self", ",", "reload_timeout", "=", "300", ",", "save_config", "=", "True", ",", "no_reload_cmd", "=", "False", ")", ":", "begin", "=", "time", ".", "time", "(", ")", "self", ".", "_chain", ".", "target_device", ".", "clear_info", ...
Reload the device and wait for device to boot up. Returns False if reload was not successful.
[ "Reload", "the", "device", "and", "wait", "for", "device", "to", "boot", "up", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L482-L512
train
Reload the device and wait for device to boot up. Returns False if reload was not successful.
kstaniek/condoor
condoor/connection.py
Connection.run_fsm
def run_fsm(self, name, command, events, transitions, timeout, max_transitions=20): """Instantiate and run the Finite State Machine for the current device connection. Here is the example of usage:: test_dir = "rw_test" dir = "disk0:" + test_dir REMOVE_DIR = re.compi...
python
def run_fsm(self, name, command, events, transitions, timeout, max_transitions=20): """Instantiate and run the Finite State Machine for the current device connection. Here is the example of usage:: test_dir = "rw_test" dir = "disk0:" + test_dir REMOVE_DIR = re.compi...
[ "def", "run_fsm", "(", "self", ",", "name", ",", "command", ",", "events", ",", "transitions", ",", "timeout", ",", "max_transitions", "=", "20", ")", ":", "return", "self", ".", "_chain", ".", "target_device", ".", "run_fsm", "(", "name", ",", "command"...
Instantiate and run the Finite State Machine for the current device connection. Here is the example of usage:: test_dir = "rw_test" dir = "disk0:" + test_dir REMOVE_DIR = re.compile(re.escape("Remove directory filename [{}]?".format(test_dir))) DELETE_CONFIRM = ...
[ "Instantiate", "and", "run", "the", "Finite", "State", "Machine", "for", "the", "current", "device", "connection", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L514-L588
train
Instantiate and run the Finite State Machine for the current device connection.
kstaniek/condoor
condoor/connection.py
Connection.emit_message
def emit_message(self, message, log_level): """Call the msg callback function with the message.""" self.log(message) if log_level == logging.ERROR: if self._error_msg_callback: self._error_msg_callback(message) return if log_level == logging.W...
python
def emit_message(self, message, log_level): """Call the msg callback function with the message.""" self.log(message) if log_level == logging.ERROR: if self._error_msg_callback: self._error_msg_callback(message) return if log_level == logging.W...
[ "def", "emit_message", "(", "self", ",", "message", ",", "log_level", ")", ":", "self", ".", "log", "(", "message", ")", "if", "log_level", "==", "logging", ".", "ERROR", ":", "if", "self", ".", "_error_msg_callback", ":", "self", ".", "_error_msg_callback...
Call the msg callback function with the message.
[ "Call", "the", "msg", "callback", "function", "with", "the", "message", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L590-L609
train
Call the msg callback function with the message.
kstaniek/condoor
condoor/connection.py
Connection.msg_callback
def msg_callback(self, callback): """Set the message callback.""" if callable(callback): self._msg_callback = callback else: self._msg_callback = None
python
def msg_callback(self, callback): """Set the message callback.""" if callable(callback): self._msg_callback = callback else: self._msg_callback = None
[ "def", "msg_callback", "(", "self", ",", "callback", ")", ":", "if", "callable", "(", "callback", ")", ":", "self", ".", "_msg_callback", "=", "callback", "else", ":", "self", ".", "_msg_callback", "=", "None" ]
Set the message callback.
[ "Set", "the", "message", "callback", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L617-L622
train
Set the message callback.
kstaniek/condoor
condoor/connection.py
Connection.error_msg_callback
def error_msg_callback(self, callback): """Set the error message callback.""" if callable(callback): self._error_msg_callback = callback else: self._error_msg_callback = None
python
def error_msg_callback(self, callback): """Set the error message callback.""" if callable(callback): self._error_msg_callback = callback else: self._error_msg_callback = None
[ "def", "error_msg_callback", "(", "self", ",", "callback", ")", ":", "if", "callable", "(", "callback", ")", ":", "self", ".", "_error_msg_callback", "=", "callback", "else", ":", "self", ".", "_error_msg_callback", "=", "None" ]
Set the error message callback.
[ "Set", "the", "error", "message", "callback", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L630-L635
train
Set the error message callback.
kstaniek/condoor
condoor/connection.py
Connection.warning_msg_callback
def warning_msg_callback(self, callback): """Set the warning message callback.""" if callable(callback): self._warning_msg_callback = callback else: self._warning_msg_callback = None
python
def warning_msg_callback(self, callback): """Set the warning message callback.""" if callable(callback): self._warning_msg_callback = callback else: self._warning_msg_callback = None
[ "def", "warning_msg_callback", "(", "self", ",", "callback", ")", ":", "if", "callable", "(", "callback", ")", ":", "self", ".", "_warning_msg_callback", "=", "callback", "else", ":", "self", ".", "_warning_msg_callback", "=", "None" ]
Set the warning message callback.
[ "Set", "the", "warning", "message", "callback", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L643-L648
train
Set the warning message callback.
kstaniek/condoor
condoor/connection.py
Connection.info_msg_callback
def info_msg_callback(self, callback): """Set the info message callback.""" if callable(callback): self._info_msg_callback = callback else: self._info_msg_callback = None
python
def info_msg_callback(self, callback): """Set the info message callback.""" if callable(callback): self._info_msg_callback = callback else: self._info_msg_callback = None
[ "def", "info_msg_callback", "(", "self", ",", "callback", ")", ":", "if", "callable", "(", "callback", ")", ":", "self", ".", "_info_msg_callback", "=", "callback", "else", ":", "self", ".", "_info_msg_callback", "=", "None" ]
Set the info message callback.
[ "Set", "the", "info", "message", "callback", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L656-L661
train
Set the info message callback.
kstaniek/condoor
condoor/connection.py
Connection.description_record
def description_record(self): """Return dict describing :class:`condoor.Connection` object. Example:: {'connections': [{'chain': [{'driver_name': 'eXR', 'family': 'ASR9K', 'hostname': 'vkg3', 'is_console...
python
def description_record(self): """Return dict describing :class:`condoor.Connection` object. Example:: {'connections': [{'chain': [{'driver_name': 'eXR', 'family': 'ASR9K', 'hostname': 'vkg3', 'is_console...
[ "def", "description_record", "(", "self", ")", ":", "if", "self", ".", "connection_chains", ":", "return", "{", "'connections'", ":", "[", "{", "'chain'", ":", "[", "device", ".", "device_info", "for", "device", "in", "chain", ".", "devices", "]", "}", "...
Return dict describing :class:`condoor.Connection` object. Example:: {'connections': [{'chain': [{'driver_name': 'eXR', 'family': 'ASR9K', 'hostname': 'vkg3', 'is_console': True, 'is...
[ "Return", "dict", "describing", ":", "class", ":", "condoor", ".", "Connection", "object", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L794-L835
train
Return dict describing a single connection record.
thomasjiangcy/django-rest-mock
rest_mock_server/core/extractor.py
Extractor._get_view_details
def _get_view_details(self, urlpatterns, parent=''): """Recursive function to extract all url details""" for pattern in urlpatterns: if isinstance(pattern, (URLPattern, RegexURLPattern)): try: d = describe_pattern(pattern) docstr = patt...
python
def _get_view_details(self, urlpatterns, parent=''): """Recursive function to extract all url details""" for pattern in urlpatterns: if isinstance(pattern, (URLPattern, RegexURLPattern)): try: d = describe_pattern(pattern) docstr = patt...
[ "def", "_get_view_details", "(", "self", ",", "urlpatterns", ",", "parent", "=", "''", ")", ":", "for", "pattern", "in", "urlpatterns", ":", "if", "isinstance", "(", "pattern", ",", "(", "URLPattern", ",", "RegexURLPattern", ")", ")", ":", "try", ":", "d...
Recursive function to extract all url details
[ "Recursive", "function", "to", "extract", "all", "url", "details" ]
09e91de20d1a5efd5c47c6e3d7fe979443012e2c
https://github.com/thomasjiangcy/django-rest-mock/blob/09e91de20d1a5efd5c47c6e3d7fe979443012e2c/rest_mock_server/core/extractor.py#L81-L139
train
Recursive function to extract all url details from urlpatterns
zestyping/star-destroyer
star_destroyer.py
for_each_child
def for_each_child(node, callback): """Calls the callback for each AST node that's a child of the given node.""" for name in node._fields: value = getattr(node, name) if isinstance(value, list): for item in value: if isinstance(item, ast.AST): call...
python
def for_each_child(node, callback): """Calls the callback for each AST node that's a child of the given node.""" for name in node._fields: value = getattr(node, name) if isinstance(value, list): for item in value: if isinstance(item, ast.AST): call...
[ "def", "for_each_child", "(", "node", ",", "callback", ")", ":", "for", "name", "in", "node", ".", "_fields", ":", "value", "=", "getattr", "(", "node", ",", "name", ")", "if", "isinstance", "(", "value", ",", "list", ")", ":", "for", "item", "in", ...
Calls the callback for each AST node that's a child of the given node.
[ "Calls", "the", "callback", "for", "each", "AST", "node", "that", "s", "a", "child", "of", "the", "given", "node", "." ]
e23584c85d1e8b8f098e5c75977c6a98a41f3f68
https://github.com/zestyping/star-destroyer/blob/e23584c85d1e8b8f098e5c75977c6a98a41f3f68/star_destroyer.py#L51-L60
train
Calls the callback for each AST node that s a child of the given node.
zestyping/star-destroyer
star_destroyer.py
resolve_frompath
def resolve_frompath(pkgpath, relpath, level=0): """Resolves the path of the module referred to by 'from ..x import y'.""" if level == 0: return relpath parts = pkgpath.split('.') + ['_'] parts = parts[:-level] + (relpath.split('.') if relpath else []) return '.'.join(parts)
python
def resolve_frompath(pkgpath, relpath, level=0): """Resolves the path of the module referred to by 'from ..x import y'.""" if level == 0: return relpath parts = pkgpath.split('.') + ['_'] parts = parts[:-level] + (relpath.split('.') if relpath else []) return '.'.join(parts)
[ "def", "resolve_frompath", "(", "pkgpath", ",", "relpath", ",", "level", "=", "0", ")", ":", "if", "level", "==", "0", ":", "return", "relpath", "parts", "=", "pkgpath", ".", "split", "(", "'.'", ")", "+", "[", "'_'", "]", "parts", "=", "parts", "[...
Resolves the path of the module referred to by 'from ..x import y'.
[ "Resolves", "the", "path", "of", "the", "module", "referred", "to", "by", "from", "..", "x", "import", "y", "." ]
e23584c85d1e8b8f098e5c75977c6a98a41f3f68
https://github.com/zestyping/star-destroyer/blob/e23584c85d1e8b8f098e5c75977c6a98a41f3f68/star_destroyer.py#L62-L68
train
Resolves the path of the module referred to by from.. x import y.
zestyping/star-destroyer
star_destroyer.py
find_module
def find_module(modpath): """Determines whether a module exists with the given modpath.""" module_path = modpath.replace('.', '/') + '.py' init_path = modpath.replace('.', '/') + '/__init__.py' for root_path in sys.path: path = os.path.join(root_path, module_path) if os.path.isfile(path)...
python
def find_module(modpath): """Determines whether a module exists with the given modpath.""" module_path = modpath.replace('.', '/') + '.py' init_path = modpath.replace('.', '/') + '/__init__.py' for root_path in sys.path: path = os.path.join(root_path, module_path) if os.path.isfile(path)...
[ "def", "find_module", "(", "modpath", ")", ":", "module_path", "=", "modpath", ".", "replace", "(", "'.'", ",", "'/'", ")", "+", "'.py'", "init_path", "=", "modpath", ".", "replace", "(", "'.'", ",", "'/'", ")", "+", "'/__init__.py'", "for", "root_path",...
Determines whether a module exists with the given modpath.
[ "Determines", "whether", "a", "module", "exists", "with", "the", "given", "modpath", "." ]
e23584c85d1e8b8f098e5c75977c6a98a41f3f68
https://github.com/zestyping/star-destroyer/blob/e23584c85d1e8b8f098e5c75977c6a98a41f3f68/star_destroyer.py#L70-L80
train
Determines whether a module exists with the given modpath.
zestyping/star-destroyer
star_destroyer.py
get_modules
def get_modules(root_path): """Gets (pkgpath, modpath, path, ast) for all modules in a file tree.""" for dir_path, dir_names, file_names in os.walk(root_path): assert dir_path[:len(root_path)] == root_path subdir_path = dir_path[len(root_path):] package_parts = list(filter(lambda x: x, s...
python
def get_modules(root_path): """Gets (pkgpath, modpath, path, ast) for all modules in a file tree.""" for dir_path, dir_names, file_names in os.walk(root_path): assert dir_path[:len(root_path)] == root_path subdir_path = dir_path[len(root_path):] package_parts = list(filter(lambda x: x, s...
[ "def", "get_modules", "(", "root_path", ")", ":", "for", "dir_path", ",", "dir_names", ",", "file_names", "in", "os", ".", "walk", "(", "root_path", ")", ":", "assert", "dir_path", "[", ":", "len", "(", "root_path", ")", "]", "==", "root_path", "subdir_p...
Gets (pkgpath, modpath, path, ast) for all modules in a file tree.
[ "Gets", "(", "pkgpath", "modpath", "path", "ast", ")", "for", "all", "modules", "in", "a", "file", "tree", "." ]
e23584c85d1e8b8f098e5c75977c6a98a41f3f68
https://github.com/zestyping/star-destroyer/blob/e23584c85d1e8b8f098e5c75977c6a98a41f3f68/star_destroyer.py#L306-L323
train
Gets all modules in a file tree.
zestyping/star-destroyer
star_destroyer.py
ImportMap.get_star_names
def get_star_names(self, modpath): """Returns all the names imported by 'import *' from a given module.""" if modpath not in self.star_names: print('Importing %s to resolve import *' % modpath, file=sys.stderr) try: module = self.import_module(modpath) ...
python
def get_star_names(self, modpath): """Returns all the names imported by 'import *' from a given module.""" if modpath not in self.star_names: print('Importing %s to resolve import *' % modpath, file=sys.stderr) try: module = self.import_module(modpath) ...
[ "def", "get_star_names", "(", "self", ",", "modpath", ")", ":", "if", "modpath", "not", "in", "self", ".", "star_names", ":", "print", "(", "'Importing %s to resolve import *'", "%", "modpath", ",", "file", "=", "sys", ".", "stderr", ")", "try", ":", "modu...
Returns all the names imported by 'import *' from a given module.
[ "Returns", "all", "the", "names", "imported", "by", "import", "*", "from", "a", "given", "module", "." ]
e23584c85d1e8b8f098e5c75977c6a98a41f3f68
https://github.com/zestyping/star-destroyer/blob/e23584c85d1e8b8f098e5c75977c6a98a41f3f68/star_destroyer.py#L101-L114
train
Returns all the names imported by import *' from a given module.
zestyping/star-destroyer
star_destroyer.py
ImportMap.add
def add(self, modpath, name, origin): """Adds a possible origin for the given name in the given module.""" self.map.setdefault(modpath, {}).setdefault(name, set()).add(origin)
python
def add(self, modpath, name, origin): """Adds a possible origin for the given name in the given module.""" self.map.setdefault(modpath, {}).setdefault(name, set()).add(origin)
[ "def", "add", "(", "self", ",", "modpath", ",", "name", ",", "origin", ")", ":", "self", ".", "map", ".", "setdefault", "(", "modpath", ",", "{", "}", ")", ".", "setdefault", "(", "name", ",", "set", "(", ")", ")", ".", "add", "(", "origin", ")...
Adds a possible origin for the given name in the given module.
[ "Adds", "a", "possible", "origin", "for", "the", "given", "name", "in", "the", "given", "module", "." ]
e23584c85d1e8b8f098e5c75977c6a98a41f3f68
https://github.com/zestyping/star-destroyer/blob/e23584c85d1e8b8f098e5c75977c6a98a41f3f68/star_destroyer.py#L116-L118
train
Adds a possible origin for the given name in the given module.
zestyping/star-destroyer
star_destroyer.py
ImportMap.add_package_origins
def add_package_origins(self, modpath): """Whenever you 'import a.b.c', Python automatically binds 'b' in a to the a.b module and binds 'c' in a.b to the a.b.c module.""" parts = modpath.split('.') parent = parts[0] for part in parts[1:]: child = parent + '.' + part ...
python
def add_package_origins(self, modpath): """Whenever you 'import a.b.c', Python automatically binds 'b' in a to the a.b module and binds 'c' in a.b to the a.b.c module.""" parts = modpath.split('.') parent = parts[0] for part in parts[1:]: child = parent + '.' + part ...
[ "def", "add_package_origins", "(", "self", ",", "modpath", ")", ":", "parts", "=", "modpath", ".", "split", "(", "'.'", ")", "parent", "=", "parts", "[", "0", "]", "for", "part", "in", "parts", "[", "1", ":", "]", ":", "child", "=", "parent", "+", ...
Whenever you 'import a.b.c', Python automatically binds 'b' in a to the a.b module and binds 'c' in a.b to the a.b.c module.
[ "Whenever", "you", "import", "a", ".", "b", ".", "c", "Python", "automatically", "binds", "b", "in", "a", "to", "the", "a", ".", "b", "module", "and", "binds", "c", "in", "a", ".", "b", "to", "the", "a", ".", "b", ".", "c", "module", "." ]
e23584c85d1e8b8f098e5c75977c6a98a41f3f68
https://github.com/zestyping/star-destroyer/blob/e23584c85d1e8b8f098e5c75977c6a98a41f3f68/star_destroyer.py#L120-L129
train
Whenever you import a. b. c Python automatically binds b to c in a. b module and binds c in a. b module.
zestyping/star-destroyer
star_destroyer.py
ImportMap.scan_module
def scan_module(self, pkgpath, modpath, node): """Scans a module, collecting possible origins for all names, assuming names can only become bound to values in other modules by import.""" def scan_imports(node): if node_type(node) == 'Import': for binding in node.name...
python
def scan_module(self, pkgpath, modpath, node): """Scans a module, collecting possible origins for all names, assuming names can only become bound to values in other modules by import.""" def scan_imports(node): if node_type(node) == 'Import': for binding in node.name...
[ "def", "scan_module", "(", "self", ",", "pkgpath", ",", "modpath", ",", "node", ")", ":", "def", "scan_imports", "(", "node", ")", ":", "if", "node_type", "(", "node", ")", "==", "'Import'", ":", "for", "binding", "in", "node", ".", "names", ":", "na...
Scans a module, collecting possible origins for all names, assuming names can only become bound to values in other modules by import.
[ "Scans", "a", "module", "collecting", "possible", "origins", "for", "all", "names", "assuming", "names", "can", "only", "become", "bound", "to", "values", "in", "other", "modules", "by", "import", "." ]
e23584c85d1e8b8f098e5c75977c6a98a41f3f68
https://github.com/zestyping/star-destroyer/blob/e23584c85d1e8b8f098e5c75977c6a98a41f3f68/star_destroyer.py#L131-L161
train
Scans a module and adds possible origins for all names assuming that names can only become bound to values in other modules by import.
zestyping/star-destroyer
star_destroyer.py
ImportMap.get_origins
def get_origins(self, modpath, name): """Returns the set of possible origins for a name in a module.""" return self.map.get(modpath, {}).get(name, set())
python
def get_origins(self, modpath, name): """Returns the set of possible origins for a name in a module.""" return self.map.get(modpath, {}).get(name, set())
[ "def", "get_origins", "(", "self", ",", "modpath", ",", "name", ")", ":", "return", "self", ".", "map", ".", "get", "(", "modpath", ",", "{", "}", ")", ".", "get", "(", "name", ",", "set", "(", ")", ")" ]
Returns the set of possible origins for a name in a module.
[ "Returns", "the", "set", "of", "possible", "origins", "for", "a", "name", "in", "a", "module", "." ]
e23584c85d1e8b8f098e5c75977c6a98a41f3f68
https://github.com/zestyping/star-destroyer/blob/e23584c85d1e8b8f098e5c75977c6a98a41f3f68/star_destroyer.py#L163-L165
train
Returns the set of possible origins for a name in a module.
zestyping/star-destroyer
star_destroyer.py
ImportMap.dump
def dump(self): """Prints out the contents of the import map.""" for modpath in sorted(self.map): title = 'Imports in %s' % modpath print('\n' + title + '\n' + '-'*len(title)) for name, value in sorted(self.map.get(modpath, {}).items()): print(' %s ->...
python
def dump(self): """Prints out the contents of the import map.""" for modpath in sorted(self.map): title = 'Imports in %s' % modpath print('\n' + title + '\n' + '-'*len(title)) for name, value in sorted(self.map.get(modpath, {}).items()): print(' %s ->...
[ "def", "dump", "(", "self", ")", ":", "for", "modpath", "in", "sorted", "(", "self", ".", "map", ")", ":", "title", "=", "'Imports in %s'", "%", "modpath", "print", "(", "'\\n'", "+", "title", "+", "'\\n'", "+", "'-'", "*", "len", "(", "title", ")"...
Prints out the contents of the import map.
[ "Prints", "out", "the", "contents", "of", "the", "import", "map", "." ]
e23584c85d1e8b8f098e5c75977c6a98a41f3f68
https://github.com/zestyping/star-destroyer/blob/e23584c85d1e8b8f098e5c75977c6a98a41f3f68/star_destroyer.py#L167-L173
train
Prints out the contents of the import map.
zestyping/star-destroyer
star_destroyer.py
UsageMap.scan_module
def scan_module(self, modpath, node): """Scans a module, collecting all used origins, assuming that modules are obtained only by dotted paths and no other kinds of expressions.""" used_origins = self.map.setdefault(modpath, set()) def get_origins(modpath, name): """Returns ...
python
def scan_module(self, modpath, node): """Scans a module, collecting all used origins, assuming that modules are obtained only by dotted paths and no other kinds of expressions.""" used_origins = self.map.setdefault(modpath, set()) def get_origins(modpath, name): """Returns ...
[ "def", "scan_module", "(", "self", ",", "modpath", ",", "node", ")", ":", "used_origins", "=", "self", ".", "map", ".", "setdefault", "(", "modpath", ",", "set", "(", ")", ")", "def", "get_origins", "(", "modpath", ",", "name", ")", ":", "\"\"\"Returns...
Scans a module, collecting all used origins, assuming that modules are obtained only by dotted paths and no other kinds of expressions.
[ "Scans", "a", "module", "collecting", "all", "used", "origins", "assuming", "that", "modules", "are", "obtained", "only", "by", "dotted", "paths", "and", "no", "other", "kinds", "of", "expressions", "." ]
e23584c85d1e8b8f098e5c75977c6a98a41f3f68
https://github.com/zestyping/star-destroyer/blob/e23584c85d1e8b8f098e5c75977c6a98a41f3f68/star_destroyer.py#L186-L239
train
Scans a module for all possible origins that could be used by a given dotted - path expression.
zestyping/star-destroyer
star_destroyer.py
UsageMap.dump
def dump(self): """Prints out the contents of the usage map.""" for modpath in sorted(self.map): title = 'Used by %s' % modpath print('\n' + title + '\n' + '-'*len(title)) for origin in sorted(self.get_used_origins(modpath)): print(' %s' % origin)
python
def dump(self): """Prints out the contents of the usage map.""" for modpath in sorted(self.map): title = 'Used by %s' % modpath print('\n' + title + '\n' + '-'*len(title)) for origin in sorted(self.get_used_origins(modpath)): print(' %s' % origin)
[ "def", "dump", "(", "self", ")", ":", "for", "modpath", "in", "sorted", "(", "self", ".", "map", ")", ":", "title", "=", "'Used by %s'", "%", "modpath", "print", "(", "'\\n'", "+", "title", "+", "'\\n'", "+", "'-'", "*", "len", "(", "title", ")", ...
Prints out the contents of the usage map.
[ "Prints", "out", "the", "contents", "of", "the", "usage", "map", "." ]
e23584c85d1e8b8f098e5c75977c6a98a41f3f68
https://github.com/zestyping/star-destroyer/blob/e23584c85d1e8b8f098e5c75977c6a98a41f3f68/star_destroyer.py#L247-L253
train
Prints out the contents of the usage map.
happyleavesaoc/aoc-mgz
mgz/util.py
convert_to_timestamp
def convert_to_timestamp(time): """Convert int to timestamp string.""" if time == -1: return None time = int(time*1000) hour = time//1000//3600 minute = (time//1000//60) % 60 second = (time//1000) % 60 return str(hour).zfill(2)+":"+str(minute).zfill(2)+":"+str(second).zfill(2)
python
def convert_to_timestamp(time): """Convert int to timestamp string.""" if time == -1: return None time = int(time*1000) hour = time//1000//3600 minute = (time//1000//60) % 60 second = (time//1000) % 60 return str(hour).zfill(2)+":"+str(minute).zfill(2)+":"+str(second).zfill(2)
[ "def", "convert_to_timestamp", "(", "time", ")", ":", "if", "time", "==", "-", "1", ":", "return", "None", "time", "=", "int", "(", "time", "*", "1000", ")", "hour", "=", "time", "//", "1000", "//", "3600", "minute", "=", "(", "time", "//", "1000",...
Convert int to timestamp string.
[ "Convert", "int", "to", "timestamp", "string", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/util.py#L43-L51
train
Convert int to timestamp string.
happyleavesaoc/aoc-mgz
mgz/util.py
MgzPrefixed._parse
def _parse(self, stream, context, path): """Parse tunnel.""" length = self.length(context) new_stream = BytesIO(construct.core._read_stream(stream, length)) return self.subcon._parse(new_stream, context, path)
python
def _parse(self, stream, context, path): """Parse tunnel.""" length = self.length(context) new_stream = BytesIO(construct.core._read_stream(stream, length)) return self.subcon._parse(new_stream, context, path)
[ "def", "_parse", "(", "self", ",", "stream", ",", "context", ",", "path", ")", ":", "length", "=", "self", ".", "length", "(", "context", ")", "new_stream", "=", "BytesIO", "(", "construct", ".", "core", ".", "_read_stream", "(", "stream", ",", "length...
Parse tunnel.
[ "Parse", "tunnel", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/util.py#L26-L30
train
Parse tunnel.
happyleavesaoc/aoc-mgz
mgz/util.py
Find._parse
def _parse(self, stream, context, path): """Parse stream to find a given byte string.""" start = stream.tell() read_bytes = "" if self.max_length: read_bytes = stream.read(self.max_length) else: read_bytes = stream.read() skip = read_bytes.find(sel...
python
def _parse(self, stream, context, path): """Parse stream to find a given byte string.""" start = stream.tell() read_bytes = "" if self.max_length: read_bytes = stream.read(self.max_length) else: read_bytes = stream.read() skip = read_bytes.find(sel...
[ "def", "_parse", "(", "self", ",", "stream", ",", "context", ",", "path", ")", ":", "start", "=", "stream", ".", "tell", "(", ")", "read_bytes", "=", "\"\"", "if", "self", ".", "max_length", ":", "read_bytes", "=", "stream", ".", "read", "(", "self",...
Parse stream to find a given byte string.
[ "Parse", "stream", "to", "find", "a", "given", "byte", "string", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/util.py#L94-L104
train
Parse the byte string and return the offset of the first byte string.
happyleavesaoc/aoc-mgz
mgz/util.py
RepeatUpTo._parse
def _parse(self, stream, context, path): """Parse until a given byte string is found.""" objs = [] while True: start = stream.tell() test = stream.read(len(self.find)) stream.seek(start) if test == self.find: break else:...
python
def _parse(self, stream, context, path): """Parse until a given byte string is found.""" objs = [] while True: start = stream.tell() test = stream.read(len(self.find)) stream.seek(start) if test == self.find: break else:...
[ "def", "_parse", "(", "self", ",", "stream", ",", "context", ",", "path", ")", ":", "objs", "=", "[", "]", "while", "True", ":", "start", "=", "stream", ".", "tell", "(", ")", "test", "=", "stream", ".", "read", "(", "len", "(", "self", ".", "f...
Parse until a given byte string is found.
[ "Parse", "until", "a", "given", "byte", "string", "is", "found", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/util.py#L117-L129
train
Parse until a given byte string is found.
happyleavesaoc/aoc-mgz
mgz/util.py
GotoObjectsEnd._parse
def _parse(self, stream, context, path): """Parse until the end of objects data.""" num_players = context._._._.replay.num_players start = stream.tell() # Have to read everything to be able to use find() read_bytes = stream.read() # Try to find the first marker, a portion...
python
def _parse(self, stream, context, path): """Parse until the end of objects data.""" num_players = context._._._.replay.num_players start = stream.tell() # Have to read everything to be able to use find() read_bytes = stream.read() # Try to find the first marker, a portion...
[ "def", "_parse", "(", "self", ",", "stream", ",", "context", ",", "path", ")", ":", "num_players", "=", "context", ".", "_", ".", "_", ".", "_", ".", "replay", ".", "num_players", "start", "=", "stream", ".", "tell", "(", ")", "# Have to read everythin...
Parse until the end of objects data.
[ "Parse", "until", "the", "end", "of", "objects", "data", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/util.py#L138-L170
train
Parse the object name and return the object ID.
kstaniek/condoor
condoor/drivers/XR.py
Driver.reload
def reload(self, reload_timeout, save_config): """Reload the device.""" PROCEED = re.compile(re.escape("Proceed with reload? [confirm]")) CONTINUE = re.compile(re.escape("Do you wish to continue?[confirm(y/n)]")) DONE = re.compile(re.escape("[Done]")) CONFIGURATION_COMPLETED = re...
python
def reload(self, reload_timeout, save_config): """Reload the device.""" PROCEED = re.compile(re.escape("Proceed with reload? [confirm]")) CONTINUE = re.compile(re.escape("Do you wish to continue?[confirm(y/n)]")) DONE = re.compile(re.escape("[Done]")) CONFIGURATION_COMPLETED = re...
[ "def", "reload", "(", "self", ",", "reload_timeout", ",", "save_config", ")", ":", "PROCEED", "=", "re", ".", "compile", "(", "re", ".", "escape", "(", "\"Proceed with reload? [confirm]\"", ")", ")", "CONTINUE", "=", "re", ".", "compile", "(", "re", ".", ...
Reload the device.
[ "Reload", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/XR.py#L46-L107
train
Reload the device.
kstaniek/condoor
condoor/drivers/XR.py
Driver.config
def config(self, config_text, plane): """Apply config.""" NO_CONFIGURATION_CHANGE = re.compile("No configuration changes to commit") CONFIGURATION_FAILED = re.compile("show configuration failed") CONFIGURATION_INCONSITENCY = re.compile("No configuration commits for this SDR will be allow...
python
def config(self, config_text, plane): """Apply config.""" NO_CONFIGURATION_CHANGE = re.compile("No configuration changes to commit") CONFIGURATION_FAILED = re.compile("show configuration failed") CONFIGURATION_INCONSITENCY = re.compile("No configuration commits for this SDR will be allow...
[ "def", "config", "(", "self", ",", "config_text", ",", "plane", ")", ":", "NO_CONFIGURATION_CHANGE", "=", "re", ".", "compile", "(", "\"No configuration changes to commit\"", ")", "CONFIGURATION_FAILED", "=", "re", ".", "compile", "(", "\"show configuration failed\"",...
Apply config.
[ "Apply", "config", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/XR.py#L109-L143
train
Apply config.
kstaniek/condoor
condoor/drivers/XR.py
Driver.rollback
def rollback(self, label, plane): """Rollback config.""" cm_label = 'condoor-{}'.format(int(time.time())) self.device.send(self.rollback_cmd.format(label), timeout=120) return cm_label
python
def rollback(self, label, plane): """Rollback config.""" cm_label = 'condoor-{}'.format(int(time.time())) self.device.send(self.rollback_cmd.format(label), timeout=120) return cm_label
[ "def", "rollback", "(", "self", ",", "label", ",", "plane", ")", ":", "cm_label", "=", "'condoor-{}'", ".", "format", "(", "int", "(", "time", ".", "time", "(", ")", ")", ")", "self", ".", "device", ".", "send", "(", "self", ".", "rollback_cmd", "....
Rollback config.
[ "Rollback", "config", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/XR.py#L145-L149
train
Rollback the current configuration.
bfarr/kombine
kombine/utils.py
gelman_rubin
def gelman_rubin(chains, return_cdf=False): """ Compute the Gelman-Rubin R-statistic from an ensemble of chains. `chains` is expected to have shape `(nsteps, nchains)` if samples are one dimensional, or `(nsteps, nchains, ndim)` if multidimensional. For multidimensional samples R-statistics will b...
python
def gelman_rubin(chains, return_cdf=False): """ Compute the Gelman-Rubin R-statistic from an ensemble of chains. `chains` is expected to have shape `(nsteps, nchains)` if samples are one dimensional, or `(nsteps, nchains, ndim)` if multidimensional. For multidimensional samples R-statistics will b...
[ "def", "gelman_rubin", "(", "chains", ",", "return_cdf", "=", "False", ")", ":", "if", "len", "(", "chains", ".", "shape", ")", ">", "2", ":", "results", "=", "[", "gelman_rubin", "(", "chains", "[", "...", ",", "param", "]", ",", "return_cdf", "=", ...
Compute the Gelman-Rubin R-statistic from an ensemble of chains. `chains` is expected to have shape `(nsteps, nchains)` if samples are one dimensional, or `(nsteps, nchains, ndim)` if multidimensional. For multidimensional samples R-statistics will be computed for each dimension. :param chains: ...
[ "Compute", "the", "Gelman", "-", "Rubin", "R", "-", "statistic", "from", "an", "ensemble", "of", "chains", ".", "chains", "is", "expected", "to", "have", "shape", "(", "nsteps", "nchains", ")", "if", "samples", "are", "one", "dimensional", "or", "(", "ns...
50c946dee5da33e7baab71d9bd6c265ff02ffb13
https://github.com/bfarr/kombine/blob/50c946dee5da33e7baab71d9bd6c265ff02ffb13/kombine/utils.py#L12-L58
train
Compute the Gelman - Rubin R - statistics from an ensemble of chains.
ajdavis/GreenletProfiler
GreenletProfiler.py
start
def start(builtins=False, profile_threads=True): """Starts profiling all threads and all greenlets. This function can be called from any thread at any time. Resumes profiling if stop() was called previously. * `builtins`: Profile builtin functions used by standart Python modules. * `profile_thread...
python
def start(builtins=False, profile_threads=True): """Starts profiling all threads and all greenlets. This function can be called from any thread at any time. Resumes profiling if stop() was called previously. * `builtins`: Profile builtin functions used by standart Python modules. * `profile_thread...
[ "def", "start", "(", "builtins", "=", "False", ",", "profile_threads", "=", "True", ")", ":", "# TODO: what about builtins False or profile_threads False?", "_vendorized_yappi", ".", "yappi", ".", "set_context_id_callback", "(", "lambda", ":", "greenlet", "and", "id", ...
Starts profiling all threads and all greenlets. This function can be called from any thread at any time. Resumes profiling if stop() was called previously. * `builtins`: Profile builtin functions used by standart Python modules. * `profile_threads`: Profile all threads if ``True``, else profile only t...
[ "Starts", "profiling", "all", "threads", "and", "all", "greenlets", "." ]
700349864a4f368a8a73a2a60f048c2e818d7cea
https://github.com/ajdavis/GreenletProfiler/blob/700349864a4f368a8a73a2a60f048c2e818d7cea/GreenletProfiler.py#L18-L35
train
Starts profiling all threads and all greenlets.
kstaniek/condoor
condoor/protocols/telnet.py
Telnet.connect
def connect(self, driver): """Connect using the Telnet protocol specific FSM.""" # 0 1 2 3 events = [ESCAPE_CHAR, driver.press_return_re, driver.standby_re, driver.username_re, # 4 ...
python
def connect(self, driver): """Connect using the Telnet protocol specific FSM.""" # 0 1 2 3 events = [ESCAPE_CHAR, driver.press_return_re, driver.standby_re, driver.username_re, # 4 ...
[ "def", "connect", "(", "self", ",", "driver", ")", ":", "# 0 1 2 3", "events", "=", "[", "ESCAPE_CHAR", ",", "driver", ".", "press_return_re", ",", "driver", ".", "standby_re", ",", "driver", ".",...
Connect using the Telnet protocol specific FSM.
[ "Connect", "using", "the", "Telnet", "protocol", "specific", "FSM", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/protocols/telnet.py#L37-L71
train
Connect using the Telnet protocol specific FSM.
kstaniek/condoor
condoor/protocols/telnet.py
Telnet.disconnect
def disconnect(self, device): """Disconnect using protocol specific method.""" # self.device.ctrl.sendcontrol(']') # self.device.ctrl.sendline('quit') self.log("TELNET disconnect") try: self.device.ctrl.send(chr(4)) except OSError: self.log("Protoc...
python
def disconnect(self, device): """Disconnect using protocol specific method.""" # self.device.ctrl.sendcontrol(']') # self.device.ctrl.sendline('quit') self.log("TELNET disconnect") try: self.device.ctrl.send(chr(4)) except OSError: self.log("Protoc...
[ "def", "disconnect", "(", "self", ",", "device", ")", ":", "# self.device.ctrl.sendcontrol(']')", "# self.device.ctrl.sendline('quit')", "self", ".", "log", "(", "\"TELNET disconnect\"", ")", "try", ":", "self", ".", "device", ".", "ctrl", ".", "send", "(", "chr",...
Disconnect using protocol specific method.
[ "Disconnect", "using", "protocol", "specific", "method", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/protocols/telnet.py#L100-L108
train
Disconnect using protocol specific method.
kstaniek/condoor
condoor/protocols/telnet.py
TelnetConsole.disconnect
def disconnect(self, driver): """Disconnect from the console.""" self.log("TELNETCONSOLE disconnect") try: while self.device.mode != 'global': self.device.send('exit', timeout=10) except OSError: self.log("TELNETCONSOLE already disconnected") ...
python
def disconnect(self, driver): """Disconnect from the console.""" self.log("TELNETCONSOLE disconnect") try: while self.device.mode != 'global': self.device.send('exit', timeout=10) except OSError: self.log("TELNETCONSOLE already disconnected") ...
[ "def", "disconnect", "(", "self", ",", "driver", ")", ":", "self", ".", "log", "(", "\"TELNETCONSOLE disconnect\"", ")", "try", ":", "while", "self", ".", "device", ".", "mode", "!=", "'global'", ":", "self", ".", "device", ".", "send", "(", "'exit'", ...
Disconnect from the console.
[ "Disconnect", "from", "the", "console", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/protocols/telnet.py#L147-L161
train
Disconnect from the console.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
_find_date
def _find_date(filename): """Find date in recorded game default(ish) filename.""" has_date = re.search(MATCH_DATE, filename) if has_date: year = has_date.group('year') month = has_date.group('month') day = has_date.group('day') if int(year) > 2000 and int(month) in range(1, 1...
python
def _find_date(filename): """Find date in recorded game default(ish) filename.""" has_date = re.search(MATCH_DATE, filename) if has_date: year = has_date.group('year') month = has_date.group('month') day = has_date.group('day') if int(year) > 2000 and int(month) in range(1, 1...
[ "def", "_find_date", "(", "filename", ")", ":", "has_date", "=", "re", ".", "search", "(", "MATCH_DATE", ",", "filename", ")", "if", "has_date", ":", "year", "=", "has_date", ".", "group", "(", "'year'", ")", "month", "=", "has_date", ".", "group", "("...
Find date in recorded game default(ish) filename.
[ "Find", "date", "in", "recorded", "game", "default", "(", "ish", ")", "filename", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L48-L56
train
Find date in recorded game default (ish ) filename.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
_calculate_apm
def _calculate_apm(index, player_actions, other_actions, duration): """Calculate player's rAPM.""" apm_per_player = {} for player_index, histogram in player_actions.items(): apm_per_player[player_index] = sum(histogram.values()) total_unattributed = sum(other_actions.values()) total_attribut...
python
def _calculate_apm(index, player_actions, other_actions, duration): """Calculate player's rAPM.""" apm_per_player = {} for player_index, histogram in player_actions.items(): apm_per_player[player_index] = sum(histogram.values()) total_unattributed = sum(other_actions.values()) total_attribut...
[ "def", "_calculate_apm", "(", "index", ",", "player_actions", ",", "other_actions", ",", "duration", ")", ":", "apm_per_player", "=", "{", "}", "for", "player_index", ",", "histogram", "in", "player_actions", ".", "items", "(", ")", ":", "apm_per_player", "[",...
Calculate player's rAPM.
[ "Calculate", "player", "s", "rAPM", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L59-L69
train
Calculate player s rAPM.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
guess_finished
def guess_finished(summary, postgame): """Sometimes a game is finished, but not recorded as such.""" if postgame and postgame.complete: return True for player in summary['players']: if 'resign' in player['action_histogram']: return True return False
python
def guess_finished(summary, postgame): """Sometimes a game is finished, but not recorded as such.""" if postgame and postgame.complete: return True for player in summary['players']: if 'resign' in player['action_histogram']: return True return False
[ "def", "guess_finished", "(", "summary", ",", "postgame", ")", ":", "if", "postgame", "and", "postgame", ".", "complete", ":", "return", "True", "for", "player", "in", "summary", "[", "'players'", "]", ":", "if", "'resign'", "in", "player", "[", "'action_h...
Sometimes a game is finished, but not recorded as such.
[ "Sometimes", "a", "game", "is", "finished", "but", "not", "recorded", "as", "such", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L72-L79
train
Guess if a game is finished and not recorded as such.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame._num_players
def _num_players(self): """Compute number of players, both human and computer.""" self._player_num = 0 self._computer_num = 0 for player in self._header.scenario.game_settings.player_info: if player.type == 'human': self._player_num += 1 elif playe...
python
def _num_players(self): """Compute number of players, both human and computer.""" self._player_num = 0 self._computer_num = 0 for player in self._header.scenario.game_settings.player_info: if player.type == 'human': self._player_num += 1 elif playe...
[ "def", "_num_players", "(", "self", ")", ":", "self", ".", "_player_num", "=", "0", "self", ".", "_computer_num", "=", "0", "for", "player", "in", "self", ".", "_header", ".", "scenario", ".", "game_settings", ".", "player_info", ":", "if", "player", "."...
Compute number of players, both human and computer.
[ "Compute", "number", "of", "players", "both", "human", "and", "computer", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L124-L132
train
Compute number of players both human and computer.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame._parse_lobby_chat
def _parse_lobby_chat(self, messages, source, timestamp): """Parse a lobby chat message.""" for message in messages: if message.message_length == 0: continue chat = ChatMessage(message.message, timestamp, self._players(), source=source) self._parse_cha...
python
def _parse_lobby_chat(self, messages, source, timestamp): """Parse a lobby chat message.""" for message in messages: if message.message_length == 0: continue chat = ChatMessage(message.message, timestamp, self._players(), source=source) self._parse_cha...
[ "def", "_parse_lobby_chat", "(", "self", ",", "messages", ",", "source", ",", "timestamp", ")", ":", "for", "message", "in", "messages", ":", "if", "message", ".", "message_length", "==", "0", ":", "continue", "chat", "=", "ChatMessage", "(", "message", "....
Parse a lobby chat message.
[ "Parse", "a", "lobby", "chat", "message", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L134-L140
train
Parse a lobby chat message.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame._parse_action
def _parse_action(self, action, current_time): """Parse a player action. TODO: handle cancels """ if action.action_type == 'research': name = mgz.const.TECHNOLOGIES[action.data.technology_type] self._research[action.data.player_id].append({ 'techn...
python
def _parse_action(self, action, current_time): """Parse a player action. TODO: handle cancels """ if action.action_type == 'research': name = mgz.const.TECHNOLOGIES[action.data.technology_type] self._research[action.data.player_id].append({ 'techn...
[ "def", "_parse_action", "(", "self", ",", "action", ",", "current_time", ")", ":", "if", "action", ".", "action_type", "==", "'research'", ":", "name", "=", "mgz", ".", "const", ".", "TECHNOLOGIES", "[", "action", ".", "data", ".", "technology_type", "]", ...
Parse a player action. TODO: handle cancels
[ "Parse", "a", "player", "action", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L142-L164
train
Parse a player action.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame.operations
def operations(self, op_types=None): """Process operation stream.""" if not op_types: op_types = ['message', 'action', 'sync', 'viewlock', 'savedchapter'] while self._handle.tell() < self._eof: current_time = mgz.util.convert_to_timestamp(self._time / 1000) tr...
python
def operations(self, op_types=None): """Process operation stream.""" if not op_types: op_types = ['message', 'action', 'sync', 'viewlock', 'savedchapter'] while self._handle.tell() < self._eof: current_time = mgz.util.convert_to_timestamp(self._time / 1000) tr...
[ "def", "operations", "(", "self", ",", "op_types", "=", "None", ")", ":", "if", "not", "op_types", ":", "op_types", "=", "[", "'message'", ",", "'action'", ",", "'sync'", ",", "'viewlock'", ",", "'savedchapter'", "]", "while", "self", ".", "_handle", "."...
Process operation stream.
[ "Process", "operation", "stream", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L167-L207
train
Yields all the operations in the stream.