repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
tariqdaouda/pyGeno
pyGeno/tools/BinarySequence.py
BinarySequence.__getSequenceVariants
def __getSequenceVariants(self, x1, polyStart, polyStop, listSequence) : """polyStop, is the polymorphisme at wixh number where the calcul of combinaisons stops""" if polyStart < len(self.polymorphisms) and polyStart < polyStop: sequence = copy.copy(listSequence) ret = [] pk = self.polymorphisms[polyS...
python
def __getSequenceVariants(self, x1, polyStart, polyStop, listSequence) : """polyStop, is the polymorphisme at wixh number where the calcul of combinaisons stops""" if polyStart < len(self.polymorphisms) and polyStart < polyStop: sequence = copy.copy(listSequence) ret = [] pk = self.polymorphisms[polyS...
[ "def", "__getSequenceVariants", "(", "self", ",", "x1", ",", "polyStart", ",", "polyStop", ",", "listSequence", ")", ":", "if", "polyStart", "<", "len", "(", "self", ".", "polymorphisms", ")", "and", "polyStart", "<", "polyStop", ":", "sequence", "=", "cop...
polyStop, is the polymorphisme at wixh number where the calcul of combinaisons stops
[ "polyStop", "is", "the", "polymorphisme", "at", "wixh", "number", "where", "the", "calcul", "of", "combinaisons", "stops" ]
train
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/BinarySequence.py#L104-L119
tariqdaouda/pyGeno
pyGeno/tools/BinarySequence.py
BinarySequence.getSequenceVariants
def getSequenceVariants(self, x1 = 0, x2 = -1, maxVariantNumber = 128) : """returns the sequences resulting from all combinaisons of all polymorphismes between x1 and x2. The results is a couple (bool, variants of sequence between x1 and x2), bool == true if there's more combinaisons than maxVariantNumber""" if x2 ...
python
def getSequenceVariants(self, x1 = 0, x2 = -1, maxVariantNumber = 128) : """returns the sequences resulting from all combinaisons of all polymorphismes between x1 and x2. The results is a couple (bool, variants of sequence between x1 and x2), bool == true if there's more combinaisons than maxVariantNumber""" if x2 ...
[ "def", "getSequenceVariants", "(", "self", ",", "x1", "=", "0", ",", "x2", "=", "-", "1", ",", "maxVariantNumber", "=", "128", ")", ":", "if", "x2", "==", "-", "1", ":", "xx2", "=", "len", "(", "self", ".", "defaultSequence", ")", "else", ":", "x...
returns the sequences resulting from all combinaisons of all polymorphismes between x1 and x2. The results is a couple (bool, variants of sequence between x1 and x2), bool == true if there's more combinaisons than maxVariantNumber
[ "returns", "the", "sequences", "resulting", "from", "all", "combinaisons", "of", "all", "polymorphismes", "between", "x1", "and", "x2", ".", "The", "results", "is", "a", "couple", "(", "bool", "variants", "of", "sequence", "between", "x1", "and", "x2", ")", ...
train
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/BinarySequence.py#L121-L150
tariqdaouda/pyGeno
pyGeno/tools/BinarySequence.py
BinarySequence.getNbVariants
def getNbVariants(self, x1, x2 = -1) : """returns the nb of variants of sequences between x1 and x2""" if x2 == -1 : xx2 = len(self.defaultSequence) else : xx2 = x2 nbP = 1 for p in self.polymorphisms: if x1 <= p[0] and p[0] <= xx2 : nbP *= len(p[1]) return nbP
python
def getNbVariants(self, x1, x2 = -1) : """returns the nb of variants of sequences between x1 and x2""" if x2 == -1 : xx2 = len(self.defaultSequence) else : xx2 = x2 nbP = 1 for p in self.polymorphisms: if x1 <= p[0] and p[0] <= xx2 : nbP *= len(p[1]) return nbP
[ "def", "getNbVariants", "(", "self", ",", "x1", ",", "x2", "=", "-", "1", ")", ":", "if", "x2", "==", "-", "1", ":", "xx2", "=", "len", "(", "self", ".", "defaultSequence", ")", "else", ":", "xx2", "=", "x2", "nbP", "=", "1", "for", "p", "in"...
returns the nb of variants of sequences between x1 and x2
[ "returns", "the", "nb", "of", "variants", "of", "sequences", "between", "x1", "and", "x2" ]
train
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/BinarySequence.py#L152-L164
tariqdaouda/pyGeno
pyGeno/tools/BinarySequence.py
BinarySequence._dichFind
def _dichFind(self, needle, currHaystack, offset, lst = None) : """dichotomic search, if lst is None, will return the first position found. If it's a list, will return a list of all positions in lst. returns -1 or [] if no match found""" if len(currHaystack) == 1 : if (offset <= (len(self) - len(needle))) and...
python
def _dichFind(self, needle, currHaystack, offset, lst = None) : """dichotomic search, if lst is None, will return the first position found. If it's a list, will return a list of all positions in lst. returns -1 or [] if no match found""" if len(currHaystack) == 1 : if (offset <= (len(self) - len(needle))) and...
[ "def", "_dichFind", "(", "self", ",", "needle", ",", "currHaystack", ",", "offset", ",", "lst", "=", "None", ")", ":", "if", "len", "(", "currHaystack", ")", "==", "1", ":", "if", "(", "offset", "<=", "(", "len", "(", "self", ")", "-", "len", "("...
dichotomic search, if lst is None, will return the first position found. If it's a list, will return a list of all positions in lst. returns -1 or [] if no match found
[ "dichotomic", "search", "if", "lst", "is", "None", "will", "return", "the", "first", "position", "found", ".", "If", "it", "s", "a", "list", "will", "return", "a", "list", "of", "all", "positions", "in", "lst", ".", "returns", "-", "1", "or", "[]", "...
train
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/BinarySequence.py#L166-L195
tariqdaouda/pyGeno
pyGeno/tools/BinarySequence.py
BinarySequence._kmp_construct_next
def _kmp_construct_next(self, pattern): """the helper function for KMP-string-searching is to construct the DFA. pattern should be an integer array. return a 2D array representing the DFA for moving the pattern.""" next = [[0 for state in pattern] for input_token in self.ALPHABETA_KMP] ...
python
def _kmp_construct_next(self, pattern): """the helper function for KMP-string-searching is to construct the DFA. pattern should be an integer array. return a 2D array representing the DFA for moving the pattern.""" next = [[0 for state in pattern] for input_token in self.ALPHABETA_KMP] ...
[ "def", "_kmp_construct_next", "(", "self", ",", "pattern", ")", ":", "next", "=", "[", "[", "0", "for", "state", "in", "pattern", "]", "for", "input_token", "in", "self", ".", "ALPHABETA_KMP", "]", "next", "[", "pattern", "[", "0", "]", "]", "[", "0"...
the helper function for KMP-string-searching is to construct the DFA. pattern should be an integer array. return a 2D array representing the DFA for moving the pattern.
[ "the", "helper", "function", "for", "KMP", "-", "string", "-", "searching", "is", "to", "construct", "the", "DFA", ".", "pattern", "should", "be", "an", "integer", "array", ".", "return", "a", "2D", "array", "representing", "the", "DFA", "for", "moving", ...
train
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/BinarySequence.py#L197-L207
tariqdaouda/pyGeno
pyGeno/tools/BinarySequence.py
BinarySequence._kmp_search_first
def _kmp_search_first(self, pInput_sequence, pPattern): """use KMP algorithm to search the first occurrence in the input_sequence of the pattern. both arguments are integer arrays. return the position of the occurence if found; otherwise, -1.""" input_sequence, pattern = pInput_sequence,...
python
def _kmp_search_first(self, pInput_sequence, pPattern): """use KMP algorithm to search the first occurrence in the input_sequence of the pattern. both arguments are integer arrays. return the position of the occurence if found; otherwise, -1.""" input_sequence, pattern = pInput_sequence,...
[ "def", "_kmp_search_first", "(", "self", ",", "pInput_sequence", ",", "pPattern", ")", ":", "input_sequence", ",", "pattern", "=", "pInput_sequence", ",", "[", "len", "(", "bin", "(", "e", ")", ")", "for", "e", "in", "pPattern", "]", "n", ",", "m", "="...
use KMP algorithm to search the first occurrence in the input_sequence of the pattern. both arguments are integer arrays. return the position of the occurence if found; otherwise, -1.
[ "use", "KMP", "algorithm", "to", "search", "the", "first", "occurrence", "in", "the", "input_sequence", "of", "the", "pattern", ".", "both", "arguments", "are", "integer", "arrays", ".", "return", "the", "position", "of", "the", "occurence", "if", "found", "...
train
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/BinarySequence.py#L209-L219
tariqdaouda/pyGeno
pyGeno/tools/BinarySequence.py
BinarySequence._kmp_search_all
def _kmp_search_all(self, pInput_sequence, pPattern): """use KMP algorithm to search all occurrence in the input_sequence of the pattern. both arguments are integer arrays. return a list of the positions of the occurences if found; otherwise, [].""" r = [] input_sequence,...
python
def _kmp_search_all(self, pInput_sequence, pPattern): """use KMP algorithm to search all occurrence in the input_sequence of the pattern. both arguments are integer arrays. return a list of the positions of the occurences if found; otherwise, [].""" r = [] input_sequence,...
[ "def", "_kmp_search_all", "(", "self", ",", "pInput_sequence", ",", "pPattern", ")", ":", "r", "=", "[", "]", "input_sequence", ",", "pattern", "=", "[", "len", "(", "bin", "(", "e", ")", ")", "for", "e", "in", "pInput_sequence", "]", ",", "[", "len"...
use KMP algorithm to search all occurrence in the input_sequence of the pattern. both arguments are integer arrays. return a list of the positions of the occurences if found; otherwise, [].
[ "use", "KMP", "algorithm", "to", "search", "all", "occurrence", "in", "the", "input_sequence", "of", "the", "pattern", ".", "both", "arguments", "are", "integer", "arrays", ".", "return", "a", "list", "of", "the", "positions", "of", "the", "occurences", "if"...
train
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/BinarySequence.py#L221-L234
tariqdaouda/pyGeno
pyGeno/tools/BinarySequence.py
BinarySequence._kmp_find
def _kmp_find(self, needle, haystack, lst = None): """find with KMP-searching. needle is an integer array, reprensenting a pattern. haystack is an integer array, reprensenting the input sequence. if lst is None, return the first position found or -1 if no match found. If it's a list, will return a list of all positio...
python
def _kmp_find(self, needle, haystack, lst = None): """find with KMP-searching. needle is an integer array, reprensenting a pattern. haystack is an integer array, reprensenting the input sequence. if lst is None, return the first position found or -1 if no match found. If it's a list, will return a list of all positio...
[ "def", "_kmp_find", "(", "self", ",", "needle", ",", "haystack", ",", "lst", "=", "None", ")", ":", "if", "lst", "!=", "None", ":", "return", "self", ".", "_kmp_search_all", "(", "haystack", ",", "needle", ")", "else", ":", "return", "self", ".", "_k...
find with KMP-searching. needle is an integer array, reprensenting a pattern. haystack is an integer array, reprensenting the input sequence. if lst is None, return the first position found or -1 if no match found. If it's a list, will return a list of all positions in lst. returns -1 or [] if no match found.
[ "find", "with", "KMP", "-", "searching", ".", "needle", "is", "an", "integer", "array", "reprensenting", "a", "pattern", ".", "haystack", "is", "an", "integer", "array", "reprensenting", "the", "input", "sequence", ".", "if", "lst", "is", "None", "return", ...
train
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/BinarySequence.py#L236-L239
tariqdaouda/pyGeno
pyGeno/tools/BinarySequence.py
BinarySequence.findByBiSearch
def findByBiSearch(self, strSeq) : """returns the first occurence of strSeq in self. Takes polymorphisms into account""" arr = self.encode(strSeq) return self._dichFind(arr[0], self, 0, lst = None)
python
def findByBiSearch(self, strSeq) : """returns the first occurence of strSeq in self. Takes polymorphisms into account""" arr = self.encode(strSeq) return self._dichFind(arr[0], self, 0, lst = None)
[ "def", "findByBiSearch", "(", "self", ",", "strSeq", ")", ":", "arr", "=", "self", ".", "encode", "(", "strSeq", ")", "return", "self", ".", "_dichFind", "(", "arr", "[", "0", "]", ",", "self", ",", "0", ",", "lst", "=", "None", ")" ]
returns the first occurence of strSeq in self. Takes polymorphisms into account
[ "returns", "the", "first", "occurence", "of", "strSeq", "in", "self", ".", "Takes", "polymorphisms", "into", "account" ]
train
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/BinarySequence.py#L241-L244
tariqdaouda/pyGeno
pyGeno/tools/BinarySequence.py
BinarySequence.findAllByBiSearch
def findAllByBiSearch(self, strSeq) : """Same as find but returns a list of all occurences""" arr = self.encode(strSeq) lst = [] self._dichFind(arr[0], self, 0, lst) return lst
python
def findAllByBiSearch(self, strSeq) : """Same as find but returns a list of all occurences""" arr = self.encode(strSeq) lst = [] self._dichFind(arr[0], self, 0, lst) return lst
[ "def", "findAllByBiSearch", "(", "self", ",", "strSeq", ")", ":", "arr", "=", "self", ".", "encode", "(", "strSeq", ")", "lst", "=", "[", "]", "self", ".", "_dichFind", "(", "arr", "[", "0", "]", ",", "self", ",", "0", ",", "lst", ")", "return", ...
Same as find but returns a list of all occurences
[ "Same", "as", "find", "but", "returns", "a", "list", "of", "all", "occurences" ]
train
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/BinarySequence.py#L246-L251
tariqdaouda/pyGeno
pyGeno/tools/BinarySequence.py
BinarySequence.find
def find(self, strSeq) : """returns the first occurence of strSeq in self. Takes polymorphisms into account""" arr = self.encode(strSeq) return self._kmp_find(arr[0], self)
python
def find(self, strSeq) : """returns the first occurence of strSeq in self. Takes polymorphisms into account""" arr = self.encode(strSeq) return self._kmp_find(arr[0], self)
[ "def", "find", "(", "self", ",", "strSeq", ")", ":", "arr", "=", "self", ".", "encode", "(", "strSeq", ")", "return", "self", ".", "_kmp_find", "(", "arr", "[", "0", "]", ",", "self", ")" ]
returns the first occurence of strSeq in self. Takes polymorphisms into account
[ "returns", "the", "first", "occurence", "of", "strSeq", "in", "self", ".", "Takes", "polymorphisms", "into", "account" ]
train
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/BinarySequence.py#L253-L256
tariqdaouda/pyGeno
pyGeno/tools/BinarySequence.py
BinarySequence.findAll
def findAll(self, strSeq) : """Same as find but returns a list of all occurences""" arr = self.encode(strSeq) lst = [] lst = self._kmp_find(arr[0], self, lst) return lst
python
def findAll(self, strSeq) : """Same as find but returns a list of all occurences""" arr = self.encode(strSeq) lst = [] lst = self._kmp_find(arr[0], self, lst) return lst
[ "def", "findAll", "(", "self", ",", "strSeq", ")", ":", "arr", "=", "self", ".", "encode", "(", "strSeq", ")", "lst", "=", "[", "]", "lst", "=", "self", ".", "_kmp_find", "(", "arr", "[", "0", "]", ",", "self", ",", "lst", ")", "return", "lst" ...
Same as find but returns a list of all occurences
[ "Same", "as", "find", "but", "returns", "a", "list", "of", "all", "occurences" ]
train
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/BinarySequence.py#L258-L263
tariqdaouda/pyGeno
pyGeno/tools/BinarySequence.py
BinarySequence.decode
def decode(self, binSequence): """decodes a binary sequence to return a string""" try: binSeq = iter(binSequence[0]) except TypeError, te: binSeq = binSequence ret = '' for b in binSeq : ch = '' for c in self.charToBin : if b & self.forma[self.charToBin[c]] > 0 : ch += c +'/' if c...
python
def decode(self, binSequence): """decodes a binary sequence to return a string""" try: binSeq = iter(binSequence[0]) except TypeError, te: binSeq = binSequence ret = '' for b in binSeq : ch = '' for c in self.charToBin : if b & self.forma[self.charToBin[c]] > 0 : ch += c +'/' if c...
[ "def", "decode", "(", "self", ",", "binSequence", ")", ":", "try", ":", "binSeq", "=", "iter", "(", "binSequence", "[", "0", "]", ")", "except", "TypeError", ",", "te", ":", "binSeq", "=", "binSequence", "ret", "=", "''", "for", "b", "in", "binSeq", ...
decodes a binary sequence to return a string
[ "decodes", "a", "binary", "sequence", "to", "return", "a", "string" ]
train
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/BinarySequence.py#L298-L315
tariqdaouda/pyGeno
pyGeno/tools/parsers/VCFTools.py
VCFFile.parse
def parse(self, filename, gziped = False, stream = False) : """opens a file""" self.stream = stream if gziped : self.f = gzip.open(filename) else : self.f = open(filename) self.filename = filename self.gziped = gziped lineId = 0 inLegend = True while inLegend : ll = self.f.readline()...
python
def parse(self, filename, gziped = False, stream = False) : """opens a file""" self.stream = stream if gziped : self.f = gzip.open(filename) else : self.f = open(filename) self.filename = filename self.gziped = gziped lineId = 0 inLegend = True while inLegend : ll = self.f.readline()...
[ "def", "parse", "(", "self", ",", "filename", ",", "gziped", "=", "False", ",", "stream", "=", "False", ")", ":", "self", ".", "stream", "=", "stream", "if", "gziped", ":", "self", ".", "f", "=", "gzip", ".", "open", "(", "filename", ")", "else", ...
opens a file
[ "opens", "a", "file" ]
train
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/VCFTools.py#L91-L142
appknox/pyaxmlparser
pyaxmlparser/stringblock.py
StringBlock._decode8
def _decode8(self, offset): """ Decode an UTF-8 String at the given offset :param offset: offset of the string inside the data :return: str """ # UTF-8 Strings contain two lengths, as they might differ: # 1) the UTF-16 length str_len, skip = self._decode_...
python
def _decode8(self, offset): """ Decode an UTF-8 String at the given offset :param offset: offset of the string inside the data :return: str """ # UTF-8 Strings contain two lengths, as they might differ: # 1) the UTF-16 length str_len, skip = self._decode_...
[ "def", "_decode8", "(", "self", ",", "offset", ")", ":", "# UTF-8 Strings contain two lengths, as they might differ:", "# 1) the UTF-16 length", "str_len", ",", "skip", "=", "self", ".", "_decode_length", "(", "offset", ",", "1", ")", "offset", "+=", "skip", "# 2) t...
Decode an UTF-8 String at the given offset :param offset: offset of the string inside the data :return: str
[ "Decode", "an", "UTF", "-", "8", "String", "at", "the", "given", "offset" ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/stringblock.py#L150-L171
appknox/pyaxmlparser
pyaxmlparser/stringblock.py
StringBlock._decode16
def _decode16(self, offset): """ Decode an UTF-16 String at the given offset :param offset: offset of the string inside the data :return: str """ str_len, skip = self._decode_length(offset, 2) offset += skip # The len is the string len in utf-16 units ...
python
def _decode16(self, offset): """ Decode an UTF-16 String at the given offset :param offset: offset of the string inside the data :return: str """ str_len, skip = self._decode_length(offset, 2) offset += skip # The len is the string len in utf-16 units ...
[ "def", "_decode16", "(", "self", ",", "offset", ")", ":", "str_len", ",", "skip", "=", "self", ".", "_decode_length", "(", "offset", ",", "2", ")", "offset", "+=", "skip", "# The len is the string len in utf-16 units", "encoded_bytes", "=", "str_len", "*", "2"...
Decode an UTF-16 String at the given offset :param offset: offset of the string inside the data :return: str
[ "Decode", "an", "UTF", "-", "16", "String", "at", "the", "given", "offset" ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/stringblock.py#L173-L191
appknox/pyaxmlparser
pyaxmlparser/stringblock.py
StringBlock._decode_length
def _decode_length(self, offset, sizeof_char): """ Generic Length Decoding at offset of string The method works for both 8 and 16 bit Strings. Length checks are enforced: * 8 bit strings: maximum of 0x7FFF bytes (See http://androidxref.com/9.0.0_r3/xref/frameworks/base/l...
python
def _decode_length(self, offset, sizeof_char): """ Generic Length Decoding at offset of string The method works for both 8 and 16 bit Strings. Length checks are enforced: * 8 bit strings: maximum of 0x7FFF bytes (See http://androidxref.com/9.0.0_r3/xref/frameworks/base/l...
[ "def", "_decode_length", "(", "self", ",", "offset", ",", "sizeof_char", ")", ":", "sizeof_2chars", "=", "sizeof_char", "<<", "1", "fmt", "=", "\"<2{}\"", ".", "format", "(", "'B'", "if", "sizeof_char", "==", "1", "else", "'H'", ")", "highbit", "=", "0x8...
Generic Length Decoding at offset of string The method works for both 8 and 16 bit Strings. Length checks are enforced: * 8 bit strings: maximum of 0x7FFF bytes (See http://androidxref.com/9.0.0_r3/xref/frameworks/base/libs/androidfw/ResourceTypes.cpp#692) * 16 bit strings: maxi...
[ "Generic", "Length", "Decoding", "at", "offset", "of", "string" ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/stringblock.py#L211-L245
appknox/pyaxmlparser
pyaxmlparser/axmlprinter.py
AXMLPrinter._fix_name
def _fix_name(self, name): """ Apply some fixes to element named and attribute names. Try to get conform to: > Like element names, attribute names are case-sensitive and must start with a letter or underscore. > The rest of the name can contain letters, digits, hyphens, underscor...
python
def _fix_name(self, name): """ Apply some fixes to element named and attribute names. Try to get conform to: > Like element names, attribute names are case-sensitive and must start with a letter or underscore. > The rest of the name can contain letters, digits, hyphens, underscor...
[ "def", "_fix_name", "(", "self", ",", "name", ")", ":", "if", "not", "name", "[", "0", "]", ".", "isalpha", "(", ")", "and", "name", "[", "0", "]", "!=", "\"_\"", ":", "log", ".", "warning", "(", "\"Invalid start for name '{}'\"", ".", "format", "(",...
Apply some fixes to element named and attribute names. Try to get conform to: > Like element names, attribute names are case-sensitive and must start with a letter or underscore. > The rest of the name can contain letters, digits, hyphens, underscores, and periods. See: https://msdn.micr...
[ "Apply", "some", "fixes", "to", "element", "named", "and", "attribute", "names", ".", "Try", "to", "get", "conform", "to", ":", ">", "Like", "element", "names", "attribute", "names", "are", "case", "-", "sensitive", "and", "must", "start", "with", "a", "...
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/axmlprinter.py#L169-L204
appknox/pyaxmlparser
pyaxmlparser/axmlprinter.py
AXMLPrinter._fix_value
def _fix_value(self, value): """ Return a cleaned version of a value according to the specification: > Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] See https://www.w3.org/TR/xml/#charsets :param value: a value to clean :r...
python
def _fix_value(self, value): """ Return a cleaned version of a value according to the specification: > Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] See https://www.w3.org/TR/xml/#charsets :param value: a value to clean :r...
[ "def", "_fix_value", "(", "self", ",", "value", ")", ":", "if", "not", "self", ".", "__charrange", "or", "not", "self", ".", "__replacement", ":", "if", "sys", ".", "maxunicode", "==", "0xFFFF", ":", "# Fix for python 2.x, surrogate pairs does not match in regex",...
Return a cleaned version of a value according to the specification: > Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] See https://www.w3.org/TR/xml/#charsets :param value: a value to clean :return: the cleaned value
[ "Return", "a", "cleaned", "version", "of", "a", "value", "according", "to", "the", "specification", ":", ">", "Char", "::", "=", "#x9", "|", "#xA", "|", "#xD", "|", "[", "#x20", "-", "#xD7FF", "]", "|", "[", "#xE000", "-", "#xFFFD", "]", "|", "[", ...
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/axmlprinter.py#L206-L244
appknox/pyaxmlparser
pyaxmlparser/core.py
APK._apk_analysis
def _apk_analysis(self): """ Run analysis on the APK file. This method is usually called by __init__ except if skip_analysis is False. It will then parse the AndroidManifest.xml and set all fields in the APK class which can be extracted from the Manifest. """ i =...
python
def _apk_analysis(self): """ Run analysis on the APK file. This method is usually called by __init__ except if skip_analysis is False. It will then parse the AndroidManifest.xml and set all fields in the APK class which can be extracted from the Manifest. """ i =...
[ "def", "_apk_analysis", "(", "self", ")", ":", "i", "=", "\"AndroidManifest.xml\"", "try", ":", "manifest_data", "=", "self", ".", "zip", ".", "read", "(", "i", ")", "except", "KeyError", ":", "log", ".", "warning", "(", "\"Missing AndroidManifest.xml. Is this...
Run analysis on the APK file. This method is usually called by __init__ except if skip_analysis is False. It will then parse the AndroidManifest.xml and set all fields in the APK class which can be extracted from the Manifest.
[ "Run", "analysis", "on", "the", "APK", "file", "." ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/core.py#L129-L193
appknox/pyaxmlparser
pyaxmlparser/core.py
APK._get_file_magic_name
def _get_file_magic_name(self, buffer): """ Return the filetype guessed for a buffer :param buffer: bytes :return: str of filetype """ default = "Unknown" ftype = None try: # Magic is optional import magic except ImportErro...
python
def _get_file_magic_name(self, buffer): """ Return the filetype guessed for a buffer :param buffer: bytes :return: str of filetype """ default = "Unknown" ftype = None try: # Magic is optional import magic except ImportErro...
[ "def", "_get_file_magic_name", "(", "self", ",", "buffer", ")", ":", "default", "=", "\"Unknown\"", "ftype", "=", "None", "try", ":", "# Magic is optional", "import", "magic", "except", "ImportError", ":", "return", "default", "try", ":", "# There are several impl...
Return the filetype guessed for a buffer :param buffer: bytes :return: str of filetype
[ "Return", "the", "filetype", "guessed", "for", "a", "buffer", ":", "param", "buffer", ":", "bytes", ":", "return", ":", "str", "of", "filetype" ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/core.py#L451-L484
appknox/pyaxmlparser
pyaxmlparser/core.py
APK.get_files_types
def get_files_types(self): """ Return the files inside the APK with their associated types (by using python-magic) :rtype: a dictionnary """ if self._files == {}: # Generate File Types / CRC List for i in self.get_files(): buffer = self.zi...
python
def get_files_types(self): """ Return the files inside the APK with their associated types (by using python-magic) :rtype: a dictionnary """ if self._files == {}: # Generate File Types / CRC List for i in self.get_files(): buffer = self.zi...
[ "def", "get_files_types", "(", "self", ")", ":", "if", "self", ".", "_files", "==", "{", "}", ":", "# Generate File Types / CRC List", "for", "i", "in", "self", ".", "get_files", "(", ")", ":", "buffer", "=", "self", ".", "zip", ".", "read", "(", "i", ...
Return the files inside the APK with their associated types (by using python-magic) :rtype: a dictionnary
[ "Return", "the", "files", "inside", "the", "APK", "with", "their", "associated", "types", "(", "by", "using", "python", "-", "magic", ")" ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/core.py#L495-L511
appknox/pyaxmlparser
pyaxmlparser/core.py
APK._patch_magic
def _patch_magic(self, buffer, orig): """ Overwrite some probably wrong detections by mime libraries :param buffer: bytes of the file to detect :param orig: guess by mime libary :return: corrected guess """ if ("Zip" in orig) or ('(JAR)' in orig): val...
python
def _patch_magic(self, buffer, orig): """ Overwrite some probably wrong detections by mime libraries :param buffer: bytes of the file to detect :param orig: guess by mime libary :return: corrected guess """ if ("Zip" in orig) or ('(JAR)' in orig): val...
[ "def", "_patch_magic", "(", "self", ",", "buffer", ",", "orig", ")", ":", "if", "(", "\"Zip\"", "in", "orig", ")", "or", "(", "'(JAR)'", "in", "orig", ")", ":", "val", "=", "is_android_raw", "(", "buffer", ")", "if", "val", "==", "\"APK\"", ":", "r...
Overwrite some probably wrong detections by mime libraries :param buffer: bytes of the file to detect :param orig: guess by mime libary :return: corrected guess
[ "Overwrite", "some", "probably", "wrong", "detections", "by", "mime", "libraries" ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/core.py#L513-L526
appknox/pyaxmlparser
pyaxmlparser/core.py
APK.get_files_crc32
def get_files_crc32(self): """ Calculates and returns a dictionary of filenames and CRC32 :return: dict of filename: CRC32 """ if self.files_crc32 == {}: for i in self.get_files(): buffer = self.zip.read(i) self.files_crc32[i] = crc32(...
python
def get_files_crc32(self): """ Calculates and returns a dictionary of filenames and CRC32 :return: dict of filename: CRC32 """ if self.files_crc32 == {}: for i in self.get_files(): buffer = self.zip.read(i) self.files_crc32[i] = crc32(...
[ "def", "get_files_crc32", "(", "self", ")", ":", "if", "self", ".", "files_crc32", "==", "{", "}", ":", "for", "i", "in", "self", ".", "get_files", "(", ")", ":", "buffer", "=", "self", ".", "zip", ".", "read", "(", "i", ")", "self", ".", "files_...
Calculates and returns a dictionary of filenames and CRC32 :return: dict of filename: CRC32
[ "Calculates", "and", "returns", "a", "dictionary", "of", "filenames", "and", "CRC32" ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/core.py#L528-L539
appknox/pyaxmlparser
pyaxmlparser/core.py
APK.is_multidex
def is_multidex(self): """ Test if the APK has multiple DEX files :return: True if multiple dex found, otherwise False """ dexre = re.compile("^classes(\d+)?.dex$") return len([instance for instance in self.get_files() if dexre.search(instance)]) > 1
python
def is_multidex(self): """ Test if the APK has multiple DEX files :return: True if multiple dex found, otherwise False """ dexre = re.compile("^classes(\d+)?.dex$") return len([instance for instance in self.get_files() if dexre.search(instance)]) > 1
[ "def", "is_multidex", "(", "self", ")", ":", "dexre", "=", "re", ".", "compile", "(", "\"^classes(\\d+)?.dex$\"", ")", "return", "len", "(", "[", "instance", "for", "instance", "in", "self", ".", "get_files", "(", ")", "if", "dexre", ".", "search", "(", ...
Test if the APK has multiple DEX files :return: True if multiple dex found, otherwise False
[ "Test", "if", "the", "APK", "has", "multiple", "DEX", "files" ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/core.py#L604-L611
appknox/pyaxmlparser
pyaxmlparser/core.py
APK.get_elements
def get_elements(self, tag_name, attribute, with_namespace=True): """ Deprecated: use `get_all_attribute_value()` instead Return elements in xml files which match with the tag name and the specific attribute :param tag_name: a string which specify the tag name :param attribute: a...
python
def get_elements(self, tag_name, attribute, with_namespace=True): """ Deprecated: use `get_all_attribute_value()` instead Return elements in xml files which match with the tag name and the specific attribute :param tag_name: a string which specify the tag name :param attribute: a...
[ "def", "get_elements", "(", "self", ",", "tag_name", ",", "attribute", ",", "with_namespace", "=", "True", ")", ":", "for", "i", "in", "self", ".", "xml", ":", "if", "self", ".", "xml", "[", "i", "]", "is", "None", ":", "continue", "for", "item", "...
Deprecated: use `get_all_attribute_value()` instead Return elements in xml files which match with the tag name and the specific attribute :param tag_name: a string which specify the tag name :param attribute: a string which specify the attribute
[ "Deprecated", ":", "use", "get_all_attribute_value", "()", "instead", "Return", "elements", "in", "xml", "files", "which", "match", "with", "the", "tag", "name", "and", "the", "specific", "attribute", ":", "param", "tag_name", ":", "a", "string", "which", "spe...
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/core.py#L614-L631
appknox/pyaxmlparser
pyaxmlparser/core.py
APK._format_value
def _format_value(self, value): """ Format a value with packagename, if not already set :param value: :return: """ if len(value) > 0: if value[0] == ".": value = self.package + value else: v_dot = value.find(".") ...
python
def _format_value(self, value): """ Format a value with packagename, if not already set :param value: :return: """ if len(value) > 0: if value[0] == ".": value = self.package + value else: v_dot = value.find(".") ...
[ "def", "_format_value", "(", "self", ",", "value", ")", ":", "if", "len", "(", "value", ")", ">", "0", ":", "if", "value", "[", "0", "]", "==", "\".\"", ":", "value", "=", "self", ".", "package", "+", "value", "else", ":", "v_dot", "=", "value", ...
Format a value with packagename, if not already set :param value: :return:
[ "Format", "a", "value", "with", "packagename", "if", "not", "already", "set" ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/core.py#L633-L649
appknox/pyaxmlparser
pyaxmlparser/core.py
APK.get_element
def get_element(self, tag_name, attribute, **attribute_filter): """ :Deprecated: use `get_attribute_value()` instead Return element in xml files which match with the tag name and the specific attribute :param tag_name: specify the tag name :type tag_name: string :param at...
python
def get_element(self, tag_name, attribute, **attribute_filter): """ :Deprecated: use `get_attribute_value()` instead Return element in xml files which match with the tag name and the specific attribute :param tag_name: specify the tag name :type tag_name: string :param at...
[ "def", "get_element", "(", "self", ",", "tag_name", ",", "attribute", ",", "*", "*", "attribute_filter", ")", ":", "for", "i", "in", "self", ".", "xml", ":", "if", "self", ".", "xml", "[", "i", "]", "is", "None", ":", "continue", "tag", "=", "self"...
:Deprecated: use `get_attribute_value()` instead Return element in xml files which match with the tag name and the specific attribute :param tag_name: specify the tag name :type tag_name: string :param attribute: specify the attribute :type attribute: string :rtype: strin...
[ ":", "Deprecated", ":", "use", "get_attribute_value", "()", "instead", "Return", "element", "in", "xml", "files", "which", "match", "with", "the", "tag", "name", "and", "the", "specific", "attribute", ":", "param", "tag_name", ":", "specify", "the", "tag", "...
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/core.py#L652-L683
appknox/pyaxmlparser
pyaxmlparser/core.py
APK.is_tag_matched
def is_tag_matched(self, tag, **attribute_filter): """ Return true if the attributes matches in attribute filter :param tag: specify the tag element :type tag: Element :param attribute: specify the attribute :type attribute: string """ if len(attribute_fil...
python
def is_tag_matched(self, tag, **attribute_filter): """ Return true if the attributes matches in attribute filter :param tag: specify the tag element :type tag: Element :param attribute: specify the attribute :type attribute: string """ if len(attribute_fil...
[ "def", "is_tag_matched", "(", "self", ",", "tag", ",", "*", "*", "attribute_filter", ")", ":", "if", "len", "(", "attribute_filter", ")", "<=", "0", ":", "return", "True", "for", "attr", ",", "value", "in", "attribute_filter", ".", "items", "(", ")", "...
Return true if the attributes matches in attribute filter :param tag: specify the tag element :type tag: Element :param attribute: specify the attribute :type attribute: string
[ "Return", "true", "if", "the", "attributes", "matches", "in", "attribute", "filter", ":", "param", "tag", ":", "specify", "the", "tag", "element", ":", "type", "tag", ":", "Element", ":", "param", "attribute", ":", "specify", "the", "attribute", ":", "type...
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/core.py#L780-L798
appknox/pyaxmlparser
pyaxmlparser/axmlparser.py
AXMLParser.name
def name(self): """ Return the String assosciated with the tag name """ if self.m_name == -1 or (self.m_event != const.START_TAG and self.m_event != const.END_TAG): return u'' return self.sb[self.m_name]
python
def name(self): """ Return the String assosciated with the tag name """ if self.m_name == -1 or (self.m_event != const.START_TAG and self.m_event != const.END_TAG): return u'' return self.sb[self.m_name]
[ "def", "name", "(", "self", ")", ":", "if", "self", ".", "m_name", "==", "-", "1", "or", "(", "self", ".", "m_event", "!=", "const", ".", "START_TAG", "and", "self", ".", "m_event", "!=", "const", ".", "END_TAG", ")", ":", "return", "u''", "return"...
Return the String assosciated with the tag name
[ "Return", "the", "String", "assosciated", "with", "the", "tag", "name" ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/axmlparser.py#L385-L392
appknox/pyaxmlparser
pyaxmlparser/axmlparser.py
AXMLParser.namespace
def namespace(self): """ Return the Namespace URI (if any) as a String for the current tag """ if self.m_name == -1 or (self.m_event != const.START_TAG and self.m_event != const.END_TAG): return u'' # No Namespace if self.m_namespaceUri == 0xFFFFFFFF: ...
python
def namespace(self): """ Return the Namespace URI (if any) as a String for the current tag """ if self.m_name == -1 or (self.m_event != const.START_TAG and self.m_event != const.END_TAG): return u'' # No Namespace if self.m_namespaceUri == 0xFFFFFFFF: ...
[ "def", "namespace", "(", "self", ")", ":", "if", "self", ".", "m_name", "==", "-", "1", "or", "(", "self", ".", "m_event", "!=", "const", ".", "START_TAG", "and", "self", ".", "m_event", "!=", "const", ".", "END_TAG", ")", ":", "return", "u''", "# ...
Return the Namespace URI (if any) as a String for the current tag
[ "Return", "the", "Namespace", "URI", "(", "if", "any", ")", "as", "a", "String", "for", "the", "current", "tag" ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/axmlparser.py#L408-L419
appknox/pyaxmlparser
pyaxmlparser/axmlparser.py
AXMLParser.text
def text(self): """ Return the String assosicated with the current text """ if self.m_name == -1 or self.m_event != const.TEXT: return u'' return self.sb[self.m_name]
python
def text(self): """ Return the String assosicated with the current text """ if self.m_name == -1 or self.m_event != const.TEXT: return u'' return self.sb[self.m_name]
[ "def", "text", "(", "self", ")", ":", "if", "self", ".", "m_name", "==", "-", "1", "or", "self", ".", "m_event", "!=", "const", ".", "TEXT", ":", "return", "u''", "return", "self", ".", "sb", "[", "self", ".", "m_name", "]" ]
Return the String assosicated with the current text
[ "Return", "the", "String", "assosicated", "with", "the", "current", "text" ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/axmlparser.py#L448-L455
appknox/pyaxmlparser
pyaxmlparser/axmlparser.py
AXMLParser.getAttributeNamespace
def getAttributeNamespace(self, index): """ Return the Namespace URI (if any) for the attribute """ uri = self.getAttributeUri(index) # No Namespace if uri == 0xFFFFFFFF: return u'' return self.sb[uri]
python
def getAttributeNamespace(self, index): """ Return the Namespace URI (if any) for the attribute """ uri = self.getAttributeUri(index) # No Namespace if uri == 0xFFFFFFFF: return u'' return self.sb[uri]
[ "def", "getAttributeNamespace", "(", "self", ",", "index", ")", ":", "uri", "=", "self", ".", "getAttributeUri", "(", "index", ")", "# No Namespace", "if", "uri", "==", "0xFFFFFFFF", ":", "return", "u''", "return", "self", ".", "sb", "[", "uri", "]" ]
Return the Namespace URI (if any) for the attribute
[ "Return", "the", "Namespace", "URI", "(", "if", "any", ")", "for", "the", "attribute" ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/axmlparser.py#L510-L520
appknox/pyaxmlparser
pyaxmlparser/axmlparser.py
AXMLParser.getAttributeName
def getAttributeName(self, index): """ Returns the String which represents the attribute name """ offset = self._get_attribute_offset(index) name = self.m_attributes[offset + const.ATTRIBUTE_IX_NAME] res = self.sb[name] # If the result is a (null) string, we need...
python
def getAttributeName(self, index): """ Returns the String which represents the attribute name """ offset = self._get_attribute_offset(index) name = self.m_attributes[offset + const.ATTRIBUTE_IX_NAME] res = self.sb[name] # If the result is a (null) string, we need...
[ "def", "getAttributeName", "(", "self", ",", "index", ")", ":", "offset", "=", "self", ".", "_get_attribute_offset", "(", "index", ")", "name", "=", "self", ".", "m_attributes", "[", "offset", "+", "const", ".", "ATTRIBUTE_IX_NAME", "]", "res", "=", "self"...
Returns the String which represents the attribute name
[ "Returns", "the", "String", "which", "represents", "the", "attribute", "name" ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/axmlparser.py#L522-L540
appknox/pyaxmlparser
pyaxmlparser/axmlparser.py
AXMLParser.getAttributeValueType
def getAttributeValueType(self, index): """ Return the type of the attribute at the given index :param index: index of the attribute """ offset = self._get_attribute_offset(index) return self.m_attributes[offset + const.ATTRIBUTE_IX_VALUE_TYPE]
python
def getAttributeValueType(self, index): """ Return the type of the attribute at the given index :param index: index of the attribute """ offset = self._get_attribute_offset(index) return self.m_attributes[offset + const.ATTRIBUTE_IX_VALUE_TYPE]
[ "def", "getAttributeValueType", "(", "self", ",", "index", ")", ":", "offset", "=", "self", ".", "_get_attribute_offset", "(", "index", ")", "return", "self", ".", "m_attributes", "[", "offset", "+", "const", ".", "ATTRIBUTE_IX_VALUE_TYPE", "]" ]
Return the type of the attribute at the given index :param index: index of the attribute
[ "Return", "the", "type", "of", "the", "attribute", "at", "the", "given", "index" ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/axmlparser.py#L542-L549
appknox/pyaxmlparser
pyaxmlparser/axmlparser.py
AXMLParser.getAttributeValueData
def getAttributeValueData(self, index): """ Return the data of the attribute at the given index :param index: index of the attribute """ offset = self._get_attribute_offset(index) return self.m_attributes[offset + const.ATTRIBUTE_IX_VALUE_DATA]
python
def getAttributeValueData(self, index): """ Return the data of the attribute at the given index :param index: index of the attribute """ offset = self._get_attribute_offset(index) return self.m_attributes[offset + const.ATTRIBUTE_IX_VALUE_DATA]
[ "def", "getAttributeValueData", "(", "self", ",", "index", ")", ":", "offset", "=", "self", ".", "_get_attribute_offset", "(", "index", ")", "return", "self", ".", "m_attributes", "[", "offset", "+", "const", ".", "ATTRIBUTE_IX_VALUE_DATA", "]" ]
Return the data of the attribute at the given index :param index: index of the attribute
[ "Return", "the", "data", "of", "the", "attribute", "at", "the", "given", "index" ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/axmlparser.py#L551-L558
appknox/pyaxmlparser
pyaxmlparser/arscutil.py
ARSCResTableConfig.get_qualifier
def get_qualifier(self): """ Return resource name qualifier for the current configuration. for example * `ldpi-v4` * `hdpi-v4` All possible qualifiers are listed in table 2 of https://developer.android.com/guide /topics/resources/providing-resources FIXM...
python
def get_qualifier(self): """ Return resource name qualifier for the current configuration. for example * `ldpi-v4` * `hdpi-v4` All possible qualifiers are listed in table 2 of https://developer.android.com/guide /topics/resources/providing-resources FIXM...
[ "def", "get_qualifier", "(", "self", ")", ":", "res", "=", "[", "]", "mcc", "=", "self", ".", "imsi", "&", "0xFFFF", "mnc", "=", "(", "self", ".", "imsi", "&", "0xFFFF0000", ")", ">>", "16", "if", "mcc", "!=", "0", ":", "res", ".", "append", "(...
Return resource name qualifier for the current configuration. for example * `ldpi-v4` * `hdpi-v4` All possible qualifiers are listed in table 2 of https://developer.android.com/guide /topics/resources/providing-resources FIXME: This name might not have all properties se...
[ "Return", "resource", "name", "qualifier", "for", "the", "current", "configuration", ".", "for", "example", "*", "ldpi", "-", "v4", "*", "hdpi", "-", "v4" ]
train
https://github.com/appknox/pyaxmlparser/blob/8ffe43e81a534f42c3620f3c1e3c6c0181a066bd/pyaxmlparser/arscutil.py#L351-L463
Kyria/EsiPy
esipy/utils.py
make_cache_key
def make_cache_key(request): """ Generate a cache key from request object data """ headers = frozenset(request._p['header'].items()) path = frozenset(request._p['path'].items()) query = frozenset(request._p['query']) return (request.url, headers, path, query)
python
def make_cache_key(request): """ Generate a cache key from request object data """ headers = frozenset(request._p['header'].items()) path = frozenset(request._p['path'].items()) query = frozenset(request._p['query']) return (request.url, headers, path, query)
[ "def", "make_cache_key", "(", "request", ")", ":", "headers", "=", "frozenset", "(", "request", ".", "_p", "[", "'header'", "]", ".", "items", "(", ")", ")", "path", "=", "frozenset", "(", "request", ".", "_p", "[", "'path'", "]", ".", "items", "(", ...
Generate a cache key from request object data
[ "Generate", "a", "cache", "key", "from", "request", "object", "data" ]
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/utils.py#L15-L20
Kyria/EsiPy
esipy/utils.py
check_cache
def check_cache(cache): """ check if a cache fits esipy needs or not """ if isinstance(cache, BaseCache): return cache elif cache is False: return DictCache() elif cache is None: return DummyCache() else: raise ValueError('Provided cache must implement BaseCache')
python
def check_cache(cache): """ check if a cache fits esipy needs or not """ if isinstance(cache, BaseCache): return cache elif cache is False: return DictCache() elif cache is None: return DummyCache() else: raise ValueError('Provided cache must implement BaseCache')
[ "def", "check_cache", "(", "cache", ")", ":", "if", "isinstance", "(", "cache", ",", "BaseCache", ")", ":", "return", "cache", "elif", "cache", "is", "False", ":", "return", "DictCache", "(", ")", "elif", "cache", "is", "None", ":", "return", "DummyCache...
check if a cache fits esipy needs or not
[ "check", "if", "a", "cache", "fits", "esipy", "needs", "or", "not" ]
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/utils.py#L23-L32
Kyria/EsiPy
esipy/utils.py
get_cache_time_left
def get_cache_time_left(expires_header): """ return the time left in second for an expires header """ epoch = datetime(1970, 1, 1) # this date is ALWAYS in UTC (RFC 7231) expire = ( datetime( *parsedate(expires_header)[:6] ) - epoch ).total_seconds() now = (datetime.u...
python
def get_cache_time_left(expires_header): """ return the time left in second for an expires header """ epoch = datetime(1970, 1, 1) # this date is ALWAYS in UTC (RFC 7231) expire = ( datetime( *parsedate(expires_header)[:6] ) - epoch ).total_seconds() now = (datetime.u...
[ "def", "get_cache_time_left", "(", "expires_header", ")", ":", "epoch", "=", "datetime", "(", "1970", ",", "1", ",", "1", ")", "# this date is ALWAYS in UTC (RFC 7231)", "expire", "=", "(", "datetime", "(", "*", "parsedate", "(", "expires_header", ")", "[", ":...
return the time left in second for an expires header
[ "return", "the", "time", "left", "in", "second", "for", "an", "expires", "header" ]
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/utils.py#L35-L45
Kyria/EsiPy
esipy/utils.py
generate_code_verifier
def generate_code_verifier(n_bytes=64): """ source: https://github.com/openstack/deb-python-oauth2client Generates a 'code_verifier' as described in section 4.1 of RFC 7636. This is a 'high-entropy cryptographic random string' that will be impractical for an attacker to guess. Args: n_by...
python
def generate_code_verifier(n_bytes=64): """ source: https://github.com/openstack/deb-python-oauth2client Generates a 'code_verifier' as described in section 4.1 of RFC 7636. This is a 'high-entropy cryptographic random string' that will be impractical for an attacker to guess. Args: n_by...
[ "def", "generate_code_verifier", "(", "n_bytes", "=", "64", ")", ":", "verifier", "=", "base64", ".", "urlsafe_b64encode", "(", "os", ".", "urandom", "(", "n_bytes", ")", ")", ".", "rstrip", "(", "b'='", ")", ".", "decode", "(", "'utf-8'", ")", "# https:...
source: https://github.com/openstack/deb-python-oauth2client Generates a 'code_verifier' as described in section 4.1 of RFC 7636. This is a 'high-entropy cryptographic random string' that will be impractical for an attacker to guess. Args: n_bytes: integer between 31 and 96, inclusive. default: ...
[ "source", ":", "https", ":", "//", "github", ".", "com", "/", "openstack", "/", "deb", "-", "python", "-", "oauth2client", "Generates", "a", "code_verifier", "as", "described", "in", "section", "4", ".", "1", "of", "RFC", "7636", ".", "This", "is", "a"...
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/utils.py#L48-L71
Kyria/EsiPy
esipy/utils.py
generate_code_challenge
def generate_code_challenge(verifier): """ source: https://github.com/openstack/deb-python-oauth2client Creates a 'code_challenge' as described in section 4.2 of RFC 7636 by taking the sha256 hash of the verifier and then urlsafe base64-encoding it. Args: verifier: bytestring, representi...
python
def generate_code_challenge(verifier): """ source: https://github.com/openstack/deb-python-oauth2client Creates a 'code_challenge' as described in section 4.2 of RFC 7636 by taking the sha256 hash of the verifier and then urlsafe base64-encoding it. Args: verifier: bytestring, representi...
[ "def", "generate_code_challenge", "(", "verifier", ")", ":", "digest", "=", "hashlib", ".", "sha256", "(", "verifier", ".", "encode", "(", "'utf-8'", ")", ")", ".", "digest", "(", ")", "return", "base64", ".", "urlsafe_b64encode", "(", "digest", ")", ".", ...
source: https://github.com/openstack/deb-python-oauth2client Creates a 'code_challenge' as described in section 4.2 of RFC 7636 by taking the sha256 hash of the verifier and then urlsafe base64-encoding it. Args: verifier: bytestring, representing a code_verifier as generated by gene...
[ "source", ":", "https", ":", "//", "github", ".", "com", "/", "openstack", "/", "deb", "-", "python", "-", "oauth2client", "Creates", "a", "code_challenge", "as", "described", "in", "section", "4", ".", "2", "of", "RFC", "7636", "by", "taking", "the", ...
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/utils.py#L74-L88
Kyria/EsiPy
esipy/events.py
Signal.add_receiver
def add_receiver(self, receiver): """ Add a receiver to the list of receivers. :param receiver: a callable variable """ if not callable(receiver): raise TypeError("receiver must be callable") self.event_receivers.append(receiver)
python
def add_receiver(self, receiver): """ Add a receiver to the list of receivers. :param receiver: a callable variable """ if not callable(receiver): raise TypeError("receiver must be callable") self.event_receivers.append(receiver)
[ "def", "add_receiver", "(", "self", ",", "receiver", ")", ":", "if", "not", "callable", "(", "receiver", ")", ":", "raise", "TypeError", "(", "\"receiver must be callable\"", ")", "self", ".", "event_receivers", ".", "append", "(", "receiver", ")" ]
Add a receiver to the list of receivers. :param receiver: a callable variable
[ "Add", "a", "receiver", "to", "the", "list", "of", "receivers", ".", ":", "param", "receiver", ":", "a", "callable", "variable" ]
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/events.py#L19-L26
Kyria/EsiPy
esipy/events.py
Signal.remove_receiver
def remove_receiver(self, receiver): """ Remove a receiver to the list of receivers. :param receiver: a callable variable """ if receiver in self.event_receivers: self.event_receivers.remove(receiver)
python
def remove_receiver(self, receiver): """ Remove a receiver to the list of receivers. :param receiver: a callable variable """ if receiver in self.event_receivers: self.event_receivers.remove(receiver)
[ "def", "remove_receiver", "(", "self", ",", "receiver", ")", ":", "if", "receiver", "in", "self", ".", "event_receivers", ":", "self", ".", "event_receivers", ".", "remove", "(", "receiver", ")" ]
Remove a receiver to the list of receivers. :param receiver: a callable variable
[ "Remove", "a", "receiver", "to", "the", "list", "of", "receivers", ".", ":", "param", "receiver", ":", "a", "callable", "variable" ]
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/events.py#L28-L34
Kyria/EsiPy
esipy/events.py
Signal.send_robust
def send_robust(self, **kwargs): """ Trigger all receiver and pass them the parameters If an exception is raised it will be catched and displayed as error in the logger (if defined). :param kwargs: all arguments from the event. """ for receiver in self.event_recei...
python
def send_robust(self, **kwargs): """ Trigger all receiver and pass them the parameters If an exception is raised it will be catched and displayed as error in the logger (if defined). :param kwargs: all arguments from the event. """ for receiver in self.event_recei...
[ "def", "send_robust", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "receiver", "in", "self", ".", "event_receivers", ":", "try", ":", "receiver", "(", "*", "*", "kwargs", ")", "except", "Exception", "as", "err", ":", "# pylint: disable=W0703\r", ...
Trigger all receiver and pass them the parameters If an exception is raised it will be catched and displayed as error in the logger (if defined). :param kwargs: all arguments from the event.
[ "Trigger", "all", "receiver", "and", "pass", "them", "the", "parameters", "If", "an", "exception", "is", "raised", "it", "will", "be", "catched", "and", "displayed", "as", "error", "in", "the", "logger", "(", "if", "defined", ")", ".", ":", "param", "kwa...
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/events.py#L46-L60
Kyria/EsiPy
esipy/app.py
EsiApp.__get_or_create_app
def __get_or_create_app(self, url, cache_key): """ Get the app from cache or generate a new one if required Because app object doesn't have etag/expiry, we have to make a head() call before, to have these informations first... """ headers = {"Accept": "application/json"} app_url...
python
def __get_or_create_app(self, url, cache_key): """ Get the app from cache or generate a new one if required Because app object doesn't have etag/expiry, we have to make a head() call before, to have these informations first... """ headers = {"Accept": "application/json"} app_url...
[ "def", "__get_or_create_app", "(", "self", ",", "url", ",", "cache_key", ")", ":", "headers", "=", "{", "\"Accept\"", ":", "\"application/json\"", "}", "app_url", "=", "'%s?datasource=%s'", "%", "(", "url", ",", "self", ".", "datasource", ")", "cached", "=",...
Get the app from cache or generate a new one if required Because app object doesn't have etag/expiry, we have to make a head() call before, to have these informations first...
[ "Get", "the", "app", "from", "cache", "or", "generate", "a", "new", "one", "if", "required" ]
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/app.py#L50-L110
Kyria/EsiPy
esipy/app.py
EsiApp.clear_cached_endpoints
def clear_cached_endpoints(self, prefix=None): """ Invalidate all cached endpoints, meta included Loop over all meta endpoints to generate all cache key the invalidate each of them. Doing it this way will prevent the app not finding keys as the user may change its prefixes Meta ...
python
def clear_cached_endpoints(self, prefix=None): """ Invalidate all cached endpoints, meta included Loop over all meta endpoints to generate all cache key the invalidate each of them. Doing it this way will prevent the app not finding keys as the user may change its prefixes Meta ...
[ "def", "clear_cached_endpoints", "(", "self", ",", "prefix", "=", "None", ")", ":", "prefix", "=", "prefix", "if", "prefix", "is", "not", "None", "else", "self", ".", "cache_prefix", "for", "endpoint", "in", "self", ".", "app", ".", "op", ".", "values", ...
Invalidate all cached endpoints, meta included Loop over all meta endpoints to generate all cache key the invalidate each of them. Doing it this way will prevent the app not finding keys as the user may change its prefixes Meta endpoint will be updated upon next call. :param: pr...
[ "Invalidate", "all", "cached", "endpoints", "meta", "included" ]
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/app.py#L147-L161
Kyria/EsiPy
esipy/security.py
EsiSecurity.__get_jwks_key
def __get_jwks_key(self, jwks_uri, **kwargs): """Get from jwks_ui all the JWK keys required to decode JWT Token. Parameters ---------- jwks_uri : string The URL where to gather JWKS key kwargs : Dict The constructor parameters """ ...
python
def __get_jwks_key(self, jwks_uri, **kwargs): """Get from jwks_ui all the JWK keys required to decode JWT Token. Parameters ---------- jwks_uri : string The URL where to gather JWKS key kwargs : Dict The constructor parameters """ ...
[ "def", "__get_jwks_key", "(", "self", ",", "jwks_uri", ",", "*", "*", "kwargs", ")", ":", "jwks_key", "=", "kwargs", ".", "pop", "(", "'jwks_key'", ",", "None", ")", "if", "not", "jwks_key", ":", "res", "=", "self", ".", "_session", ".", "get", "(", ...
Get from jwks_ui all the JWK keys required to decode JWT Token. Parameters ---------- jwks_uri : string The URL where to gather JWKS key kwargs : Dict The constructor parameters
[ "Get", "from", "jwks_ui", "all", "the", "JWK", "keys", "required", "to", "decode", "JWT", "Token", ".", "Parameters", "----------", "jwks_uri", ":", "string", "The", "URL", "where", "to", "gather", "JWKS", "key", "kwargs", ":", "Dict", "The", "constructor", ...
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/security.py#L123-L146
Kyria/EsiPy
esipy/security.py
EsiSecurity.__get_basic_auth_header
def __get_basic_auth_header(self): """Return the Basic Authorization header for oauth if secret_key exists Returns ------- type A dictionary that contains the Basic Authorization key/value, or {} if secret_key is None """ if self.secret...
python
def __get_basic_auth_header(self): """Return the Basic Authorization header for oauth if secret_key exists Returns ------- type A dictionary that contains the Basic Authorization key/value, or {} if secret_key is None """ if self.secret...
[ "def", "__get_basic_auth_header", "(", "self", ")", ":", "if", "self", ".", "secret_key", "is", "None", ":", "return", "{", "}", "# encode/decode for py2/py3 compatibility\r", "auth_b64", "=", "\"%s:%s\"", "%", "(", "self", ".", "client_id", ",", "self", ".", ...
Return the Basic Authorization header for oauth if secret_key exists Returns ------- type A dictionary that contains the Basic Authorization key/value, or {} if secret_key is None
[ "Return", "the", "Basic", "Authorization", "header", "for", "oauth", "if", "secret_key", "exists", "Returns", "-------", "type", "A", "dictionary", "that", "contains", "the", "Basic", "Authorization", "key", "/", "value", "or", "{}", "if", "secret_key", "is", ...
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/security.py#L148-L166
Kyria/EsiPy
esipy/security.py
EsiSecurity.__prepare_token_request
def __prepare_token_request(self, params, url=None): """Generate the request parameters to execute the POST call to get or refresh a token. Parameters ---------- params : dictionary Contains the parameters that will be given as data to the oauth e...
python
def __prepare_token_request(self, params, url=None): """Generate the request parameters to execute the POST call to get or refresh a token. Parameters ---------- params : dictionary Contains the parameters that will be given as data to the oauth e...
[ "def", "__prepare_token_request", "(", "self", ",", "params", ",", "url", "=", "None", ")", ":", "if", "self", ".", "secret_key", "is", "None", ":", "params", "[", "'code_verifier'", "]", "=", "self", ".", "code_verifier", "params", "[", "'client_id'", "]"...
Generate the request parameters to execute the POST call to get or refresh a token. Parameters ---------- params : dictionary Contains the parameters that will be given as data to the oauth endpoint Returns ------- type ...
[ "Generate", "the", "request", "parameters", "to", "execute", "the", "POST", "call", "to", "get", "or", "refresh", "a", "token", ".", "Parameters", "----------", "params", ":", "dictionary", "Contains", "the", "parameters", "that", "will", "be", "given", "as", ...
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/security.py#L168-L194
Kyria/EsiPy
esipy/security.py
EsiSecurity.get_auth_uri
def get_auth_uri(self, state, scopes=None, implicit=False): """Constructs the full auth uri and returns it.. Parameters ---------- state : string The state to pass through the auth process scopes : list (optional) The list of scope to have ...
python
def get_auth_uri(self, state, scopes=None, implicit=False): """Constructs the full auth uri and returns it.. Parameters ---------- state : string The state to pass through the auth process scopes : list (optional) The list of scope to have ...
[ "def", "get_auth_uri", "(", "self", ",", "state", ",", "scopes", "=", "None", ",", "implicit", "=", "False", ")", ":", "if", "state", "is", "None", "or", "state", "==", "''", ":", "raise", "AttributeError", "(", "'\"state\" must be non empty, non None string'"...
Constructs the full auth uri and returns it.. Parameters ---------- state : string The state to pass through the auth process scopes : list (optional) The list of scope to have implicit : Boolean (optional) Activate or not the implici...
[ "Constructs", "the", "full", "auth", "uri", "and", "returns", "it", "..", "Parameters", "----------", "state", ":", "string", "The", "state", "to", "pass", "through", "the", "auth", "process", "scopes", ":", "list", "(", "optional", ")", "The", "list", "of...
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/security.py#L196-L235
Kyria/EsiPy
esipy/security.py
EsiSecurity.get_refresh_token_params
def get_refresh_token_params(self, scope_list=None): """ Return the param object for the post() call to get the access_token from the refresh_token :param code: the refresh token :return: a dict with the url, params and header """ if self.refresh_token is None: ...
python
def get_refresh_token_params(self, scope_list=None): """ Return the param object for the post() call to get the access_token from the refresh_token :param code: the refresh token :return: a dict with the url, params and header """ if self.refresh_token is None: ...
[ "def", "get_refresh_token_params", "(", "self", ",", "scope_list", "=", "None", ")", ":", "if", "self", ".", "refresh_token", "is", "None", ":", "raise", "AttributeError", "(", "'No refresh token is defined.'", ")", "params", "=", "{", "'grant_type'", ":", "'ref...
Return the param object for the post() call to get the access_token from the refresh_token :param code: the refresh token :return: a dict with the url, params and header
[ "Return", "the", "param", "object", "for", "the", "post", "()", "call", "to", "get", "the", "access_token", "from", "the", "refresh_token", ":", "param", "code", ":", "the", "refresh", "token", ":", "return", ":", "a", "dict", "with", "the", "url", "para...
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/security.py#L251-L273
Kyria/EsiPy
esipy/security.py
EsiSecurity.update_token
def update_token(self, response_json, **kwargs): """ Update access_token, refresh_token and token_expiry from the response body. The response must be converted to a json object before being passed as a parameter :param response_json: the response body to use. :par...
python
def update_token(self, response_json, **kwargs): """ Update access_token, refresh_token and token_expiry from the response body. The response must be converted to a json object before being passed as a parameter :param response_json: the response body to use. :par...
[ "def", "update_token", "(", "self", ",", "response_json", ",", "*", "*", "kwargs", ")", ":", "self", ".", "token_identifier", "=", "kwargs", ".", "pop", "(", "'token_identifier'", ",", "self", ".", "token_identifier", ")", "self", ".", "access_token", "=", ...
Update access_token, refresh_token and token_expiry from the response body. The response must be converted to a json object before being passed as a parameter :param response_json: the response body to use. :param token_identifier: the user identifier for the token
[ "Update", "access_token", "refresh_token", "and", "token_expiry", "from", "the", "response", "body", ".", "The", "response", "must", "be", "converted", "to", "a", "json", "object", "before", "being", "passed", "as", "a", "parameter", ":", "param", "response_json...
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/security.py#L275-L292
Kyria/EsiPy
esipy/security.py
EsiSecurity.is_token_expired
def is_token_expired(self, offset=0): """ Return true if the token is expired. The offset can be used to change the expiry time: - positive value decrease the time (sooner) - negative value increase the time (later) If the expiry is not set, always return True. This case a...
python
def is_token_expired(self, offset=0): """ Return true if the token is expired. The offset can be used to change the expiry time: - positive value decrease the time (sooner) - negative value increase the time (later) If the expiry is not set, always return True. This case a...
[ "def", "is_token_expired", "(", "self", ",", "offset", "=", "0", ")", ":", "if", "self", ".", "token_expiry", "is", "None", ":", "return", "True", "return", "int", "(", "time", ".", "time", "(", ")", ")", ">=", "(", "self", ".", "token_expiry", "-", ...
Return true if the token is expired. The offset can be used to change the expiry time: - positive value decrease the time (sooner) - negative value increase the time (later) If the expiry is not set, always return True. This case allow the users to define a security object...
[ "Return", "true", "if", "the", "token", "is", "expired", ".", "The", "offset", "can", "be", "used", "to", "change", "the", "expiry", "time", ":", "-", "positive", "value", "decrease", "the", "time", "(", "sooner", ")", "-", "negative", "value", "increase...
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/security.py#L294-L309
Kyria/EsiPy
esipy/security.py
EsiSecurity.refresh
def refresh(self, scope_list=None): """ Update the auth data (tokens) using the refresh token in auth. """ request_data = self.get_refresh_token_params(scope_list) res = self._session.post(**request_data) if res.status_code != 200: raise APIException( ...
python
def refresh(self, scope_list=None): """ Update the auth data (tokens) using the refresh token in auth. """ request_data = self.get_refresh_token_params(scope_list) res = self._session.post(**request_data) if res.status_code != 200: raise APIException( ...
[ "def", "refresh", "(", "self", ",", "scope_list", "=", "None", ")", ":", "request_data", "=", "self", ".", "get_refresh_token_params", "(", "scope_list", ")", "res", "=", "self", ".", "_session", ".", "post", "(", "*", "*", "request_data", ")", "if", "re...
Update the auth data (tokens) using the refresh token in auth.
[ "Update", "the", "auth", "data", "(", "tokens", ")", "using", "the", "refresh", "token", "in", "auth", "." ]
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/security.py#L311-L326
Kyria/EsiPy
esipy/security.py
EsiSecurity.auth
def auth(self, code): """ Request the token to the /oauth/token endpoint. Update the security tokens. :param code: the code you get from the auth process """ request_data = self.get_access_token_params(code) res = self._session.post(**request_data) if r...
python
def auth(self, code): """ Request the token to the /oauth/token endpoint. Update the security tokens. :param code: the code you get from the auth process """ request_data = self.get_access_token_params(code) res = self._session.post(**request_data) if r...
[ "def", "auth", "(", "self", ",", "code", ")", ":", "request_data", "=", "self", ".", "get_access_token_params", "(", "code", ")", "res", "=", "self", ".", "_session", ".", "post", "(", "*", "*", "request_data", ")", "if", "res", ".", "status_code", "!=...
Request the token to the /oauth/token endpoint. Update the security tokens. :param code: the code you get from the auth process
[ "Request", "the", "token", "to", "the", "/", "oauth", "/", "token", "endpoint", ".", "Update", "the", "security", "tokens", ".", ":", "param", "code", ":", "the", "code", "you", "get", "from", "the", "auth", "process" ]
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/security.py#L328-L348
Kyria/EsiPy
esipy/security.py
EsiSecurity.revoke
def revoke(self): """Revoke the current tokens then empty all stored tokens This returns nothing since the endpoint return HTTP/200 whatever the result is... Currently not working with JWT, left here for compatibility. """ if not self.refresh_token and not self.ac...
python
def revoke(self): """Revoke the current tokens then empty all stored tokens This returns nothing since the endpoint return HTTP/200 whatever the result is... Currently not working with JWT, left here for compatibility. """ if not self.refresh_token and not self.ac...
[ "def", "revoke", "(", "self", ")", ":", "if", "not", "self", ".", "refresh_token", "and", "not", "self", ".", "access_token", ":", "raise", "AttributeError", "(", "'No access/refresh token are defined.'", ")", "if", "self", ".", "refresh_token", ":", "data", "...
Revoke the current tokens then empty all stored tokens This returns nothing since the endpoint return HTTP/200 whatever the result is... Currently not working with JWT, left here for compatibility.
[ "Revoke", "the", "current", "tokens", "then", "empty", "all", "stored", "tokens", "This", "returns", "nothing", "since", "the", "endpoint", "return", "HTTP", "/", "200", "whatever", "the", "result", "is", "...", "Currently", "not", "working", "with", "JWT", ...
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/security.py#L350-L376
Kyria/EsiPy
esipy/security.py
EsiSecurity.verify
def verify(self, kid='JWT-Signature-Key', options=None): """Decode and verify the token and return the decoded informations Parameters ---------- kid : string The JWKS key id to identify the key to decode the token. Default is 'JWT-Signature-Key'. Only cha...
python
def verify(self, kid='JWT-Signature-Key', options=None): """Decode and verify the token and return the decoded informations Parameters ---------- kid : string The JWKS key id to identify the key to decode the token. Default is 'JWT-Signature-Key'. Only cha...
[ "def", "verify", "(", "self", ",", "kid", "=", "'JWT-Signature-Key'", ",", "options", "=", "None", ")", ":", "if", "self", ".", "access_token", "is", "None", "or", "self", ".", "access_token", "==", "\"\"", ":", "raise", "AttributeError", "(", "'No access ...
Decode and verify the token and return the decoded informations Parameters ---------- kid : string The JWKS key id to identify the key to decode the token. Default is 'JWT-Signature-Key'. Only change if CCP changes it. options : Dict The dicti...
[ "Decode", "and", "verify", "the", "token", "and", "return", "the", "decoded", "informations", "Parameters", "----------", "kid", ":", "string", "The", "JWKS", "key", "id", "to", "identify", "the", "key", "to", "decode", "the", "token", ".", "Default", "is", ...
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/security.py#L378-L416
Kyria/EsiPy
esipy/client.py
EsiClient._retry_request
def _retry_request(self, req_and_resp, _retry=0, **kwargs): """Uses self._request in a sane retry loop (for 5xx level errors). Do not use the _retry parameter, use the same params as _request Used when ESIClient is initialized with retry_requests=True if raise_on_error is True, t...
python
def _retry_request(self, req_and_resp, _retry=0, **kwargs): """Uses self._request in a sane retry loop (for 5xx level errors). Do not use the _retry parameter, use the same params as _request Used when ESIClient is initialized with retry_requests=True if raise_on_error is True, t...
[ "def", "_retry_request", "(", "self", ",", "req_and_resp", ",", "_retry", "=", "0", ",", "*", "*", "kwargs", ")", ":", "raise_on_error", "=", "kwargs", ".", "pop", "(", "'raise_on_error'", ",", "False", ")", "if", "_retry", ":", "# backoff delay loop in seco...
Uses self._request in a sane retry loop (for 5xx level errors). Do not use the _retry parameter, use the same params as _request Used when ESIClient is initialized with retry_requests=True if raise_on_error is True, this will only raise exception after all retry have been done
[ "Uses", "self", ".", "_request", "in", "a", "sane", "retry", "loop", "(", "for", "5xx", "level", "errors", ")", ".", "Do", "not", "use", "the", "_retry", "parameter", "use", "the", "same", "params", "as", "_request", "Used", "when", "ESIClient", "is", ...
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/client.py#L108-L152
Kyria/EsiPy
esipy/client.py
EsiClient.multi_request
def multi_request(self, reqs_and_resps, threads=20, **kwargs): """Use a threadpool to send multiple requests in parallel. :param reqs_and_resps: iterable of req_and_resp tuples :param raw_body_only: applied to every request call :param opt: applies to every request call :p...
python
def multi_request(self, reqs_and_resps, threads=20, **kwargs): """Use a threadpool to send multiple requests in parallel. :param reqs_and_resps: iterable of req_and_resp tuples :param raw_body_only: applied to every request call :param opt: applies to every request call :p...
[ "def", "multi_request", "(", "self", ",", "reqs_and_resps", ",", "threads", "=", "20", ",", "*", "*", "kwargs", ")", ":", "opt", "=", "kwargs", ".", "pop", "(", "'opt'", ",", "{", "}", ")", "raw_body_only", "=", "kwargs", ".", "pop", "(", "'raw_body_...
Use a threadpool to send multiple requests in parallel. :param reqs_and_resps: iterable of req_and_resp tuples :param raw_body_only: applied to every request call :param opt: applies to every request call :param threads: number of concurrent workers to use :return: a lis...
[ "Use", "a", "threadpool", "to", "send", "multiple", "requests", "in", "parallel", ".", ":", "param", "reqs_and_resps", ":", "iterable", "of", "req_and_resp", "tuples", ":", "param", "raw_body_only", ":", "applied", "to", "every", "request", "call", ":", "param...
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/client.py#L154-L185
Kyria/EsiPy
esipy/client.py
EsiClient._request
def _request(self, req_and_resp, **kwargs): """ Take a request_and_response object from pyswagger.App and check auth, token, headers, prepare the actual request and fill the response Note on performance : if you need more performance (because you are using this in a batch)...
python
def _request(self, req_and_resp, **kwargs): """ Take a request_and_response object from pyswagger.App and check auth, token, headers, prepare the actual request and fill the response Note on performance : if you need more performance (because you are using this in a batch)...
[ "def", "_request", "(", "self", ",", "req_and_resp", ",", "*", "*", "kwargs", ")", ":", "opt", "=", "kwargs", ".", "pop", "(", "'opt'", ",", "{", "}", ")", "# reset the request and response to reuse existing req_and_resp\r", "req_and_resp", "[", "0", "]", ".",...
Take a request_and_response object from pyswagger.App and check auth, token, headers, prepare the actual request and fill the response Note on performance : if you need more performance (because you are using this in a batch) you'd rather set raw_body_only=True, as parsed ...
[ "Take", "a", "request_and_response", "object", "from", "pyswagger", ".", "App", "and", "check", "auth", "token", "headers", "prepare", "the", "actual", "request", "and", "fill", "the", "response", "Note", "on", "performance", ":", "if", "you", "need", "more", ...
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/client.py#L187-L260
Kyria/EsiPy
esipy/client.py
EsiClient.head
def head(self, req_and_resp, **kwargs): """ Take a request_and_response object from pyswagger.App, check and prepare everything to make a valid HEAD request :param req_and_resp: the request and response object from pyswagger.App :param opt: options, see pyswagger/blob/master/pyswag...
python
def head(self, req_and_resp, **kwargs): """ Take a request_and_response object from pyswagger.App, check and prepare everything to make a valid HEAD request :param req_and_resp: the request and response object from pyswagger.App :param opt: options, see pyswagger/blob/master/pyswag...
[ "def", "head", "(", "self", ",", "req_and_resp", ",", "*", "*", "kwargs", ")", ":", "opt", "=", "kwargs", ".", "pop", "(", "'opt'", ",", "{", "}", ")", "# reset the request and response to reuse existing req_and_resp\r", "req_and_resp", "[", "0", "]", ".", "...
Take a request_and_response object from pyswagger.App, check and prepare everything to make a valid HEAD request :param req_and_resp: the request and response object from pyswagger.App :param opt: options, see pyswagger/blob/master/pyswagger/io.py#L144 :param raise_on_error: boolea...
[ "Take", "a", "request_and_response", "object", "from", "pyswagger", ".", "App", "check", "and", "prepare", "everything", "to", "make", "a", "valid", "HEAD", "request", ":", "param", "req_and_resp", ":", "the", "request", "and", "response", "object", "from", "p...
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/client.py#L262-L305
Kyria/EsiPy
esipy/client.py
EsiClient.__cache_response
def __cache_response(self, cache_key, res, method): """ cache the response if method is one of self.__uncached_method__, don't cache anything """ if ('expires' in res.headers and method not in self.__uncached_methods__): cache_timeout = get_cache_time_...
python
def __cache_response(self, cache_key, res, method): """ cache the response if method is one of self.__uncached_method__, don't cache anything """ if ('expires' in res.headers and method not in self.__uncached_methods__): cache_timeout = get_cache_time_...
[ "def", "__cache_response", "(", "self", ",", "cache_key", ",", "res", ",", "method", ")", ":", "if", "(", "'expires'", "in", "res", ".", "headers", "and", "method", "not", "in", "self", ".", "__uncached_methods__", ")", ":", "cache_timeout", "=", "get_cach...
cache the response if method is one of self.__uncached_method__, don't cache anything
[ "cache", "the", "response", "if", "method", "is", "one", "of", "self", ".", "__uncached_method__", "don", "t", "cache", "anything" ]
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/client.py#L307-L332
Kyria/EsiPy
esipy/client.py
EsiClient.__make_request
def __make_request(self, request, opt, cache_key=None, method=None): """ Check cache, deal with expiration and etag, make the request and return the response or cached response. :param request: the pyswagger.io.Request object to prepare the request :param opt: options, see pyswagge...
python
def __make_request(self, request, opt, cache_key=None, method=None): """ Check cache, deal with expiration and etag, make the request and return the response or cached response. :param request: the pyswagger.io.Request object to prepare the request :param opt: options, see pyswagge...
[ "def", "__make_request", "(", "self", ",", "request", ",", "opt", ",", "cache_key", "=", "None", ",", "method", "=", "None", ")", ":", "# check expiration and etags\r", "opt_headers", "=", "{", "}", "cached_response", "=", "self", ".", "cache", ".", "get", ...
Check cache, deal with expiration and etag, make the request and return the response or cached response. :param request: the pyswagger.io.Request object to prepare the request :param opt: options, see pyswagger/blob/master/pyswagger/io.py#L144 :param cache_key: the cache key used f...
[ "Check", "cache", "deal", "with", "expiration", "and", "etag", "make", "the", "request", "and", "return", "the", "response", "or", "cached", "response", ".", ":", "param", "request", ":", "the", "pyswagger", ".", "io", ".", "Request", "object", "to", "prep...
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/client.py#L334-L419
Kyria/EsiPy
esipy/cache.py
_hash
def _hash(data): """ generate a hash from data object to be used as cache key """ hash_algo = hashlib.new('md5') hash_algo.update(pickle.dumps(data)) # prefix allows possibility of multiple applications # sharing same keyspace return 'esi_' + hash_algo.hexdigest()
python
def _hash(data): """ generate a hash from data object to be used as cache key """ hash_algo = hashlib.new('md5') hash_algo.update(pickle.dumps(data)) # prefix allows possibility of multiple applications # sharing same keyspace return 'esi_' + hash_algo.hexdigest()
[ "def", "_hash", "(", "data", ")", ":", "hash_algo", "=", "hashlib", ".", "new", "(", "'md5'", ")", "hash_algo", ".", "update", "(", "pickle", ".", "dumps", "(", "data", ")", ")", "# prefix allows possibility of multiple applications\r", "# sharing same keyspace\r"...
generate a hash from data object to be used as cache key
[ "generate", "a", "hash", "from", "data", "object", "to", "be", "used", "as", "cache", "key" ]
train
https://github.com/Kyria/EsiPy/blob/06407a0218a126678f80d8a7e8a67b9729327865/esipy/cache.py#L14-L20
mjirik/imcut
imcut/models.py
Model3D.fit_from_image
def fit_from_image(self, data, voxelsize, seeds, unique_cls): """ This Method allows computes feature vector and train model. :cls: list of index number of requested classes in seeds """ fvs, clsselected = self.features_from_image(data, voxelsize, seeds, unique_cls) self...
python
def fit_from_image(self, data, voxelsize, seeds, unique_cls): """ This Method allows computes feature vector and train model. :cls: list of index number of requested classes in seeds """ fvs, clsselected = self.features_from_image(data, voxelsize, seeds, unique_cls) self...
[ "def", "fit_from_image", "(", "self", ",", "data", ",", "voxelsize", ",", "seeds", ",", "unique_cls", ")", ":", "fvs", ",", "clsselected", "=", "self", ".", "features_from_image", "(", "data", ",", "voxelsize", ",", "seeds", ",", "unique_cls", ")", "self",...
This Method allows computes feature vector and train model. :cls: list of index number of requested classes in seeds
[ "This", "Method", "allows", "computes", "feature", "vector", "and", "train", "model", "." ]
train
https://github.com/mjirik/imcut/blob/1b38e7cd18a7a38fe683c1cabe1222fe5fa03aa3/imcut/models.py#L118-L125
mjirik/imcut
imcut/models.py
Model3D.save
def save(self, filename): """ Save model to pickle file. External feature function is not stored """ import dill tmpmodelparams = self.modelparams.copy() # fv_extern_src = None fv_extern_name = None # try: # fv_extern_src = dill.source.getsour...
python
def save(self, filename): """ Save model to pickle file. External feature function is not stored """ import dill tmpmodelparams = self.modelparams.copy() # fv_extern_src = None fv_extern_name = None # try: # fv_extern_src = dill.source.getsour...
[ "def", "save", "(", "self", ",", "filename", ")", ":", "import", "dill", "tmpmodelparams", "=", "self", ".", "modelparams", ".", "copy", "(", ")", "# fv_extern_src = None", "fv_extern_name", "=", "None", "# try:", "# fv_extern_src = dill.source.getsource(tmpmodelp...
Save model to pickle file. External feature function is not stored
[ "Save", "model", "to", "pickle", "file", ".", "External", "feature", "function", "is", "not", "stored" ]
train
https://github.com/mjirik/imcut/blob/1b38e7cd18a7a38fe683c1cabe1222fe5fa03aa3/imcut/models.py#L133-L163
mjirik/imcut
imcut/models.py
Model3D.load
def load(self, mdl_file): """ load model from file. fv_type is not set with this function. It is expected to set it before. """ import dill as pickle mdl_file_e = op.expanduser(mdl_file) sv = pickle.load(open(mdl_file_e, "rb")) self.mdl = sv["mdl"] # sel...
python
def load(self, mdl_file): """ load model from file. fv_type is not set with this function. It is expected to set it before. """ import dill as pickle mdl_file_e = op.expanduser(mdl_file) sv = pickle.load(open(mdl_file_e, "rb")) self.mdl = sv["mdl"] # sel...
[ "def", "load", "(", "self", ",", "mdl_file", ")", ":", "import", "dill", "as", "pickle", "mdl_file_e", "=", "op", ".", "expanduser", "(", "mdl_file", ")", "sv", "=", "pickle", ".", "load", "(", "open", "(", "mdl_file_e", ",", "\"rb\"", ")", ")", "sel...
load model from file. fv_type is not set with this function. It is expected to set it before.
[ "load", "model", "from", "file", ".", "fv_type", "is", "not", "set", "with", "this", "function", ".", "It", "is", "expected", "to", "set", "it", "before", "." ]
train
https://github.com/mjirik/imcut/blob/1b38e7cd18a7a38fe683c1cabe1222fe5fa03aa3/imcut/models.py#L165-L185
mjirik/imcut
imcut/models.py
Model.features_from_image
def features_from_image( self, data, voxelsize, seeds=None, unique_cls=None ): # , voxels=None): """ Input data is 3d image :param data: is 3d image :param seeds: ndimage with same shape as data, nonzero values means seeds. :param unique_cls: can select only fv for ...
python
def features_from_image( self, data, voxelsize, seeds=None, unique_cls=None ): # , voxels=None): """ Input data is 3d image :param data: is 3d image :param seeds: ndimage with same shape as data, nonzero values means seeds. :param unique_cls: can select only fv for ...
[ "def", "features_from_image", "(", "self", ",", "data", ",", "voxelsize", ",", "seeds", "=", "None", ",", "unique_cls", "=", "None", ")", ":", "# , voxels=None):", "fv_type", "=", "self", ".", "modelparams", "[", "\"fv_type\"", "]", "logger", ".", "debug", ...
Input data is 3d image :param data: is 3d image :param seeds: ndimage with same shape as data, nonzero values means seeds. :param unique_cls: can select only fv for seeds from specific class. f.e. unique_cls = [1, 2] ignores label 0 funcion is called twice in graph cut ...
[ "Input", "data", "is", "3d", "image" ]
train
https://github.com/mjirik/imcut/blob/1b38e7cd18a7a38fe683c1cabe1222fe5fa03aa3/imcut/models.py#L203-L273
mjirik/imcut
imcut/models.py
Model._fit_one_class
def _fit_one_class(self, clx, cl): """ Train clas number cl with data clx. Use trainFromImageAndSeeds() function if you want to use 3D image data as an input. clx: data, 2d matrix cl: label, integer label: gmmsame, gaussian_kde, dpgmm, stored """ logge...
python
def _fit_one_class(self, clx, cl): """ Train clas number cl with data clx. Use trainFromImageAndSeeds() function if you want to use 3D image data as an input. clx: data, 2d matrix cl: label, integer label: gmmsame, gaussian_kde, dpgmm, stored """ logge...
[ "def", "_fit_one_class", "(", "self", ",", "clx", ",", "cl", ")", ":", "logger", ".", "debug", "(", "\"clx \"", "+", "str", "(", "clx", "[", ":", "10", ",", ":", "]", ")", ")", "logger", ".", "debug", "(", "\"clx type\"", "+", "str", "(", "clx", ...
Train clas number cl with data clx. Use trainFromImageAndSeeds() function if you want to use 3D image data as an input. clx: data, 2d matrix cl: label, integer label: gmmsame, gaussian_kde, dpgmm, stored
[ "Train", "clas", "number", "cl", "with", "data", "clx", "." ]
train
https://github.com/mjirik/imcut/blob/1b38e7cd18a7a38fe683c1cabe1222fe5fa03aa3/imcut/models.py#L311-L391
mjirik/imcut
imcut/models.py
Model.likelihood
def likelihood(self, x, cl): """ X = numpy.random.random([2,3,4]) # we have data 2x3 with fature vector with 4 fatures Use likelihoodFromImage() function for 3d image input m.likelihood(X,0) """ # sha = x.shape # xr = x.reshape(-1, sha[-1]) # out...
python
def likelihood(self, x, cl): """ X = numpy.random.random([2,3,4]) # we have data 2x3 with fature vector with 4 fatures Use likelihoodFromImage() function for 3d image input m.likelihood(X,0) """ # sha = x.shape # xr = x.reshape(-1, sha[-1]) # out...
[ "def", "likelihood", "(", "self", ",", "x", ",", "cl", ")", ":", "# sha = x.shape", "# xr = x.reshape(-1, sha[-1])", "# outsha = sha[:-1]", "# from PyQt4.QtCore import pyqtRemoveInputHook", "# pyqtRemoveInputHook()", "logger", ".", "debug", "(", "\"likel \"", "+", "str", ...
X = numpy.random.random([2,3,4]) # we have data 2x3 with fature vector with 4 fatures Use likelihoodFromImage() function for 3d image input m.likelihood(X,0)
[ "X", "=", "numpy", ".", "random", ".", "random", "(", "[", "2", "3", "4", "]", ")", "#", "we", "have", "data", "2x3", "with", "fature", "vector", "with", "4", "fatures" ]
train
https://github.com/mjirik/imcut/blob/1b38e7cd18a7a38fe683c1cabe1222fe5fa03aa3/imcut/models.py#L397-L442
mjirik/imcut
imcut/pycut.py
inspect_node_neighborhood
def inspect_node_neighborhood(nlinks, msinds, node_msindex): """ Get information about one node in graph :param nlinks: neighboorhood edges :param msinds: indexes in 3d image :param node_msindex: int, multiscale index of selected voxel :return: node_neighboor_edges_and_weights, node_neighboor_s...
python
def inspect_node_neighborhood(nlinks, msinds, node_msindex): """ Get information about one node in graph :param nlinks: neighboorhood edges :param msinds: indexes in 3d image :param node_msindex: int, multiscale index of selected voxel :return: node_neighboor_edges_and_weights, node_neighboor_s...
[ "def", "inspect_node_neighborhood", "(", "nlinks", ",", "msinds", ",", "node_msindex", ")", ":", "# seed_indexes = np.nonzero(node_seed)", "# selected_inds = msinds[seed_indexes]", "# node_msindex = selected_inds[0]", "node_neighbor_edges", "=", "get_neighborhood_edes", "(", "nlink...
Get information about one node in graph :param nlinks: neighboorhood edges :param msinds: indexes in 3d image :param node_msindex: int, multiscale index of selected voxel :return: node_neighboor_edges_and_weights, node_neighboor_seeds
[ "Get", "information", "about", "one", "node", "in", "graph" ]
train
https://github.com/mjirik/imcut/blob/1b38e7cd18a7a38fe683c1cabe1222fe5fa03aa3/imcut/pycut.py#L1496-L1520
mjirik/imcut
imcut/pycut.py
inspect_node
def inspect_node(nlinks, unariesalt, msinds, node_msindex): """ Get information about one node in graph :param nlinks: neighboorhood edges :param unariesalt: weights :param msinds: indexes in 3d image :param node_msindex: msindex of selected node. See get_node_msindex() :return: node_unarie...
python
def inspect_node(nlinks, unariesalt, msinds, node_msindex): """ Get information about one node in graph :param nlinks: neighboorhood edges :param unariesalt: weights :param msinds: indexes in 3d image :param node_msindex: msindex of selected node. See get_node_msindex() :return: node_unarie...
[ "def", "inspect_node", "(", "nlinks", ",", "unariesalt", ",", "msinds", ",", "node_msindex", ")", ":", "node_unariesalt", "=", "unariesalt", "[", "node_msindex", "]", "neigh_edges", ",", "neigh_seeds", "=", "inspect_node_neighborhood", "(", "nlinks", ",", "msinds"...
Get information about one node in graph :param nlinks: neighboorhood edges :param unariesalt: weights :param msinds: indexes in 3d image :param node_msindex: msindex of selected node. See get_node_msindex() :return: node_unariesalt, node_neighboor_edges_and_weights, node_neighboor_seeds
[ "Get", "information", "about", "one", "node", "in", "graph" ]
train
https://github.com/mjirik/imcut/blob/1b38e7cd18a7a38fe683c1cabe1222fe5fa03aa3/imcut/pycut.py#L1523-L1536
mjirik/imcut
imcut/pycut.py
get_node_msindex
def get_node_msindex(msinds, node_seed): """ Convert seeds-like selection of voxel to multiscale index. :param msinds: ndarray with indexes :param node_seed: ndarray with 1 where selected pixel is, or list of indexes in this array :return: multiscale index of first found seed """ if type(nod...
python
def get_node_msindex(msinds, node_seed): """ Convert seeds-like selection of voxel to multiscale index. :param msinds: ndarray with indexes :param node_seed: ndarray with 1 where selected pixel is, or list of indexes in this array :return: multiscale index of first found seed """ if type(nod...
[ "def", "get_node_msindex", "(", "msinds", ",", "node_seed", ")", ":", "if", "type", "(", "node_seed", ")", "==", "np", ".", "ndarray", ":", "seed_indexes", "=", "np", ".", "nonzero", "(", "node_seed", ")", "elif", "type", "(", "node_seed", ")", "==", "...
Convert seeds-like selection of voxel to multiscale index. :param msinds: ndarray with indexes :param node_seed: ndarray with 1 where selected pixel is, or list of indexes in this array :return: multiscale index of first found seed
[ "Convert", "seeds", "-", "like", "selection", "of", "voxel", "to", "multiscale", "index", ".", ":", "param", "msinds", ":", "ndarray", "with", "indexes", ":", "param", "node_seed", ":", "ndarray", "with", "1", "where", "selected", "pixel", "is", "or", "lis...
train
https://github.com/mjirik/imcut/blob/1b38e7cd18a7a38fe683c1cabe1222fe5fa03aa3/imcut/pycut.py#L1539-L1555
mjirik/imcut
imcut/pycut.py
relabel_squeeze
def relabel_squeeze(data): """ Makes relabeling of data if there are unused values. """ palette, index = np.unique(data, return_inverse=True) data = index.reshape(data.shape) # realy slow solution # unq = np.unique(data) # actual_label = 0 # for lab in unq: # ...
python
def relabel_squeeze(data): """ Makes relabeling of data if there are unused values. """ palette, index = np.unique(data, return_inverse=True) data = index.reshape(data.shape) # realy slow solution # unq = np.unique(data) # actual_label = 0 # for lab in unq: # ...
[ "def", "relabel_squeeze", "(", "data", ")", ":", "palette", ",", "index", "=", "np", ".", "unique", "(", "data", ",", "return_inverse", "=", "True", ")", "data", "=", "index", ".", "reshape", "(", "data", ".", "shape", ")", "# realy slow solution", "# ...
Makes relabeling of data if there are unused values.
[ "Makes", "relabeling", "of", "data", "if", "there", "are", "unused", "values", "." ]
train
https://github.com/mjirik/imcut/blob/1b38e7cd18a7a38fe683c1cabe1222fe5fa03aa3/imcut/pycut.py#L1607-L1622
mjirik/imcut
imcut/pycut.py
ImageGraphCut.load
def load(self, filename, fv_extern=None): """ Read model stored in the file. :param filename: Path to file with model :param fv_extern: external feature vector function is passed here :return: """ self.modelparams["mdl_stored_file"] = filename if fv_exter...
python
def load(self, filename, fv_extern=None): """ Read model stored in the file. :param filename: Path to file with model :param fv_extern: external feature vector function is passed here :return: """ self.modelparams["mdl_stored_file"] = filename if fv_exter...
[ "def", "load", "(", "self", ",", "filename", ",", "fv_extern", "=", "None", ")", ":", "self", ".", "modelparams", "[", "\"mdl_stored_file\"", "]", "=", "filename", "if", "fv_extern", "is", "not", "None", ":", "self", ".", "modelparams", "[", "\"fv_extern\"...
Read model stored in the file. :param filename: Path to file with model :param fv_extern: external feature vector function is passed here :return:
[ "Read", "model", "stored", "in", "the", "file", "." ]
train
https://github.com/mjirik/imcut/blob/1b38e7cd18a7a38fe683c1cabe1222fe5fa03aa3/imcut/pycut.py#L153-L169
mjirik/imcut
imcut/pycut.py
ImageGraphCut.__ms_npenalty_fcn
def __ms_npenalty_fcn(self, axis, mask, orig_shape): """ :param axis: direction of edge :param mask: 3d ndarray with ones where is fine resolution Neighboorhood penalty between small pixels should be smaller then in bigger tiles. This is the way how to set it. """ ...
python
def __ms_npenalty_fcn(self, axis, mask, orig_shape): """ :param axis: direction of edge :param mask: 3d ndarray with ones where is fine resolution Neighboorhood penalty between small pixels should be smaller then in bigger tiles. This is the way how to set it. """ ...
[ "def", "__ms_npenalty_fcn", "(", "self", ",", "axis", ",", "mask", ",", "orig_shape", ")", ":", "maskz", "=", "zoom_to_shape", "(", "mask", ",", "orig_shape", ")", "maskz_new", "=", "np", ".", "zeros", "(", "orig_shape", ",", "dtype", "=", "np", ".", "...
:param axis: direction of edge :param mask: 3d ndarray with ones where is fine resolution Neighboorhood penalty between small pixels should be smaller then in bigger tiles. This is the way how to set it.
[ ":", "param", "axis", ":", "direction", "of", "edge", ":", "param", "mask", ":", "3d", "ndarray", "with", "ones", "where", "is", "fine", "resolution" ]
train
https://github.com/mjirik/imcut/blob/1b38e7cd18a7a38fe683c1cabe1222fe5fa03aa3/imcut/pycut.py#L203-L221
mjirik/imcut
imcut/pycut.py
ImageGraphCut.__msgc_step12_low_resolution_segmentation
def __msgc_step12_low_resolution_segmentation(self): """ Get the segmentation and the :return: """ import scipy start = self._start_time # ===== low resolution data processing # default parameters # TODO segparams_lo and segparams_hi je tam asi zb...
python
def __msgc_step12_low_resolution_segmentation(self): """ Get the segmentation and the :return: """ import scipy start = self._start_time # ===== low resolution data processing # default parameters # TODO segparams_lo and segparams_hi je tam asi zb...
[ "def", "__msgc_step12_low_resolution_segmentation", "(", "self", ")", ":", "import", "scipy", "start", "=", "self", ".", "_start_time", "# ===== low resolution data processing", "# default parameters", "# TODO segparams_lo and segparams_hi je tam asi zbytecně", "sparams_lo", "=", ...
Get the segmentation and the :return:
[ "Get", "the", "segmentation", "and", "the", ":", "return", ":" ]
train
https://github.com/mjirik/imcut/blob/1b38e7cd18a7a38fe683c1cabe1222fe5fa03aa3/imcut/pycut.py#L238-L321