repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
CZ-NIC/python-rt
rt.py
Rt.create_ticket
def create_ticket(self, Queue=None, files=[], **kwargs): """ Create new ticket and set given parameters. Example of message sended to ``http://tracker.example.com/REST/1.0/ticket/new``:: content=id: ticket/new Queue: General Owner: Nobody Requestors: som...
python
def create_ticket(self, Queue=None, files=[], **kwargs): """ Create new ticket and set given parameters. Example of message sended to ``http://tracker.example.com/REST/1.0/ticket/new``:: content=id: ticket/new Queue: General Owner: Nobody Requestors: som...
[ "def", "create_ticket", "(", "self", ",", "Queue", "=", "None", ",", "files", "=", "[", "]", ",", "**", "kwargs", ")", ":", "post_data", "=", "'id: ticket/new\\nQueue: {}\\n'", ".", "format", "(", "Queue", "or", "self", ".", "default_queue", ",", ")", "f...
Create new ticket and set given parameters. Example of message sended to ``http://tracker.example.com/REST/1.0/ticket/new``:: content=id: ticket/new Queue: General Owner: Nobody Requestors: somebody@example.com Subject: Ticket created through REST AP...
[ "Create", "new", "ticket", "and", "set", "given", "parameters", "." ]
e7a9f555e136708aec3317f857045145a2271e16
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L642-L700
train
CZ-NIC/python-rt
rt.py
Rt.edit_ticket
def edit_ticket(self, ticket_id, **kwargs): """ Edit ticket values. :param ticket_id: ID of ticket to edit :keyword kwargs: Other arguments possible to set: Requestors, Subject, Cc, AdminCc, Owner, Status, Priority, InitialPriority, FinalPriori...
python
def edit_ticket(self, ticket_id, **kwargs): """ Edit ticket values. :param ticket_id: ID of ticket to edit :keyword kwargs: Other arguments possible to set: Requestors, Subject, Cc, AdminCc, Owner, Status, Priority, InitialPriority, FinalPriori...
[ "def", "edit_ticket", "(", "self", ",", "ticket_id", ",", "**", "kwargs", ")", ":", "post_data", "=", "''", "for", "key", ",", "value", "in", "iteritems", "(", "kwargs", ")", ":", "if", "isinstance", "(", "value", ",", "(", "list", ",", "tuple", ")",...
Edit ticket values. :param ticket_id: ID of ticket to edit :keyword kwargs: Other arguments possible to set: Requestors, Subject, Cc, AdminCc, Owner, Status, Priority, InitialPriority, FinalPriority, TimeEstimated, Starts, Due,...
[ "Edit", "ticket", "values", "." ]
e7a9f555e136708aec3317f857045145a2271e16
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L702-L731
train
CZ-NIC/python-rt
rt.py
Rt.get_history
def get_history(self, ticket_id, transaction_id=None): """ Get set of history items. :param ticket_id: ID of ticket :keyword transaction_id: If set to None, all history items are returned, if set to ID of valid transaction just o...
python
def get_history(self, ticket_id, transaction_id=None): """ Get set of history items. :param ticket_id: ID of ticket :keyword transaction_id: If set to None, all history items are returned, if set to ID of valid transaction just o...
[ "def", "get_history", "(", "self", ",", "ticket_id", ",", "transaction_id", "=", "None", ")", ":", "if", "transaction_id", "is", "None", ":", "msgs", "=", "self", ".", "__request", "(", "'ticket/{}/history?format=l'", ".", "format", "(", "str", "(", "ticket_...
Get set of history items. :param ticket_id: ID of ticket :keyword transaction_id: If set to None, all history items are returned, if set to ID of valid transaction just one history item is returned :returns: List of history item...
[ "Get", "set", "of", "history", "items", "." ]
e7a9f555e136708aec3317f857045145a2271e16
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L733-L801
train
CZ-NIC/python-rt
rt.py
Rt.get_short_history
def get_short_history(self, ticket_id): """ Get set of short history items :param ticket_id: ID of ticket :returns: List of history items ordered increasingly by time of event. Each history item is a tuple containing (id, Description). Returns None if ticket ...
python
def get_short_history(self, ticket_id): """ Get set of short history items :param ticket_id: ID of ticket :returns: List of history items ordered increasingly by time of event. Each history item is a tuple containing (id, Description). Returns None if ticket ...
[ "def", "get_short_history", "(", "self", ",", "ticket_id", ")", ":", "msg", "=", "self", ".", "__request", "(", "'ticket/{}/history'", ".", "format", "(", "str", "(", "ticket_id", ")", ",", ")", ")", "items", "=", "[", "]", "lines", "=", "msg", ".", ...
Get set of short history items :param ticket_id: ID of ticket :returns: List of history items ordered increasingly by time of event. Each history item is a tuple containing (id, Description). Returns None if ticket does not exist.
[ "Get", "set", "of", "short", "history", "items" ]
e7a9f555e136708aec3317f857045145a2271e16
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L803-L837
train
CZ-NIC/python-rt
rt.py
Rt.reply
def reply(self, ticket_id, text='', cc='', bcc='', content_type='text/plain', files=[]): """ Sends email message to the contacts in ``Requestors`` field of given ticket with subject as is set in ``Subject`` field. Form of message according to documentation:: id: <ticket-id> ...
python
def reply(self, ticket_id, text='', cc='', bcc='', content_type='text/plain', files=[]): """ Sends email message to the contacts in ``Requestors`` field of given ticket with subject as is set in ``Subject`` field. Form of message according to documentation:: id: <ticket-id> ...
[ "def", "reply", "(", "self", ",", "ticket_id", ",", "text", "=", "''", ",", "cc", "=", "''", ",", "bcc", "=", "''", ",", "content_type", "=", "'text/plain'", ",", "files", "=", "[", "]", ")", ":", "return", "self", ".", "__correspond", "(", "ticket...
Sends email message to the contacts in ``Requestors`` field of given ticket with subject as is set in ``Subject`` field. Form of message according to documentation:: id: <ticket-id> Action: correspond Text: the text comment second line starts with ...
[ "Sends", "email", "message", "to", "the", "contacts", "in", "Requestors", "field", "of", "given", "ticket", "with", "subject", "as", "is", "set", "in", "Subject", "field", "." ]
e7a9f555e136708aec3317f857045145a2271e16
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L868-L896
train
CZ-NIC/python-rt
rt.py
Rt.get_attachments
def get_attachments(self, ticket_id): """ Get attachment list for a given ticket :param ticket_id: ID of ticket :returns: List of tuples for attachments belonging to given ticket. Tuple format: (id, name, content_type, size) Returns None if ticket does not ex...
python
def get_attachments(self, ticket_id): """ Get attachment list for a given ticket :param ticket_id: ID of ticket :returns: List of tuples for attachments belonging to given ticket. Tuple format: (id, name, content_type, size) Returns None if ticket does not ex...
[ "def", "get_attachments", "(", "self", ",", "ticket_id", ")", ":", "msg", "=", "self", ".", "__request", "(", "'ticket/{}/attachments'", ".", "format", "(", "str", "(", "ticket_id", ")", ",", ")", ")", "lines", "=", "msg", ".", "split", "(", "'\\n'", "...
Get attachment list for a given ticket :param ticket_id: ID of ticket :returns: List of tuples for attachments belonging to given ticket. Tuple format: (id, name, content_type, size) Returns None if ticket does not exist.
[ "Get", "attachment", "list", "for", "a", "given", "ticket" ]
e7a9f555e136708aec3317f857045145a2271e16
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L933-L951
train
CZ-NIC/python-rt
rt.py
Rt.get_attachments_ids
def get_attachments_ids(self, ticket_id): """ Get IDs of attachments for given ticket. :param ticket_id: ID of ticket :returns: List of IDs (type int) of attachments belonging to given ticket. Returns None if ticket does not exist. """ attachments = self.get_at...
python
def get_attachments_ids(self, ticket_id): """ Get IDs of attachments for given ticket. :param ticket_id: ID of ticket :returns: List of IDs (type int) of attachments belonging to given ticket. Returns None if ticket does not exist. """ attachments = self.get_at...
[ "def", "get_attachments_ids", "(", "self", ",", "ticket_id", ")", ":", "attachments", "=", "self", ".", "get_attachments", "(", "ticket_id", ")", "return", "[", "int", "(", "at", "[", "0", "]", ")", "for", "at", "in", "attachments", "]", "if", "attachmen...
Get IDs of attachments for given ticket. :param ticket_id: ID of ticket :returns: List of IDs (type int) of attachments belonging to given ticket. Returns None if ticket does not exist.
[ "Get", "IDs", "of", "attachments", "for", "given", "ticket", "." ]
e7a9f555e136708aec3317f857045145a2271e16
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L953-L961
train
CZ-NIC/python-rt
rt.py
Rt.get_attachment
def get_attachment(self, ticket_id, attachment_id): """ Get attachment. :param ticket_id: ID of ticket :param attachment_id: ID of attachment for obtain :returns: Attachment as dictionary with these keys: * Transaction * ContentType ...
python
def get_attachment(self, ticket_id, attachment_id): """ Get attachment. :param ticket_id: ID of ticket :param attachment_id: ID of attachment for obtain :returns: Attachment as dictionary with these keys: * Transaction * ContentType ...
[ "def", "get_attachment", "(", "self", ",", "ticket_id", ",", "attachment_id", ")", ":", "msg", "=", "self", ".", "__request", "(", "'ticket/{}/attachments/{}'", ".", "format", "(", "str", "(", "ticket_id", ")", ",", "str", "(", "attachment_id", ")", ")", "...
Get attachment. :param ticket_id: ID of ticket :param attachment_id: ID of attachment for obtain :returns: Attachment as dictionary with these keys: * Transaction * ContentType * Parent * Creator ...
[ "Get", "attachment", "." ]
e7a9f555e136708aec3317f857045145a2271e16
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L963-L1051
train
CZ-NIC/python-rt
rt.py
Rt.get_attachment_content
def get_attachment_content(self, ticket_id, attachment_id): """ Get content of attachment without headers. This function is necessary to use for binary attachment, as it can contain ``\\n`` chars, which would disrupt parsing of message if :py:meth:`~Rt.get_attachment` is used. ...
python
def get_attachment_content(self, ticket_id, attachment_id): """ Get content of attachment without headers. This function is necessary to use for binary attachment, as it can contain ``\\n`` chars, which would disrupt parsing of message if :py:meth:`~Rt.get_attachment` is used. ...
[ "def", "get_attachment_content", "(", "self", ",", "ticket_id", ",", "attachment_id", ")", ":", "msg", "=", "self", ".", "__request", "(", "'ticket/{}/attachments/{}/content'", ".", "format", "(", "str", "(", "ticket_id", ")", ",", "str", "(", "attachment_id", ...
Get content of attachment without headers. This function is necessary to use for binary attachment, as it can contain ``\\n`` chars, which would disrupt parsing of message if :py:meth:`~Rt.get_attachment` is used. Format of message:: RT/3.8.7 200 Ok\n\nStart of the content...
[ "Get", "content", "of", "attachment", "without", "headers", "." ]
e7a9f555e136708aec3317f857045145a2271e16
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L1053-L1077
train
CZ-NIC/python-rt
rt.py
Rt.get_user
def get_user(self, user_id): """ Get user details. :param user_id: Identification of user by username (str) or user ID (int) :returns: User details as strings in dictionary with these keys for RT users: * Lang ...
python
def get_user(self, user_id): """ Get user details. :param user_id: Identification of user by username (str) or user ID (int) :returns: User details as strings in dictionary with these keys for RT users: * Lang ...
[ "def", "get_user", "(", "self", ",", "user_id", ")", ":", "msg", "=", "self", ".", "__request", "(", "'user/{}'", ".", "format", "(", "str", "(", "user_id", ")", ",", ")", ")", "status_code", "=", "self", ".", "__get_status_code", "(", "msg", ")", "i...
Get user details. :param user_id: Identification of user by username (str) or user ID (int) :returns: User details as strings in dictionary with these keys for RT users: * Lang * RealName * Priv...
[ "Get", "user", "details", "." ]
e7a9f555e136708aec3317f857045145a2271e16
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L1079-L1123
train
CZ-NIC/python-rt
rt.py
Rt.get_links
def get_links(self, ticket_id): """ Gets the ticket links for a single ticket. :param ticket_id: ticket ID :returns: Links as lists of strings in dictionary with these keys (just those which are defined): * id * Members ...
python
def get_links(self, ticket_id): """ Gets the ticket links for a single ticket. :param ticket_id: ticket ID :returns: Links as lists of strings in dictionary with these keys (just those which are defined): * id * Members ...
[ "def", "get_links", "(", "self", ",", "ticket_id", ")", ":", "msg", "=", "self", ".", "__request", "(", "'ticket/{}/links/show'", ".", "format", "(", "str", "(", "ticket_id", ")", ",", ")", ")", "status_code", "=", "self", ".", "__get_status_code", "(", ...
Gets the ticket links for a single ticket. :param ticket_id: ticket ID :returns: Links as lists of strings in dictionary with these keys (just those which are defined): * id * Members * MemberOf *...
[ "Gets", "the", "ticket", "links", "for", "a", "single", "ticket", "." ]
e7a9f555e136708aec3317f857045145a2271e16
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L1286-L1329
train
CZ-NIC/python-rt
rt.py
Rt.edit_ticket_links
def edit_ticket_links(self, ticket_id, **kwargs): """ Edit ticket links. .. warning:: This method is deprecated in favour of edit_link method, because there exists bug in RT 3.8 REST API causing mapping created links to ticket/1. The only drawback is that edit_link cannot process ...
python
def edit_ticket_links(self, ticket_id, **kwargs): """ Edit ticket links. .. warning:: This method is deprecated in favour of edit_link method, because there exists bug in RT 3.8 REST API causing mapping created links to ticket/1. The only drawback is that edit_link cannot process ...
[ "def", "edit_ticket_links", "(", "self", ",", "ticket_id", ",", "**", "kwargs", ")", ":", "post_data", "=", "''", "for", "key", "in", "kwargs", ":", "post_data", "+=", "\"{}: {}\\n\"", ".", "format", "(", "key", ",", "str", "(", "kwargs", "[", "key", "...
Edit ticket links. .. warning:: This method is deprecated in favour of edit_link method, because there exists bug in RT 3.8 REST API causing mapping created links to ticket/1. The only drawback is that edit_link cannot process multiple links all at once. :param ticket_...
[ "Edit", "ticket", "links", "." ]
e7a9f555e136708aec3317f857045145a2271e16
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L1331-L1357
train
CZ-NIC/python-rt
rt.py
Rt.split_header
def split_header(line): """ Split a header line into field name and field value. Note that custom fields may contain colons inside the curly braces, so we need a special test for them. :param line: A message line to be split. :returns: (Field name, field value) tuple. ...
python
def split_header(line): """ Split a header line into field name and field value. Note that custom fields may contain colons inside the curly braces, so we need a special test for them. :param line: A message line to be split. :returns: (Field name, field value) tuple. ...
[ "def", "split_header", "(", "line", ")", ":", "match", "=", "re", ".", "match", "(", "r'^(CF\\.\\{.*?}): (.*)$'", ",", "line", ")", "if", "match", ":", "return", "(", "match", ".", "group", "(", "1", ")", ",", "match", ".", "group", "(", "2", ")", ...
Split a header line into field name and field value. Note that custom fields may contain colons inside the curly braces, so we need a special test for them. :param line: A message line to be split. :returns: (Field name, field value) tuple.
[ "Split", "a", "header", "line", "into", "field", "name", "and", "field", "value", "." ]
e7a9f555e136708aec3317f857045145a2271e16
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L1450-L1463
train
CityOfZion/neo-python-core
neocore/KeyPair.py
KeyPair.PrivateKeyFromWIF
def PrivateKeyFromWIF(wif): """ Get the private key from a WIF key Args: wif (str): The wif key Returns: bytes: The private key """ if wif is None or len(wif) is not 52: raise ValueError('Please provide a wif with a length of 52 bytes...
python
def PrivateKeyFromWIF(wif): """ Get the private key from a WIF key Args: wif (str): The wif key Returns: bytes: The private key """ if wif is None or len(wif) is not 52: raise ValueError('Please provide a wif with a length of 52 bytes...
[ "def", "PrivateKeyFromWIF", "(", "wif", ")", ":", "if", "wif", "is", "None", "or", "len", "(", "wif", ")", "is", "not", "52", ":", "raise", "ValueError", "(", "'Please provide a wif with a length of 52 bytes (LEN: {0:d})'", ".", "format", "(", "len", "(", "wif...
Get the private key from a WIF key Args: wif (str): The wif key Returns: bytes: The private key
[ "Get", "the", "private", "key", "from", "a", "WIF", "key" ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/KeyPair.py#L81-L106
train
CityOfZion/neo-python-core
neocore/KeyPair.py
KeyPair.PrivateKeyFromNEP2
def PrivateKeyFromNEP2(nep2_key, passphrase): """ Gets the private key from a NEP-2 encrypted private key Args: nep2_key (str): The nep-2 encrypted private key passphrase (str): The password to encrypt the private key with, as unicode string Returns: ...
python
def PrivateKeyFromNEP2(nep2_key, passphrase): """ Gets the private key from a NEP-2 encrypted private key Args: nep2_key (str): The nep-2 encrypted private key passphrase (str): The password to encrypt the private key with, as unicode string Returns: ...
[ "def", "PrivateKeyFromNEP2", "(", "nep2_key", ",", "passphrase", ")", ":", "if", "not", "nep2_key", "or", "len", "(", "nep2_key", ")", "!=", "58", ":", "raise", "ValueError", "(", "'Please provide a nep2_key with a length of 58 bytes (LEN: {0:d})'", ".", "format", "...
Gets the private key from a NEP-2 encrypted private key Args: nep2_key (str): The nep-2 encrypted private key passphrase (str): The password to encrypt the private key with, as unicode string Returns: bytes: The private key
[ "Gets", "the", "private", "key", "from", "a", "NEP", "-", "2", "encrypted", "private", "key" ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/KeyPair.py#L109-L157
train
CityOfZion/neo-python-core
neocore/KeyPair.py
KeyPair.GetAddress
def GetAddress(self): """ Returns the public NEO address for this KeyPair Returns: str: The private key """ script = b'21' + self.PublicKey.encode_point(True) + b'ac' script_hash = Crypto.ToScriptHash(script) address = Crypto.ToAddress(script_hash) ...
python
def GetAddress(self): """ Returns the public NEO address for this KeyPair Returns: str: The private key """ script = b'21' + self.PublicKey.encode_point(True) + b'ac' script_hash = Crypto.ToScriptHash(script) address = Crypto.ToAddress(script_hash) ...
[ "def", "GetAddress", "(", "self", ")", ":", "script", "=", "b'21'", "+", "self", ".", "PublicKey", ".", "encode_point", "(", "True", ")", "+", "b'ac'", "script_hash", "=", "Crypto", ".", "ToScriptHash", "(", "script", ")", "address", "=", "Crypto", ".", ...
Returns the public NEO address for this KeyPair Returns: str: The private key
[ "Returns", "the", "public", "NEO", "address", "for", "this", "KeyPair" ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/KeyPair.py#L159-L169
train
CityOfZion/neo-python-core
neocore/KeyPair.py
KeyPair.Export
def Export(self): """ Export this KeyPair's private key in WIF format. Returns: str: The key in wif format """ data = bytearray(38) data[0] = 0x80 data[1:33] = self.PrivateKey[0:32] data[33] = 0x01 checksum = Crypto.Default().Hash256(...
python
def Export(self): """ Export this KeyPair's private key in WIF format. Returns: str: The key in wif format """ data = bytearray(38) data[0] = 0x80 data[1:33] = self.PrivateKey[0:32] data[33] = 0x01 checksum = Crypto.Default().Hash256(...
[ "def", "Export", "(", "self", ")", ":", "data", "=", "bytearray", "(", "38", ")", "data", "[", "0", "]", "=", "0x80", "data", "[", "1", ":", "33", "]", "=", "self", ".", "PrivateKey", "[", "0", ":", "32", "]", "data", "[", "33", "]", "=", "...
Export this KeyPair's private key in WIF format. Returns: str: The key in wif format
[ "Export", "this", "KeyPair", "s", "private", "key", "in", "WIF", "format", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/KeyPair.py#L171-L187
train
CityOfZion/neo-python-core
neocore/KeyPair.py
KeyPair.ExportNEP2
def ExportNEP2(self, passphrase): """ Export the encrypted private key in NEP-2 format. Args: passphrase (str): The password to encrypt the private key with, as unicode string Returns: str: The NEP-2 encrypted private key """ if len(passphrase) <...
python
def ExportNEP2(self, passphrase): """ Export the encrypted private key in NEP-2 format. Args: passphrase (str): The password to encrypt the private key with, as unicode string Returns: str: The NEP-2 encrypted private key """ if len(passphrase) <...
[ "def", "ExportNEP2", "(", "self", ",", "passphrase", ")", ":", "if", "len", "(", "passphrase", ")", "<", "2", ":", "raise", "ValueError", "(", "\"Passphrase must have a minimum of 2 characters\"", ")", "address_hash_tmp", "=", "hashlib", ".", "sha256", "(", "sel...
Export the encrypted private key in NEP-2 format. Args: passphrase (str): The password to encrypt the private key with, as unicode string Returns: str: The NEP-2 encrypted private key
[ "Export", "the", "encrypted", "private", "key", "in", "NEP", "-", "2", "format", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/KeyPair.py#L189-L233
train
CityOfZion/neo-python-core
neocore/IO/BinaryReader.py
BinaryReader.ReadByte
def ReadByte(self, do_ord=True): """ Read a single byte. Args: do_ord (bool): (default True) convert the byte to an ordinal first. Returns: bytes: a single byte if successful. 0 (int) if an exception occurred. """ try: if do_ord: ...
python
def ReadByte(self, do_ord=True): """ Read a single byte. Args: do_ord (bool): (default True) convert the byte to an ordinal first. Returns: bytes: a single byte if successful. 0 (int) if an exception occurred. """ try: if do_ord: ...
[ "def", "ReadByte", "(", "self", ",", "do_ord", "=", "True", ")", ":", "try", ":", "if", "do_ord", ":", "return", "ord", "(", "self", ".", "stream", ".", "read", "(", "1", ")", ")", "return", "self", ".", "stream", ".", "read", "(", "1", ")", "e...
Read a single byte. Args: do_ord (bool): (default True) convert the byte to an ordinal first. Returns: bytes: a single byte if successful. 0 (int) if an exception occurred.
[ "Read", "a", "single", "byte", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/IO/BinaryReader.py#L46-L62
train
CityOfZion/neo-python-core
neocore/IO/BinaryReader.py
BinaryReader.SafeReadBytes
def SafeReadBytes(self, length): """ Read exactly `length` number of bytes from the stream. Raises: ValueError is not enough data Returns: bytes: `length` number of bytes """ data = self.ReadBytes(length) if len(data) < length: ...
python
def SafeReadBytes(self, length): """ Read exactly `length` number of bytes from the stream. Raises: ValueError is not enough data Returns: bytes: `length` number of bytes """ data = self.ReadBytes(length) if len(data) < length: ...
[ "def", "SafeReadBytes", "(", "self", ",", "length", ")", ":", "data", "=", "self", ".", "ReadBytes", "(", "length", ")", "if", "len", "(", "data", ")", "<", "length", ":", "raise", "ValueError", "(", "\"Not enough data available\"", ")", "else", ":", "re...
Read exactly `length` number of bytes from the stream. Raises: ValueError is not enough data Returns: bytes: `length` number of bytes
[ "Read", "exactly", "length", "number", "of", "bytes", "from", "the", "stream", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/IO/BinaryReader.py#L77-L91
train
CityOfZion/neo-python-core
neocore/Cryptography/Crypto.py
Crypto.ToScriptHash
def ToScriptHash(data, unhex=True): """ Get a script hash of the data. Args: data (bytes): data to hash. unhex (bool): (Default) True. Set to unhexlify the stream. Use when the bytes are not raw bytes; i.e. b'aabb' Returns: UInt160: script hash. ...
python
def ToScriptHash(data, unhex=True): """ Get a script hash of the data. Args: data (bytes): data to hash. unhex (bool): (Default) True. Set to unhexlify the stream. Use when the bytes are not raw bytes; i.e. b'aabb' Returns: UInt160: script hash. ...
[ "def", "ToScriptHash", "(", "data", ",", "unhex", "=", "True", ")", ":", "if", "len", "(", "data", ")", ">", "1", "and", "unhex", ":", "data", "=", "binascii", ".", "unhexlify", "(", "data", ")", "return", "UInt160", "(", "data", "=", "binascii", "...
Get a script hash of the data. Args: data (bytes): data to hash. unhex (bool): (Default) True. Set to unhexlify the stream. Use when the bytes are not raw bytes; i.e. b'aabb' Returns: UInt160: script hash.
[ "Get", "a", "script", "hash", "of", "the", "data", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/Crypto.py#L77-L90
train
CityOfZion/neo-python-core
neocore/Cryptography/Crypto.py
Crypto.Sign
def Sign(message, private_key): """ Sign the message with the given private key. Args: message (str): message to be signed private_key (str): 32 byte key as a double digit hex string (e.g. having a length of 64) Returns: bytearray: the signature of th...
python
def Sign(message, private_key): """ Sign the message with the given private key. Args: message (str): message to be signed private_key (str): 32 byte key as a double digit hex string (e.g. having a length of 64) Returns: bytearray: the signature of th...
[ "def", "Sign", "(", "message", ",", "private_key", ")", ":", "hash", "=", "hashlib", ".", "sha256", "(", "binascii", ".", "unhexlify", "(", "message", ")", ")", ".", "hexdigest", "(", ")", "v", ",", "r", ",", "s", "=", "bitcoin", ".", "ecdsa_raw_sign...
Sign the message with the given private key. Args: message (str): message to be signed private_key (str): 32 byte key as a double digit hex string (e.g. having a length of 64) Returns: bytearray: the signature of the message.
[ "Sign", "the", "message", "with", "the", "given", "private", "key", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/Crypto.py#L106-L126
train
CityOfZion/neo-python-core
neocore/Cryptography/ECCurve.py
FiniteField.sqrt
def sqrt(self, val, flag): """ calculate the square root modulus p """ if val.iszero(): return val sw = self.p % 8 if sw == 3 or sw == 7: res = val ** ((self.p + 1) / 4) elif sw == 5: x = val ** ((self.p + 1) / 4) if...
python
def sqrt(self, val, flag): """ calculate the square root modulus p """ if val.iszero(): return val sw = self.p % 8 if sw == 3 or sw == 7: res = val ** ((self.p + 1) / 4) elif sw == 5: x = val ** ((self.p + 1) / 4) if...
[ "def", "sqrt", "(", "self", ",", "val", ",", "flag", ")", ":", "if", "val", ".", "iszero", "(", ")", ":", "return", "val", "sw", "=", "self", ".", "p", "%", "8", "if", "sw", "==", "3", "or", "sw", "==", "7", ":", "res", "=", "val", "**", ...
calculate the square root modulus p
[ "calculate", "the", "square", "root", "modulus", "p" ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L287-L308
train
CityOfZion/neo-python-core
neocore/Cryptography/ECCurve.py
FiniteField.value
def value(self, x): """ converts an integer or FinitField.Value to a value of this FiniteField. """ return x if isinstance(x, FiniteField.Value) and x.field == self else FiniteField.Value(self, x)
python
def value(self, x): """ converts an integer or FinitField.Value to a value of this FiniteField. """ return x if isinstance(x, FiniteField.Value) and x.field == self else FiniteField.Value(self, x)
[ "def", "value", "(", "self", ",", "x", ")", ":", "return", "x", "if", "isinstance", "(", "x", ",", "FiniteField", ".", "Value", ")", "and", "x", ".", "field", "==", "self", "else", "FiniteField", ".", "Value", "(", "self", ",", "x", ")" ]
converts an integer or FinitField.Value to a value of this FiniteField.
[ "converts", "an", "integer", "or", "FinitField", ".", "Value", "to", "a", "value", "of", "this", "FiniteField", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L316-L320
train
CityOfZion/neo-python-core
neocore/Cryptography/ECCurve.py
FiniteField.integer
def integer(self, x): """ returns a plain integer """ if type(x) is str: hex = binascii.unhexlify(x) return int.from_bytes(hex, 'big') return x.value if isinstance(x, FiniteField.Value) else x
python
def integer(self, x): """ returns a plain integer """ if type(x) is str: hex = binascii.unhexlify(x) return int.from_bytes(hex, 'big') return x.value if isinstance(x, FiniteField.Value) else x
[ "def", "integer", "(", "self", ",", "x", ")", ":", "if", "type", "(", "x", ")", "is", "str", ":", "hex", "=", "binascii", ".", "unhexlify", "(", "x", ")", "return", "int", ".", "from_bytes", "(", "hex", ",", "'big'", ")", "return", "x", ".", "v...
returns a plain integer
[ "returns", "a", "plain", "integer" ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L322-L330
train
CityOfZion/neo-python-core
neocore/Cryptography/ECCurve.py
EllipticCurve.add
def add(self, p, q): """ perform elliptic curve addition """ if p.iszero(): return q if q.iszero(): return p lft = 0 # calculate the slope of the intersection line if p == q: if p.y == 0: return self.zer...
python
def add(self, p, q): """ perform elliptic curve addition """ if p.iszero(): return q if q.iszero(): return p lft = 0 # calculate the slope of the intersection line if p == q: if p.y == 0: return self.zer...
[ "def", "add", "(", "self", ",", "p", ",", "q", ")", ":", "if", "p", ".", "iszero", "(", ")", ":", "return", "q", "if", "q", ".", "iszero", "(", ")", ":", "return", "p", "lft", "=", "0", "if", "p", "==", "q", ":", "if", "p", ".", "y", "=...
perform elliptic curve addition
[ "perform", "elliptic", "curve", "addition" ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L486-L509
train
CityOfZion/neo-python-core
neocore/Cryptography/ECCurve.py
EllipticCurve.point
def point(self, x, y): """ construct a point from 2 values """ return EllipticCurve.ECPoint(self, self.field.value(x), self.field.value(y))
python
def point(self, x, y): """ construct a point from 2 values """ return EllipticCurve.ECPoint(self, self.field.value(x), self.field.value(y))
[ "def", "point", "(", "self", ",", "x", ",", "y", ")", ":", "return", "EllipticCurve", ".", "ECPoint", "(", "self", ",", "self", ".", "field", ".", "value", "(", "x", ")", ",", "self", ".", "field", ".", "value", "(", "y", ")", ")" ]
construct a point from 2 values
[ "construct", "a", "point", "from", "2", "values" ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L550-L554
train
CityOfZion/neo-python-core
neocore/Cryptography/ECCurve.py
EllipticCurve.isoncurve
def isoncurve(self, p): """ verifies if a point is on the curve """ return p.iszero() or p.y ** 2 == p.x ** 3 + self.a * p.x + self.b
python
def isoncurve(self, p): """ verifies if a point is on the curve """ return p.iszero() or p.y ** 2 == p.x ** 3 + self.a * p.x + self.b
[ "def", "isoncurve", "(", "self", ",", "p", ")", ":", "return", "p", ".", "iszero", "(", ")", "or", "p", ".", "y", "**", "2", "==", "p", ".", "x", "**", "3", "+", "self", ".", "a", "*", "p", ".", "x", "+", "self", ".", "b" ]
verifies if a point is on the curve
[ "verifies", "if", "a", "point", "is", "on", "the", "curve" ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L556-L560
train
CityOfZion/neo-python-core
neocore/Cryptography/ECCurve.py
ECDSA.secp256r1
def secp256r1(): """ create the secp256r1 curve """ GFp = FiniteField(int("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", 16)) ec = EllipticCurve(GFp, 115792089210356248762697446949407573530086143415290314195533631308867097853948, 41058363725152142129326129780...
python
def secp256r1(): """ create the secp256r1 curve """ GFp = FiniteField(int("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", 16)) ec = EllipticCurve(GFp, 115792089210356248762697446949407573530086143415290314195533631308867097853948, 41058363725152142129326129780...
[ "def", "secp256r1", "(", ")", ":", "GFp", "=", "FiniteField", "(", "int", "(", "\"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF\"", ",", "16", ")", ")", "ec", "=", "EllipticCurve", "(", "GFp", ",", "115792089210356248762697446949407573530086143415290314...
create the secp256r1 curve
[ "create", "the", "secp256r1", "curve" ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L805-L814
train
CityOfZion/neo-python-core
neocore/Cryptography/ECCurve.py
ECDSA.decode_secp256r1
def decode_secp256r1(str, unhex=True, check_on_curve=True): """ decode a public key on the secp256r1 curve """ GFp = FiniteField(int("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", 16)) ec = EllipticCurve(GFp, 1157920892103562487626974469494075735300861434152...
python
def decode_secp256r1(str, unhex=True, check_on_curve=True): """ decode a public key on the secp256r1 curve """ GFp = FiniteField(int("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", 16)) ec = EllipticCurve(GFp, 1157920892103562487626974469494075735300861434152...
[ "def", "decode_secp256r1", "(", "str", ",", "unhex", "=", "True", ",", "check_on_curve", "=", "True", ")", ":", "GFp", "=", "FiniteField", "(", "int", "(", "\"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF\"", ",", "16", ")", ")", "ec", "=", "E...
decode a public key on the secp256r1 curve
[ "decode", "a", "public", "key", "on", "the", "secp256r1", "curve" ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L817-L834
train
CityOfZion/neo-python-core
neocore/Cryptography/ECCurve.py
ECDSA.secp256k1
def secp256k1(): """ create the secp256k1 curve """ GFp = FiniteField(2 ** 256 - 2 ** 32 - 977) # This is P from below... aka FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F ec = EllipticCurve(GFp, 0, 7) return ECDSA(ec, ec.point(0x79BE667EF9DCBBAC55A062...
python
def secp256k1(): """ create the secp256k1 curve """ GFp = FiniteField(2 ** 256 - 2 ** 32 - 977) # This is P from below... aka FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F ec = EllipticCurve(GFp, 0, 7) return ECDSA(ec, ec.point(0x79BE667EF9DCBBAC55A062...
[ "def", "secp256k1", "(", ")", ":", "GFp", "=", "FiniteField", "(", "2", "**", "256", "-", "2", "**", "32", "-", "977", ")", "ec", "=", "EllipticCurve", "(", "GFp", ",", "0", ",", "7", ")", "return", "ECDSA", "(", "ec", ",", "ec", ".", "point", ...
create the secp256k1 curve
[ "create", "the", "secp256k1", "curve" ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L864-L870
train
CityOfZion/neo-python-core
neocore/Utils.py
isValidPublicAddress
def isValidPublicAddress(address: str) -> bool: """Check if address is a valid NEO address""" valid = False if len(address) == 34 and address[0] == 'A': try: base58.b58decode_check(address.encode()) valid = True except ValueError: # checksum mismatch ...
python
def isValidPublicAddress(address: str) -> bool: """Check if address is a valid NEO address""" valid = False if len(address) == 34 and address[0] == 'A': try: base58.b58decode_check(address.encode()) valid = True except ValueError: # checksum mismatch ...
[ "def", "isValidPublicAddress", "(", "address", ":", "str", ")", "->", "bool", ":", "valid", "=", "False", "if", "len", "(", "address", ")", "==", "34", "and", "address", "[", "0", "]", "==", "'A'", ":", "try", ":", "base58", ".", "b58decode_check", "...
Check if address is a valid NEO address
[ "Check", "if", "address", "is", "a", "valid", "NEO", "address" ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Utils.py#L4-L16
train
CityOfZion/neo-python-core
neocore/Cryptography/MerkleTree.py
MerkleTree.__Build
def __Build(leaves): """ Build the merkle tree. Args: leaves (list): items are of type MerkleTreeNode. Returns: MerkleTreeNode: the root node. """ if len(leaves) < 1: raise Exception('Leaves must have length') if len(leaves) =...
python
def __Build(leaves): """ Build the merkle tree. Args: leaves (list): items are of type MerkleTreeNode. Returns: MerkleTreeNode: the root node. """ if len(leaves) < 1: raise Exception('Leaves must have length') if len(leaves) =...
[ "def", "__Build", "(", "leaves", ")", ":", "if", "len", "(", "leaves", ")", "<", "1", ":", "raise", "Exception", "(", "'Leaves must have length'", ")", "if", "len", "(", "leaves", ")", "==", "1", ":", "return", "leaves", "[", "0", "]", "num_parents", ...
Build the merkle tree. Args: leaves (list): items are of type MerkleTreeNode. Returns: MerkleTreeNode: the root node.
[ "Build", "the", "merkle", "tree", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/MerkleTree.py#L70-L101
train
CityOfZion/neo-python-core
neocore/Cryptography/MerkleTree.py
MerkleTree.ComputeRoot
def ComputeRoot(hashes): """ Compute the root hash. Args: hashes (list): the list of hashes to build the root from. Returns: bytes: the root hash. """ if not len(hashes): raise Exception('Hashes must have length') if len(hashe...
python
def ComputeRoot(hashes): """ Compute the root hash. Args: hashes (list): the list of hashes to build the root from. Returns: bytes: the root hash. """ if not len(hashes): raise Exception('Hashes must have length') if len(hashe...
[ "def", "ComputeRoot", "(", "hashes", ")", ":", "if", "not", "len", "(", "hashes", ")", ":", "raise", "Exception", "(", "'Hashes must have length'", ")", "if", "len", "(", "hashes", ")", "==", "1", ":", "return", "hashes", "[", "0", "]", "tree", "=", ...
Compute the root hash. Args: hashes (list): the list of hashes to build the root from. Returns: bytes: the root hash.
[ "Compute", "the", "root", "hash", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/MerkleTree.py#L109-L125
train
CityOfZion/neo-python-core
neocore/Cryptography/MerkleTree.py
MerkleTree.ToHashArray
def ToHashArray(self): """ Turn the tree into a list of hashes. Returns: list: """ hashes = set() MerkleTree.__DepthFirstSearch(self.Root, hashes) return list(hashes)
python
def ToHashArray(self): """ Turn the tree into a list of hashes. Returns: list: """ hashes = set() MerkleTree.__DepthFirstSearch(self.Root, hashes) return list(hashes)
[ "def", "ToHashArray", "(", "self", ")", ":", "hashes", "=", "set", "(", ")", "MerkleTree", ".", "__DepthFirstSearch", "(", "self", ".", "Root", ",", "hashes", ")", "return", "list", "(", "hashes", ")" ]
Turn the tree into a list of hashes. Returns: list:
[ "Turn", "the", "tree", "into", "a", "list", "of", "hashes", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/MerkleTree.py#L142-L151
train
CityOfZion/neo-python-core
neocore/Cryptography/MerkleTree.py
MerkleTree.Trim
def Trim(self, flags): """ Trim the nodes from the tree keeping only the root hash. Args: flags: "0000" for trimming, any other value for keeping the nodes. """ logger.info("Trimming!") flags = bytearray(flags) length = 1 << self.Depth - 1 whi...
python
def Trim(self, flags): """ Trim the nodes from the tree keeping only the root hash. Args: flags: "0000" for trimming, any other value for keeping the nodes. """ logger.info("Trimming!") flags = bytearray(flags) length = 1 << self.Depth - 1 whi...
[ "def", "Trim", "(", "self", ",", "flags", ")", ":", "logger", ".", "info", "(", "\"Trimming!\"", ")", "flags", "=", "bytearray", "(", "flags", ")", "length", "=", "1", "<<", "self", ".", "Depth", "-", "1", "while", "len", "(", "flags", ")", "<", ...
Trim the nodes from the tree keeping only the root hash. Args: flags: "0000" for trimming, any other value for keeping the nodes.
[ "Trim", "the", "nodes", "from", "the", "tree", "keeping", "only", "the", "root", "hash", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/MerkleTree.py#L153-L166
train
CityOfZion/neo-python-core
neocore/Cryptography/MerkleTree.py
MerkleTree._TrimNode
def _TrimNode(node, index, depth, flags): """ Internal helper method to trim a node. Args: node (MerkleTreeNode): index (int): flag index. depth (int): node tree depth to start trim from. flags (bytearray): of left/right pairs. 1 byte for the left...
python
def _TrimNode(node, index, depth, flags): """ Internal helper method to trim a node. Args: node (MerkleTreeNode): index (int): flag index. depth (int): node tree depth to start trim from. flags (bytearray): of left/right pairs. 1 byte for the left...
[ "def", "_TrimNode", "(", "node", ",", "index", ",", "depth", ",", "flags", ")", ":", "if", "depth", "==", "1", "or", "node", ".", "LeftChild", "is", "None", ":", "return", "if", "depth", "==", "2", ":", "if", "not", "flags", "[", "index", "*", "2...
Internal helper method to trim a node. Args: node (MerkleTreeNode): index (int): flag index. depth (int): node tree depth to start trim from. flags (bytearray): of left/right pairs. 1 byte for the left node, 1 byte for the right node. ...
[ "Internal", "helper", "method", "to", "trim", "a", "node", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/MerkleTree.py#L169-L195
train
CityOfZion/neo-python-core
neocore/Cryptography/Helper.py
double_sha256
def double_sha256(ba): """ Perform two SHA256 operations on the input. Args: ba (bytes): data to hash. Returns: str: hash as a double digit hex string. """ d1 = hashlib.sha256(ba) d2 = hashlib.sha256() d1.hexdigest() d2.update(d1.digest()) return d2.hexdigest()
python
def double_sha256(ba): """ Perform two SHA256 operations on the input. Args: ba (bytes): data to hash. Returns: str: hash as a double digit hex string. """ d1 = hashlib.sha256(ba) d2 = hashlib.sha256() d1.hexdigest() d2.update(d1.digest()) return d2.hexdigest()
[ "def", "double_sha256", "(", "ba", ")", ":", "d1", "=", "hashlib", ".", "sha256", "(", "ba", ")", "d2", "=", "hashlib", ".", "sha256", "(", ")", "d1", ".", "hexdigest", "(", ")", "d2", ".", "update", "(", "d1", ".", "digest", "(", ")", ")", "re...
Perform two SHA256 operations on the input. Args: ba (bytes): data to hash. Returns: str: hash as a double digit hex string.
[ "Perform", "two", "SHA256", "operations", "on", "the", "input", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/Helper.py#L28-L42
train
CityOfZion/neo-python-core
neocore/Cryptography/Helper.py
scripthash_to_address
def scripthash_to_address(scripthash): """ Convert a script hash to a public address. Args: scripthash (bytes): Returns: str: base58 encoded string representing the wallet address. """ sb = bytearray([ADDRESS_VERSION]) + scripthash c256 = bin_dbl_sha256(sb)[0:4] outb = ...
python
def scripthash_to_address(scripthash): """ Convert a script hash to a public address. Args: scripthash (bytes): Returns: str: base58 encoded string representing the wallet address. """ sb = bytearray([ADDRESS_VERSION]) + scripthash c256 = bin_dbl_sha256(sb)[0:4] outb = ...
[ "def", "scripthash_to_address", "(", "scripthash", ")", ":", "sb", "=", "bytearray", "(", "[", "ADDRESS_VERSION", "]", ")", "+", "scripthash", "c256", "=", "bin_dbl_sha256", "(", "sb", ")", "[", "0", ":", "4", "]", "outb", "=", "sb", "+", "bytearray", ...
Convert a script hash to a public address. Args: scripthash (bytes): Returns: str: base58 encoded string representing the wallet address.
[ "Convert", "a", "script", "hash", "to", "a", "public", "address", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/Helper.py#L71-L84
train
CityOfZion/neo-python-core
neocore/Cryptography/Helper.py
base256_encode
def base256_encode(n, minwidth=0): # int/long to byte array """ Encode the input with base256. Args: n (int): input value. minwidth: minimum return value length. Raises: ValueError: if a negative number is provided. Returns: bytearray: """ if n > 0: ...
python
def base256_encode(n, minwidth=0): # int/long to byte array """ Encode the input with base256. Args: n (int): input value. minwidth: minimum return value length. Raises: ValueError: if a negative number is provided. Returns: bytearray: """ if n > 0: ...
[ "def", "base256_encode", "(", "n", ",", "minwidth", "=", "0", ")", ":", "if", "n", ">", "0", ":", "arr", "=", "[", "]", "while", "n", ":", "n", ",", "rem", "=", "divmod", "(", "n", ",", "256", ")", "arr", ".", "append", "(", "rem", ")", "b"...
Encode the input with base256. Args: n (int): input value. minwidth: minimum return value length. Raises: ValueError: if a negative number is provided. Returns: bytearray:
[ "Encode", "the", "input", "with", "base256", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/Helper.py#L141-L171
train
CityOfZion/neo-python-core
neocore/Cryptography/Helper.py
xor_bytes
def xor_bytes(a, b): """ XOR on two bytes objects Args: a (bytes): object 1 b (bytes): object 2 Returns: bytes: The XOR result """ assert isinstance(a, bytes) assert isinstance(b, bytes) assert len(a) == len(b) res = bytearray() for i in range(len(a)): ...
python
def xor_bytes(a, b): """ XOR on two bytes objects Args: a (bytes): object 1 b (bytes): object 2 Returns: bytes: The XOR result """ assert isinstance(a, bytes) assert isinstance(b, bytes) assert len(a) == len(b) res = bytearray() for i in range(len(a)): ...
[ "def", "xor_bytes", "(", "a", ",", "b", ")", ":", "assert", "isinstance", "(", "a", ",", "bytes", ")", "assert", "isinstance", "(", "b", ",", "bytes", ")", "assert", "len", "(", "a", ")", "==", "len", "(", "b", ")", "res", "=", "bytearray", "(", ...
XOR on two bytes objects Args: a (bytes): object 1 b (bytes): object 2 Returns: bytes: The XOR result
[ "XOR", "on", "two", "bytes", "objects" ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/Helper.py#L174-L191
train
CityOfZion/neo-python-core
neocore/IO/BinaryWriter.py
BinaryWriter.WriteBytes
def WriteBytes(self, value, unhex=True): """ Write a `bytes` type to the stream. Args: value (bytes): array of bytes to write to the stream. unhex (bool): (Default) True. Set to unhexlify the stream. Use when the bytes are not raw bytes; i.e. b'aabb' Returns: ...
python
def WriteBytes(self, value, unhex=True): """ Write a `bytes` type to the stream. Args: value (bytes): array of bytes to write to the stream. unhex (bool): (Default) True. Set to unhexlify the stream. Use when the bytes are not raw bytes; i.e. b'aabb' Returns: ...
[ "def", "WriteBytes", "(", "self", ",", "value", ",", "unhex", "=", "True", ")", ":", "if", "unhex", ":", "try", ":", "value", "=", "binascii", ".", "unhexlify", "(", "value", ")", "except", "binascii", ".", "Error", ":", "pass", "return", "self", "."...
Write a `bytes` type to the stream. Args: value (bytes): array of bytes to write to the stream. unhex (bool): (Default) True. Set to unhexlify the stream. Use when the bytes are not raw bytes; i.e. b'aabb' Returns: int: the number of bytes written.
[ "Write", "a", "bytes", "type", "to", "the", "stream", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/IO/BinaryWriter.py#L88-L104
train
CityOfZion/neo-python-core
neocore/IO/BinaryWriter.py
BinaryWriter.WriteUInt160
def WriteUInt160(self, value): """ Write a UInt160 type to the stream. Args: value (UInt160): Raises: Exception: when `value` is not of neocore.UInt160 type. """ if type(value) is UInt160: value.Serialize(self) else: ...
python
def WriteUInt160(self, value): """ Write a UInt160 type to the stream. Args: value (UInt160): Raises: Exception: when `value` is not of neocore.UInt160 type. """ if type(value) is UInt160: value.Serialize(self) else: ...
[ "def", "WriteUInt160", "(", "self", ",", "value", ")", ":", "if", "type", "(", "value", ")", "is", "UInt160", ":", "value", ".", "Serialize", "(", "self", ")", "else", ":", "raise", "Exception", "(", "\"value must be UInt160 instance \"", ")" ]
Write a UInt160 type to the stream. Args: value (UInt160): Raises: Exception: when `value` is not of neocore.UInt160 type.
[ "Write", "a", "UInt160", "type", "to", "the", "stream", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/IO/BinaryWriter.py#L274-L287
train
CityOfZion/neo-python-core
neocore/IO/BinaryWriter.py
BinaryWriter.WriteUInt256
def WriteUInt256(self, value): """ Write a UInt256 type to the stream. Args: value (UInt256): Raises: Exception: when `value` is not of neocore.UInt256 type. """ if type(value) is UInt256: value.Serialize(self) else: ...
python
def WriteUInt256(self, value): """ Write a UInt256 type to the stream. Args: value (UInt256): Raises: Exception: when `value` is not of neocore.UInt256 type. """ if type(value) is UInt256: value.Serialize(self) else: ...
[ "def", "WriteUInt256", "(", "self", ",", "value", ")", ":", "if", "type", "(", "value", ")", "is", "UInt256", ":", "value", ".", "Serialize", "(", "self", ")", "else", ":", "raise", "Exception", "(", "\"Cannot write value that is not UInt256\"", ")" ]
Write a UInt256 type to the stream. Args: value (UInt256): Raises: Exception: when `value` is not of neocore.UInt256 type.
[ "Write", "a", "UInt256", "type", "to", "the", "stream", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/IO/BinaryWriter.py#L289-L302
train
CityOfZion/neo-python-core
neocore/IO/BinaryWriter.py
BinaryWriter.Write2000256List
def Write2000256List(self, arr): """ Write an array of 64 byte items to the stream. Args: arr (list): a list of 2000 items of 64 bytes in size. """ for item in arr: ba = bytearray(binascii.unhexlify(item)) ba.reverse() self.WriteBy...
python
def Write2000256List(self, arr): """ Write an array of 64 byte items to the stream. Args: arr (list): a list of 2000 items of 64 bytes in size. """ for item in arr: ba = bytearray(binascii.unhexlify(item)) ba.reverse() self.WriteBy...
[ "def", "Write2000256List", "(", "self", ",", "arr", ")", ":", "for", "item", "in", "arr", ":", "ba", "=", "bytearray", "(", "binascii", ".", "unhexlify", "(", "item", ")", ")", "ba", ".", "reverse", "(", ")", "self", ".", "WriteBytes", "(", "ba", "...
Write an array of 64 byte items to the stream. Args: arr (list): a list of 2000 items of 64 bytes in size.
[ "Write", "an", "array", "of", "64", "byte", "items", "to", "the", "stream", "." ]
786c02cc2f41712d70b1f064ae3d67f86167107f
https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/IO/BinaryWriter.py#L410-L420
train
OTA-Insight/djangosaml2idp
djangosaml2idp/processors.py
BaseProcessor.get_user_id
def get_user_id(self, user): """ Get identifier for a user. Take the one defined in settings.SAML_IDP_DJANGO_USERNAME_FIELD first, if not set use the USERNAME_FIELD property which is set on the user Model. This defaults to the user.username field. """ user_field = getattr(settings, '...
python
def get_user_id(self, user): """ Get identifier for a user. Take the one defined in settings.SAML_IDP_DJANGO_USERNAME_FIELD first, if not set use the USERNAME_FIELD property which is set on the user Model. This defaults to the user.username field. """ user_field = getattr(settings, '...
[ "def", "get_user_id", "(", "self", ",", "user", ")", ":", "user_field", "=", "getattr", "(", "settings", ",", "'SAML_IDP_DJANGO_USERNAME_FIELD'", ",", "None", ")", "or", "getattr", "(", "user", ",", "'USERNAME_FIELD'", ",", "'username'", ")", "return", "str", ...
Get identifier for a user. Take the one defined in settings.SAML_IDP_DJANGO_USERNAME_FIELD first, if not set use the USERNAME_FIELD property which is set on the user Model. This defaults to the user.username field.
[ "Get", "identifier", "for", "a", "user", ".", "Take", "the", "one", "defined", "in", "settings", ".", "SAML_IDP_DJANGO_USERNAME_FIELD", "first", "if", "not", "set", "use", "the", "USERNAME_FIELD", "property", "which", "is", "set", "on", "the", "user", "Model",...
8a238063da55bf4823bdc2192168171767c4e056
https://github.com/OTA-Insight/djangosaml2idp/blob/8a238063da55bf4823bdc2192168171767c4e056/djangosaml2idp/processors.py#L22-L28
train
OTA-Insight/djangosaml2idp
djangosaml2idp/processors.py
BaseProcessor.create_identity
def create_identity(self, user, sp_mapping, **extra_config): """ Generate an identity dictionary of the user based on the given mapping of desired user attributes by the SP """ return { out_attr: getattr(user, user_attr) for user_attr, out_attr in sp_mapping.items() ...
python
def create_identity(self, user, sp_mapping, **extra_config): """ Generate an identity dictionary of the user based on the given mapping of desired user attributes by the SP """ return { out_attr: getattr(user, user_attr) for user_attr, out_attr in sp_mapping.items() ...
[ "def", "create_identity", "(", "self", ",", "user", ",", "sp_mapping", ",", "**", "extra_config", ")", ":", "return", "{", "out_attr", ":", "getattr", "(", "user", ",", "user_attr", ")", "for", "user_attr", ",", "out_attr", "in", "sp_mapping", ".", "items"...
Generate an identity dictionary of the user based on the given mapping of desired user attributes by the SP
[ "Generate", "an", "identity", "dictionary", "of", "the", "user", "based", "on", "the", "given", "mapping", "of", "desired", "user", "attributes", "by", "the", "SP" ]
8a238063da55bf4823bdc2192168171767c4e056
https://github.com/OTA-Insight/djangosaml2idp/blob/8a238063da55bf4823bdc2192168171767c4e056/djangosaml2idp/processors.py#L30-L38
train
OTA-Insight/djangosaml2idp
djangosaml2idp/views.py
sso_entry
def sso_entry(request): """ Entrypoint view for SSO. Gathers the parameters from the HTTP request, stores them in the session and redirects the requester to the login_process view. """ if request.method == 'POST': passed_data = request.POST binding = BINDING_HTTP_POST else: ...
python
def sso_entry(request): """ Entrypoint view for SSO. Gathers the parameters from the HTTP request, stores them in the session and redirects the requester to the login_process view. """ if request.method == 'POST': passed_data = request.POST binding = BINDING_HTTP_POST else: ...
[ "def", "sso_entry", "(", "request", ")", ":", "if", "request", ".", "method", "==", "'POST'", ":", "passed_data", "=", "request", ".", "POST", "binding", "=", "BINDING_HTTP_POST", "else", ":", "passed_data", "=", "request", ".", "GET", "binding", "=", "BIN...
Entrypoint view for SSO. Gathers the parameters from the HTTP request, stores them in the session and redirects the requester to the login_process view.
[ "Entrypoint", "view", "for", "SSO", ".", "Gathers", "the", "parameters", "from", "the", "HTTP", "request", "stores", "them", "in", "the", "session", "and", "redirects", "the", "requester", "to", "the", "login_process", "view", "." ]
8a238063da55bf4823bdc2192168171767c4e056
https://github.com/OTA-Insight/djangosaml2idp/blob/8a238063da55bf4823bdc2192168171767c4e056/djangosaml2idp/views.py#L41-L63
train
OTA-Insight/djangosaml2idp
djangosaml2idp/views.py
metadata
def metadata(request): """ Returns an XML with the SAML 2.0 metadata for this Idp. The metadata is constructed on-the-fly based on the config dict in the django settings. """ conf = IdPConfig() conf.load(copy.deepcopy(settings.SAML_IDP_CONFIG)) metadata = entity_descriptor(conf) return H...
python
def metadata(request): """ Returns an XML with the SAML 2.0 metadata for this Idp. The metadata is constructed on-the-fly based on the config dict in the django settings. """ conf = IdPConfig() conf.load(copy.deepcopy(settings.SAML_IDP_CONFIG)) metadata = entity_descriptor(conf) return H...
[ "def", "metadata", "(", "request", ")", ":", "conf", "=", "IdPConfig", "(", ")", "conf", ".", "load", "(", "copy", ".", "deepcopy", "(", "settings", ".", "SAML_IDP_CONFIG", ")", ")", "metadata", "=", "entity_descriptor", "(", "conf", ")", "return", "Http...
Returns an XML with the SAML 2.0 metadata for this Idp. The metadata is constructed on-the-fly based on the config dict in the django settings.
[ "Returns", "an", "XML", "with", "the", "SAML", "2", ".", "0", "metadata", "for", "this", "Idp", ".", "The", "metadata", "is", "constructed", "on", "-", "the", "-", "fly", "based", "on", "the", "config", "dict", "in", "the", "django", "settings", "." ]
8a238063da55bf4823bdc2192168171767c4e056
https://github.com/OTA-Insight/djangosaml2idp/blob/8a238063da55bf4823bdc2192168171767c4e056/djangosaml2idp/views.py#L284-L291
train
OTA-Insight/djangosaml2idp
djangosaml2idp/views.py
IdPHandlerViewMixin.dispatch
def dispatch(self, request, *args, **kwargs): """ Construct IDP server with config from settings dict """ conf = IdPConfig() try: conf.load(copy.deepcopy(settings.SAML_IDP_CONFIG)) self.IDP = Server(config=conf) except Exception as e: return se...
python
def dispatch(self, request, *args, **kwargs): """ Construct IDP server with config from settings dict """ conf = IdPConfig() try: conf.load(copy.deepcopy(settings.SAML_IDP_CONFIG)) self.IDP = Server(config=conf) except Exception as e: return se...
[ "def", "dispatch", "(", "self", ",", "request", ",", "*", "args", ",", "**", "kwargs", ")", ":", "conf", "=", "IdPConfig", "(", ")", "try", ":", "conf", ".", "load", "(", "copy", ".", "deepcopy", "(", "settings", ".", "SAML_IDP_CONFIG", ")", ")", "...
Construct IDP server with config from settings dict
[ "Construct", "IDP", "server", "with", "config", "from", "settings", "dict" ]
8a238063da55bf4823bdc2192168171767c4e056
https://github.com/OTA-Insight/djangosaml2idp/blob/8a238063da55bf4823bdc2192168171767c4e056/djangosaml2idp/views.py#L74-L83
train
OTA-Insight/djangosaml2idp
djangosaml2idp/views.py
IdPHandlerViewMixin.get_processor
def get_processor(self, entity_id, sp_config): """ Instantiate user-specified processor or default to an all-access base processor. Raises an exception if the configured processor class can not be found or initialized. """ processor_string = sp_config.get('processor', None) i...
python
def get_processor(self, entity_id, sp_config): """ Instantiate user-specified processor or default to an all-access base processor. Raises an exception if the configured processor class can not be found or initialized. """ processor_string = sp_config.get('processor', None) i...
[ "def", "get_processor", "(", "self", ",", "entity_id", ",", "sp_config", ")", ":", "processor_string", "=", "sp_config", ".", "get", "(", "'processor'", ",", "None", ")", "if", "processor_string", ":", "try", ":", "return", "import_string", "(", "processor_str...
Instantiate user-specified processor or default to an all-access base processor. Raises an exception if the configured processor class can not be found or initialized.
[ "Instantiate", "user", "-", "specified", "processor", "or", "default", "to", "an", "all", "-", "access", "base", "processor", ".", "Raises", "an", "exception", "if", "the", "configured", "processor", "class", "can", "not", "be", "found", "or", "initialized", ...
8a238063da55bf4823bdc2192168171767c4e056
https://github.com/OTA-Insight/djangosaml2idp/blob/8a238063da55bf4823bdc2192168171767c4e056/djangosaml2idp/views.py#L85-L96
train
MartijnBraam/python-isc-dhcp-leases
isc_dhcp_leases/iscdhcpleases.py
IscDhcpLeases.get
def get(self, include_backups=False): """ Parse the lease file and return a list of Lease instances. """ leases = [] with open(self.filename) if not self.gzip else gzip.open(self.filename) as lease_file: lease_data = lease_file.read() if self.gzip: ...
python
def get(self, include_backups=False): """ Parse the lease file and return a list of Lease instances. """ leases = [] with open(self.filename) if not self.gzip else gzip.open(self.filename) as lease_file: lease_data = lease_file.read() if self.gzip: ...
[ "def", "get", "(", "self", ",", "include_backups", "=", "False", ")", ":", "leases", "=", "[", "]", "with", "open", "(", "self", ".", "filename", ")", "if", "not", "self", ".", "gzip", "else", "gzip", ".", "open", "(", "self", ".", "filename", ")",...
Parse the lease file and return a list of Lease instances.
[ "Parse", "the", "lease", "file", "and", "return", "a", "list", "of", "Lease", "instances", "." ]
e96c00e31f3a52c01ef98193577d614d08a93285
https://github.com/MartijnBraam/python-isc-dhcp-leases/blob/e96c00e31f3a52c01ef98193577d614d08a93285/isc_dhcp_leases/iscdhcpleases.py#L115-L151
train
MartijnBraam/python-isc-dhcp-leases
isc_dhcp_leases/iscdhcpleases.py
IscDhcpLeases.get_current
def get_current(self): """ Parse the lease file and return a dict of active and valid Lease instances. The key for this dict is the ethernet address of the lease. """ all_leases = self.get() leases = {} for lease in all_leases: if lease.valid and lease...
python
def get_current(self): """ Parse the lease file and return a dict of active and valid Lease instances. The key for this dict is the ethernet address of the lease. """ all_leases = self.get() leases = {} for lease in all_leases: if lease.valid and lease...
[ "def", "get_current", "(", "self", ")", ":", "all_leases", "=", "self", ".", "get", "(", ")", "leases", "=", "{", "}", "for", "lease", "in", "all_leases", ":", "if", "lease", ".", "valid", "and", "lease", ".", "active", ":", "if", "type", "(", "lea...
Parse the lease file and return a dict of active and valid Lease instances. The key for this dict is the ethernet address of the lease.
[ "Parse", "the", "lease", "file", "and", "return", "a", "dict", "of", "active", "and", "valid", "Lease", "instances", ".", "The", "key", "for", "this", "dict", "is", "the", "ethernet", "address", "of", "the", "lease", "." ]
e96c00e31f3a52c01ef98193577d614d08a93285
https://github.com/MartijnBraam/python-isc-dhcp-leases/blob/e96c00e31f3a52c01ef98193577d614d08a93285/isc_dhcp_leases/iscdhcpleases.py#L153-L166
train
crate/crash
src/crate/crash/layout.py
create_layout
def create_layout(lexer=None, reserve_space_for_menu=8, get_prompt_tokens=None, get_bottom_toolbar_tokens=None, extra_input_processors=None, multiline=False, wrap_lines=True): """ Creates a custom `Layout` for the Crash in...
python
def create_layout(lexer=None, reserve_space_for_menu=8, get_prompt_tokens=None, get_bottom_toolbar_tokens=None, extra_input_processors=None, multiline=False, wrap_lines=True): """ Creates a custom `Layout` for the Crash in...
[ "def", "create_layout", "(", "lexer", "=", "None", ",", "reserve_space_for_menu", "=", "8", ",", "get_prompt_tokens", "=", "None", ",", "get_bottom_toolbar_tokens", "=", "None", ",", "extra_input_processors", "=", "None", ",", "multiline", "=", "False", ",", "wr...
Creates a custom `Layout` for the Crash input REPL This layout includes: * a bottom left-aligned session toolbar container * a bottom right-aligned side-bar container +-------------------------------------------+ | cr> select 1; | | ...
[ "Creates", "a", "custom", "Layout", "for", "the", "Crash", "input", "REPL" ]
32d3ddc78fd2f7848ed2b99d9cd8889e322528d9
https://github.com/crate/crash/blob/32d3ddc78fd2f7848ed2b99d9cd8889e322528d9/src/crate/crash/layout.py#L39-L157
train
crate/crash
src/crate/crash/command.py
_parse_statements
def _parse_statements(lines): """Return a generator of statements Args: A list of strings that can contain one or more statements. Statements are separated using ';' at the end of a line Everything after the last ';' will be treated as the last statement. >>> list(_parse_statements(['s...
python
def _parse_statements(lines): """Return a generator of statements Args: A list of strings that can contain one or more statements. Statements are separated using ';' at the end of a line Everything after the last ';' will be treated as the last statement. >>> list(_parse_statements(['s...
[ "def", "_parse_statements", "(", "lines", ")", ":", "lines", "=", "(", "l", ".", "strip", "(", ")", "for", "l", "in", "lines", "if", "l", ")", "lines", "=", "(", "l", "for", "l", "in", "lines", "if", "l", "and", "not", "l", ".", "startswith", "...
Return a generator of statements Args: A list of strings that can contain one or more statements. Statements are separated using ';' at the end of a line Everything after the last ';' will be treated as the last statement. >>> list(_parse_statements(['select * from ', 't1;', 'select name']...
[ "Return", "a", "generator", "of", "statements" ]
32d3ddc78fd2f7848ed2b99d9cd8889e322528d9
https://github.com/crate/crash/blob/32d3ddc78fd2f7848ed2b99d9cd8889e322528d9/src/crate/crash/command.py#L191-L213
train
crate/crash
src/crate/crash/command.py
CrateShell._show_tables
def _show_tables(self, *args): """ print the existing tables within the 'doc' schema """ v = self.connection.lowest_server_version schema_name = \ "table_schema" if v >= TABLE_SCHEMA_MIN_VERSION else "schema_name" table_filter = \ " AND table_type = 'BASE TABLE'" ...
python
def _show_tables(self, *args): """ print the existing tables within the 'doc' schema """ v = self.connection.lowest_server_version schema_name = \ "table_schema" if v >= TABLE_SCHEMA_MIN_VERSION else "schema_name" table_filter = \ " AND table_type = 'BASE TABLE'" ...
[ "def", "_show_tables", "(", "self", ",", "*", "args", ")", ":", "v", "=", "self", ".", "connection", ".", "lowest_server_version", "schema_name", "=", "\"table_schema\"", "if", "v", ">=", "TABLE_SCHEMA_MIN_VERSION", "else", "\"schema_name\"", "table_filter", "=", ...
print the existing tables within the 'doc' schema
[ "print", "the", "existing", "tables", "within", "the", "doc", "schema" ]
32d3ddc78fd2f7848ed2b99d9cd8889e322528d9
https://github.com/crate/crash/blob/32d3ddc78fd2f7848ed2b99d9cd8889e322528d9/src/crate/crash/command.py#L321-L333
train
crate/crash
src/crate/crash/sysinfo.py
SysInfoCommand.execute
def execute(self): """ print system and cluster info """ if not self.cmd.is_conn_available(): return if self.cmd.connection.lowest_server_version >= SYSINFO_MIN_VERSION: success, rows = self._sys_info() self.cmd.exit_code = self.cmd.exit_code or int(not succes...
python
def execute(self): """ print system and cluster info """ if not self.cmd.is_conn_available(): return if self.cmd.connection.lowest_server_version >= SYSINFO_MIN_VERSION: success, rows = self._sys_info() self.cmd.exit_code = self.cmd.exit_code or int(not succes...
[ "def", "execute", "(", "self", ")", ":", "if", "not", "self", ".", "cmd", ".", "is_conn_available", "(", ")", ":", "return", "if", "self", ".", "cmd", ".", "connection", ".", "lowest_server_version", ">=", "SYSINFO_MIN_VERSION", ":", "success", ",", "rows"...
print system and cluster info
[ "print", "system", "and", "cluster", "info" ]
32d3ddc78fd2f7848ed2b99d9cd8889e322528d9
https://github.com/crate/crash/blob/32d3ddc78fd2f7848ed2b99d9cd8889e322528d9/src/crate/crash/sysinfo.py#L72-L87
train
crate/crash
src/crate/crash/config.py
Configuration.bwc_bool_transform_from
def bwc_bool_transform_from(cls, x): """ Read boolean values from old config files correctly and interpret 'True' and 'False' as correct booleans. """ if x.lower() == 'true': return True elif x.lower() == 'false': return False return bool(i...
python
def bwc_bool_transform_from(cls, x): """ Read boolean values from old config files correctly and interpret 'True' and 'False' as correct booleans. """ if x.lower() == 'true': return True elif x.lower() == 'false': return False return bool(i...
[ "def", "bwc_bool_transform_from", "(", "cls", ",", "x", ")", ":", "if", "x", ".", "lower", "(", ")", "==", "'true'", ":", "return", "True", "elif", "x", ".", "lower", "(", ")", "==", "'false'", ":", "return", "False", "return", "bool", "(", "int", ...
Read boolean values from old config files correctly and interpret 'True' and 'False' as correct booleans.
[ "Read", "boolean", "values", "from", "old", "config", "files", "correctly", "and", "interpret", "True", "and", "False", "as", "correct", "booleans", "." ]
32d3ddc78fd2f7848ed2b99d9cd8889e322528d9
https://github.com/crate/crash/blob/32d3ddc78fd2f7848ed2b99d9cd8889e322528d9/src/crate/crash/config.py#L44-L53
train
crate/crash
src/crate/crash/outputs.py
_transform_field
def _transform_field(field): """transform field for displaying""" if isinstance(field, bool): return TRUE if field else FALSE elif isinstance(field, (list, dict)): return json.dumps(field, sort_keys=True, ensure_ascii=False) else: return field
python
def _transform_field(field): """transform field for displaying""" if isinstance(field, bool): return TRUE if field else FALSE elif isinstance(field, (list, dict)): return json.dumps(field, sort_keys=True, ensure_ascii=False) else: return field
[ "def", "_transform_field", "(", "field", ")", ":", "if", "isinstance", "(", "field", ",", "bool", ")", ":", "return", "TRUE", "if", "field", "else", "FALSE", "elif", "isinstance", "(", "field", ",", "(", "list", ",", "dict", ")", ")", ":", "return", ...
transform field for displaying
[ "transform", "field", "for", "displaying" ]
32d3ddc78fd2f7848ed2b99d9cd8889e322528d9
https://github.com/crate/crash/blob/32d3ddc78fd2f7848ed2b99d9cd8889e322528d9/src/crate/crash/outputs.py#L42-L49
train
supermihi/pytaglib
src/pyprinttags.py
script
def script(): """Run the command-line script.""" parser = argparse.ArgumentParser(description="Print all textual tags of one or more audio files.") parser.add_argument("-b", "--batch", help="disable user interaction", action="store_true") parser.add_argument("file", nargs="+", help="file(s) to print tag...
python
def script(): """Run the command-line script.""" parser = argparse.ArgumentParser(description="Print all textual tags of one or more audio files.") parser.add_argument("-b", "--batch", help="disable user interaction", action="store_true") parser.add_argument("file", nargs="+", help="file(s) to print tag...
[ "def", "script", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Print all textual tags of one or more audio files.\"", ")", "parser", ".", "add_argument", "(", "\"-b\"", ",", "\"--batch\"", ",", "help", "=", "\"disable u...
Run the command-line script.
[ "Run", "the", "command", "-", "line", "script", "." ]
719224d4fdfee09925b865335f2af510ccdcad58
https://github.com/supermihi/pytaglib/blob/719224d4fdfee09925b865335f2af510ccdcad58/src/pyprinttags.py#L23-L51
train
adafruit/Adafruit_CircuitPython_seesaw
adafruit_seesaw/seesaw.py
Seesaw.sw_reset
def sw_reset(self): """Trigger a software reset of the SeeSaw chip""" self.write8(_STATUS_BASE, _STATUS_SWRST, 0xFF) time.sleep(.500) chip_id = self.read8(_STATUS_BASE, _STATUS_HW_ID) if chip_id != _HW_ID_CODE: raise RuntimeError("Seesaw hardware ID returned (0x{:x}...
python
def sw_reset(self): """Trigger a software reset of the SeeSaw chip""" self.write8(_STATUS_BASE, _STATUS_SWRST, 0xFF) time.sleep(.500) chip_id = self.read8(_STATUS_BASE, _STATUS_HW_ID) if chip_id != _HW_ID_CODE: raise RuntimeError("Seesaw hardware ID returned (0x{:x}...
[ "def", "sw_reset", "(", "self", ")", ":", "self", ".", "write8", "(", "_STATUS_BASE", ",", "_STATUS_SWRST", ",", "0xFF", ")", "time", ".", "sleep", "(", ".500", ")", "chip_id", "=", "self", ".", "read8", "(", "_STATUS_BASE", ",", "_STATUS_HW_ID", ")", ...
Trigger a software reset of the SeeSaw chip
[ "Trigger", "a", "software", "reset", "of", "the", "SeeSaw", "chip" ]
3f55058dbdfcfde8cb5ce8708c0a37aacde9b313
https://github.com/adafruit/Adafruit_CircuitPython_seesaw/blob/3f55058dbdfcfde8cb5ce8708c0a37aacde9b313/adafruit_seesaw/seesaw.py#L144-L165
train
lipoja/URLExtract
urlextract/cachefile.py
CacheFile._get_default_cache_file_path
def _get_default_cache_file_path(self): """ Returns default cache file path :return: default cache file path (to data directory) :rtype: str """ default_list_path = os.path.join( self._get_default_cache_dir(), self._CACHE_FILE_NAME) if not os.access...
python
def _get_default_cache_file_path(self): """ Returns default cache file path :return: default cache file path (to data directory) :rtype: str """ default_list_path = os.path.join( self._get_default_cache_dir(), self._CACHE_FILE_NAME) if not os.access...
[ "def", "_get_default_cache_file_path", "(", "self", ")", ":", "default_list_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_get_default_cache_dir", "(", ")", ",", "self", ".", "_CACHE_FILE_NAME", ")", "if", "not", "os", ".", "access", "(", ...
Returns default cache file path :return: default cache file path (to data directory) :rtype: str
[ "Returns", "default", "cache", "file", "path" ]
b53fd2adfaed3cd23a811aed4d277b0ade7b4640
https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/cachefile.py#L77-L94
train
lipoja/URLExtract
urlextract/cachefile.py
CacheFile._get_writable_cache_dir
def _get_writable_cache_dir(self): """ Get writable cache directory with fallback to user's cache directory and global temp directory :raises: CacheFileError when cached directory is not writable for user :return: path to cache directory :rtype: str """ d...
python
def _get_writable_cache_dir(self): """ Get writable cache directory with fallback to user's cache directory and global temp directory :raises: CacheFileError when cached directory is not writable for user :return: path to cache directory :rtype: str """ d...
[ "def", "_get_writable_cache_dir", "(", "self", ")", ":", "dir_path_data", "=", "self", ".", "_get_default_cache_dir", "(", ")", "if", "os", ".", "access", "(", "dir_path_data", ",", "os", ".", "W_OK", ")", ":", "self", ".", "_default_cache_file", "=", "True"...
Get writable cache directory with fallback to user's cache directory and global temp directory :raises: CacheFileError when cached directory is not writable for user :return: path to cache directory :rtype: str
[ "Get", "writable", "cache", "directory", "with", "fallback", "to", "user", "s", "cache", "directory", "and", "global", "temp", "directory" ]
b53fd2adfaed3cd23a811aed4d277b0ade7b4640
https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/cachefile.py#L96-L122
train
lipoja/URLExtract
urlextract/cachefile.py
CacheFile._get_cache_file_path
def _get_cache_file_path(self, cache_dir=None): """ Get path for cache file :param str cache_dir: base path for TLD cache, defaults to data dir :raises: CacheFileError when cached directory is not writable for user :return: Full path to cached file with TLDs :rtype: str ...
python
def _get_cache_file_path(self, cache_dir=None): """ Get path for cache file :param str cache_dir: base path for TLD cache, defaults to data dir :raises: CacheFileError when cached directory is not writable for user :return: Full path to cached file with TLDs :rtype: str ...
[ "def", "_get_cache_file_path", "(", "self", ",", "cache_dir", "=", "None", ")", ":", "if", "cache_dir", "is", "None", ":", "cache_dir", "=", "self", ".", "_get_writable_cache_dir", "(", ")", "else", ":", "if", "not", "os", ".", "access", "(", "cache_dir", ...
Get path for cache file :param str cache_dir: base path for TLD cache, defaults to data dir :raises: CacheFileError when cached directory is not writable for user :return: Full path to cached file with TLDs :rtype: str
[ "Get", "path", "for", "cache", "file" ]
b53fd2adfaed3cd23a811aed4d277b0ade7b4640
https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/cachefile.py#L124-L142
train
lipoja/URLExtract
urlextract/cachefile.py
CacheFile._load_cached_tlds
def _load_cached_tlds(self): """ Loads TLDs from cached file to set. :return: Set of current TLDs :rtype: set """ # check if cached file is readable if not os.access(self._tld_list_path, os.R_OK): self._logger.error("Cached file is not readable for c...
python
def _load_cached_tlds(self): """ Loads TLDs from cached file to set. :return: Set of current TLDs :rtype: set """ # check if cached file is readable if not os.access(self._tld_list_path, os.R_OK): self._logger.error("Cached file is not readable for c...
[ "def", "_load_cached_tlds", "(", "self", ")", ":", "if", "not", "os", ".", "access", "(", "self", ".", "_tld_list_path", ",", "os", ".", "R_OK", ")", ":", "self", ".", "_logger", ".", "error", "(", "\"Cached file is not readable for current \"", "\"user. ({})\...
Loads TLDs from cached file to set. :return: Set of current TLDs :rtype: set
[ "Loads", "TLDs", "from", "cached", "file", "to", "set", "." ]
b53fd2adfaed3cd23a811aed4d277b0ade7b4640
https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/cachefile.py#L190-L220
train
lipoja/URLExtract
urlextract/cachefile.py
CacheFile._get_last_cachefile_modification
def _get_last_cachefile_modification(self): """ Get last modification of cache file with TLDs. :return: Date and time of last modification or None when file does not exist :rtype: datetime|None """ try: mtime = os.path.getmtime(self._tld_lis...
python
def _get_last_cachefile_modification(self): """ Get last modification of cache file with TLDs. :return: Date and time of last modification or None when file does not exist :rtype: datetime|None """ try: mtime = os.path.getmtime(self._tld_lis...
[ "def", "_get_last_cachefile_modification", "(", "self", ")", ":", "try", ":", "mtime", "=", "os", ".", "path", ".", "getmtime", "(", "self", ".", "_tld_list_path", ")", "except", "OSError", ":", "return", "None", "return", "datetime", ".", "fromtimestamp", "...
Get last modification of cache file with TLDs. :return: Date and time of last modification or None when file does not exist :rtype: datetime|None
[ "Get", "last", "modification", "of", "cache", "file", "with", "TLDs", "." ]
b53fd2adfaed3cd23a811aed4d277b0ade7b4640
https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/cachefile.py#L222-L236
train
lipoja/URLExtract
urlextract/urlextract_core.py
URLExtract._get_after_tld_chars
def _get_after_tld_chars(self): """ Initialize after tld characters """ after_tld_chars = set(string.whitespace) after_tld_chars |= {'/', '\"', '\'', '<', '>', '?', ':', '.', ','} # get left enclosure characters _, right_enclosure = zip(*self._enclosure) #...
python
def _get_after_tld_chars(self): """ Initialize after tld characters """ after_tld_chars = set(string.whitespace) after_tld_chars |= {'/', '\"', '\'', '<', '>', '?', ':', '.', ','} # get left enclosure characters _, right_enclosure = zip(*self._enclosure) #...
[ "def", "_get_after_tld_chars", "(", "self", ")", ":", "after_tld_chars", "=", "set", "(", "string", ".", "whitespace", ")", "after_tld_chars", "|=", "{", "'/'", ",", "'\\\"'", ",", "'\\''", ",", "'<'", ",", "'>'", ",", "'?'", ",", "':'", ",", "'.'", ",...
Initialize after tld characters
[ "Initialize", "after", "tld", "characters" ]
b53fd2adfaed3cd23a811aed4d277b0ade7b4640
https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/urlextract_core.py#L91-L103
train
lipoja/URLExtract
urlextract/urlextract_core.py
URLExtract.update_when_older
def update_when_older(self, days): """ Update TLD list cache file if the list is older than number of days given in parameter `days` or if does not exist. :param int days: number of days from last change :return: True if update was successful, False otherwise :rtype: boo...
python
def update_when_older(self, days): """ Update TLD list cache file if the list is older than number of days given in parameter `days` or if does not exist. :param int days: number of days from last change :return: True if update was successful, False otherwise :rtype: boo...
[ "def", "update_when_older", "(", "self", ",", "days", ")", ":", "last_cache", "=", "self", ".", "_get_last_cachefile_modification", "(", ")", "if", "last_cache", "is", "None", ":", "return", "self", ".", "update", "(", ")", "time_to_update", "=", "last_cache",...
Update TLD list cache file if the list is older than number of days given in parameter `days` or if does not exist. :param int days: number of days from last change :return: True if update was successful, False otherwise :rtype: bool
[ "Update", "TLD", "list", "cache", "file", "if", "the", "list", "is", "older", "than", "number", "of", "days", "given", "in", "parameter", "days", "or", "if", "does", "not", "exist", "." ]
b53fd2adfaed3cd23a811aed4d277b0ade7b4640
https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/urlextract_core.py#L129-L148
train
lipoja/URLExtract
urlextract/urlextract_core.py
URLExtract.set_stop_chars
def set_stop_chars(self, stop_chars): """ Set stop characters used when determining end of URL. .. deprecated:: 0.7 Use :func:`set_stop_chars_left` or :func:`set_stop_chars_right` instead. :param list stop_chars: list of characters """ warnings....
python
def set_stop_chars(self, stop_chars): """ Set stop characters used when determining end of URL. .. deprecated:: 0.7 Use :func:`set_stop_chars_left` or :func:`set_stop_chars_right` instead. :param list stop_chars: list of characters """ warnings....
[ "def", "set_stop_chars", "(", "self", ",", "stop_chars", ")", ":", "warnings", ".", "warn", "(", "\"Method set_stop_chars is deprecated, \"", "\"use `set_stop_chars_left` or \"", "\"`set_stop_chars_right` instead\"", ",", "DeprecationWarning", ")", "self", ".", "_stop_chars",...
Set stop characters used when determining end of URL. .. deprecated:: 0.7 Use :func:`set_stop_chars_left` or :func:`set_stop_chars_right` instead. :param list stop_chars: list of characters
[ "Set", "stop", "characters", "used", "when", "determining", "end", "of", "URL", "." ]
b53fd2adfaed3cd23a811aed4d277b0ade7b4640
https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/urlextract_core.py#L196-L212
train
lipoja/URLExtract
urlextract/urlextract_core.py
URLExtract.set_stop_chars_left
def set_stop_chars_left(self, stop_chars): """ Set stop characters for text on left from TLD. Stop characters are used when determining end of URL. :param set stop_chars: set of characters :raises: TypeError """ if not isinstance(stop_chars, set): rai...
python
def set_stop_chars_left(self, stop_chars): """ Set stop characters for text on left from TLD. Stop characters are used when determining end of URL. :param set stop_chars: set of characters :raises: TypeError """ if not isinstance(stop_chars, set): rai...
[ "def", "set_stop_chars_left", "(", "self", ",", "stop_chars", ")", ":", "if", "not", "isinstance", "(", "stop_chars", ",", "set", ")", ":", "raise", "TypeError", "(", "\"stop_chars should be type set \"", "\"but {} was given\"", ".", "format", "(", "type", "(", ...
Set stop characters for text on left from TLD. Stop characters are used when determining end of URL. :param set stop_chars: set of characters :raises: TypeError
[ "Set", "stop", "characters", "for", "text", "on", "left", "from", "TLD", ".", "Stop", "characters", "are", "used", "when", "determining", "end", "of", "URL", "." ]
b53fd2adfaed3cd23a811aed4d277b0ade7b4640
https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/urlextract_core.py#L223-L236
train
lipoja/URLExtract
urlextract/urlextract_core.py
URLExtract.add_enclosure
def add_enclosure(self, left_char, right_char): """ Add new enclosure pair of characters. That and should be removed when their presence is detected at beginning and end of found URL :param str left_char: left character of enclosure pair - e.g. "(" :param str right_char: right c...
python
def add_enclosure(self, left_char, right_char): """ Add new enclosure pair of characters. That and should be removed when their presence is detected at beginning and end of found URL :param str left_char: left character of enclosure pair - e.g. "(" :param str right_char: right c...
[ "def", "add_enclosure", "(", "self", ",", "left_char", ",", "right_char", ")", ":", "assert", "len", "(", "left_char", ")", "==", "1", ",", "\"Parameter left_char must be character not string\"", "assert", "len", "(", "right_char", ")", "==", "1", ",", "\"Parame...
Add new enclosure pair of characters. That and should be removed when their presence is detected at beginning and end of found URL :param str left_char: left character of enclosure pair - e.g. "(" :param str right_char: right character of enclosure pair - e.g. ")"
[ "Add", "new", "enclosure", "pair", "of", "characters", ".", "That", "and", "should", "be", "removed", "when", "their", "presence", "is", "detected", "at", "beginning", "and", "end", "of", "found", "URL" ]
b53fd2adfaed3cd23a811aed4d277b0ade7b4640
https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/urlextract_core.py#L272-L286
train
lipoja/URLExtract
urlextract/urlextract_core.py
URLExtract.remove_enclosure
def remove_enclosure(self, left_char, right_char): """ Remove enclosure pair from set of enclosures. :param str left_char: left character of enclosure pair - e.g. "(" :param str right_char: right character of enclosure pair - e.g. ")" """ assert len(left_char) == 1, \ ...
python
def remove_enclosure(self, left_char, right_char): """ Remove enclosure pair from set of enclosures. :param str left_char: left character of enclosure pair - e.g. "(" :param str right_char: right character of enclosure pair - e.g. ")" """ assert len(left_char) == 1, \ ...
[ "def", "remove_enclosure", "(", "self", ",", "left_char", ",", "right_char", ")", ":", "assert", "len", "(", "left_char", ")", "==", "1", ",", "\"Parameter left_char must be character not string\"", "assert", "len", "(", "right_char", ")", "==", "1", ",", "\"Par...
Remove enclosure pair from set of enclosures. :param str left_char: left character of enclosure pair - e.g. "(" :param str right_char: right character of enclosure pair - e.g. ")"
[ "Remove", "enclosure", "pair", "from", "set", "of", "enclosures", "." ]
b53fd2adfaed3cd23a811aed4d277b0ade7b4640
https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/urlextract_core.py#L288-L303
train
lipoja/URLExtract
urlextract/urlextract_core.py
URLExtract._complete_url
def _complete_url(self, text, tld_pos, tld): """ Expand string in both sides to match whole URL. :param str text: text where we want to find URL :param int tld_pos: position of TLD :param str tld: matched TLD which should be in text :return: returns URL :rtype: s...
python
def _complete_url(self, text, tld_pos, tld): """ Expand string in both sides to match whole URL. :param str text: text where we want to find URL :param int tld_pos: position of TLD :param str tld: matched TLD which should be in text :return: returns URL :rtype: s...
[ "def", "_complete_url", "(", "self", ",", "text", ",", "tld_pos", ",", "tld", ")", ":", "left_ok", "=", "True", "right_ok", "=", "True", "max_len", "=", "len", "(", "text", ")", "-", "1", "end_pos", "=", "tld_pos", "start_pos", "=", "tld_pos", "while",...
Expand string in both sides to match whole URL. :param str text: text where we want to find URL :param int tld_pos: position of TLD :param str tld: matched TLD which should be in text :return: returns URL :rtype: str
[ "Expand", "string", "in", "both", "sides", "to", "match", "whole", "URL", "." ]
b53fd2adfaed3cd23a811aed4d277b0ade7b4640
https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/urlextract_core.py#L305-L354
train
lipoja/URLExtract
urlextract/urlextract_core.py
URLExtract._validate_tld_match
def _validate_tld_match(self, text, matched_tld, tld_pos): """ Validate TLD match - tells if at found position is really TLD. :param str text: text where we want to find URLs :param str matched_tld: matched TLD :param int tld_pos: position of matched TLD :return: True if...
python
def _validate_tld_match(self, text, matched_tld, tld_pos): """ Validate TLD match - tells if at found position is really TLD. :param str text: text where we want to find URLs :param str matched_tld: matched TLD :param int tld_pos: position of matched TLD :return: True if...
[ "def", "_validate_tld_match", "(", "self", ",", "text", ",", "matched_tld", ",", "tld_pos", ")", ":", "if", "tld_pos", ">", "len", "(", "text", ")", ":", "return", "False", "right_tld_pos", "=", "tld_pos", "+", "len", "(", "matched_tld", ")", "if", "len"...
Validate TLD match - tells if at found position is really TLD. :param str text: text where we want to find URLs :param str matched_tld: matched TLD :param int tld_pos: position of matched TLD :return: True if match is valid, False otherwise :rtype: bool
[ "Validate", "TLD", "match", "-", "tells", "if", "at", "found", "position", "is", "really", "TLD", "." ]
b53fd2adfaed3cd23a811aed4d277b0ade7b4640
https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/urlextract_core.py#L356-L379
train
lipoja/URLExtract
urlextract/urlextract_core.py
URLExtract._split_markdown
def _split_markdown(text_url, tld_pos): """ Split markdown URL. There is an issue wen Markdown URL is found. Parsing of the URL does not stop on right place so wrongly found URL has to be split. :param str text_url: URL that we want to extract from enclosure :param int t...
python
def _split_markdown(text_url, tld_pos): """ Split markdown URL. There is an issue wen Markdown URL is found. Parsing of the URL does not stop on right place so wrongly found URL has to be split. :param str text_url: URL that we want to extract from enclosure :param int t...
[ "def", "_split_markdown", "(", "text_url", ",", "tld_pos", ")", ":", "left_bracket_pos", "=", "text_url", ".", "find", "(", "'['", ")", "if", "left_bracket_pos", ">", "tld_pos", "-", "3", ":", "return", "text_url", "right_bracket_pos", "=", "text_url", ".", ...
Split markdown URL. There is an issue wen Markdown URL is found. Parsing of the URL does not stop on right place so wrongly found URL has to be split. :param str text_url: URL that we want to extract from enclosure :param int tld_pos: position of TLD :return: URL that has remove...
[ "Split", "markdown", "URL", ".", "There", "is", "an", "issue", "wen", "Markdown", "URL", "is", "found", ".", "Parsing", "of", "the", "URL", "does", "not", "stop", "on", "right", "place", "so", "wrongly", "found", "URL", "has", "to", "be", "split", "." ...
b53fd2adfaed3cd23a811aed4d277b0ade7b4640
https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/urlextract_core.py#L497-L523
train
lipoja/URLExtract
urlextract/urlextract_core.py
URLExtract.gen_urls
def gen_urls(self, text): """ Creates generator over found URLs in given text. :param str text: text where we want to find URLs :yields: URL found in text or empty string if no found :rtype: str """ tld_pos = 0 matched_tlds = self._tlds_re.findall(text) ...
python
def gen_urls(self, text): """ Creates generator over found URLs in given text. :param str text: text where we want to find URLs :yields: URL found in text or empty string if no found :rtype: str """ tld_pos = 0 matched_tlds = self._tlds_re.findall(text) ...
[ "def", "gen_urls", "(", "self", ",", "text", ")", ":", "tld_pos", "=", "0", "matched_tlds", "=", "self", ".", "_tlds_re", ".", "findall", "(", "text", ")", "for", "tld", "in", "matched_tlds", ":", "tmp_text", "=", "text", "[", "tld_pos", ":", "]", "o...
Creates generator over found URLs in given text. :param str text: text where we want to find URLs :yields: URL found in text or empty string if no found :rtype: str
[ "Creates", "generator", "over", "found", "URLs", "in", "given", "text", "." ]
b53fd2adfaed3cd23a811aed4d277b0ade7b4640
https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/urlextract_core.py#L525-L555
train
lipoja/URLExtract
urlextract/urlextract_core.py
URLExtract.find_urls
def find_urls(self, text, only_unique=False): """ Find all URLs in given text. :param str text: text where we want to find URLs :param bool only_unique: return only unique URLs :return: list of URLs found in text :rtype: list """ urls = self.gen_urls(text...
python
def find_urls(self, text, only_unique=False): """ Find all URLs in given text. :param str text: text where we want to find URLs :param bool only_unique: return only unique URLs :return: list of URLs found in text :rtype: list """ urls = self.gen_urls(text...
[ "def", "find_urls", "(", "self", ",", "text", ",", "only_unique", "=", "False", ")", ":", "urls", "=", "self", ".", "gen_urls", "(", "text", ")", "urls", "=", "OrderedDict", ".", "fromkeys", "(", "urls", ")", "if", "only_unique", "else", "urls", "retur...
Find all URLs in given text. :param str text: text where we want to find URLs :param bool only_unique: return only unique URLs :return: list of URLs found in text :rtype: list
[ "Find", "all", "URLs", "in", "given", "text", "." ]
b53fd2adfaed3cd23a811aed4d277b0ade7b4640
https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/urlextract_core.py#L557-L568
train
pinax/pinax-badges
pinax/badges/base.py
Badge.possibly_award
def possibly_award(self, **state): """ Will see if the user should be awarded a badge. If this badge is asynchronous it just queues up the badge awarding. """ assert "user" in state if self.async: from .tasks import AsyncBadgeAward state = self.fr...
python
def possibly_award(self, **state): """ Will see if the user should be awarded a badge. If this badge is asynchronous it just queues up the badge awarding. """ assert "user" in state if self.async: from .tasks import AsyncBadgeAward state = self.fr...
[ "def", "possibly_award", "(", "self", ",", "**", "state", ")", ":", "assert", "\"user\"", "in", "state", "if", "self", ".", "async", ":", "from", ".", "tasks", "import", "AsyncBadgeAward", "state", "=", "self", ".", "freeze", "(", "**", "state", ")", "...
Will see if the user should be awarded a badge. If this badge is asynchronous it just queues up the badge awarding.
[ "Will", "see", "if", "the", "user", "should", "be", "awarded", "a", "badge", ".", "If", "this", "badge", "is", "asynchronous", "it", "just", "queues", "up", "the", "badge", "awarding", "." ]
0921c388088e7c7a77098dc7d0eea393b4707ce5
https://github.com/pinax/pinax-badges/blob/0921c388088e7c7a77098dc7d0eea393b4707ce5/pinax/badges/base.py#L26-L37
train
pinax/pinax-badges
pinax/badges/base.py
Badge.actually_possibly_award
def actually_possibly_award(self, **state): """ Does the actual work of possibly awarding a badge. """ user = state["user"] force_timestamp = state.pop("force_timestamp", None) awarded = self.award(**state) if awarded is None: return if awarded...
python
def actually_possibly_award(self, **state): """ Does the actual work of possibly awarding a badge. """ user = state["user"] force_timestamp = state.pop("force_timestamp", None) awarded = self.award(**state) if awarded is None: return if awarded...
[ "def", "actually_possibly_award", "(", "self", ",", "**", "state", ")", ":", "user", "=", "state", "[", "\"user\"", "]", "force_timestamp", "=", "state", ".", "pop", "(", "\"force_timestamp\"", ",", "None", ")", "awarded", "=", "self", ".", "award", "(", ...
Does the actual work of possibly awarding a badge.
[ "Does", "the", "actual", "work", "of", "possibly", "awarding", "a", "badge", "." ]
0921c388088e7c7a77098dc7d0eea393b4707ce5
https://github.com/pinax/pinax-badges/blob/0921c388088e7c7a77098dc7d0eea393b4707ce5/pinax/badges/base.py#L39-L69
train
pinax/pinax-badges
pinax/badges/base.py
Badge.send_badge_messages
def send_badge_messages(self, badge_award): """ If the Badge class defines a message, send it to the user who was just awarded the badge. """ user_message = getattr(badge_award.badge, "user_message", None) if callable(user_message): message = user_message(badg...
python
def send_badge_messages(self, badge_award): """ If the Badge class defines a message, send it to the user who was just awarded the badge. """ user_message = getattr(badge_award.badge, "user_message", None) if callable(user_message): message = user_message(badg...
[ "def", "send_badge_messages", "(", "self", ",", "badge_award", ")", ":", "user_message", "=", "getattr", "(", "badge_award", ".", "badge", ",", "\"user_message\"", ",", "None", ")", "if", "callable", "(", "user_message", ")", ":", "message", "=", "user_message...
If the Badge class defines a message, send it to the user who was just awarded the badge.
[ "If", "the", "Badge", "class", "defines", "a", "message", "send", "it", "to", "the", "user", "who", "was", "just", "awarded", "the", "badge", "." ]
0921c388088e7c7a77098dc7d0eea393b4707ce5
https://github.com/pinax/pinax-badges/blob/0921c388088e7c7a77098dc7d0eea393b4707ce5/pinax/badges/base.py#L71-L82
train
JBKahn/flake8-print
flake8_print.py
PrintFinder.visit_Print
def visit_Print(self, node): """Only exists in python 2.""" self.prints_used[(node.lineno, node.col_offset)] = VIOLATIONS["found"][PRINT_FUNCTION_NAME]
python
def visit_Print(self, node): """Only exists in python 2.""" self.prints_used[(node.lineno, node.col_offset)] = VIOLATIONS["found"][PRINT_FUNCTION_NAME]
[ "def", "visit_Print", "(", "self", ",", "node", ")", ":", "self", ".", "prints_used", "[", "(", "node", ".", "lineno", ",", "node", ".", "col_offset", ")", "]", "=", "VIOLATIONS", "[", "\"found\"", "]", "[", "PRINT_FUNCTION_NAME", "]" ]
Only exists in python 2.
[ "Only", "exists", "in", "python", "2", "." ]
e5d3812c4c93628ed804e9ecf74c2d31780627e5
https://github.com/JBKahn/flake8-print/blob/e5d3812c4c93628ed804e9ecf74c2d31780627e5/flake8_print.py#L30-L32
train
peterdemin/pip-compile-multi
pipcompilemulti/environment.py
Environment.create_lockfile
def create_lockfile(self): """ Write recursive dependencies list to outfile with hard-pinned versions. Then fix it. """ process = subprocess.Popen( self.pin_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) stdo...
python
def create_lockfile(self): """ Write recursive dependencies list to outfile with hard-pinned versions. Then fix it. """ process = subprocess.Popen( self.pin_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) stdo...
[ "def", "create_lockfile", "(", "self", ")", ":", "process", "=", "subprocess", ".", "Popen", "(", "self", ".", "pin_command", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "stderr", "=", "subprocess", ".", "PIPE", ",", ")", "stdout", ",", "stderr",...
Write recursive dependencies list to outfile with hard-pinned versions. Then fix it.
[ "Write", "recursive", "dependencies", "list", "to", "outfile", "with", "hard", "-", "pinned", "versions", ".", "Then", "fix", "it", "." ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/environment.py#L31-L50
train
peterdemin/pip-compile-multi
pipcompilemulti/environment.py
Environment.infile
def infile(self): """Path of the input file""" return os.path.join(OPTIONS['base_dir'], '{0}.{1}'.format(self.name, OPTIONS['in_ext']))
python
def infile(self): """Path of the input file""" return os.path.join(OPTIONS['base_dir'], '{0}.{1}'.format(self.name, OPTIONS['in_ext']))
[ "def", "infile", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "OPTIONS", "[", "'base_dir'", "]", ",", "'{0}.{1}'", ".", "format", "(", "self", ".", "name", ",", "OPTIONS", "[", "'in_ext'", "]", ")", ")" ]
Path of the input file
[ "Path", "of", "the", "input", "file" ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/environment.py#L74-L77
train
peterdemin/pip-compile-multi
pipcompilemulti/environment.py
Environment.outfile
def outfile(self): """Path of the output file""" return os.path.join(OPTIONS['base_dir'], '{0}.{1}'.format(self.name, OPTIONS['out_ext']))
python
def outfile(self): """Path of the output file""" return os.path.join(OPTIONS['base_dir'], '{0}.{1}'.format(self.name, OPTIONS['out_ext']))
[ "def", "outfile", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "OPTIONS", "[", "'base_dir'", "]", ",", "'{0}.{1}'", ".", "format", "(", "self", ".", "name", ",", "OPTIONS", "[", "'out_ext'", "]", ")", ")" ]
Path of the output file
[ "Path", "of", "the", "output", "file" ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/environment.py#L80-L83
train
peterdemin/pip-compile-multi
pipcompilemulti/environment.py
Environment.pin_command
def pin_command(self): """Compose pip-compile shell command""" parts = [ 'pip-compile', '--no-header', '--verbose', '--rebuild', '--no-index', '--output-file', self.outfile, self.infile, ] if OPTIONS['upg...
python
def pin_command(self): """Compose pip-compile shell command""" parts = [ 'pip-compile', '--no-header', '--verbose', '--rebuild', '--no-index', '--output-file', self.outfile, self.infile, ] if OPTIONS['upg...
[ "def", "pin_command", "(", "self", ")", ":", "parts", "=", "[", "'pip-compile'", ",", "'--no-header'", ",", "'--verbose'", ",", "'--rebuild'", ",", "'--no-index'", ",", "'--output-file'", ",", "self", ".", "outfile", ",", "self", ".", "infile", ",", "]", "...
Compose pip-compile shell command
[ "Compose", "pip", "-", "compile", "shell", "command" ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/environment.py#L86-L101
train
peterdemin/pip-compile-multi
pipcompilemulti/environment.py
Environment.fix_lockfile
def fix_lockfile(self): """Run each line of outfile through fix_pin""" with open(self.outfile, 'rt') as fp: lines = [ self.fix_pin(line) for line in self.concatenated(fp) ] with open(self.outfile, 'wt') as fp: fp.writelines([ ...
python
def fix_lockfile(self): """Run each line of outfile through fix_pin""" with open(self.outfile, 'rt') as fp: lines = [ self.fix_pin(line) for line in self.concatenated(fp) ] with open(self.outfile, 'wt') as fp: fp.writelines([ ...
[ "def", "fix_lockfile", "(", "self", ")", ":", "with", "open", "(", "self", ".", "outfile", ",", "'rt'", ")", "as", "fp", ":", "lines", "=", "[", "self", ".", "fix_pin", "(", "line", ")", "for", "line", "in", "self", ".", "concatenated", "(", "fp", ...
Run each line of outfile through fix_pin
[ "Run", "each", "line", "of", "outfile", "through", "fix_pin" ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/environment.py#L103-L115
train
peterdemin/pip-compile-multi
pipcompilemulti/environment.py
Environment.fix_pin
def fix_pin(self, line): """ Fix dependency by removing post-releases from versions and loosing constraints on internal packages. Drop packages from ignore set Also populate packages set """ dep = Dependency(line) if dep.valid: if dep.package ...
python
def fix_pin(self, line): """ Fix dependency by removing post-releases from versions and loosing constraints on internal packages. Drop packages from ignore set Also populate packages set """ dep = Dependency(line) if dep.valid: if dep.package ...
[ "def", "fix_pin", "(", "self", ",", "line", ")", ":", "dep", "=", "Dependency", "(", "line", ")", "if", "dep", ".", "valid", ":", "if", "dep", ".", "package", "in", "self", ".", "ignore", ":", "ignored_version", "=", "self", ".", "ignore", "[", "de...
Fix dependency by removing post-releases from versions and loosing constraints on internal packages. Drop packages from ignore set Also populate packages set
[ "Fix", "dependency", "by", "removing", "post", "-", "releases", "from", "versions", "and", "loosing", "constraints", "on", "internal", "packages", ".", "Drop", "packages", "from", "ignore", "set" ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/environment.py#L133-L163
train
peterdemin/pip-compile-multi
pipcompilemulti/environment.py
Environment.add_references
def add_references(self, other_names): """Add references to other_names in outfile""" if not other_names: # Skip on empty list return with open(self.outfile, 'rt') as fp: header, body = self.split_header(fp) with open(self.outfile, 'wt') as fp: ...
python
def add_references(self, other_names): """Add references to other_names in outfile""" if not other_names: # Skip on empty list return with open(self.outfile, 'rt') as fp: header, body = self.split_header(fp) with open(self.outfile, 'wt') as fp: ...
[ "def", "add_references", "(", "self", ",", "other_names", ")", ":", "if", "not", "other_names", ":", "return", "with", "open", "(", "self", ".", "outfile", ",", "'rt'", ")", "as", "fp", ":", "header", ",", "body", "=", "self", ".", "split_header", "(",...
Add references to other_names in outfile
[ "Add", "references", "to", "other_names", "in", "outfile" ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/environment.py#L165-L178
train
peterdemin/pip-compile-multi
pipcompilemulti/environment.py
Environment.replace_header
def replace_header(self, header_text): """Replace pip-compile header with custom text""" with open(self.outfile, 'rt') as fp: _, body = self.split_header(fp) with open(self.outfile, 'wt') as fp: fp.write(header_text) fp.writelines(body)
python
def replace_header(self, header_text): """Replace pip-compile header with custom text""" with open(self.outfile, 'rt') as fp: _, body = self.split_header(fp) with open(self.outfile, 'wt') as fp: fp.write(header_text) fp.writelines(body)
[ "def", "replace_header", "(", "self", ",", "header_text", ")", ":", "with", "open", "(", "self", ".", "outfile", ",", "'rt'", ")", "as", "fp", ":", "_", ",", "body", "=", "self", ".", "split_header", "(", "fp", ")", "with", "open", "(", "self", "."...
Replace pip-compile header with custom text
[ "Replace", "pip", "-", "compile", "header", "with", "custom", "text" ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/environment.py#L197-L203
train
peterdemin/pip-compile-multi
pipcompilemulti/discover.py
order_by_refs
def order_by_refs(envs): """ Return topologicaly sorted list of environments. I.e. all referenced environments are placed before their references. """ topology = { env['name']: set(env['refs']) for env in envs } by_name = { env['name']: env for env in envs ...
python
def order_by_refs(envs): """ Return topologicaly sorted list of environments. I.e. all referenced environments are placed before their references. """ topology = { env['name']: set(env['refs']) for env in envs } by_name = { env['name']: env for env in envs ...
[ "def", "order_by_refs", "(", "envs", ")", ":", "topology", "=", "{", "env", "[", "'name'", "]", ":", "set", "(", "env", "[", "'refs'", "]", ")", "for", "env", "in", "envs", "}", "by_name", "=", "{", "env", "[", "'name'", "]", ":", "env", "for", ...
Return topologicaly sorted list of environments. I.e. all referenced environments are placed before their references.
[ "Return", "topologicaly", "sorted", "list", "of", "environments", ".", "I", ".", "e", ".", "all", "referenced", "environments", "are", "placed", "before", "their", "references", "." ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/discover.py#L46-L62
train
peterdemin/pip-compile-multi
pipcompilemulti/dependency.py
Dependency.is_compatible
def is_compatible(self): """Check if package name is matched by compatible_patterns""" for pattern in OPTIONS['compatible_patterns']: if fnmatch(self.package.lower(), pattern): return True return False
python
def is_compatible(self): """Check if package name is matched by compatible_patterns""" for pattern in OPTIONS['compatible_patterns']: if fnmatch(self.package.lower(), pattern): return True return False
[ "def", "is_compatible", "(", "self", ")", ":", "for", "pattern", "in", "OPTIONS", "[", "'compatible_patterns'", "]", ":", "if", "fnmatch", "(", "self", ".", "package", ".", "lower", "(", ")", ",", "pattern", ")", ":", "return", "True", "return", "False" ...
Check if package name is matched by compatible_patterns
[ "Check", "if", "package", "name", "is", "matched", "by", "compatible_patterns" ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/dependency.py#L104-L109
train
peterdemin/pip-compile-multi
pipcompilemulti/dependency.py
Dependency.drop_post
def drop_post(self): """Remove .postXXXX postfix from version""" post_index = self.version.find('.post') if post_index >= 0: self.version = self.version[:post_index]
python
def drop_post(self): """Remove .postXXXX postfix from version""" post_index = self.version.find('.post') if post_index >= 0: self.version = self.version[:post_index]
[ "def", "drop_post", "(", "self", ")", ":", "post_index", "=", "self", ".", "version", ".", "find", "(", "'.post'", ")", "if", "post_index", ">=", "0", ":", "self", ".", "version", "=", "self", ".", "version", "[", ":", "post_index", "]" ]
Remove .postXXXX postfix from version
[ "Remove", ".", "postXXXX", "postfix", "from", "version" ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/dependency.py#L111-L115
train
peterdemin/pip-compile-multi
pipcompilemulti/verify.py
verify_environments
def verify_environments(): """ For each environment verify hash comments and report failures. If any failure occured, exit with code 1. """ env_confs = discover( os.path.join( OPTIONS['base_dir'], '*.' + OPTIONS['in_ext'], ) ) success = True for co...
python
def verify_environments(): """ For each environment verify hash comments and report failures. If any failure occured, exit with code 1. """ env_confs = discover( os.path.join( OPTIONS['base_dir'], '*.' + OPTIONS['in_ext'], ) ) success = True for co...
[ "def", "verify_environments", "(", ")", ":", "env_confs", "=", "discover", "(", "os", ".", "path", ".", "join", "(", "OPTIONS", "[", "'base_dir'", "]", ",", "'*.'", "+", "OPTIONS", "[", "'in_ext'", "]", ",", ")", ")", "success", "=", "True", "for", "...
For each environment verify hash comments and report failures. If any failure occured, exit with code 1.
[ "For", "each", "environment", "verify", "hash", "comments", "and", "report", "failures", ".", "If", "any", "failure", "occured", "exit", "with", "code", "1", "." ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/verify.py#L15-L40
train
peterdemin/pip-compile-multi
pipcompilemulti/verify.py
generate_hash_comment
def generate_hash_comment(file_path): """ Read file with given file_path and return string of format # SHA1:da39a3ee5e6b4b0d3255bfef95601890afd80709 which is hex representation of SHA1 file content hash """ with open(file_path, 'rb') as fp: hexdigest = hashlib.sha1(fp.read().strip(...
python
def generate_hash_comment(file_path): """ Read file with given file_path and return string of format # SHA1:da39a3ee5e6b4b0d3255bfef95601890afd80709 which is hex representation of SHA1 file content hash """ with open(file_path, 'rb') as fp: hexdigest = hashlib.sha1(fp.read().strip(...
[ "def", "generate_hash_comment", "(", "file_path", ")", ":", "with", "open", "(", "file_path", ",", "'rb'", ")", "as", "fp", ":", "hexdigest", "=", "hashlib", ".", "sha1", "(", "fp", ".", "read", "(", ")", ".", "strip", "(", ")", ")", ".", "hexdigest"...
Read file with given file_path and return string of format # SHA1:da39a3ee5e6b4b0d3255bfef95601890afd80709 which is hex representation of SHA1 file content hash
[ "Read", "file", "with", "given", "file_path", "and", "return", "string", "of", "format" ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/verify.py#L43-L53
train
peterdemin/pip-compile-multi
pipcompilemulti/config.py
parse_value
def parse_value(key, value): """Parse value as comma-delimited list if default value for it is list""" default = OPTIONS.get(key) if isinstance(default, collections.Iterable): if not isinstance(default, six.string_types): return [item.strip() for item in value.split('...
python
def parse_value(key, value): """Parse value as comma-delimited list if default value for it is list""" default = OPTIONS.get(key) if isinstance(default, collections.Iterable): if not isinstance(default, six.string_types): return [item.strip() for item in value.split('...
[ "def", "parse_value", "(", "key", ",", "value", ")", ":", "default", "=", "OPTIONS", ".", "get", "(", "key", ")", "if", "isinstance", "(", "default", ",", "collections", ".", "Iterable", ")", ":", "if", "not", "isinstance", "(", "default", ",", "six", ...
Parse value as comma-delimited list if default value for it is list
[ "Parse", "value", "as", "comma", "-", "delimited", "list", "if", "default", "value", "for", "it", "is", "list" ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/config.py#L53-L60
train
peterdemin/pip-compile-multi
pipcompilemulti/config.py
python_version_matchers
def python_version_matchers(): """Return set of string representations of current python version""" version = sys.version_info patterns = [ "{0}", "{0}{1}", "{0}.{1}", ] matchers = [ pattern.format(*version) for pattern in patterns ] + [None] return se...
python
def python_version_matchers(): """Return set of string representations of current python version""" version = sys.version_info patterns = [ "{0}", "{0}{1}", "{0}.{1}", ] matchers = [ pattern.format(*version) for pattern in patterns ] + [None] return se...
[ "def", "python_version_matchers", "(", ")", ":", "version", "=", "sys", ".", "version_info", "patterns", "=", "[", "\"{0}\"", ",", "\"{0}{1}\"", ",", "\"{0}.{1}\"", ",", "]", "matchers", "=", "[", "pattern", ".", "format", "(", "*", "version", ")", "for", ...
Return set of string representations of current python version
[ "Return", "set", "of", "string", "representations", "of", "current", "python", "version" ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/config.py#L63-L75
train
peterdemin/pip-compile-multi
pipcompilemulti/cli_v2.py
verify
def verify(ctx): """Upgrade locked dependency versions""" oks = run_configurations( skipper(verify_environments), read_sections, ) ctx.exit(0 if False not in oks else 1)
python
def verify(ctx): """Upgrade locked dependency versions""" oks = run_configurations( skipper(verify_environments), read_sections, ) ctx.exit(0 if False not in oks else 1)
[ "def", "verify", "(", "ctx", ")", ":", "oks", "=", "run_configurations", "(", "skipper", "(", "verify_environments", ")", ",", "read_sections", ",", ")", "ctx", ".", "exit", "(", "0", "if", "False", "not", "in", "oks", "else", "1", ")" ]
Upgrade locked dependency versions
[ "Upgrade", "locked", "dependency", "versions" ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/cli_v2.py#L38-L46
train
peterdemin/pip-compile-multi
pipcompilemulti/cli_v2.py
skipper
def skipper(func): """Decorator that memorizes base_dir, in_ext and out_ext from OPTIONS and skips execution for duplicates.""" @functools.wraps(func) def wrapped(): """Dummy docstring to make pylint happy.""" key = (OPTIONS['base_dir'], OPTIONS['in_ext'], OPTIONS['out_ext']) if ...
python
def skipper(func): """Decorator that memorizes base_dir, in_ext and out_ext from OPTIONS and skips execution for duplicates.""" @functools.wraps(func) def wrapped(): """Dummy docstring to make pylint happy.""" key = (OPTIONS['base_dir'], OPTIONS['in_ext'], OPTIONS['out_ext']) if ...
[ "def", "skipper", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapped", "(", ")", ":", "key", "=", "(", "OPTIONS", "[", "'base_dir'", "]", ",", "OPTIONS", "[", "'in_ext'", "]", ",", "OPTIONS", "[", "'out_ext'", ...
Decorator that memorizes base_dir, in_ext and out_ext from OPTIONS and skips execution for duplicates.
[ "Decorator", "that", "memorizes", "base_dir", "in_ext", "and", "out_ext", "from", "OPTIONS", "and", "skips", "execution", "for", "duplicates", "." ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/cli_v2.py#L49-L60
train
peterdemin/pip-compile-multi
pipcompilemulti/cli_v2.py
run_configurations
def run_configurations(callback, sections_reader): """Parse configurations and execute callback for matching.""" base = dict(OPTIONS) sections = sections_reader() if sections is None: logger.info("Configuration not found in .ini files. " "Running with default settings") ...
python
def run_configurations(callback, sections_reader): """Parse configurations and execute callback for matching.""" base = dict(OPTIONS) sections = sections_reader() if sections is None: logger.info("Configuration not found in .ini files. " "Running with default settings") ...
[ "def", "run_configurations", "(", "callback", ",", "sections_reader", ")", ":", "base", "=", "dict", "(", "OPTIONS", ")", "sections", "=", "sections_reader", "(", ")", "if", "sections", "is", "None", ":", "logger", ".", "info", "(", "\"Configuration not found ...
Parse configurations and execute callback for matching.
[ "Parse", "configurations", "and", "execute", "callback", "for", "matching", "." ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/cli_v2.py#L63-L82
train
peterdemin/pip-compile-multi
pipcompilemulti/actions.py
recompile
def recompile(): """ Compile requirements files for all environments. """ pinned_packages = {} env_confs = discover( os.path.join( OPTIONS['base_dir'], '*.' + OPTIONS['in_ext'], ), ) if OPTIONS['header_file']: with open(OPTIONS['header_file']) ...
python
def recompile(): """ Compile requirements files for all environments. """ pinned_packages = {} env_confs = discover( os.path.join( OPTIONS['base_dir'], '*.' + OPTIONS['in_ext'], ), ) if OPTIONS['header_file']: with open(OPTIONS['header_file']) ...
[ "def", "recompile", "(", ")", ":", "pinned_packages", "=", "{", "}", "env_confs", "=", "discover", "(", "os", ".", "path", ".", "join", "(", "OPTIONS", "[", "'base_dir'", "]", ",", "'*.'", "+", "OPTIONS", "[", "'in_ext'", "]", ",", ")", ",", ")", "...
Compile requirements files for all environments.
[ "Compile", "requirements", "files", "for", "all", "environments", "." ]
7bd1968c424dd7ce3236885b4b3e4e28523e6915
https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/actions.py#L17-L62
train