partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
PE._parseExportDirectory
Parses the C{IMAGE_EXPORT_DIRECTORY} directory. @type rva: int @param rva: The RVA where the C{IMAGE_EXPORT_DIRECTORY} directory starts. @type size: int @param size: The size of the C{IMAGE_EXPORT_DIRECTORY} directory. @type magic: int @param m...
pype32/pype32.py
def _parseExportDirectory(self, rva, size, magic = consts.PE32): """ Parses the C{IMAGE_EXPORT_DIRECTORY} directory. @type rva: int @param rva: The RVA where the C{IMAGE_EXPORT_DIRECTORY} directory starts. @type size: int @param size: The size of the C{...
def _parseExportDirectory(self, rva, size, magic = consts.PE32): """ Parses the C{IMAGE_EXPORT_DIRECTORY} directory. @type rva: int @param rva: The RVA where the C{IMAGE_EXPORT_DIRECTORY} directory starts. @type size: int @param size: The size of the C{...
[ "Parses", "the", "C", "{", "IMAGE_EXPORT_DIRECTORY", "}", "directory", "." ]
crackinglandia/pype32
python
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/pype32.py#L1132-L1202
[ "def", "_parseExportDirectory", "(", "self", ",", "rva", ",", "size", ",", "magic", "=", "consts", ".", "PE32", ")", ":", "data", "=", "self", ".", "getDataAtRva", "(", "rva", ",", "size", ")", "rd", "=", "utils", ".", "ReadData", "(", "data", ")", ...
192fd14dfc0dd36d953739a81c17fbaf5e3d6076
train
PE._parseDebugDirectory
Parses the C{IMAGE_DEBUG_DIRECTORY} directory. @see: U{http://msdn.microsoft.com/es-es/library/windows/desktop/ms680307(v=vs.85).aspx} @type rva: int @param rva: The RVA where the C{IMAGE_DEBUG_DIRECTORY} directory starts. @type size: int @param size: The size ...
pype32/pype32.py
def _parseDebugDirectory(self, rva, size, magic = consts.PE32): """ Parses the C{IMAGE_DEBUG_DIRECTORY} directory. @see: U{http://msdn.microsoft.com/es-es/library/windows/desktop/ms680307(v=vs.85).aspx} @type rva: int @param rva: The RVA where the C{IMAGE_DEBUG_DIRECTOR...
def _parseDebugDirectory(self, rva, size, magic = consts.PE32): """ Parses the C{IMAGE_DEBUG_DIRECTORY} directory. @see: U{http://msdn.microsoft.com/es-es/library/windows/desktop/ms680307(v=vs.85).aspx} @type rva: int @param rva: The RVA where the C{IMAGE_DEBUG_DIRECTOR...
[ "Parses", "the", "C", "{", "IMAGE_DEBUG_DIRECTORY", "}", "directory", "." ]
crackinglandia/pype32
python
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/pype32.py#L1204-L1224
[ "def", "_parseDebugDirectory", "(", "self", ",", "rva", ",", "size", ",", "magic", "=", "consts", ".", "PE32", ")", ":", "debugDirData", "=", "self", ".", "getDataAtRva", "(", "rva", ",", "size", ")", "numberOfEntries", "=", "size", "/", "consts", ".", ...
192fd14dfc0dd36d953739a81c17fbaf5e3d6076
train
PE._parseImportDirectory
Parses the C{IMAGE_IMPORT_DIRECTORY} directory. @type rva: int @param rva: The RVA where the C{IMAGE_IMPORT_DIRECTORY} directory starts. @type size: int @param size: The size of the C{IMAGE_IMPORT_DIRECTORY} directory. @type magic: int @param m...
pype32/pype32.py
def _parseImportDirectory(self, rva, size, magic = consts.PE32): """ Parses the C{IMAGE_IMPORT_DIRECTORY} directory. @type rva: int @param rva: The RVA where the C{IMAGE_IMPORT_DIRECTORY} directory starts. @type size: int @param size: The size of the C{...
def _parseImportDirectory(self, rva, size, magic = consts.PE32): """ Parses the C{IMAGE_IMPORT_DIRECTORY} directory. @type rva: int @param rva: The RVA where the C{IMAGE_IMPORT_DIRECTORY} directory starts. @type size: int @param size: The size of the C{...
[ "Parses", "the", "C", "{", "IMAGE_IMPORT_DIRECTORY", "}", "directory", "." ]
crackinglandia/pype32
python
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/pype32.py#L1226-L1362
[ "def", "_parseImportDirectory", "(", "self", ",", "rva", ",", "size", ",", "magic", "=", "consts", ".", "PE32", ")", ":", "#print \"RVA: %x - Size: %x\" % (rva, size) ", "importsDirData", "=", "self", ".", "getDataAtRva", "(", "rva", ",", "size", ")", "#p...
192fd14dfc0dd36d953739a81c17fbaf5e3d6076
train
PE._parseNetDirectory
Parses the NET directory. @see: U{http://www.ntcore.com/files/dotnetformat.htm} @type rva: int @param rva: The RVA where the NET directory starts. @type size: int @param size: The size of the NET directory. @type magic: int @param magic...
pype32/pype32.py
def _parseNetDirectory(self, rva, size, magic = consts.PE32): """ Parses the NET directory. @see: U{http://www.ntcore.com/files/dotnetformat.htm} @type rva: int @param rva: The RVA where the NET directory starts. @type size: int @param size: The...
def _parseNetDirectory(self, rva, size, magic = consts.PE32): """ Parses the NET directory. @see: U{http://www.ntcore.com/files/dotnetformat.htm} @type rva: int @param rva: The RVA where the NET directory starts. @type size: int @param size: The...
[ "Parses", "the", "NET", "directory", "." ]
crackinglandia/pype32
python
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/pype32.py#L1364-L1458
[ "def", "_parseNetDirectory", "(", "self", ",", "rva", ",", "size", ",", "magic", "=", "consts", ".", "PE32", ")", ":", "if", "not", "rva", "or", "not", "size", ":", "return", "None", "# create a NETDirectory class to hold the data", "netDirectoryClass", "=", "...
192fd14dfc0dd36d953739a81c17fbaf5e3d6076
train
DosHeader.parse
Returns a new L{DosHeader} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{DosHeader} object. @rtype: L{DosHeader} @return: A new L{DosHeader} object.
pype32/pype32.py
def parse(readDataInstance): """ Returns a new L{DosHeader} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{DosHeader} object. @rtype: L{DosHeader} @return: A new L{DosHeader} object...
def parse(readDataInstance): """ Returns a new L{DosHeader} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{DosHeader} object. @rtype: L{DosHeader} @return: A new L{DosHeader} object...
[ "Returns", "a", "new", "L", "{", "DosHeader", "}", "object", "." ]
crackinglandia/pype32
python
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/pype32.py#L1617-L1656
[ "def", "parse", "(", "readDataInstance", ")", ":", "dosHdr", "=", "DosHeader", "(", ")", "dosHdr", ".", "e_magic", ".", "value", "=", "readDataInstance", ".", "readWord", "(", ")", "dosHdr", ".", "e_cblp", ".", "value", "=", "readDataInstance", ".", "readW...
192fd14dfc0dd36d953739a81c17fbaf5e3d6076
train
NtHeaders.parse
Returns a new L{NtHeaders} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{NtHeaders} object. @rtype: L{NtHeaders} @return: A new L{NtHeaders} object.
pype32/pype32.py
def parse(readDataInstance): """ Returns a new L{NtHeaders} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{NtHeaders} object. @rtype: L{NtHeaders} @return: A new L{NtHeaders} object...
def parse(readDataInstance): """ Returns a new L{NtHeaders} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{NtHeaders} object. @rtype: L{NtHeaders} @return: A new L{NtHeaders} object...
[ "Returns", "a", "new", "L", "{", "NtHeaders", "}", "object", "." ]
crackinglandia/pype32
python
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/pype32.py#L1682-L1696
[ "def", "parse", "(", "readDataInstance", ")", ":", "nt", "=", "NtHeaders", "(", ")", "nt", ".", "signature", ".", "value", "=", "readDataInstance", ".", "readDword", "(", ")", "nt", ".", "fileHeader", "=", "FileHeader", ".", "parse", "(", "readDataInstance...
192fd14dfc0dd36d953739a81c17fbaf5e3d6076
train
FileHeader.parse
Returns a new L{FileHeader} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{FileHeader} object. @rtype: L{FileHeader} @return: A new L{ReadData} object.
pype32/pype32.py
def parse(readDataInstance): """ Returns a new L{FileHeader} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{FileHeader} object. @rtype: L{FileHeader} @return: A new L{ReadData} obje...
def parse(readDataInstance): """ Returns a new L{FileHeader} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{FileHeader} object. @rtype: L{FileHeader} @return: A new L{ReadData} obje...
[ "Returns", "a", "new", "L", "{", "FileHeader", "}", "object", "." ]
crackinglandia/pype32
python
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/pype32.py#L1726-L1744
[ "def", "parse", "(", "readDataInstance", ")", ":", "fh", "=", "FileHeader", "(", ")", "fh", ".", "machine", ".", "value", "=", "readDataInstance", ".", "readWord", "(", ")", "fh", ".", "numberOfSections", ".", "value", "=", "readDataInstance", ".", "readWo...
192fd14dfc0dd36d953739a81c17fbaf5e3d6076
train
OptionalHeader.parse
Returns a new L{OptionalHeader} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{OptionalHeader} object. @rtype: L{OptionalHeader} @return: A new L{OptionalHeader} object.
pype32/pype32.py
def parse(readDataInstance): """ Returns a new L{OptionalHeader} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{OptionalHeader} object. @rtype: L{OptionalHeader} @return: A new L{Op...
def parse(readDataInstance): """ Returns a new L{OptionalHeader} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{OptionalHeader} object. @rtype: L{OptionalHeader} @return: A new L{Op...
[ "Returns", "a", "new", "L", "{", "OptionalHeader", "}", "object", "." ]
crackinglandia/pype32
python
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/pype32.py#L1802-L1849
[ "def", "parse", "(", "readDataInstance", ")", ":", "oh", "=", "OptionalHeader", "(", ")", "oh", ".", "magic", ".", "value", "=", "readDataInstance", ".", "readWord", "(", ")", "oh", ".", "majorLinkerVersion", ".", "value", "=", "readDataInstance", ".", "re...
192fd14dfc0dd36d953739a81c17fbaf5e3d6076
train
SectionHeader.parse
Returns a new L{SectionHeader} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{SectionHeader} object. @rtype: L{SectionHeader} @return: A new L{SectionHeader} object.
pype32/pype32.py
def parse(readDataInstance): """ Returns a new L{SectionHeader} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{SectionHeader} object. @rtype: L{SectionHeader} @return: A new L{Secti...
def parse(readDataInstance): """ Returns a new L{SectionHeader} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{SectionHeader} object. @rtype: L{SectionHeader} @return: A new L{Secti...
[ "Returns", "a", "new", "L", "{", "SectionHeader", "}", "object", "." ]
crackinglandia/pype32
python
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/pype32.py#L2017-L2038
[ "def", "parse", "(", "readDataInstance", ")", ":", "sh", "=", "SectionHeader", "(", ")", "sh", ".", "name", ".", "value", "=", "readDataInstance", ".", "read", "(", "8", ")", "sh", ".", "misc", ".", "value", "=", "readDataInstance", ".", "readDword", "...
192fd14dfc0dd36d953739a81c17fbaf5e3d6076
train
SectionHeaders.parse
Returns a new L{SectionHeaders} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{SectionHeaders} object. @type numberOfSectionHeaders: int @param numberOfSectionHeaders: The number of L{SectionHeader...
pype32/pype32.py
def parse(readDataInstance, numberOfSectionHeaders): """ Returns a new L{SectionHeaders} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{SectionHeaders} object. @type numberOfSectionHeaders...
def parse(readDataInstance, numberOfSectionHeaders): """ Returns a new L{SectionHeaders} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{SectionHeaders} object. @type numberOfSectionHeaders...
[ "Returns", "a", "new", "L", "{", "SectionHeaders", "}", "object", "." ]
crackinglandia/pype32
python
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/pype32.py#L2069-L2097
[ "def", "parse", "(", "readDataInstance", ",", "numberOfSectionHeaders", ")", ":", "sHdrs", "=", "SectionHeaders", "(", "numberOfSectionHeaders", "=", "0", ")", "for", "i", "in", "range", "(", "numberOfSectionHeaders", ")", ":", "sh", "=", "SectionHeader", "(", ...
192fd14dfc0dd36d953739a81c17fbaf5e3d6076
train
Sections.parse
Returns a new L{Sections} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{Sections} object. @type sectionHeadersInstance: instance @param sectionHeadersInstance: The L{SectionHeaders} instance with ...
pype32/pype32.py
def parse(readDataInstance, sectionHeadersInstance): """ Returns a new L{Sections} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{Sections} object. @type sectionHeadersInstance: instance ...
def parse(readDataInstance, sectionHeadersInstance): """ Returns a new L{Sections} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{Sections} object. @type sectionHeadersInstance: instance ...
[ "Returns", "a", "new", "L", "{", "Sections", "}", "object", "." ]
crackinglandia/pype32
python
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/pype32.py#L2118-L2151
[ "def", "parse", "(", "readDataInstance", ",", "sectionHeadersInstance", ")", ":", "sData", "=", "Sections", "(", ")", "for", "sectionHdr", "in", "sectionHeadersInstance", ":", "if", "sectionHdr", ".", "sizeOfRawData", ".", "value", ">", "len", "(", "readDataInst...
192fd14dfc0dd36d953739a81c17fbaf5e3d6076
train
get_addresses_on_both_chains
Get addresses across both subchains based on the filter criteria passed in Returns a list of dicts of the following form: [ {'address': '1abc123...', 'path': 'm/0/9', 'pubkeyhex': '0123456...'}, ..., ] Dicts may also contain WIF and privkeyhex if wallet_obj has private ...
bcwallet/bcwallet.py
def get_addresses_on_both_chains(wallet_obj, used=None, zero_balance=None): ''' Get addresses across both subchains based on the filter criteria passed in Returns a list of dicts of the following form: [ {'address': '1abc123...', 'path': 'm/0/9', 'pubkeyhex': '0123456...'}, ...
def get_addresses_on_both_chains(wallet_obj, used=None, zero_balance=None): ''' Get addresses across both subchains based on the filter criteria passed in Returns a list of dicts of the following form: [ {'address': '1abc123...', 'path': 'm/0/9', 'pubkeyhex': '0123456...'}, ...
[ "Get", "addresses", "across", "both", "subchains", "based", "on", "the", "filter", "criteria", "passed", "in" ]
blockcypher/bcwallet
python
https://github.com/blockcypher/bcwallet/blob/4c623a8e19705332c9398c3fea9d5dc3c1dafb9b/bcwallet/bcwallet.py#L153-L202
[ "def", "get_addresses_on_both_chains", "(", "wallet_obj", ",", "used", "=", "None", ",", "zero_balance", "=", "None", ")", ":", "mpub", "=", "wallet_obj", ".", "serialize_b58", "(", "private", "=", "False", ")", "wallet_name", "=", "get_blockcypher_walletname_from...
4c623a8e19705332c9398c3fea9d5dc3c1dafb9b
train
register_unused_addresses
Hit /derive to register new unused_addresses on a subchain_index and verify them client-side Returns a list of dicts of the following form: [ {'address': '1abc123...', 'path': 'm/0/9', 'public': '0123456...'}, ..., ]
bcwallet/bcwallet.py
def register_unused_addresses(wallet_obj, subchain_index, num_addrs=1): ''' Hit /derive to register new unused_addresses on a subchain_index and verify them client-side Returns a list of dicts of the following form: [ {'address': '1abc123...', 'path': 'm/0/9', 'public': '0123456...'}, ...
def register_unused_addresses(wallet_obj, subchain_index, num_addrs=1): ''' Hit /derive to register new unused_addresses on a subchain_index and verify them client-side Returns a list of dicts of the following form: [ {'address': '1abc123...', 'path': 'm/0/9', 'public': '0123456...'}, ...
[ "Hit", "/", "derive", "to", "register", "new", "unused_addresses", "on", "a", "subchain_index", "and", "verify", "them", "client", "-", "side" ]
blockcypher/bcwallet
python
https://github.com/blockcypher/bcwallet/blob/4c623a8e19705332c9398c3fea9d5dc3c1dafb9b/bcwallet/bcwallet.py#L205-L254
[ "def", "register_unused_addresses", "(", "wallet_obj", ",", "subchain_index", ",", "num_addrs", "=", "1", ")", ":", "verbose_print", "(", "'register_unused_addresses called on subchain %s for %s addrs'", "%", "(", "subchain_index", ",", "num_addrs", ",", ")", ")", "asse...
4c623a8e19705332c9398c3fea9d5dc3c1dafb9b
train
dump_all_keys_or_addrs
Offline-enabled mechanism to dump addresses
bcwallet/bcwallet.py
def dump_all_keys_or_addrs(wallet_obj): ''' Offline-enabled mechanism to dump addresses ''' print_traversal_warning() puts('\nDo you understand this warning?') if not confirm(user_prompt=DEFAULT_PROMPT, default=False): puts(colored.red('Dump Cancelled!')) return mpub = wal...
def dump_all_keys_or_addrs(wallet_obj): ''' Offline-enabled mechanism to dump addresses ''' print_traversal_warning() puts('\nDo you understand this warning?') if not confirm(user_prompt=DEFAULT_PROMPT, default=False): puts(colored.red('Dump Cancelled!')) return mpub = wal...
[ "Offline", "-", "enabled", "mechanism", "to", "dump", "addresses" ]
blockcypher/bcwallet
python
https://github.com/blockcypher/bcwallet/blob/4c623a8e19705332c9398c3fea9d5dc3c1dafb9b/bcwallet/bcwallet.py#L869-L932
[ "def", "dump_all_keys_or_addrs", "(", "wallet_obj", ")", ":", "print_traversal_warning", "(", ")", "puts", "(", "'\\nDo you understand this warning?'", ")", "if", "not", "confirm", "(", "user_prompt", "=", "DEFAULT_PROMPT", ",", "default", "=", "False", ")", ":", ...
4c623a8e19705332c9398c3fea9d5dc3c1dafb9b
train
dump_selected_keys_or_addrs
Works for both public key only or private key access
bcwallet/bcwallet.py
def dump_selected_keys_or_addrs(wallet_obj, used=None, zero_balance=None): ''' Works for both public key only or private key access ''' if wallet_obj.private_key: content_str = 'private keys' else: content_str = 'addresses' if not USER_ONLINE: puts(colored.red('\nInterne...
def dump_selected_keys_or_addrs(wallet_obj, used=None, zero_balance=None): ''' Works for both public key only or private key access ''' if wallet_obj.private_key: content_str = 'private keys' else: content_str = 'addresses' if not USER_ONLINE: puts(colored.red('\nInterne...
[ "Works", "for", "both", "public", "key", "only", "or", "private", "key", "access" ]
blockcypher/bcwallet
python
https://github.com/blockcypher/bcwallet/blob/4c623a8e19705332c9398c3fea9d5dc3c1dafb9b/bcwallet/bcwallet.py#L935-L998
[ "def", "dump_selected_keys_or_addrs", "(", "wallet_obj", ",", "used", "=", "None", ",", "zero_balance", "=", "None", ")", ":", "if", "wallet_obj", ".", "private_key", ":", "content_str", "=", "'private keys'", "else", ":", "content_str", "=", "'addresses'", "if"...
4c623a8e19705332c9398c3fea9d5dc3c1dafb9b
train
dump_private_keys_or_addrs_chooser
Offline-enabled mechanism to dump everything
bcwallet/bcwallet.py
def dump_private_keys_or_addrs_chooser(wallet_obj): ''' Offline-enabled mechanism to dump everything ''' if wallet_obj.private_key: puts('Which private keys and addresses do you want?') else: puts('Which addresses do you want?') with indent(2): puts(colored.cyan('1: Acti...
def dump_private_keys_or_addrs_chooser(wallet_obj): ''' Offline-enabled mechanism to dump everything ''' if wallet_obj.private_key: puts('Which private keys and addresses do you want?') else: puts('Which addresses do you want?') with indent(2): puts(colored.cyan('1: Acti...
[ "Offline", "-", "enabled", "mechanism", "to", "dump", "everything" ]
blockcypher/bcwallet
python
https://github.com/blockcypher/bcwallet/blob/4c623a8e19705332c9398c3fea9d5dc3c1dafb9b/bcwallet/bcwallet.py#L1001-L1034
[ "def", "dump_private_keys_or_addrs_chooser", "(", "wallet_obj", ")", ":", "if", "wallet_obj", ".", "private_key", ":", "puts", "(", "'Which private keys and addresses do you want?'", ")", "else", ":", "puts", "(", "'Which addresses do you want?'", ")", "with", "indent", ...
4c623a8e19705332c9398c3fea9d5dc3c1dafb9b
train
wallet_home
Loaded on bootup (and stays in while loop until quitting)
bcwallet/bcwallet.py
def wallet_home(wallet_obj): ''' Loaded on bootup (and stays in while loop until quitting) ''' mpub = wallet_obj.serialize_b58(private=False) if wallet_obj.private_key is None: print_pubwallet_notice(mpub=mpub) else: print_bcwallet_basic_pub_opening(mpub=mpub) coin_symbol =...
def wallet_home(wallet_obj): ''' Loaded on bootup (and stays in while loop until quitting) ''' mpub = wallet_obj.serialize_b58(private=False) if wallet_obj.private_key is None: print_pubwallet_notice(mpub=mpub) else: print_bcwallet_basic_pub_opening(mpub=mpub) coin_symbol =...
[ "Loaded", "on", "bootup", "(", "and", "stays", "in", "while", "loop", "until", "quitting", ")" ]
blockcypher/bcwallet
python
https://github.com/blockcypher/bcwallet/blob/4c623a8e19705332c9398c3fea9d5dc3c1dafb9b/bcwallet/bcwallet.py#L1091-L1173
[ "def", "wallet_home", "(", "wallet_obj", ")", ":", "mpub", "=", "wallet_obj", ".", "serialize_b58", "(", "private", "=", "False", ")", "if", "wallet_obj", ".", "private_key", "is", "None", ":", "print_pubwallet_notice", "(", "mpub", "=", "mpub", ")", "else",...
4c623a8e19705332c9398c3fea9d5dc3c1dafb9b
train
TrailSolver.solve
Solves the GFL for a fixed value of lambda.
pygfl/solver.py
def solve(self, lam): '''Solves the GFL for a fixed value of lambda.''' if self.penalty == 'dp': return self.solve_dp(lam) if self.penalty == 'gfl': return self.solve_gfl(lam) if self.penalty == 'gamlasso': return self.solve_gfl(lam) raise Exce...
def solve(self, lam): '''Solves the GFL for a fixed value of lambda.''' if self.penalty == 'dp': return self.solve_dp(lam) if self.penalty == 'gfl': return self.solve_gfl(lam) if self.penalty == 'gamlasso': return self.solve_gfl(lam) raise Exce...
[ "Solves", "the", "GFL", "for", "a", "fixed", "value", "of", "lambda", "." ]
tansey/gfl
python
https://github.com/tansey/gfl/blob/ae0f078bab57aba9e827ed6162f247ff9dc2aa19/pygfl/solver.py#L80-L88
[ "def", "solve", "(", "self", ",", "lam", ")", ":", "if", "self", ".", "penalty", "==", "'dp'", ":", "return", "self", ".", "solve_dp", "(", "lam", ")", "if", "self", ".", "penalty", "==", "'gfl'", ":", "return", "self", ".", "solve_gfl", "(", "lam"...
ae0f078bab57aba9e827ed6162f247ff9dc2aa19
train
TrailSolver.solve_dp
Solves the Graph-fused double Pareto (non-convex, local optima only)
pygfl/solver.py
def solve_dp(self, lam): '''Solves the Graph-fused double Pareto (non-convex, local optima only)''' cur_converge = self.converge+1 step = 0 # Get an initial estimate using the GFL self.solve_gfl(lam) beta2 = np.copy(self.beta) while cur_converge > self.converge an...
def solve_dp(self, lam): '''Solves the Graph-fused double Pareto (non-convex, local optima only)''' cur_converge = self.converge+1 step = 0 # Get an initial estimate using the GFL self.solve_gfl(lam) beta2 = np.copy(self.beta) while cur_converge > self.converge an...
[ "Solves", "the", "Graph", "-", "fused", "double", "Pareto", "(", "non", "-", "convex", "local", "optima", "only", ")" ]
tansey/gfl
python
https://github.com/tansey/gfl/blob/ae0f078bab57aba9e827ed6162f247ff9dc2aa19/pygfl/solver.py#L120-L140
[ "def", "solve_dp", "(", "self", ",", "lam", ")", ":", "cur_converge", "=", "self", ".", "converge", "+", "1", "step", "=", "0", "# Get an initial estimate using the GFL", "self", ".", "solve_gfl", "(", "lam", ")", "beta2", "=", "np", ".", "copy", "(", "s...
ae0f078bab57aba9e827ed6162f247ff9dc2aa19
train
TrailSolver.solve_gamlasso
Solves the Graph-fused gamma lasso via POSE (Taddy, 2013)
pygfl/solver.py
def solve_gamlasso(self, lam): '''Solves the Graph-fused gamma lasso via POSE (Taddy, 2013)''' weights = lam / (1 + self.gamma * np.abs(self.beta[self.trails[::2]] - self.beta[self.trails[1::2]])) s = self.solve_gfl(u) self.steps.append(s) return self.beta
def solve_gamlasso(self, lam): '''Solves the Graph-fused gamma lasso via POSE (Taddy, 2013)''' weights = lam / (1 + self.gamma * np.abs(self.beta[self.trails[::2]] - self.beta[self.trails[1::2]])) s = self.solve_gfl(u) self.steps.append(s) return self.beta
[ "Solves", "the", "Graph", "-", "fused", "gamma", "lasso", "via", "POSE", "(", "Taddy", "2013", ")" ]
tansey/gfl
python
https://github.com/tansey/gfl/blob/ae0f078bab57aba9e827ed6162f247ff9dc2aa19/pygfl/solver.py#L142-L147
[ "def", "solve_gamlasso", "(", "self", ",", "lam", ")", ":", "weights", "=", "lam", "/", "(", "1", "+", "self", ".", "gamma", "*", "np", ".", "abs", "(", "self", ".", "beta", "[", "self", ".", "trails", "[", ":", ":", "2", "]", "]", "-", "self...
ae0f078bab57aba9e827ed6162f247ff9dc2aa19
train
TrailSolver.solution_path
Follows the solution path to find the best lambda value.
pygfl/solver.py
def solution_path(self, min_lambda, max_lambda, lambda_bins, verbose=0): '''Follows the solution path to find the best lambda value.''' lambda_grid = np.exp(np.linspace(np.log(max_lambda), np.log(min_lambda), lambda_bins)) aic_trace = np.zeros(lambda_grid.shape) # The AIC score for each lambda v...
def solution_path(self, min_lambda, max_lambda, lambda_bins, verbose=0): '''Follows the solution path to find the best lambda value.''' lambda_grid = np.exp(np.linspace(np.log(max_lambda), np.log(min_lambda), lambda_bins)) aic_trace = np.zeros(lambda_grid.shape) # The AIC score for each lambda v...
[ "Follows", "the", "solution", "path", "to", "find", "the", "best", "lambda", "value", "." ]
tansey/gfl
python
https://github.com/tansey/gfl/blob/ae0f078bab57aba9e827ed6162f247ff9dc2aa19/pygfl/solver.py#L152-L217
[ "def", "solution_path", "(", "self", ",", "min_lambda", ",", "max_lambda", ",", "lambda_bins", ",", "verbose", "=", "0", ")", ":", "lambda_grid", "=", "np", ".", "exp", "(", "np", ".", "linspace", "(", "np", ".", "log", "(", "max_lambda", ")", ",", "...
ae0f078bab57aba9e827ed6162f247ff9dc2aa19
train
main
Generate sequences.
olga/generate_sequences.py
def main(): """ Generate sequences.""" parser = OptionParser(conflict_handler="resolve") parser.add_option('--humanTRA', '--human_T_alpha', action='store_true', dest='humanTRA', default=False, help='use default human TRA model (T cell alpha chain)') parser.add_option('--humanTRB', '--human_T_beta', ac...
def main(): """ Generate sequences.""" parser = OptionParser(conflict_handler="resolve") parser.add_option('--humanTRA', '--human_T_alpha', action='store_true', dest='humanTRA', default=False, help='use default human TRA model (T cell alpha chain)') parser.add_option('--humanTRB', '--human_T_beta', ac...
[ "Generate", "sequences", "." ]
zsethna/OLGA
python
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generate_sequences.py#L144-L345
[ "def", "main", "(", ")", ":", "parser", "=", "OptionParser", "(", "conflict_handler", "=", "\"resolve\"", ")", "parser", ".", "add_option", "(", "'--humanTRA'", ",", "'--human_T_alpha'", ",", "action", "=", "'store_true'", ",", "dest", "=", "'humanTRA'", ",", ...
e825c333f0f9a4eb02132e0bcf86f0dca9123114
train
PANOSDriver._send_merge_commands
Netmiko is being used to push set commands.
napalm_panos/panos.py
def _send_merge_commands(self, config, file_config): """ Netmiko is being used to push set commands. """ if self.loaded is False: if self._save_backup() is False: raise MergeConfigException('Error while storing backup ' ...
def _send_merge_commands(self, config, file_config): """ Netmiko is being used to push set commands. """ if self.loaded is False: if self._save_backup() is False: raise MergeConfigException('Error while storing backup ' ...
[ "Netmiko", "is", "being", "used", "to", "push", "set", "commands", "." ]
napalm-automation-community/napalm-panos
python
https://github.com/napalm-automation-community/napalm-panos/blob/9210a81a7a4a47c724d169031414a0743de4b035/napalm_panos/panos.py#L212-L232
[ "def", "_send_merge_commands", "(", "self", ",", "config", ",", "file_config", ")", ":", "if", "self", ".", "loaded", "is", "False", ":", "if", "self", ".", "_save_backup", "(", ")", "is", "False", ":", "raise", "MergeConfigException", "(", "'Error while sto...
9210a81a7a4a47c724d169031414a0743de4b035
train
PANOSDriver.compare_config
Netmiko is being used to obtain config diffs because pan-python doesn't support the needed command.
napalm_panos/panos.py
def compare_config(self): """ Netmiko is being used to obtain config diffs because pan-python doesn't support the needed command. """ if self.ssh_connection is False: self._open_ssh() self.ssh_device.exit_config_mode() diff = self.ssh_device.send_comm...
def compare_config(self): """ Netmiko is being used to obtain config diffs because pan-python doesn't support the needed command. """ if self.ssh_connection is False: self._open_ssh() self.ssh_device.exit_config_mode() diff = self.ssh_device.send_comm...
[ "Netmiko", "is", "being", "used", "to", "obtain", "config", "diffs", "because", "pan", "-", "python", "doesn", "t", "support", "the", "needed", "command", "." ]
napalm-automation-community/napalm-panos
python
https://github.com/napalm-automation-community/napalm-panos/blob/9210a81a7a4a47c724d169031414a0743de4b035/napalm_panos/panos.py#L280-L290
[ "def", "compare_config", "(", "self", ")", ":", "if", "self", ".", "ssh_connection", "is", "False", ":", "self", ".", "_open_ssh", "(", ")", "self", ".", "ssh_device", ".", "exit_config_mode", "(", ")", "diff", "=", "self", ".", "ssh_device", ".", "send_...
9210a81a7a4a47c724d169031414a0743de4b035
train
PANOSDriver.commit_config
Netmiko is being used to commit the configuration because it takes a better care of results compared to pan-python.
napalm_panos/panos.py
def commit_config(self): """ Netmiko is being used to commit the configuration because it takes a better care of results compared to pan-python. """ if self.loaded: if self.ssh_connection is False: self._open_ssh() try: self...
def commit_config(self): """ Netmiko is being used to commit the configuration because it takes a better care of results compared to pan-python. """ if self.loaded: if self.ssh_connection is False: self._open_ssh() try: self...
[ "Netmiko", "is", "being", "used", "to", "commit", "the", "configuration", "because", "it", "takes", "a", "better", "care", "of", "results", "compared", "to", "pan", "-", "python", "." ]
napalm-automation-community/napalm-panos
python
https://github.com/napalm-automation-community/napalm-panos/blob/9210a81a7a4a47c724d169031414a0743de4b035/napalm_panos/panos.py#L302-L321
[ "def", "commit_config", "(", "self", ")", ":", "if", "self", ".", "loaded", ":", "if", "self", ".", "ssh_connection", "is", "False", ":", "self", ".", "_open_ssh", "(", ")", "try", ":", "self", ".", "ssh_device", ".", "commit", "(", ")", "time", ".",...
9210a81a7a4a47c724d169031414a0743de4b035
train
PANOSDriver.rollback
Netmiko is being used to commit the rollback configuration because it takes a better care of results compared to pan-python.
napalm_panos/panos.py
def rollback(self): """ Netmiko is being used to commit the rollback configuration because it takes a better care of results compared to pan-python. """ if self.changed: rollback_cmd = '<load><config><from>{0}</from></config></load>'.format(self.backup_file) ...
def rollback(self): """ Netmiko is being used to commit the rollback configuration because it takes a better care of results compared to pan-python. """ if self.changed: rollback_cmd = '<load><config><from>{0}</from></config></load>'.format(self.backup_file) ...
[ "Netmiko", "is", "being", "used", "to", "commit", "the", "rollback", "configuration", "because", "it", "takes", "a", "better", "care", "of", "results", "compared", "to", "pan", "-", "python", "." ]
napalm-automation-community/napalm-panos
python
https://github.com/napalm-automation-community/napalm-panos/blob/9210a81a7a4a47c724d169031414a0743de4b035/napalm_panos/panos.py#L334-L352
[ "def", "rollback", "(", "self", ")", ":", "if", "self", ".", "changed", ":", "rollback_cmd", "=", "'<load><config><from>{0}</from></config></load>'", ".", "format", "(", "self", ".", "backup_file", ")", "self", ".", "device", ".", "op", "(", "cmd", "=", "rol...
9210a81a7a4a47c724d169031414a0743de4b035
train
PANOSDriver.get_lldp_neighbors
Return LLDP neighbors details.
napalm_panos/panos.py
def get_lldp_neighbors(self): """Return LLDP neighbors details.""" neighbors = {} cmd = '<show><lldp><neighbors>all</neighbors></lldp></show>' try: self.device.op(cmd=cmd) lldp_table_xml = xmltodict.parse(self.device.xml_root()) lldp_table_json = jso...
def get_lldp_neighbors(self): """Return LLDP neighbors details.""" neighbors = {} cmd = '<show><lldp><neighbors>all</neighbors></lldp></show>' try: self.device.op(cmd=cmd) lldp_table_xml = xmltodict.parse(self.device.xml_root()) lldp_table_json = jso...
[ "Return", "LLDP", "neighbors", "details", "." ]
napalm-automation-community/napalm-panos
python
https://github.com/napalm-automation-community/napalm-panos/blob/9210a81a7a4a47c724d169031414a0743de4b035/napalm_panos/panos.py#L398-L430
[ "def", "get_lldp_neighbors", "(", "self", ")", ":", "neighbors", "=", "{", "}", "cmd", "=", "'<show><lldp><neighbors>all</neighbors></lldp></show>'", "try", ":", "self", ".", "device", ".", "op", "(", "cmd", "=", "cmd", ")", "lldp_table_xml", "=", "xmltodict", ...
9210a81a7a4a47c724d169031414a0743de4b035
train
PANOSDriver.get_route_to
Return route details to a specific destination, learned from a certain protocol.
napalm_panos/panos.py
def get_route_to(self, destination='', protocol=''): """Return route details to a specific destination, learned from a certain protocol.""" # Note, it should be possible to query the FIB: # "<show><routing><fib></fib></routing></show>" # To add informations to this getter routes...
def get_route_to(self, destination='', protocol=''): """Return route details to a specific destination, learned from a certain protocol.""" # Note, it should be possible to query the FIB: # "<show><routing><fib></fib></routing></show>" # To add informations to this getter routes...
[ "Return", "route", "details", "to", "a", "specific", "destination", "learned", "from", "a", "certain", "protocol", "." ]
napalm-automation-community/napalm-panos
python
https://github.com/napalm-automation-community/napalm-panos/blob/9210a81a7a4a47c724d169031414a0743de4b035/napalm_panos/panos.py#L432-L507
[ "def", "get_route_to", "(", "self", ",", "destination", "=", "''", ",", "protocol", "=", "''", ")", ":", "# Note, it should be possible to query the FIB:", "# \"<show><routing><fib></fib></routing></show>\"", "# To add informations to this getter", "routes", "=", "{", "}", ...
9210a81a7a4a47c724d169031414a0743de4b035
train
PANOSDriver.get_interfaces_ip
Return IP interface data.
napalm_panos/panos.py
def get_interfaces_ip(self): '''Return IP interface data.''' def extract_ip_info(parsed_intf_dict): ''' IPv4: - Primary IP is in the '<ip>' tag. If no v4 is configured the return value is 'N/A'. - Secondary IP's are in '<addr>'. If no secondaries, thi...
def get_interfaces_ip(self): '''Return IP interface data.''' def extract_ip_info(parsed_intf_dict): ''' IPv4: - Primary IP is in the '<ip>' tag. If no v4 is configured the return value is 'N/A'. - Secondary IP's are in '<addr>'. If no secondaries, thi...
[ "Return", "IP", "interface", "data", "." ]
napalm-automation-community/napalm-panos
python
https://github.com/napalm-automation-community/napalm-panos/blob/9210a81a7a4a47c724d169031414a0743de4b035/napalm_panos/panos.py#L561-L660
[ "def", "get_interfaces_ip", "(", "self", ")", ":", "def", "extract_ip_info", "(", "parsed_intf_dict", ")", ":", "'''\n IPv4:\n - Primary IP is in the '<ip>' tag. If no v4 is configured the return value is 'N/A'.\n - Secondary IP's are in '<addr>'. If no s...
9210a81a7a4a47c724d169031414a0743de4b035
train
CSG.refine
Return a refined CSG. To each polygon, a middle point is added to each edge and to the center of the polygon
csg/core.py
def refine(self): """ Return a refined CSG. To each polygon, a middle point is added to each edge and to the center of the polygon """ newCSG = CSG() for poly in self.polygons: verts = poly.vertices numVerts = len(verts) if numVerts ...
def refine(self): """ Return a refined CSG. To each polygon, a middle point is added to each edge and to the center of the polygon """ newCSG = CSG() for poly in self.polygons: verts = poly.vertices numVerts = len(verts) if numVerts ...
[ "Return", "a", "refined", "CSG", ".", "To", "each", "polygon", "a", "middle", "point", "is", "added", "to", "each", "edge", "and", "to", "the", "center", "of", "the", "polygon" ]
timknip/pycsg
python
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/core.py#L75-L111
[ "def", "refine", "(", "self", ")", ":", "newCSG", "=", "CSG", "(", ")", "for", "poly", "in", "self", ".", "polygons", ":", "verts", "=", "poly", ".", "vertices", "numVerts", "=", "len", "(", "verts", ")", "if", "numVerts", "==", "0", ":", "continue...
b8f9710fd15c38dcc275d56a2108f604af38dcc8
train
CSG.translate
Translate Geometry. disp: displacement (array of floats)
csg/core.py
def translate(self, disp): """ Translate Geometry. disp: displacement (array of floats) """ d = Vector(disp[0], disp[1], disp[2]) for poly in self.polygons: for v in poly.vertices: v.pos = v.pos.plus(d)
def translate(self, disp): """ Translate Geometry. disp: displacement (array of floats) """ d = Vector(disp[0], disp[1], disp[2]) for poly in self.polygons: for v in poly.vertices: v.pos = v.pos.plus(d)
[ "Translate", "Geometry", ".", "disp", ":", "displacement", "(", "array", "of", "floats", ")" ]
timknip/pycsg
python
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/core.py#L113-L121
[ "def", "translate", "(", "self", ",", "disp", ")", ":", "d", "=", "Vector", "(", "disp", "[", "0", "]", ",", "disp", "[", "1", "]", ",", "disp", "[", "2", "]", ")", "for", "poly", "in", "self", ".", "polygons", ":", "for", "v", "in", "poly", ...
b8f9710fd15c38dcc275d56a2108f604af38dcc8
train
CSG.rotate
Rotate geometry. axis: axis of rotation (array of floats) angleDeg: rotation angle in degrees
csg/core.py
def rotate(self, axis, angleDeg): """ Rotate geometry. axis: axis of rotation (array of floats) angleDeg: rotation angle in degrees """ ax = Vector(axis[0], axis[1], axis[2]).unit() cosAngle = math.cos(math.pi * angleDeg / 180.) sinAngle = math.sin(m...
def rotate(self, axis, angleDeg): """ Rotate geometry. axis: axis of rotation (array of floats) angleDeg: rotation angle in degrees """ ax = Vector(axis[0], axis[1], axis[2]).unit() cosAngle = math.cos(math.pi * angleDeg / 180.) sinAngle = math.sin(m...
[ "Rotate", "geometry", ".", "axis", ":", "axis", "of", "rotation", "(", "array", "of", "floats", ")", "angleDeg", ":", "rotation", "angle", "in", "degrees" ]
timknip/pycsg
python
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/core.py#L124-L152
[ "def", "rotate", "(", "self", ",", "axis", ",", "angleDeg", ")", ":", "ax", "=", "Vector", "(", "axis", "[", "0", "]", ",", "axis", "[", "1", "]", ",", "axis", "[", "2", "]", ")", ".", "unit", "(", ")", "cosAngle", "=", "math", ".", "cos", ...
b8f9710fd15c38dcc275d56a2108f604af38dcc8
train
CSG.toVerticesAndPolygons
Return list of vertices, polygons (cells), and the total number of vertex indices in the polygon connectivity list (count).
csg/core.py
def toVerticesAndPolygons(self): """ Return list of vertices, polygons (cells), and the total number of vertex indices in the polygon connectivity list (count). """ offset = 1.234567890 verts = [] polys = [] vertexIndexMap = {} count = 0 ...
def toVerticesAndPolygons(self): """ Return list of vertices, polygons (cells), and the total number of vertex indices in the polygon connectivity list (count). """ offset = 1.234567890 verts = [] polys = [] vertexIndexMap = {} count = 0 ...
[ "Return", "list", "of", "vertices", "polygons", "(", "cells", ")", "and", "the", "total", "number", "of", "vertex", "indices", "in", "the", "polygon", "connectivity", "list", "(", "count", ")", "." ]
timknip/pycsg
python
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/core.py#L154-L193
[ "def", "toVerticesAndPolygons", "(", "self", ")", ":", "offset", "=", "1.234567890", "verts", "=", "[", "]", "polys", "=", "[", "]", "vertexIndexMap", "=", "{", "}", "count", "=", "0", "for", "poly", "in", "self", ".", "polygons", ":", "verts", "=", ...
b8f9710fd15c38dcc275d56a2108f604af38dcc8
train
CSG.saveVTK
Save polygons in VTK file.
csg/core.py
def saveVTK(self, filename): """ Save polygons in VTK file. """ with open(filename, 'w') as f: f.write('# vtk DataFile Version 3.0\n') f.write('pycsg output\n') f.write('ASCII\n') f.write('DATASET POLYDATA\n') verts, ce...
def saveVTK(self, filename): """ Save polygons in VTK file. """ with open(filename, 'w') as f: f.write('# vtk DataFile Version 3.0\n') f.write('pycsg output\n') f.write('ASCII\n') f.write('DATASET POLYDATA\n') verts, ce...
[ "Save", "polygons", "in", "VTK", "file", "." ]
timknip/pycsg
python
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/core.py#L195-L216
[ "def", "saveVTK", "(", "self", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "f", ":", "f", ".", "write", "(", "'# vtk DataFile Version 3.0\\n'", ")", "f", ".", "write", "(", "'pycsg output\\n'", ")", "f", ".", "wri...
b8f9710fd15c38dcc275d56a2108f604af38dcc8
train
CSG.union
Return a new CSG solid representing space in either this solid or in the solid `csg`. Neither this solid nor the solid `csg` are modified.:: A.union(B) +-------+ +-------+ | | | | | A | | | ...
csg/core.py
def union(self, csg): """ Return a new CSG solid representing space in either this solid or in the solid `csg`. Neither this solid nor the solid `csg` are modified.:: A.union(B) +-------+ +-------+ | | | | ...
def union(self, csg): """ Return a new CSG solid representing space in either this solid or in the solid `csg`. Neither this solid nor the solid `csg` are modified.:: A.union(B) +-------+ +-------+ | | | | ...
[ "Return", "a", "new", "CSG", "solid", "representing", "space", "in", "either", "this", "solid", "or", "in", "the", "solid", "csg", ".", "Neither", "this", "solid", "nor", "the", "solid", "csg", "are", "modified", ".", "::", "A", ".", "union", "(", "B",...
timknip/pycsg
python
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/core.py#L218-L242
[ "def", "union", "(", "self", ",", "csg", ")", ":", "a", "=", "BSPNode", "(", "self", ".", "clone", "(", ")", ".", "polygons", ")", "b", "=", "BSPNode", "(", "csg", ".", "clone", "(", ")", ".", "polygons", ")", "a", ".", "clipTo", "(", "b", ")...
b8f9710fd15c38dcc275d56a2108f604af38dcc8
train
CSG.inverse
Return a new CSG solid with solid and empty space switched. This solid is not modified.
csg/core.py
def inverse(self): """ Return a new CSG solid with solid and empty space switched. This solid is not modified. """ csg = self.clone() map(lambda p: p.flip(), csg.polygons) return csg
def inverse(self): """ Return a new CSG solid with solid and empty space switched. This solid is not modified. """ csg = self.clone() map(lambda p: p.flip(), csg.polygons) return csg
[ "Return", "a", "new", "CSG", "solid", "with", "solid", "and", "empty", "space", "switched", ".", "This", "solid", "is", "not", "modified", "." ]
timknip/pycsg
python
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/core.py#L308-L315
[ "def", "inverse", "(", "self", ")", ":", "csg", "=", "self", ".", "clone", "(", ")", "map", "(", "lambda", "p", ":", "p", ".", "flip", "(", ")", ",", "csg", ".", "polygons", ")", "return", "csg" ]
b8f9710fd15c38dcc275d56a2108f604af38dcc8
train
CSG.cube
Construct an axis-aligned solid cuboid. Optional parameters are `center` and `radius`, which default to `[0, 0, 0]` and `[1, 1, 1]`. The radius can be specified using a single number or a list of three numbers, one for each axis. Example code:: cube = CSG.cube( ...
csg/core.py
def cube(cls, center=[0,0,0], radius=[1,1,1]): """ Construct an axis-aligned solid cuboid. Optional parameters are `center` and `radius`, which default to `[0, 0, 0]` and `[1, 1, 1]`. The radius can be specified using a single number or a list of three numbers, one for each axis. ...
def cube(cls, center=[0,0,0], radius=[1,1,1]): """ Construct an axis-aligned solid cuboid. Optional parameters are `center` and `radius`, which default to `[0, 0, 0]` and `[1, 1, 1]`. The radius can be specified using a single number or a list of three numbers, one for each axis. ...
[ "Construct", "an", "axis", "-", "aligned", "solid", "cuboid", ".", "Optional", "parameters", "are", "center", "and", "radius", "which", "default", "to", "[", "0", "0", "0", "]", "and", "[", "1", "1", "1", "]", ".", "The", "radius", "can", "be", "spec...
timknip/pycsg
python
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/core.py#L318-L356
[ "def", "cube", "(", "cls", ",", "center", "=", "[", "0", ",", "0", ",", "0", "]", ",", "radius", "=", "[", "1", ",", "1", ",", "1", "]", ")", ":", "c", "=", "Vector", "(", "0", ",", "0", ",", "0", ")", "r", "=", "[", "1", ",", "1", ...
b8f9710fd15c38dcc275d56a2108f604af38dcc8
train
CSG.sphere
Returns a sphere. Kwargs: center (list): Center of sphere, default [0, 0, 0]. radius (float): Radius of sphere, default 1.0. slices (int): Number of slices, default 16. stacks (int...
csg/core.py
def sphere(cls, **kwargs): """ Returns a sphere. Kwargs: center (list): Center of sphere, default [0, 0, 0]. radius (float): Radius of sphere, default 1.0. slices (int): Number of slices, default 16. ...
def sphere(cls, **kwargs): """ Returns a sphere. Kwargs: center (list): Center of sphere, default [0, 0, 0]. radius (float): Radius of sphere, default 1.0. slices (int): Number of slices, default 16. ...
[ "Returns", "a", "sphere", ".", "Kwargs", ":", "center", "(", "list", ")", ":", "Center", "of", "sphere", "default", "[", "0", "0", "0", "]", ".", "radius", "(", "float", ")", ":", "Radius", "of", "sphere", "default", "1", ".", "0", ".", "slices", ...
timknip/pycsg
python
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/core.py#L359-L451
[ "def", "sphere", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "center", "=", "kwargs", ".", "get", "(", "'center'", ",", "[", "0.0", ",", "0.0", ",", "0.0", "]", ")", "if", "isinstance", "(", "center", ",", "float", ")", ":", "center", "=", "...
b8f9710fd15c38dcc275d56a2108f604af38dcc8
train
CSG.cylinder
Returns a cylinder. Kwargs: start (list): Start of cylinder, default [0, -1, 0]. end (list): End of cylinder, default [0, 1, 0]. radius (float): Radius of cylinder, default 1.0. sl...
csg/core.py
def cylinder(cls, **kwargs): """ Returns a cylinder. Kwargs: start (list): Start of cylinder, default [0, -1, 0]. end (list): End of cylinder, default [0, 1, 0]. radius (float): Radius of cylinder, default...
def cylinder(cls, **kwargs): """ Returns a cylinder. Kwargs: start (list): Start of cylinder, default [0, -1, 0]. end (list): End of cylinder, default [0, 1, 0]. radius (float): Radius of cylinder, default...
[ "Returns", "a", "cylinder", ".", "Kwargs", ":", "start", "(", "list", ")", ":", "Start", "of", "cylinder", "default", "[", "0", "-", "1", "0", "]", ".", "end", "(", "list", ")", ":", "End", "of", "cylinder", "default", "[", "0", "1", "0", "]", ...
timknip/pycsg
python
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/core.py#L454-L508
[ "def", "cylinder", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "s", "=", "kwargs", ".", "get", "(", "'start'", ",", "Vector", "(", "0.0", ",", "-", "1.0", ",", "0.0", ")", ")", "e", "=", "kwargs", ".", "get", "(", "'end'", ",", "Vector", "...
b8f9710fd15c38dcc275d56a2108f604af38dcc8
train
CSG.cone
Returns a cone. Kwargs: start (list): Start of cone, default [0, -1, 0]. end (list): End of cone, default [0, 1, 0]. radius (float): Maximum radius of cone at start, default 1.0. s...
csg/core.py
def cone(cls, **kwargs): """ Returns a cone. Kwargs: start (list): Start of cone, default [0, -1, 0]. end (list): End of cone, default [0, 1, 0]. radius (float): Maximum radius of cone at start, default 1....
def cone(cls, **kwargs): """ Returns a cone. Kwargs: start (list): Start of cone, default [0, -1, 0]. end (list): End of cone, default [0, 1, 0]. radius (float): Maximum radius of cone at start, default 1....
[ "Returns", "a", "cone", ".", "Kwargs", ":", "start", "(", "list", ")", ":", "Start", "of", "cone", "default", "[", "0", "-", "1", "0", "]", ".", "end", "(", "list", ")", ":", "End", "of", "cone", "default", "[", "0", "1", "0", "]", ".", "radi...
timknip/pycsg
python
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/core.py#L511-L573
[ "def", "cone", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "s", "=", "kwargs", ".", "get", "(", "'start'", ",", "Vector", "(", "0.0", ",", "-", "1.0", ",", "0.0", ")", ")", "e", "=", "kwargs", ".", "get", "(", "'end'", ",", "Vector", "(", ...
b8f9710fd15c38dcc275d56a2108f604af38dcc8
train
load
Load the nbt file at the specified location. By default, the function will figure out by itself if the file is gzipped before loading it. You can pass a boolean to the `gzipped` keyword only argument to specify explicitly whether the file is compressed or not. You can also use the `byteorder` keyw...
nbtlib/nbt.py
def load(filename, *, gzipped=None, byteorder='big'): """Load the nbt file at the specified location. By default, the function will figure out by itself if the file is gzipped before loading it. You can pass a boolean to the `gzipped` keyword only argument to specify explicitly whether the file is...
def load(filename, *, gzipped=None, byteorder='big'): """Load the nbt file at the specified location. By default, the function will figure out by itself if the file is gzipped before loading it. You can pass a boolean to the `gzipped` keyword only argument to specify explicitly whether the file is...
[ "Load", "the", "nbt", "file", "at", "the", "specified", "location", ".", "By", "default", "the", "function", "will", "figure", "out", "by", "itself", "if", "the", "file", "is", "gzipped", "before", "loading", "it", ".", "You", "can", "pass", "a", "boolea...
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/nbt.py#L17-L37
[ "def", "load", "(", "filename", ",", "*", ",", "gzipped", "=", "None", ",", "byteorder", "=", "'big'", ")", ":", "if", "gzipped", "is", "not", "None", ":", "return", "File", ".", "load", "(", "filename", ",", "gzipped", ",", "byteorder", ")", "# if w...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
File.from_buffer
Load nbt file from a file-like object. The `buff` argument can be either a standard `io.BufferedReader` for uncompressed nbt or a `gzip.GzipFile` for gzipped nbt data.
nbtlib/nbt.py
def from_buffer(cls, buff, byteorder='big'): """Load nbt file from a file-like object. The `buff` argument can be either a standard `io.BufferedReader` for uncompressed nbt or a `gzip.GzipFile` for gzipped nbt data. """ self = cls.parse(buff, byteorder) self.filen...
def from_buffer(cls, buff, byteorder='big'): """Load nbt file from a file-like object. The `buff` argument can be either a standard `io.BufferedReader` for uncompressed nbt or a `gzip.GzipFile` for gzipped nbt data. """ self = cls.parse(buff, byteorder) self.filen...
[ "Load", "nbt", "file", "from", "a", "file", "-", "like", "object", ".", "The", "buff", "argument", "can", "be", "either", "a", "standard", "io", ".", "BufferedReader", "for", "uncompressed", "nbt", "or", "a", "gzip", ".", "GzipFile", "for", "gzipped", "n...
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/nbt.py#L90-L100
[ "def", "from_buffer", "(", "cls", ",", "buff", ",", "byteorder", "=", "'big'", ")", ":", "self", "=", "cls", ".", "parse", "(", "buff", ",", "byteorder", ")", "self", ".", "filename", "=", "getattr", "(", "buff", ",", "'name'", ",", "self", ".", "f...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
File.load
Read, parse and return the file at the specified location. The `gzipped` argument is used to indicate if the specified file is gzipped. The `byteorder` argument lets you specify whether the file is big-endian or little-endian.
nbtlib/nbt.py
def load(cls, filename, gzipped, byteorder='big'): """Read, parse and return the file at the specified location. The `gzipped` argument is used to indicate if the specified file is gzipped. The `byteorder` argument lets you specify whether the file is big-endian or little-endian. ...
def load(cls, filename, gzipped, byteorder='big'): """Read, parse and return the file at the specified location. The `gzipped` argument is used to indicate if the specified file is gzipped. The `byteorder` argument lets you specify whether the file is big-endian or little-endian. ...
[ "Read", "parse", "and", "return", "the", "file", "at", "the", "specified", "location", ".", "The", "gzipped", "argument", "is", "used", "to", "indicate", "if", "the", "specified", "file", "is", "gzipped", ".", "The", "byteorder", "argument", "lets", "you", ...
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/nbt.py#L103-L112
[ "def", "load", "(", "cls", ",", "filename", ",", "gzipped", ",", "byteorder", "=", "'big'", ")", ":", "open_file", "=", "gzip", ".", "open", "if", "gzipped", "else", "open", "with", "open_file", "(", "filename", ",", "'rb'", ")", "as", "buff", ":", "...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
File.save
Write the file at the specified location. The `gzipped` keyword only argument indicates if the file should be gzipped. The `byteorder` keyword only argument lets you specify whether the file should be big-endian or little-endian. If the method is called without any argument, it w...
nbtlib/nbt.py
def save(self, filename=None, *, gzipped=None, byteorder=None): """Write the file at the specified location. The `gzipped` keyword only argument indicates if the file should be gzipped. The `byteorder` keyword only argument lets you specify whether the file should be big-endian or ...
def save(self, filename=None, *, gzipped=None, byteorder=None): """Write the file at the specified location. The `gzipped` keyword only argument indicates if the file should be gzipped. The `byteorder` keyword only argument lets you specify whether the file should be big-endian or ...
[ "Write", "the", "file", "at", "the", "specified", "location", ".", "The", "gzipped", "keyword", "only", "argument", "indicates", "if", "the", "file", "should", "be", "gzipped", ".", "The", "byteorder", "keyword", "only", "argument", "lets", "you", "specify", ...
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/nbt.py#L114-L137
[ "def", "save", "(", "self", ",", "filename", "=", "None", ",", "*", ",", "gzipped", "=", "None", ",", "byteorder", "=", "None", ")", ":", "if", "gzipped", "is", "None", ":", "gzipped", "=", "self", ".", "gzipped", "if", "filename", "is", "None", ":...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
return_collection
Change method return value from raw API output to collection of models
crunchyroll/util.py
def return_collection(collection_type): """Change method return value from raw API output to collection of models """ def outer_func(func): @functools.wraps(func) def inner_func(self, *pargs, **kwargs): result = func(self, *pargs, **kwargs) return list(map(collection_...
def return_collection(collection_type): """Change method return value from raw API output to collection of models """ def outer_func(func): @functools.wraps(func) def inner_func(self, *pargs, **kwargs): result = func(self, *pargs, **kwargs) return list(map(collection_...
[ "Change", "method", "return", "value", "from", "raw", "API", "output", "to", "collection", "of", "models" ]
aheadley/python-crunchyroll
python
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/util.py#L47-L56
[ "def", "return_collection", "(", "collection_type", ")", ":", "def", "outer_func", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "inner_func", "(", "self", ",", "*", "pargs", ",", "*", "*", "kwargs", ")", ":", "result"...
9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178
train
post_save_stop
Update related objects when the Stop is updated
multigtfs/models/stop.py
def post_save_stop(sender, instance, **kwargs): '''Update related objects when the Stop is updated''' from multigtfs.models.trip import Trip trip_ids = instance.stoptime_set.filter( trip__shape=None).values_list('trip_id', flat=True).distinct() for trip in Trip.objects.filter(id__in=trip_ids): ...
def post_save_stop(sender, instance, **kwargs): '''Update related objects when the Stop is updated''' from multigtfs.models.trip import Trip trip_ids = instance.stoptime_set.filter( trip__shape=None).values_list('trip_id', flat=True).distinct() for trip in Trip.objects.filter(id__in=trip_ids): ...
[ "Update", "related", "objects", "when", "the", "Stop", "is", "updated" ]
tulsawebdevs/django-multi-gtfs
python
https://github.com/tulsawebdevs/django-multi-gtfs/blob/8c442bfb67e87566c24a7364d8fa0aacd4a0a652/multigtfs/models/stop.py#L166-L172
[ "def", "post_save_stop", "(", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "from", "multigtfs", ".", "models", ".", "trip", "import", "Trip", "trip_ids", "=", "instance", ".", "stoptime_set", ".", "filter", "(", "trip__shape", "=", "None",...
8c442bfb67e87566c24a7364d8fa0aacd4a0a652
train
AndroidMangaApi._do_post_request_tasks
Handle actions that need to be done with every response I'm not sure what these session_ops are actually used for yet, seems to be a way to tell the client to do *something* if needed.
crunchyroll/apis/android_manga.py
def _do_post_request_tasks(self, response_data): """Handle actions that need to be done with every response I'm not sure what these session_ops are actually used for yet, seems to be a way to tell the client to do *something* if needed. """ try: sess_ops = response_d...
def _do_post_request_tasks(self, response_data): """Handle actions that need to be done with every response I'm not sure what these session_ops are actually used for yet, seems to be a way to tell the client to do *something* if needed. """ try: sess_ops = response_d...
[ "Handle", "actions", "that", "need", "to", "be", "done", "with", "every", "response" ]
aheadley/python-crunchyroll
python
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/android_manga.py#L94-L105
[ "def", "_do_post_request_tasks", "(", "self", ",", "response_data", ")", ":", "try", ":", "sess_ops", "=", "response_data", ".", "get", "(", "'ops'", ",", "[", "]", ")", "except", "AttributeError", ":", "pass", "else", ":", "self", ".", "_session_ops", "."...
9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178
train
AndroidMangaApi._build_request
Build a function to do an API request "We have to go deeper" or "It's functions all the way down!"
crunchyroll/apis/android_manga.py
def _build_request(self, method, url, params=None): """Build a function to do an API request "We have to go deeper" or "It's functions all the way down!" """ full_params = self._get_base_params() if params is not None: full_params.update(params) try: ...
def _build_request(self, method, url, params=None): """Build a function to do an API request "We have to go deeper" or "It's functions all the way down!" """ full_params = self._get_base_params() if params is not None: full_params.update(params) try: ...
[ "Build", "a", "function", "to", "do", "an", "API", "request" ]
aheadley/python-crunchyroll
python
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/android_manga.py#L107-L161
[ "def", "_build_request", "(", "self", ",", "method", ",", "url", ",", "params", "=", "None", ")", ":", "full_params", "=", "self", ".", "_get_base_params", "(", ")", "if", "params", "is", "not", "None", ":", "full_params", ".", "update", "(", "params", ...
9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178
train
AndroidMangaApi._build_request_url
Build a URL for a API method request
crunchyroll/apis/android_manga.py
def _build_request_url(self, secure, api_method): """Build a URL for a API method request """ if secure: proto = ANDROID_MANGA.PROTOCOL_SECURE else: proto = ANDROID_MANGA.PROTOCOL_INSECURE req_url = ANDROID_MANGA.API_URL.format( protocol=proto,...
def _build_request_url(self, secure, api_method): """Build a URL for a API method request """ if secure: proto = ANDROID_MANGA.PROTOCOL_SECURE else: proto = ANDROID_MANGA.PROTOCOL_INSECURE req_url = ANDROID_MANGA.API_URL.format( protocol=proto,...
[ "Build", "a", "URL", "for", "a", "API", "method", "request" ]
aheadley/python-crunchyroll
python
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/android_manga.py#L163-L174
[ "def", "_build_request_url", "(", "self", ",", "secure", ",", "api_method", ")", ":", "if", "secure", ":", "proto", "=", "ANDROID_MANGA", ".", "PROTOCOL_SECURE", "else", ":", "proto", "=", "ANDROID_MANGA", ".", "PROTOCOL_INSECURE", "req_url", "=", "ANDROID_MANGA...
9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178
train
AndroidMangaApi.cr_login
Login using email/username and password, used to get the auth token @param str account @param str password @param str hash_id (optional)
crunchyroll/apis/android_manga.py
def cr_login(self, response): """ Login using email/username and password, used to get the auth token @param str account @param str password @param str hash_id (optional) """ self._state_params['auth'] = response['auth'] self._user_data = response['user']...
def cr_login(self, response): """ Login using email/username and password, used to get the auth token @param str account @param str password @param str hash_id (optional) """ self._state_params['auth'] = response['auth'] self._user_data = response['user']...
[ "Login", "using", "email", "/", "username", "and", "password", "used", "to", "get", "the", "auth", "token" ]
aheadley/python-crunchyroll
python
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/android_manga.py#L251-L262
[ "def", "cr_login", "(", "self", ",", "response", ")", ":", "self", ".", "_state_params", "[", "'auth'", "]", "=", "response", "[", "'auth'", "]", "self", ".", "_user_data", "=", "response", "[", "'user'", "]", "if", "not", "self", ".", "logged_in", ":"...
9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178
train
SecondsField.from_db_value
Handle data loaded from database.
multigtfs/models/fields/seconds.py
def from_db_value(self, value, expression, connection, context): '''Handle data loaded from database.''' if value is None: return value return self.parse_seconds(value)
def from_db_value(self, value, expression, connection, context): '''Handle data loaded from database.''' if value is None: return value return self.parse_seconds(value)
[ "Handle", "data", "loaded", "from", "database", "." ]
tulsawebdevs/django-multi-gtfs
python
https://github.com/tulsawebdevs/django-multi-gtfs/blob/8c442bfb67e87566c24a7364d8fa0aacd4a0a652/multigtfs/models/fields/seconds.py#L72-L76
[ "def", "from_db_value", "(", "self", ",", "value", ",", "expression", ",", "connection", ",", "context", ")", ":", "if", "value", "is", "None", ":", "return", "value", "return", "self", ".", "parse_seconds", "(", "value", ")" ]
8c442bfb67e87566c24a7364d8fa0aacd4a0a652
train
SecondsField.to_python
Handle data from serialization and form clean() methods.
multigtfs/models/fields/seconds.py
def to_python(self, value): '''Handle data from serialization and form clean() methods.''' if isinstance(value, Seconds): return value if value in self.empty_values: return None return self.parse_seconds(value)
def to_python(self, value): '''Handle data from serialization and form clean() methods.''' if isinstance(value, Seconds): return value if value in self.empty_values: return None return self.parse_seconds(value)
[ "Handle", "data", "from", "serialization", "and", "form", "clean", "()", "methods", "." ]
tulsawebdevs/django-multi-gtfs
python
https://github.com/tulsawebdevs/django-multi-gtfs/blob/8c442bfb67e87566c24a7364d8fa0aacd4a0a652/multigtfs/models/fields/seconds.py#L78-L84
[ "def", "to_python", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "Seconds", ")", ":", "return", "value", "if", "value", "in", "self", ".", "empty_values", ":", "return", "None", "return", "self", ".", "parse_seconds", "(", ...
8c442bfb67e87566c24a7364d8fa0aacd4a0a652
train
SecondsField.parse_seconds
Parse string into Seconds instances. Handled formats: HH:MM:SS HH:MM SS
multigtfs/models/fields/seconds.py
def parse_seconds(value): ''' Parse string into Seconds instances. Handled formats: HH:MM:SS HH:MM SS ''' svalue = str(value) colons = svalue.count(':') if colons == 2: hours, minutes, seconds = [int(v) for v in svalue.split(':...
def parse_seconds(value): ''' Parse string into Seconds instances. Handled formats: HH:MM:SS HH:MM SS ''' svalue = str(value) colons = svalue.count(':') if colons == 2: hours, minutes, seconds = [int(v) for v in svalue.split(':...
[ "Parse", "string", "into", "Seconds", "instances", "." ]
tulsawebdevs/django-multi-gtfs
python
https://github.com/tulsawebdevs/django-multi-gtfs/blob/8c442bfb67e87566c24a7364d8fa0aacd4a0a652/multigtfs/models/fields/seconds.py#L87-L109
[ "def", "parse_seconds", "(", "value", ")", ":", "svalue", "=", "str", "(", "value", ")", "colons", "=", "svalue", ".", "count", "(", "':'", ")", "if", "colons", "==", "2", ":", "hours", ",", "minutes", ",", "seconds", "=", "[", "int", "(", "v", "...
8c442bfb67e87566c24a7364d8fa0aacd4a0a652
train
SecondsField.get_prep_value
Prepare value for database storage.
multigtfs/models/fields/seconds.py
def get_prep_value(self, value): '''Prepare value for database storage.''' if isinstance(value, Seconds): return value.seconds elif value: return self.parse_seconds(value).seconds else: return None
def get_prep_value(self, value): '''Prepare value for database storage.''' if isinstance(value, Seconds): return value.seconds elif value: return self.parse_seconds(value).seconds else: return None
[ "Prepare", "value", "for", "database", "storage", "." ]
tulsawebdevs/django-multi-gtfs
python
https://github.com/tulsawebdevs/django-multi-gtfs/blob/8c442bfb67e87566c24a7364d8fa0aacd4a0a652/multigtfs/models/fields/seconds.py#L111-L118
[ "def", "get_prep_value", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "Seconds", ")", ":", "return", "value", ".", "seconds", "elif", "value", ":", "return", "self", ".", "parse_seconds", "(", "value", ")", ".", "seconds", ...
8c442bfb67e87566c24a7364d8fa0aacd4a0a652
train
ColorbarCalculator.calculate_colorbar
Returns the positions and colors of all intervals inside the colorbar.
matplotlib_colorbar/colorbar.py
def calculate_colorbar(self): """ Returns the positions and colors of all intervals inside the colorbar. """ self._base._process_values() self._base._find_range() X, Y = self._base._mesh() C = self._base._values[:, np.newaxis] return X, Y, C
def calculate_colorbar(self): """ Returns the positions and colors of all intervals inside the colorbar. """ self._base._process_values() self._base._find_range() X, Y = self._base._mesh() C = self._base._values[:, np.newaxis] return X, Y, C
[ "Returns", "the", "positions", "and", "colors", "of", "all", "intervals", "inside", "the", "colorbar", "." ]
ppinard/matplotlib-colorbar
python
https://github.com/ppinard/matplotlib-colorbar/blob/d53748c54dd18ba5183bff8da3f11cfd107282e6/matplotlib_colorbar/colorbar.py#L152-L160
[ "def", "calculate_colorbar", "(", "self", ")", ":", "self", ".", "_base", ".", "_process_values", "(", ")", "self", ".", "_base", ".", "_find_range", "(", ")", "X", ",", "Y", "=", "self", ".", "_base", ".", "_mesh", "(", ")", "C", "=", "self", ".",...
d53748c54dd18ba5183bff8da3f11cfd107282e6
train
ColorbarCalculator.calculate_ticks
Returns the sequence of ticks (colorbar data locations), ticklabels (strings), and the corresponding offset string.
matplotlib_colorbar/colorbar.py
def calculate_ticks(self): """ Returns the sequence of ticks (colorbar data locations), ticklabels (strings), and the corresponding offset string. """ current_version = packaging.version.parse(matplotlib.__version__) critical_version = packaging.version.parse('3.0.0') ...
def calculate_ticks(self): """ Returns the sequence of ticks (colorbar data locations), ticklabels (strings), and the corresponding offset string. """ current_version = packaging.version.parse(matplotlib.__version__) critical_version = packaging.version.parse('3.0.0') ...
[ "Returns", "the", "sequence", "of", "ticks", "(", "colorbar", "data", "locations", ")", "ticklabels", "(", "strings", ")", "and", "the", "corresponding", "offset", "string", "." ]
ppinard/matplotlib-colorbar
python
https://github.com/ppinard/matplotlib-colorbar/blob/d53748c54dd18ba5183bff8da3f11cfd107282e6/matplotlib_colorbar/colorbar.py#L162-L174
[ "def", "calculate_ticks", "(", "self", ")", ":", "current_version", "=", "packaging", ".", "version", ".", "parse", "(", "matplotlib", ".", "__version__", ")", "critical_version", "=", "packaging", ".", "version", ".", "parse", "(", "'3.0.0'", ")", "if", "cu...
d53748c54dd18ba5183bff8da3f11cfd107282e6
train
ScraperApi.get_media_formats
CR doesn't seem to provide the video_format and video_quality params through any of the APIs so we have to scrape the video page
crunchyroll/apis/scraper.py
def get_media_formats(self, media_id): """CR doesn't seem to provide the video_format and video_quality params through any of the APIs so we have to scrape the video page """ url = (SCRAPER.API_URL + 'media-' + media_id).format( protocol=SCRAPER.PROTOCOL_INSECURE) for...
def get_media_formats(self, media_id): """CR doesn't seem to provide the video_format and video_quality params through any of the APIs so we have to scrape the video page """ url = (SCRAPER.API_URL + 'media-' + media_id).format( protocol=SCRAPER.PROTOCOL_INSECURE) for...
[ "CR", "doesn", "t", "seem", "to", "provide", "the", "video_format", "and", "video_quality", "params", "through", "any", "of", "the", "APIs", "so", "we", "have", "to", "scrape", "the", "video", "page" ]
aheadley/python-crunchyroll
python
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/scraper.py#L34-L53
[ "def", "get_media_formats", "(", "self", ",", "media_id", ")", ":", "url", "=", "(", "SCRAPER", ".", "API_URL", "+", "'media-'", "+", "media_id", ")", ".", "format", "(", "protocol", "=", "SCRAPER", ".", "PROTOCOL_INSECURE", ")", "format_pattern", "=", "re...
9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178
train
parse_nbt
Parse a literal nbt string and return the resulting tag.
nbtlib/literal/parser.py
def parse_nbt(literal): """Parse a literal nbt string and return the resulting tag.""" parser = Parser(tokenize(literal)) tag = parser.parse() cursor = parser.token_span[1] leftover = literal[cursor:] if leftover.strip(): parser.token_span = cursor, cursor + len(leftover) raise ...
def parse_nbt(literal): """Parse a literal nbt string and return the resulting tag.""" parser = Parser(tokenize(literal)) tag = parser.parse() cursor = parser.token_span[1] leftover = literal[cursor:] if leftover.strip(): parser.token_span = cursor, cursor + len(leftover) raise ...
[ "Parse", "a", "literal", "nbt", "string", "and", "return", "the", "resulting", "tag", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L85-L96
[ "def", "parse_nbt", "(", "literal", ")", ":", "parser", "=", "Parser", "(", "tokenize", "(", "literal", ")", ")", "tag", "=", "parser", ".", "parse", "(", ")", "cursor", "=", "parser", ".", "token_span", "[", "1", "]", "leftover", "=", "literal", "["...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
tokenize
Match and yield all the tokens of the input string.
nbtlib/literal/parser.py
def tokenize(string): """Match and yield all the tokens of the input string.""" for match in TOKENS_REGEX.finditer(string): yield Token(match.lastgroup, match.group().strip(), match.span())
def tokenize(string): """Match and yield all the tokens of the input string.""" for match in TOKENS_REGEX.finditer(string): yield Token(match.lastgroup, match.group().strip(), match.span())
[ "Match", "and", "yield", "all", "the", "tokens", "of", "the", "input", "string", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L104-L107
[ "def", "tokenize", "(", "string", ")", ":", "for", "match", "in", "TOKENS_REGEX", ".", "finditer", "(", "string", ")", ":", "yield", "Token", "(", "match", ".", "lastgroup", ",", "match", ".", "group", "(", ")", ".", "strip", "(", ")", ",", "match", ...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Parser.next
Move to the next token in the token stream.
nbtlib/literal/parser.py
def next(self): """Move to the next token in the token stream.""" self.current_token = next(self.token_stream, None) if self.current_token is None: self.token_span = self.token_span[1], self.token_span[1] raise self.error('Unexpected end of input') self.token_span...
def next(self): """Move to the next token in the token stream.""" self.current_token = next(self.token_stream, None) if self.current_token is None: self.token_span = self.token_span[1], self.token_span[1] raise self.error('Unexpected end of input') self.token_span...
[ "Move", "to", "the", "next", "token", "in", "the", "token", "stream", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L133-L140
[ "def", "next", "(", "self", ")", ":", "self", ".", "current_token", "=", "next", "(", "self", ".", "token_stream", ",", "None", ")", "if", "self", ".", "current_token", "is", "None", ":", "self", ".", "token_span", "=", "self", ".", "token_span", "[", ...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Parser.parse
Parse and return an nbt literal from the token stream.
nbtlib/literal/parser.py
def parse(self): """Parse and return an nbt literal from the token stream.""" token_type = self.current_token.type.lower() handler = getattr(self, f'parse_{token_type}', None) if handler is None: raise self.error(f'Invalid literal {self.current_token.value!r}') return...
def parse(self): """Parse and return an nbt literal from the token stream.""" token_type = self.current_token.type.lower() handler = getattr(self, f'parse_{token_type}', None) if handler is None: raise self.error(f'Invalid literal {self.current_token.value!r}') return...
[ "Parse", "and", "return", "an", "nbt", "literal", "from", "the", "token", "stream", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L142-L148
[ "def", "parse", "(", "self", ")", ":", "token_type", "=", "self", ".", "current_token", ".", "type", ".", "lower", "(", ")", "handler", "=", "getattr", "(", "self", ",", "f'parse_{token_type}'", ",", "None", ")", "if", "handler", "is", "None", ":", "ra...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Parser.parse_number
Parse a number from the token stream.
nbtlib/literal/parser.py
def parse_number(self): """Parse a number from the token stream.""" value = self.current_token.value suffix = value[-1].lower() try: if suffix in NUMBER_SUFFIXES: return NUMBER_SUFFIXES[suffix](value[:-1]) return Double(value) if '.' in value else...
def parse_number(self): """Parse a number from the token stream.""" value = self.current_token.value suffix = value[-1].lower() try: if suffix in NUMBER_SUFFIXES: return NUMBER_SUFFIXES[suffix](value[:-1]) return Double(value) if '.' in value else...
[ "Parse", "a", "number", "from", "the", "token", "stream", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L154-L164
[ "def", "parse_number", "(", "self", ")", ":", "value", "=", "self", ".", "current_token", ".", "value", "suffix", "=", "value", "[", "-", "1", "]", ".", "lower", "(", ")", "try", ":", "if", "suffix", "in", "NUMBER_SUFFIXES", ":", "return", "NUMBER_SUFF...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Parser.parse_string
Parse a regular unquoted string from the token stream.
nbtlib/literal/parser.py
def parse_string(self): """Parse a regular unquoted string from the token stream.""" aliased_value = LITERAL_ALIASES.get(self.current_token.value.lower()) if aliased_value is not None: return aliased_value return String(self.current_token.value)
def parse_string(self): """Parse a regular unquoted string from the token stream.""" aliased_value = LITERAL_ALIASES.get(self.current_token.value.lower()) if aliased_value is not None: return aliased_value return String(self.current_token.value)
[ "Parse", "a", "regular", "unquoted", "string", "from", "the", "token", "stream", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L166-L171
[ "def", "parse_string", "(", "self", ")", ":", "aliased_value", "=", "LITERAL_ALIASES", ".", "get", "(", "self", ".", "current_token", ".", "value", ".", "lower", "(", ")", ")", "if", "aliased_value", "is", "not", "None", ":", "return", "aliased_value", "re...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Parser.collect_tokens_until
Yield the item tokens in a comma-separated tag collection.
nbtlib/literal/parser.py
def collect_tokens_until(self, token_type): """Yield the item tokens in a comma-separated tag collection.""" self.next() if self.current_token.type == token_type: return while True: yield self.current_token self.next() if self.current_tok...
def collect_tokens_until(self, token_type): """Yield the item tokens in a comma-separated tag collection.""" self.next() if self.current_token.type == token_type: return while True: yield self.current_token self.next() if self.current_tok...
[ "Yield", "the", "item", "tokens", "in", "a", "comma", "-", "separated", "tag", "collection", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L173-L189
[ "def", "collect_tokens_until", "(", "self", ",", "token_type", ")", ":", "self", ".", "next", "(", ")", "if", "self", ".", "current_token", ".", "type", "==", "token_type", ":", "return", "while", "True", ":", "yield", "self", ".", "current_token", "self",...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Parser.parse_compound
Parse a compound from the token stream.
nbtlib/literal/parser.py
def parse_compound(self): """Parse a compound from the token stream.""" compound_tag = Compound() for token in self.collect_tokens_until('CLOSE_COMPOUND'): item_key = token.value if token.type not in ('NUMBER', 'STRING', 'QUOTED_STRING'): raise self.error...
def parse_compound(self): """Parse a compound from the token stream.""" compound_tag = Compound() for token in self.collect_tokens_until('CLOSE_COMPOUND'): item_key = token.value if token.type not in ('NUMBER', 'STRING', 'QUOTED_STRING'): raise self.error...
[ "Parse", "a", "compound", "from", "the", "token", "stream", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L191-L208
[ "def", "parse_compound", "(", "self", ")", ":", "compound_tag", "=", "Compound", "(", ")", "for", "token", "in", "self", ".", "collect_tokens_until", "(", "'CLOSE_COMPOUND'", ")", ":", "item_key", "=", "token", ".", "value", "if", "token", ".", "type", "no...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Parser.array_items
Parse and yield array items from the token stream.
nbtlib/literal/parser.py
def array_items(self, number_type, *, number_suffix=''): """Parse and yield array items from the token stream.""" for token in self.collect_tokens_until('CLOSE_BRACKET'): is_number = token.type == 'NUMBER' value = token.value.lower() if not (is_number and value.endswi...
def array_items(self, number_type, *, number_suffix=''): """Parse and yield array items from the token stream.""" for token in self.collect_tokens_until('CLOSE_BRACKET'): is_number = token.type == 'NUMBER' value = token.value.lower() if not (is_number and value.endswi...
[ "Parse", "and", "yield", "array", "items", "from", "the", "token", "stream", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L210-L218
[ "def", "array_items", "(", "self", ",", "number_type", ",", "*", ",", "number_suffix", "=", "''", ")", ":", "for", "token", "in", "self", ".", "collect_tokens_until", "(", "'CLOSE_BRACKET'", ")", ":", "is_number", "=", "token", ".", "type", "==", "'NUMBER'...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Parser.parse_list
Parse a list from the token stream.
nbtlib/literal/parser.py
def parse_list(self): """Parse a list from the token stream.""" try: return List([self.parse() for _ in self.collect_tokens_until('CLOSE_BRACKET')]) except IncompatibleItemType as exc: raise self.error(f'Item {str(exc.item)!r} is not a ' ...
def parse_list(self): """Parse a list from the token stream.""" try: return List([self.parse() for _ in self.collect_tokens_until('CLOSE_BRACKET')]) except IncompatibleItemType as exc: raise self.error(f'Item {str(exc.item)!r} is not a ' ...
[ "Parse", "a", "list", "from", "the", "token", "stream", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L232-L239
[ "def", "parse_list", "(", "self", ")", ":", "try", ":", "return", "List", "(", "[", "self", ".", "parse", "(", ")", "for", "_", "in", "self", ".", "collect_tokens_until", "(", "'CLOSE_BRACKET'", ")", "]", ")", "except", "IncompatibleItemType", "as", "exc...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Parser.unquote_string
Return the unquoted value of a quoted string.
nbtlib/literal/parser.py
def unquote_string(self, string): """Return the unquoted value of a quoted string.""" value = string[1:-1] forbidden_sequences = {ESCAPE_SUBS[STRING_QUOTES[string[0]]]} valid_sequences = set(ESCAPE_SEQUENCES) - forbidden_sequences for seq in ESCAPE_REGEX.findall(value): ...
def unquote_string(self, string): """Return the unquoted value of a quoted string.""" value = string[1:-1] forbidden_sequences = {ESCAPE_SUBS[STRING_QUOTES[string[0]]]} valid_sequences = set(ESCAPE_SEQUENCES) - forbidden_sequences for seq in ESCAPE_REGEX.findall(value): ...
[ "Return", "the", "unquoted", "value", "of", "a", "quoted", "string", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L245-L259
[ "def", "unquote_string", "(", "self", ",", "string", ")", ":", "value", "=", "string", "[", "1", ":", "-", "1", "]", "forbidden_sequences", "=", "{", "ESCAPE_SUBS", "[", "STRING_QUOTES", "[", "string", "[", "0", "]", "]", "]", "}", "valid_sequences", "...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
opener_from_zipfile
Returns a function that will open a file in a zipfile by name. For Python3 compatibility, the raw file will be converted to text.
multigtfs/compat.py
def opener_from_zipfile(zipfile): """ Returns a function that will open a file in a zipfile by name. For Python3 compatibility, the raw file will be converted to text. """ def opener(filename): inner_file = zipfile.open(filename) if PY3: from io import TextIOWrapper ...
def opener_from_zipfile(zipfile): """ Returns a function that will open a file in a zipfile by name. For Python3 compatibility, the raw file will be converted to text. """ def opener(filename): inner_file = zipfile.open(filename) if PY3: from io import TextIOWrapper ...
[ "Returns", "a", "function", "that", "will", "open", "a", "file", "in", "a", "zipfile", "by", "name", "." ]
tulsawebdevs/django-multi-gtfs
python
https://github.com/tulsawebdevs/django-multi-gtfs/blob/8c442bfb67e87566c24a7364d8fa0aacd4a0a652/multigtfs/compat.py#L73-L88
[ "def", "opener_from_zipfile", "(", "zipfile", ")", ":", "def", "opener", "(", "filename", ")", ":", "inner_file", "=", "zipfile", ".", "open", "(", "filename", ")", "if", "PY3", ":", "from", "io", "import", "TextIOWrapper", "return", "TextIOWrapper", "(", ...
8c442bfb67e87566c24a7364d8fa0aacd4a0a652
train
write_text_rows
Write CSV row data which may include text.
multigtfs/compat.py
def write_text_rows(writer, rows): '''Write CSV row data which may include text.''' for row in rows: try: writer.writerow(row) except UnicodeEncodeError: # Python 2 csv does badly with unicode outside of ASCII new_row = [] for item in row: ...
def write_text_rows(writer, rows): '''Write CSV row data which may include text.''' for row in rows: try: writer.writerow(row) except UnicodeEncodeError: # Python 2 csv does badly with unicode outside of ASCII new_row = [] for item in row: ...
[ "Write", "CSV", "row", "data", "which", "may", "include", "text", "." ]
tulsawebdevs/django-multi-gtfs
python
https://github.com/tulsawebdevs/django-multi-gtfs/blob/8c442bfb67e87566c24a7364d8fa0aacd4a0a652/multigtfs/compat.py#L91-L104
[ "def", "write_text_rows", "(", "writer", ",", "rows", ")", ":", "for", "row", "in", "rows", ":", "try", ":", "writer", ".", "writerow", "(", "row", ")", "except", "UnicodeEncodeError", ":", "# Python 2 csv does badly with unicode outside of ASCII", "new_row", "=",...
8c442bfb67e87566c24a7364d8fa0aacd4a0a652
train
serialize_tag
Serialize an nbt tag to its literal representation.
nbtlib/literal/serializer.py
def serialize_tag(tag, *, indent=None, compact=False, quote=None): """Serialize an nbt tag to its literal representation.""" serializer = Serializer(indent=indent, compact=compact, quote=quote) return serializer.serialize(tag)
def serialize_tag(tag, *, indent=None, compact=False, quote=None): """Serialize an nbt tag to its literal representation.""" serializer = Serializer(indent=indent, compact=compact, quote=quote) return serializer.serialize(tag)
[ "Serialize", "an", "nbt", "tag", "to", "its", "literal", "representation", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L48-L51
[ "def", "serialize_tag", "(", "tag", ",", "*", ",", "indent", "=", "None", ",", "compact", "=", "False", ",", "quote", "=", "None", ")", ":", "serializer", "=", "Serializer", "(", "indent", "=", "indent", ",", "compact", "=", "compact", ",", "quote", ...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Serializer.depth
Increase the level of indentation by one.
nbtlib/literal/serializer.py
def depth(self): """Increase the level of indentation by one.""" if self.indentation is None: yield else: previous = self.previous_indent self.previous_indent = self.indent self.indent += self.indentation yield self.indent =...
def depth(self): """Increase the level of indentation by one.""" if self.indentation is None: yield else: previous = self.previous_indent self.previous_indent = self.indent self.indent += self.indentation yield self.indent =...
[ "Increase", "the", "level", "of", "indentation", "by", "one", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L71-L81
[ "def", "depth", "(", "self", ")", ":", "if", "self", ".", "indentation", "is", "None", ":", "yield", "else", ":", "previous", "=", "self", ".", "previous_indent", "self", ".", "previous_indent", "=", "self", ".", "indent", "self", ".", "indent", "+=", ...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Serializer.should_expand
Return whether the specified tag should be expanded.
nbtlib/literal/serializer.py
def should_expand(self, tag): """Return whether the specified tag should be expanded.""" return self.indentation is not None and tag and ( not self.previous_indent or ( tag.serializer == 'list' and tag.subtype.serializer in ('array', 'list', 'compound') ...
def should_expand(self, tag): """Return whether the specified tag should be expanded.""" return self.indentation is not None and tag and ( not self.previous_indent or ( tag.serializer == 'list' and tag.subtype.serializer in ('array', 'list', 'compound') ...
[ "Return", "whether", "the", "specified", "tag", "should", "be", "expanded", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L83-L92
[ "def", "should_expand", "(", "self", ",", "tag", ")", ":", "return", "self", ".", "indentation", "is", "not", "None", "and", "tag", "and", "(", "not", "self", ".", "previous_indent", "or", "(", "tag", ".", "serializer", "==", "'list'", "and", "tag", "....
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Serializer.escape_string
Return the escaped literal representation of an nbt string.
nbtlib/literal/serializer.py
def escape_string(self, string): """Return the escaped literal representation of an nbt string.""" if self.quote: quote = self.quote else: found = QUOTE_REGEX.search(string) quote = STRING_QUOTES[found.group()] if found else next(iter(STRING_QUOTES)) ...
def escape_string(self, string): """Return the escaped literal representation of an nbt string.""" if self.quote: quote = self.quote else: found = QUOTE_REGEX.search(string) quote = STRING_QUOTES[found.group()] if found else next(iter(STRING_QUOTES)) ...
[ "Return", "the", "escaped", "literal", "representation", "of", "an", "nbt", "string", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L101-L113
[ "def", "escape_string", "(", "self", ",", "string", ")", ":", "if", "self", ".", "quote", ":", "quote", "=", "self", ".", "quote", "else", ":", "found", "=", "QUOTE_REGEX", ".", "search", "(", "string", ")", "quote", "=", "STRING_QUOTES", "[", "found",...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Serializer.stringify_compound_key
Escape the compound key if it can't be represented unquoted.
nbtlib/literal/serializer.py
def stringify_compound_key(self, key): """Escape the compound key if it can't be represented unquoted.""" if UNQUOTED_COMPOUND_KEY.match(key): return key return self.escape_string(key)
def stringify_compound_key(self, key): """Escape the compound key if it can't be represented unquoted.""" if UNQUOTED_COMPOUND_KEY.match(key): return key return self.escape_string(key)
[ "Escape", "the", "compound", "key", "if", "it", "can", "t", "be", "represented", "unquoted", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L115-L119
[ "def", "stringify_compound_key", "(", "self", ",", "key", ")", ":", "if", "UNQUOTED_COMPOUND_KEY", ".", "match", "(", "key", ")", ":", "return", "key", "return", "self", ".", "escape_string", "(", "key", ")" ]
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Serializer.serialize
Return the literal representation of a tag.
nbtlib/literal/serializer.py
def serialize(self, tag): """Return the literal representation of a tag.""" handler = getattr(self, f'serialize_{tag.serializer}', None) if handler is None: raise TypeError(f'Can\'t serialize {type(tag)!r} instance') return handler(tag)
def serialize(self, tag): """Return the literal representation of a tag.""" handler = getattr(self, f'serialize_{tag.serializer}', None) if handler is None: raise TypeError(f'Can\'t serialize {type(tag)!r} instance') return handler(tag)
[ "Return", "the", "literal", "representation", "of", "a", "tag", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L121-L126
[ "def", "serialize", "(", "self", ",", "tag", ")", ":", "handler", "=", "getattr", "(", "self", ",", "f'serialize_{tag.serializer}'", ",", "None", ")", "if", "handler", "is", "None", ":", "raise", "TypeError", "(", "f'Can\\'t serialize {type(tag)!r} instance'", "...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Serializer.serialize_numeric
Return the literal representation of a numeric tag.
nbtlib/literal/serializer.py
def serialize_numeric(self, tag): """Return the literal representation of a numeric tag.""" str_func = int.__str__ if isinstance(tag, int) else float.__str__ return str_func(tag) + tag.suffix
def serialize_numeric(self, tag): """Return the literal representation of a numeric tag.""" str_func = int.__str__ if isinstance(tag, int) else float.__str__ return str_func(tag) + tag.suffix
[ "Return", "the", "literal", "representation", "of", "a", "numeric", "tag", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L128-L131
[ "def", "serialize_numeric", "(", "self", ",", "tag", ")", ":", "str_func", "=", "int", ".", "__str__", "if", "isinstance", "(", "tag", ",", "int", ")", "else", "float", ".", "__str__", "return", "str_func", "(", "tag", ")", "+", "tag", ".", "suffix" ]
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Serializer.serialize_array
Return the literal representation of an array tag.
nbtlib/literal/serializer.py
def serialize_array(self, tag): """Return the literal representation of an array tag.""" elements = self.comma.join(f'{el}{tag.item_suffix}' for el in tag) return f'[{tag.array_prefix}{self.semicolon}{elements}]'
def serialize_array(self, tag): """Return the literal representation of an array tag.""" elements = self.comma.join(f'{el}{tag.item_suffix}' for el in tag) return f'[{tag.array_prefix}{self.semicolon}{elements}]'
[ "Return", "the", "literal", "representation", "of", "an", "array", "tag", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L133-L136
[ "def", "serialize_array", "(", "self", ",", "tag", ")", ":", "elements", "=", "self", ".", "comma", ".", "join", "(", "f'{el}{tag.item_suffix}'", "for", "el", "in", "tag", ")", "return", "f'[{tag.array_prefix}{self.semicolon}{elements}]'" ]
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Serializer.serialize_list
Return the literal representation of a list tag.
nbtlib/literal/serializer.py
def serialize_list(self, tag): """Return the literal representation of a list tag.""" separator, fmt = self.comma, '[{}]' with self.depth(): if self.should_expand(tag): separator, fmt = self.expand(separator, fmt) return fmt.format(separator.join(map(sel...
def serialize_list(self, tag): """Return the literal representation of a list tag.""" separator, fmt = self.comma, '[{}]' with self.depth(): if self.should_expand(tag): separator, fmt = self.expand(separator, fmt) return fmt.format(separator.join(map(sel...
[ "Return", "the", "literal", "representation", "of", "a", "list", "tag", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L142-L150
[ "def", "serialize_list", "(", "self", ",", "tag", ")", ":", "separator", ",", "fmt", "=", "self", ".", "comma", ",", "'[{}]'", "with", "self", ".", "depth", "(", ")", ":", "if", "self", ".", "should_expand", "(", "tag", ")", ":", "separator", ",", ...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Serializer.serialize_compound
Return the literal representation of a compound tag.
nbtlib/literal/serializer.py
def serialize_compound(self, tag): """Return the literal representation of a compound tag.""" separator, fmt = self.comma, '{{{}}}' with self.depth(): if self.should_expand(tag): separator, fmt = self.expand(separator, fmt) return fmt.format(separator.jo...
def serialize_compound(self, tag): """Return the literal representation of a compound tag.""" separator, fmt = self.comma, '{{{}}}' with self.depth(): if self.should_expand(tag): separator, fmt = self.expand(separator, fmt) return fmt.format(separator.jo...
[ "Return", "the", "literal", "representation", "of", "a", "compound", "tag", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L152-L163
[ "def", "serialize_compound", "(", "self", ",", "tag", ")", ":", "separator", ",", "fmt", "=", "self", ".", "comma", ",", "'{{{}}}'", "with", "self", ".", "depth", "(", ")", ":", "if", "self", ".", "should_expand", "(", "tag", ")", ":", "separator", "...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
BaseQuerySet.populated_column_map
Return the _column_map without unused optional fields
multigtfs/models/base.py
def populated_column_map(self): '''Return the _column_map without unused optional fields''' column_map = [] cls = self.model for csv_name, field_pattern in cls._column_map: # Separate the local field name from foreign columns if '__' in field_pattern: ...
def populated_column_map(self): '''Return the _column_map without unused optional fields''' column_map = [] cls = self.model for csv_name, field_pattern in cls._column_map: # Separate the local field name from foreign columns if '__' in field_pattern: ...
[ "Return", "the", "_column_map", "without", "unused", "optional", "fields" ]
tulsawebdevs/django-multi-gtfs
python
https://github.com/tulsawebdevs/django-multi-gtfs/blob/8c442bfb67e87566c24a7364d8fa0aacd4a0a652/multigtfs/models/base.py#L37-L62
[ "def", "populated_column_map", "(", "self", ")", ":", "column_map", "=", "[", "]", "cls", "=", "self", ".", "model", "for", "csv_name", ",", "field_pattern", "in", "cls", ".", "_column_map", ":", "# Separate the local field name from foreign columns", "if", "'__'"...
8c442bfb67e87566c24a7364d8fa0aacd4a0a652
train
BaseManager.in_feed
Return the objects in the target feed
multigtfs/models/base.py
def in_feed(self, feed): '''Return the objects in the target feed''' kwargs = {self.model._rel_to_feed: feed} return self.filter(**kwargs)
def in_feed(self, feed): '''Return the objects in the target feed''' kwargs = {self.model._rel_to_feed: feed} return self.filter(**kwargs)
[ "Return", "the", "objects", "in", "the", "target", "feed" ]
tulsawebdevs/django-multi-gtfs
python
https://github.com/tulsawebdevs/django-multi-gtfs/blob/8c442bfb67e87566c24a7364d8fa0aacd4a0a652/multigtfs/models/base.py#L70-L73
[ "def", "in_feed", "(", "self", ",", "feed", ")", ":", "kwargs", "=", "{", "self", ".", "model", ".", "_rel_to_feed", ":", "feed", "}", "return", "self", ".", "filter", "(", "*", "*", "kwargs", ")" ]
8c442bfb67e87566c24a7364d8fa0aacd4a0a652
train
Base.import_txt
Import from the GTFS text file
multigtfs/models/base.py
def import_txt(cls, txt_file, feed, filter_func=None): '''Import from the GTFS text file''' # Setup the conversion from GTFS to Django Format # Conversion functions def no_convert(value): return value def date_convert(value): return datetime.strptime(value, '%Y%m%d') d...
def import_txt(cls, txt_file, feed, filter_func=None): '''Import from the GTFS text file''' # Setup the conversion from GTFS to Django Format # Conversion functions def no_convert(value): return value def date_convert(value): return datetime.strptime(value, '%Y%m%d') d...
[ "Import", "from", "the", "GTFS", "text", "file" ]
tulsawebdevs/django-multi-gtfs
python
https://github.com/tulsawebdevs/django-multi-gtfs/blob/8c442bfb67e87566c24a7364d8fa0aacd4a0a652/multigtfs/models/base.py#L108-L300
[ "def", "import_txt", "(", "cls", ",", "txt_file", ",", "feed", ",", "filter_func", "=", "None", ")", ":", "# Setup the conversion from GTFS to Django Format", "# Conversion functions", "def", "no_convert", "(", "value", ")", ":", "return", "value", "def", "date_conv...
8c442bfb67e87566c24a7364d8fa0aacd4a0a652
train
Base.export_txt
Export records as a GTFS comma-separated file
multigtfs/models/base.py
def export_txt(cls, feed): '''Export records as a GTFS comma-separated file''' objects = cls.objects.in_feed(feed) # If no records, return None if not objects.exists(): return # Get the columns used in the dataset column_map = objects.populated_column_map() ...
def export_txt(cls, feed): '''Export records as a GTFS comma-separated file''' objects = cls.objects.in_feed(feed) # If no records, return None if not objects.exists(): return # Get the columns used in the dataset column_map = objects.populated_column_map() ...
[ "Export", "records", "as", "a", "GTFS", "comma", "-", "separated", "file" ]
tulsawebdevs/django-multi-gtfs
python
https://github.com/tulsawebdevs/django-multi-gtfs/blob/8c442bfb67e87566c24a7364d8fa0aacd4a0a652/multigtfs/models/base.py#L303-L410
[ "def", "export_txt", "(", "cls", ",", "feed", ")", ":", "objects", "=", "cls", ".", "objects", ".", "in_feed", "(", "feed", ")", "# If no records, return None", "if", "not", "objects", ".", "exists", "(", ")", ":", "return", "# Get the columns used in the data...
8c442bfb67e87566c24a7364d8fa0aacd4a0a652
train
make_android_api_method
Turn an AndroidApi's method into a function that builds the request, sends it, then passes the response to the actual method. Should be used as a decorator.
crunchyroll/apis/android.py
def make_android_api_method(req_method, secure=True, version=0): """Turn an AndroidApi's method into a function that builds the request, sends it, then passes the response to the actual method. Should be used as a decorator. """ def outer_func(func): def inner_func(self, **kwargs): ...
def make_android_api_method(req_method, secure=True, version=0): """Turn an AndroidApi's method into a function that builds the request, sends it, then passes the response to the actual method. Should be used as a decorator. """ def outer_func(func): def inner_func(self, **kwargs): ...
[ "Turn", "an", "AndroidApi", "s", "method", "into", "a", "function", "that", "builds", "the", "request", "sends", "it", "then", "passes", "the", "response", "to", "the", "actual", "method", ".", "Should", "be", "used", "as", "a", "decorator", "." ]
aheadley/python-crunchyroll
python
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/android.py#L32-L45
[ "def", "make_android_api_method", "(", "req_method", ",", "secure", "=", "True", ",", "version", "=", "0", ")", ":", "def", "outer_func", "(", "func", ")", ":", "def", "inner_func", "(", "self", ",", "*", "*", "kwargs", ")", ":", "req_url", "=", "self"...
9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178
train
AndroidApi._get_base_params
Get the params that will be included with every request
crunchyroll/apis/android.py
def _get_base_params(self): """Get the params that will be included with every request """ base_params = { 'locale': self._get_locale(), 'device_id': ANDROID.DEVICE_ID, 'device_type': ANDROID.APP_PACKAGE, 'access_token': ANDROID.ACCESS_TO...
def _get_base_params(self): """Get the params that will be included with every request """ base_params = { 'locale': self._get_locale(), 'device_id': ANDROID.DEVICE_ID, 'device_type': ANDROID.APP_PACKAGE, 'access_token': ANDROID.ACCESS_TO...
[ "Get", "the", "params", "that", "will", "be", "included", "with", "every", "request" ]
aheadley/python-crunchyroll
python
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/android.py#L105-L118
[ "def", "_get_base_params", "(", "self", ")", ":", "base_params", "=", "{", "'locale'", ":", "self", ".", "_get_locale", "(", ")", ",", "'device_id'", ":", "ANDROID", ".", "DEVICE_ID", ",", "'device_type'", ":", "ANDROID", ".", "APP_PACKAGE", ",", "'access_to...
9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178
train
AndroidApi._build_request_url
Build a URL for a API method request
crunchyroll/apis/android.py
def _build_request_url(self, secure, api_method, version): """Build a URL for a API method request """ if secure: proto = ANDROID.PROTOCOL_SECURE else: proto = ANDROID.PROTOCOL_INSECURE req_url = ANDROID.API_URL.format( protocol=proto, ...
def _build_request_url(self, secure, api_method, version): """Build a URL for a API method request """ if secure: proto = ANDROID.PROTOCOL_SECURE else: proto = ANDROID.PROTOCOL_INSECURE req_url = ANDROID.API_URL.format( protocol=proto, ...
[ "Build", "a", "URL", "for", "a", "API", "method", "request" ]
aheadley/python-crunchyroll
python
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/android.py#L174-L186
[ "def", "_build_request_url", "(", "self", ",", "secure", ",", "api_method", ",", "version", ")", ":", "if", "secure", ":", "proto", "=", "ANDROID", ".", "PROTOCOL_SECURE", "else", ":", "proto", "=", "ANDROID", ".", "PROTOCOL_INSECURE", "req_url", "=", "ANDRO...
9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178
train
AndroidApi.is_premium
Get if the session is premium for a given media type @param str media_type Should be one of ANDROID.MEDIA_TYPE_* @return bool
crunchyroll/apis/android.py
def is_premium(self, media_type): """Get if the session is premium for a given media type @param str media_type Should be one of ANDROID.MEDIA_TYPE_* @return bool """ if self.logged_in: if media_type in self._user_data['premium']: return True ...
def is_premium(self, media_type): """Get if the session is premium for a given media type @param str media_type Should be one of ANDROID.MEDIA_TYPE_* @return bool """ if self.logged_in: if media_type in self._user_data['premium']: return True ...
[ "Get", "if", "the", "session", "is", "premium", "for", "a", "given", "media", "type" ]
aheadley/python-crunchyroll
python
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/android.py#L196-L205
[ "def", "is_premium", "(", "self", ",", "media_type", ")", ":", "if", "self", ".", "logged_in", ":", "if", "media_type", "in", "self", ".", "_user_data", "[", "'premium'", "]", ":", "return", "True", "return", "False" ]
9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178
train
AndroidApi.login
Login using email/username and password, used to get the auth token @param str account @param str password @param int duration (optional)
crunchyroll/apis/android.py
def login(self, response): """ Login using email/username and password, used to get the auth token @param str account @param str password @param int duration (optional) """ self._state_params['auth'] = response['auth'] self._user_data = response['user'] ...
def login(self, response): """ Login using email/username and password, used to get the auth token @param str account @param str password @param int duration (optional) """ self._state_params['auth'] = response['auth'] self._user_data = response['user'] ...
[ "Login", "using", "email", "/", "username", "and", "password", "used", "to", "get", "the", "auth", "token" ]
aheadley/python-crunchyroll
python
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/android.py#L242-L253
[ "def", "login", "(", "self", ",", "response", ")", ":", "self", ".", "_state_params", "[", "'auth'", "]", "=", "response", "[", "'auth'", "]", "self", ".", "_user_data", "=", "response", "[", "'user'", "]", "if", "not", "self", ".", "logged_in", ":", ...
9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178
train
read_numeric
Read a numeric value from a file-like object.
nbtlib/tag.py
def read_numeric(fmt, buff, byteorder='big'): """Read a numeric value from a file-like object.""" try: fmt = fmt[byteorder] return fmt.unpack(buff.read(fmt.size))[0] except StructError: return 0 except KeyError as exc: raise ValueError('Invalid byte order') from e...
def read_numeric(fmt, buff, byteorder='big'): """Read a numeric value from a file-like object.""" try: fmt = fmt[byteorder] return fmt.unpack(buff.read(fmt.size))[0] except StructError: return 0 except KeyError as exc: raise ValueError('Invalid byte order') from e...
[ "Read", "a", "numeric", "value", "from", "a", "file", "-", "like", "object", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/tag.py#L99-L107
[ "def", "read_numeric", "(", "fmt", ",", "buff", ",", "byteorder", "=", "'big'", ")", ":", "try", ":", "fmt", "=", "fmt", "[", "byteorder", "]", "return", "fmt", ".", "unpack", "(", "buff", ".", "read", "(", "fmt", ".", "size", ")", ")", "[", "0",...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
write_numeric
Write a numeric value to a file-like object.
nbtlib/tag.py
def write_numeric(fmt, value, buff, byteorder='big'): """Write a numeric value to a file-like object.""" try: buff.write(fmt[byteorder].pack(value)) except KeyError as exc: raise ValueError('Invalid byte order') from exc
def write_numeric(fmt, value, buff, byteorder='big'): """Write a numeric value to a file-like object.""" try: buff.write(fmt[byteorder].pack(value)) except KeyError as exc: raise ValueError('Invalid byte order') from exc
[ "Write", "a", "numeric", "value", "to", "a", "file", "-", "like", "object", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/tag.py#L110-L115
[ "def", "write_numeric", "(", "fmt", ",", "value", ",", "buff", ",", "byteorder", "=", "'big'", ")", ":", "try", ":", "buff", ".", "write", "(", "fmt", "[", "byteorder", "]", ".", "pack", "(", "value", ")", ")", "except", "KeyError", "as", "exc", ":...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
read_string
Read a string from a file-like object.
nbtlib/tag.py
def read_string(buff, byteorder='big'): """Read a string from a file-like object.""" length = read_numeric(USHORT, buff, byteorder) return buff.read(length).decode('utf-8')
def read_string(buff, byteorder='big'): """Read a string from a file-like object.""" length = read_numeric(USHORT, buff, byteorder) return buff.read(length).decode('utf-8')
[ "Read", "a", "string", "from", "a", "file", "-", "like", "object", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/tag.py#L118-L121
[ "def", "read_string", "(", "buff", ",", "byteorder", "=", "'big'", ")", ":", "length", "=", "read_numeric", "(", "USHORT", ",", "buff", ",", "byteorder", ")", "return", "buff", ".", "read", "(", "length", ")", ".", "decode", "(", "'utf-8'", ")" ]
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
write_string
Write a string to a file-like object.
nbtlib/tag.py
def write_string(value, buff, byteorder='big'): """Write a string to a file-like object.""" data = value.encode('utf-8') write_numeric(USHORT, len(data), buff, byteorder) buff.write(data)
def write_string(value, buff, byteorder='big'): """Write a string to a file-like object.""" data = value.encode('utf-8') write_numeric(USHORT, len(data), buff, byteorder) buff.write(data)
[ "Write", "a", "string", "to", "a", "file", "-", "like", "object", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/tag.py#L124-L128
[ "def", "write_string", "(", "value", ",", "buff", ",", "byteorder", "=", "'big'", ")", ":", "data", "=", "value", ".", "encode", "(", "'utf-8'", ")", "write_numeric", "(", "USHORT", ",", "len", "(", "data", ")", ",", "buff", ",", "byteorder", ")", "b...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
List.infer_list_subtype
Infer a list subtype from a collection of items.
nbtlib/tag.py
def infer_list_subtype(items): """Infer a list subtype from a collection of items.""" subtype = End for item in items: item_type = type(item) if not issubclass(item_type, Base): continue if subtype is End: subtype = ...
def infer_list_subtype(items): """Infer a list subtype from a collection of items.""" subtype = End for item in items: item_type = type(item) if not issubclass(item_type, Base): continue if subtype is End: subtype = ...
[ "Infer", "a", "list", "subtype", "from", "a", "collection", "of", "items", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/tag.py#L414-L438
[ "def", "infer_list_subtype", "(", "items", ")", ":", "subtype", "=", "End", "for", "item", "in", "items", ":", "item_type", "=", "type", "(", "item", ")", "if", "not", "issubclass", "(", "item_type", ",", "Base", ")", ":", "continue", "if", "subtype", ...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
List.cast_item
Cast list item to the appropriate tag type.
nbtlib/tag.py
def cast_item(cls, item): """Cast list item to the appropriate tag type.""" if not isinstance(item, cls.subtype): incompatible = isinstance(item, Base) and not any( issubclass(cls.subtype, tag_type) and isinstance(item, tag_type) for tag_type in cls.all_t...
def cast_item(cls, item): """Cast list item to the appropriate tag type.""" if not isinstance(item, cls.subtype): incompatible = isinstance(item, Base) and not any( issubclass(cls.subtype, tag_type) and isinstance(item, tag_type) for tag_type in cls.all_t...
[ "Cast", "list", "item", "to", "the", "appropriate", "tag", "type", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/tag.py#L465-L486
[ "def", "cast_item", "(", "cls", ",", "item", ")", ":", "if", "not", "isinstance", "(", "item", ",", "cls", ".", "subtype", ")", ":", "incompatible", "=", "isinstance", "(", "item", ",", "Base", ")", "and", "not", "any", "(", "issubclass", "(", "cls",...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
Compound.merge
Recursively merge tags from another compound.
nbtlib/tag.py
def merge(self, other): """Recursively merge tags from another compound.""" for key, value in other.items(): if key in self and (isinstance(self[key], Compound) and isinstance(value, dict)): self[key].merge(value) else: ...
def merge(self, other): """Recursively merge tags from another compound.""" for key, value in other.items(): if key in self and (isinstance(self[key], Compound) and isinstance(value, dict)): self[key].merge(value) else: ...
[ "Recursively", "merge", "tags", "from", "another", "compound", "." ]
vberlier/nbtlib
python
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/tag.py#L522-L529
[ "def", "merge", "(", "self", ",", "other", ")", ":", "for", "key", ",", "value", "in", "other", ".", "items", "(", ")", ":", "if", "key", "in", "self", "and", "(", "isinstance", "(", "self", "[", "key", "]", ",", "Compound", ")", "and", "isinstan...
9c9d58b5c4a530b0f1ffd76dda176f00406c3547
train
SubtitleDecrypter.decrypt_subtitle
Decrypt encrypted subtitle data in high level model object @param crunchyroll.models.Subtitle subtitle @return str
crunchyroll/subtitles.py
def decrypt_subtitle(self, subtitle): """Decrypt encrypted subtitle data in high level model object @param crunchyroll.models.Subtitle subtitle @return str """ return self.decrypt(self._build_encryption_key(int(subtitle.id)), subtitle['iv'][0].text.decode('base64'), ...
def decrypt_subtitle(self, subtitle): """Decrypt encrypted subtitle data in high level model object @param crunchyroll.models.Subtitle subtitle @return str """ return self.decrypt(self._build_encryption_key(int(subtitle.id)), subtitle['iv'][0].text.decode('base64'), ...
[ "Decrypt", "encrypted", "subtitle", "data", "in", "high", "level", "model", "object" ]
aheadley/python-crunchyroll
python
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/subtitles.py#L51-L59
[ "def", "decrypt_subtitle", "(", "self", ",", "subtitle", ")", ":", "return", "self", ".", "decrypt", "(", "self", ".", "_build_encryption_key", "(", "int", "(", "subtitle", ".", "id", ")", ")", ",", "subtitle", "[", "'iv'", "]", "[", "0", "]", ".", "...
9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178
train
SubtitleDecrypter.decrypt
Decrypt encrypted subtitle data @param int subtitle_id @param str iv @param str encrypted_data @return str
crunchyroll/subtitles.py
def decrypt(self, encryption_key, iv, encrypted_data): """Decrypt encrypted subtitle data @param int subtitle_id @param str iv @param str encrypted_data @return str """ logger.info('Decrypting subtitles with length (%d bytes), key=%r', len(encrypted_...
def decrypt(self, encryption_key, iv, encrypted_data): """Decrypt encrypted subtitle data @param int subtitle_id @param str iv @param str encrypted_data @return str """ logger.info('Decrypting subtitles with length (%d bytes), key=%r', len(encrypted_...
[ "Decrypt", "encrypted", "subtitle", "data" ]
aheadley/python-crunchyroll
python
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/subtitles.py#L61-L72
[ "def", "decrypt", "(", "self", ",", "encryption_key", ",", "iv", ",", "encrypted_data", ")", ":", "logger", ".", "info", "(", "'Decrypting subtitles with length (%d bytes), key=%r'", ",", "len", "(", "encrypted_data", ")", ",", "encryption_key", ")", "return", "zl...
9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178
train
SubtitleDecrypter._build_encryption_key
Generate the encryption key for a given media item Encryption key is basically just sha1(<magic value based on subtitle_id> + '"#$&).6CXzPHw=2N_+isZK') then padded with 0s to 32 chars @param int subtitle_id @param int key_size @return str
crunchyroll/subtitles.py
def _build_encryption_key(self, subtitle_id, key_size=ENCRYPTION_KEY_SIZE): """Generate the encryption key for a given media item Encryption key is basically just sha1(<magic value based on subtitle_id> + '"#$&).6CXzPHw=2N_+isZK') then padded with 0s to 32 chars @param int subt...
def _build_encryption_key(self, subtitle_id, key_size=ENCRYPTION_KEY_SIZE): """Generate the encryption key for a given media item Encryption key is basically just sha1(<magic value based on subtitle_id> + '"#$&).6CXzPHw=2N_+isZK') then padded with 0s to 32 chars @param int subt...
[ "Generate", "the", "encryption", "key", "for", "a", "given", "media", "item" ]
aheadley/python-crunchyroll
python
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/subtitles.py#L74-L91
[ "def", "_build_encryption_key", "(", "self", ",", "subtitle_id", ",", "key_size", "=", "ENCRYPTION_KEY_SIZE", ")", ":", "# generate a 160-bit SHA1 hash", "sha1_hash", "=", "hashlib", ".", "new", "(", "'sha1'", ",", "self", ".", "_build_hash_secret", "(", "(", "1",...
9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178
train
SubtitleDecrypter._build_hash_magic
Build the other half of the encryption key hash I have no idea what is going on here @param int subtitle_id @return str
crunchyroll/subtitles.py
def _build_hash_magic(self, subtitle_id): """Build the other half of the encryption key hash I have no idea what is going on here @param int subtitle_id @return str """ media_magic = self.HASH_MAGIC_CONST ^ subtitle_id hash_magic = media_magic ^ media_magic >> ...
def _build_hash_magic(self, subtitle_id): """Build the other half of the encryption key hash I have no idea what is going on here @param int subtitle_id @return str """ media_magic = self.HASH_MAGIC_CONST ^ subtitle_id hash_magic = media_magic ^ media_magic >> ...
[ "Build", "the", "other", "half", "of", "the", "encryption", "key", "hash" ]
aheadley/python-crunchyroll
python
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/subtitles.py#L93-L104
[ "def", "_build_hash_magic", "(", "self", ",", "subtitle_id", ")", ":", "media_magic", "=", "self", ".", "HASH_MAGIC_CONST", "^", "subtitle_id", "hash_magic", "=", "media_magic", "^", "media_magic", ">>", "3", "^", "media_magic", "*", "32", "return", "str", "("...
9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178