repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
lrq3000/pyFileFixity
pyFileFixity/lib/gooey/gui/windows/advanced_config.py
ConfigPanel.chunk
def chunk(self, iterable, n, fillvalue=None): "itertools recipe: Collect data into fixed-length chunks or blocks" # grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx args = [iter(iterable)] * n return izip_longest(fillvalue=fillvalue, *args)
python
def chunk(self, iterable, n, fillvalue=None): "itertools recipe: Collect data into fixed-length chunks or blocks" # grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx args = [iter(iterable)] * n return izip_longest(fillvalue=fillvalue, *args)
[ "def", "chunk", "(", "self", ",", "iterable", ",", "n", ",", "fillvalue", "=", "None", ")", ":", "# grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx", "args", "=", "[", "iter", "(", "iterable", ")", "]", "*", "n", "return", "izip_longest", "(", "fillvalue", "=", ...
itertools recipe: Collect data into fixed-length chunks or blocks
[ "itertools", "recipe", ":", "Collect", "data", "into", "fixed", "-", "length", "chunks", "or", "blocks" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/gooey/gui/windows/advanced_config.py#L104-L108
lrq3000/pyFileFixity
pyFileFixity/lib/gooey/gui/components.py
Positional.GetValue
def GetValue(self): ''' Positionals have no associated options_string, so only the supplied arguments are returned. The order is assumed to be the same as the order of declaration in the client code Returns "argument_value" ''' self.AssertInitialization('Positional') if str(se...
python
def GetValue(self): ''' Positionals have no associated options_string, so only the supplied arguments are returned. The order is assumed to be the same as the order of declaration in the client code Returns "argument_value" ''' self.AssertInitialization('Positional') if str(se...
[ "def", "GetValue", "(", "self", ")", ":", "self", ".", "AssertInitialization", "(", "'Positional'", ")", "if", "str", "(", "self", ".", "_widget", ".", "GetValue", "(", ")", ")", "==", "EMPTY", ":", "return", "None", "return", "self", ".", "_widget", "...
Positionals have no associated options_string, so only the supplied arguments are returned. The order is assumed to be the same as the order of declaration in the client code Returns "argument_value"
[ "Positionals", "have", "no", "associated", "options_string", "so", "only", "the", "supplied", "arguments", "are", "returned", ".", "The", "order", "is", "assumed", "to", "be", "the", "same", "as", "the", "order", "of", "declaration", "in", "the", "client", "...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/gooey/gui/components.py#L265-L278
lrq3000/pyFileFixity
pyFileFixity/lib/gooey/gui/components.py
Choice.GetValue
def GetValue(self): ''' Returns "--option_name argument" ''' self.AssertInitialization('Choice') if self._widget.GetValue() == self._DEFAULT_VALUE: return None return ' '.join( [self._action.option_strings[0] if self._action.option_strings else '', # get the verbose copy if av...
python
def GetValue(self): ''' Returns "--option_name argument" ''' self.AssertInitialization('Choice') if self._widget.GetValue() == self._DEFAULT_VALUE: return None return ' '.join( [self._action.option_strings[0] if self._action.option_strings else '', # get the verbose copy if av...
[ "def", "GetValue", "(", "self", ")", ":", "self", ".", "AssertInitialization", "(", "'Choice'", ")", "if", "self", ".", "_widget", ".", "GetValue", "(", ")", "==", "self", ".", "_DEFAULT_VALUE", ":", "return", "None", "return", "' '", ".", "join", "(", ...
Returns "--option_name argument"
[ "Returns", "--", "option_name", "argument" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/gooey/gui/components.py#L291-L301
lrq3000/pyFileFixity
pyFileFixity/lib/gooey/gui/components.py
Optional.GetValue
def GetValue(self): ''' General options are key/value style pairs (conceptually). Thus the name of the option, as well as the argument to it are returned e.g. >>> myscript --outfile myfile.txt returns "--Option Value" ''' self.AssertInitialization('Optional') value = self...
python
def GetValue(self): ''' General options are key/value style pairs (conceptually). Thus the name of the option, as well as the argument to it are returned e.g. >>> myscript --outfile myfile.txt returns "--Option Value" ''' self.AssertInitialization('Optional') value = self...
[ "def", "GetValue", "(", "self", ")", ":", "self", ".", "AssertInitialization", "(", "'Optional'", ")", "value", "=", "self", ".", "_widget", ".", "GetValue", "(", ")", "if", "not", "value", "or", "len", "(", "value", ")", "<=", "0", ":", "return", "N...
General options are key/value style pairs (conceptually). Thus the name of the option, as well as the argument to it are returned e.g. >>> myscript --outfile myfile.txt returns "--Option Value"
[ "General", "options", "are", "key", "/", "value", "style", "pairs", "(", "conceptually", ")", ".", "Thus", "the", "name", "of", "the", "option", "as", "well", "as", "the", "argument", "to", "it", "are", "returned", "e", ".", "g", ".", ">>>", "myscript"...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/gooey/gui/components.py#L323-L339
lrq3000/pyFileFixity
pyFileFixity/lib/gooey/gui/components.py
Flag.GetValue
def GetValue(self): ''' Flag options have no param associated with them. Thus we only need the name of the option. e.g >>> Python -v myscript returns Options name for argument (-v) ''' if not self._widget.GetValue() or len(self._widget.GetValue()) <= 0: return None el...
python
def GetValue(self): ''' Flag options have no param associated with them. Thus we only need the name of the option. e.g >>> Python -v myscript returns Options name for argument (-v) ''' if not self._widget.GetValue() or len(self._widget.GetValue()) <= 0: return None el...
[ "def", "GetValue", "(", "self", ")", ":", "if", "not", "self", ".", "_widget", ".", "GetValue", "(", ")", "or", "len", "(", "self", ".", "_widget", ".", "GetValue", "(", ")", ")", "<=", "0", ":", "return", "None", "else", ":", "return", "self", "...
Flag options have no param associated with them. Thus we only need the name of the option. e.g >>> Python -v myscript returns Options name for argument (-v)
[ "Flag", "options", "have", "no", "param", "associated", "with", "them", ".", "Thus", "we", "only", "need", "the", "name", "of", "the", "option", ".", "e", ".", "g", ">>>", "Python", "-", "v", "myscript", "returns", "Options", "name", "for", "argument", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/gooey/gui/components.py#L381-L393
lrq3000/pyFileFixity
pyFileFixity/lib/gooey/gui/components.py
Flag.Update
def Update(self, size): ''' Custom wrapper calculator to account for the increased size of the _msg widget after being inlined with the wx.CheckBox ''' if self._msg is None: return help_msg = self._msg width, height = size content_area = int((width / 3) * .70) wiggle_room ...
python
def Update(self, size): ''' Custom wrapper calculator to account for the increased size of the _msg widget after being inlined with the wx.CheckBox ''' if self._msg is None: return help_msg = self._msg width, height = size content_area = int((width / 3) * .70) wiggle_room ...
[ "def", "Update", "(", "self", ",", "size", ")", ":", "if", "self", ".", "_msg", "is", "None", ":", "return", "help_msg", "=", "self", ".", "_msg", "width", ",", "height", "=", "size", "content_area", "=", "int", "(", "(", "width", "/", "3", ")", ...
Custom wrapper calculator to account for the increased size of the _msg widget after being inlined with the wx.CheckBox
[ "Custom", "wrapper", "calculator", "to", "account", "for", "the", "increased", "size", "of", "the", "_msg", "widget", "after", "being", "inlined", "with", "the", "wx", ".", "CheckBox" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/gooey/gui/components.py#L395-L410
lrq3000/pyFileFixity
pyFileFixity/lib/gooey/gui/components.py
Counter.GetValue
def GetValue(self): ''' NOTE: Added on plane. Cannot remember exact implementation of counter objects. I believe that they count sequentail pairings of options e.g. -vvvvv But I'm not sure. That's what I'm going with for now. Returns str(action.options_string[0]) * DropDown Valu...
python
def GetValue(self): ''' NOTE: Added on plane. Cannot remember exact implementation of counter objects. I believe that they count sequentail pairings of options e.g. -vvvvv But I'm not sure. That's what I'm going with for now. Returns str(action.options_string[0]) * DropDown Valu...
[ "def", "GetValue", "(", "self", ")", ":", "dropdown_value", "=", "self", ".", "_widget", ".", "GetValue", "(", ")", "if", "not", "str", "(", "dropdown_value", ")", ".", "isdigit", "(", ")", ":", "return", "None", "arg", "=", "str", "(", "self", ".", ...
NOTE: Added on plane. Cannot remember exact implementation of counter objects. I believe that they count sequentail pairings of options e.g. -vvvvv But I'm not sure. That's what I'm going with for now. Returns str(action.options_string[0]) * DropDown Value
[ "NOTE", ":", "Added", "on", "plane", ".", "Cannot", "remember", "exact", "implementation", "of", "counter", "objects", ".", "I", "believe", "that", "they", "count", "sequentail", "pairings", "of", "options", "e", ".", "g", ".", "-", "vvvvv", "But", "I", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/gooey/gui/components.py#L429-L446
lrq3000/pyFileFixity
pyFileFixity/lib/gooey/gui/lang/i18n.py
get_path
def get_path(language): ''' Returns the full path to the language file ''' filename = language.lower() + '.json' lang_file_path = os.path.join(_DEFAULT_DIR, filename) if not os.path.exists(lang_file_path): raise IOError('Could not find {} language file'.format(language)) return lang_file_path
python
def get_path(language): ''' Returns the full path to the language file ''' filename = language.lower() + '.json' lang_file_path = os.path.join(_DEFAULT_DIR, filename) if not os.path.exists(lang_file_path): raise IOError('Could not find {} language file'.format(language)) return lang_file_path
[ "def", "get_path", "(", "language", ")", ":", "filename", "=", "language", ".", "lower", "(", ")", "+", "'.json'", "lang_file_path", "=", "os", ".", "path", ".", "join", "(", "_DEFAULT_DIR", ",", "filename", ")", "if", "not", "os", ".", "path", ".", ...
Returns the full path to the language file
[ "Returns", "the", "full", "path", "to", "the", "language", "file" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/gooey/gui/lang/i18n.py#L23-L29
lrq3000/pyFileFixity
pyFileFixity/lib/gooey/gui/lang/i18n.py
load
def load(filename): ''' Open and return the supplied json file ''' global _DICTIONARY try: json_file = filename + '.json' with open(os.path.join(_DEFAULT_DIR, json_file), 'rb') as f: _DICTIONARY = json.load(f) except IOError: raise IOError('Language file not found. Make sure that your ', ...
python
def load(filename): ''' Open and return the supplied json file ''' global _DICTIONARY try: json_file = filename + '.json' with open(os.path.join(_DEFAULT_DIR, json_file), 'rb') as f: _DICTIONARY = json.load(f) except IOError: raise IOError('Language file not found. Make sure that your ', ...
[ "def", "load", "(", "filename", ")", ":", "global", "_DICTIONARY", "try", ":", "json_file", "=", "filename", "+", "'.json'", "with", "open", "(", "os", ".", "path", ".", "join", "(", "_DEFAULT_DIR", ",", "json_file", ")", ",", "'rb'", ")", "as", "f", ...
Open and return the supplied json file
[ "Open", "and", "return", "the", "supplied", "json", "file" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/gooey/gui/lang/i18n.py#L32-L41
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/util/stringutils.py
safe_repr
def safe_repr(obj, clip=None): """ Convert object to string representation, yielding the same result a `repr` but catches all exceptions and returns 'N/A' instead of raising the exception. Strings may be truncated by providing `clip`. >>> safe_repr(42) '42' >>> safe_repr('Clipped text', cli...
python
def safe_repr(obj, clip=None): """ Convert object to string representation, yielding the same result a `repr` but catches all exceptions and returns 'N/A' instead of raising the exception. Strings may be truncated by providing `clip`. >>> safe_repr(42) '42' >>> safe_repr('Clipped text', cli...
[ "def", "safe_repr", "(", "obj", ",", "clip", "=", "None", ")", ":", "try", ":", "s", "=", "repr", "(", "obj", ")", "if", "not", "clip", "or", "len", "(", "s", ")", "<=", "clip", ":", "return", "s", "else", ":", "return", "s", "[", ":", "clip"...
Convert object to string representation, yielding the same result a `repr` but catches all exceptions and returns 'N/A' instead of raising the exception. Strings may be truncated by providing `clip`. >>> safe_repr(42) '42' >>> safe_repr('Clipped text', clip=8) 'Clip..xt' >>> safe_repr([1,2,...
[ "Convert", "object", "to", "string", "representation", "yielding", "the", "same", "result", "a", "repr", "but", "catches", "all", "exceptions", "and", "returns", "N", "/", "A", "instead", "of", "raising", "the", "exception", ".", "Strings", "may", "be", "tru...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/util/stringutils.py#L5-L25
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/util/stringutils.py
trunc
def trunc(obj, max, left=0): """ Convert `obj` to string, eliminate newlines and truncate the string to `max` characters. If there are more characters in the string add ``...`` to the string. With `left=True`, the string can be truncated at the beginning. @note: Does not catch exceptions when conve...
python
def trunc(obj, max, left=0): """ Convert `obj` to string, eliminate newlines and truncate the string to `max` characters. If there are more characters in the string add ``...`` to the string. With `left=True`, the string can be truncated at the beginning. @note: Does not catch exceptions when conve...
[ "def", "trunc", "(", "obj", ",", "max", ",", "left", "=", "0", ")", ":", "s", "=", "str", "(", "obj", ")", "s", "=", "s", ".", "replace", "(", "'\\n'", ",", "'|'", ")", "if", "len", "(", "s", ")", ">", "max", ":", "if", "left", ":", "retu...
Convert `obj` to string, eliminate newlines and truncate the string to `max` characters. If there are more characters in the string add ``...`` to the string. With `left=True`, the string can be truncated at the beginning. @note: Does not catch exceptions when converting `obj` to string with `str`. >>...
[ "Convert", "obj", "to", "string", "eliminate", "newlines", "and", "truncate", "the", "string", "to", "max", "characters", ".", "If", "there", "are", "more", "characters", "in", "the", "string", "add", "...", "to", "the", "string", ".", "With", "left", "=",...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/util/stringutils.py#L28-L49
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/util/stringutils.py
pp
def pp(i, base=1024): """ Pretty-print the integer `i` as a human-readable size representation. """ degree = 0 pattern = "%4d %s" while i > base: pattern = "%7.2f %s" i = i / float(base) degree += 1 scales = ['B', 'KB', 'MB', 'GB', 'TB', 'EB'] return pattern %...
python
def pp(i, base=1024): """ Pretty-print the integer `i` as a human-readable size representation. """ degree = 0 pattern = "%4d %s" while i > base: pattern = "%7.2f %s" i = i / float(base) degree += 1 scales = ['B', 'KB', 'MB', 'GB', 'TB', 'EB'] return pattern %...
[ "def", "pp", "(", "i", ",", "base", "=", "1024", ")", ":", "degree", "=", "0", "pattern", "=", "\"%4d %s\"", "while", "i", ">", "base", ":", "pattern", "=", "\"%7.2f %s\"", "i", "=", "i", "/", "float", "(", "base", ")", "degree", "+=", "1", "...
Pretty-print the integer `i` as a human-readable size representation.
[ "Pretty", "-", "print", "the", "integer", "i", "as", "a", "human", "-", "readable", "size", "representation", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/util/stringutils.py#L51-L62
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/util/stringutils.py
pp_timestamp
def pp_timestamp(t): """ Get a friendly timestamp represented as a string. """ if t is None: return '' h, m, s = int(t / 3600), int(t / 60 % 60), t % 60 return "%02d:%02d:%05.2f" % (h, m, s)
python
def pp_timestamp(t): """ Get a friendly timestamp represented as a string. """ if t is None: return '' h, m, s = int(t / 3600), int(t / 60 % 60), t % 60 return "%02d:%02d:%05.2f" % (h, m, s)
[ "def", "pp_timestamp", "(", "t", ")", ":", "if", "t", "is", "None", ":", "return", "''", "h", ",", "m", ",", "s", "=", "int", "(", "t", "/", "3600", ")", ",", "int", "(", "t", "/", "60", "%", "60", ")", ",", "t", "%", "60", "return", "\"%...
Get a friendly timestamp represented as a string.
[ "Get", "a", "friendly", "timestamp", "represented", "as", "a", "string", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/util/stringutils.py#L64-L71
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/garbagegraph.py
GarbageGraph.print_stats
def print_stats(self, stream=None): """ Log annotated garbage objects to console or file. :param stream: open file, uses sys.stdout if not given """ if not stream: # pragma: no cover stream = sys.stdout self.metadata.sort(key=lambda x: -x.size) stream...
python
def print_stats(self, stream=None): """ Log annotated garbage objects to console or file. :param stream: open file, uses sys.stdout if not given """ if not stream: # pragma: no cover stream = sys.stdout self.metadata.sort(key=lambda x: -x.size) stream...
[ "def", "print_stats", "(", "self", ",", "stream", "=", "None", ")", ":", "if", "not", "stream", ":", "# pragma: no cover", "stream", "=", "sys", ".", "stdout", "self", ".", "metadata", ".", "sort", "(", "key", "=", "lambda", "x", ":", "-", "x", ".", ...
Log annotated garbage objects to console or file. :param stream: open file, uses sys.stdout if not given
[ "Log", "annotated", "garbage", "objects", "to", "console", "or", "file", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/garbagegraph.py#L47-L61
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/pprofile/pprofile.py
ProfileBase.getFilenameSet
def getFilenameSet(self): """ Returns a set of profiled file names. Note: "file name" is used loosely here. See python documentation for co_filename, linecache module and PEP302. It may not be a valid filesystem path. """ result = set(self.file_dict) # Ig...
python
def getFilenameSet(self): """ Returns a set of profiled file names. Note: "file name" is used loosely here. See python documentation for co_filename, linecache module and PEP302. It may not be a valid filesystem path. """ result = set(self.file_dict) # Ig...
[ "def", "getFilenameSet", "(", "self", ")", ":", "result", "=", "set", "(", "self", ".", "file_dict", ")", "# Ignore profiling code. __file__ does not always provide consistent", "# results with f_code.co_filename (ex: easy_install with zipped egg),", "# so inspect current frame inste...
Returns a set of profiled file names. Note: "file name" is used loosely here. See python documentation for co_filename, linecache module and PEP302. It may not be a valid filesystem path.
[ "Returns", "a", "set", "of", "profiled", "file", "names", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/pprofile/pprofile.py#L165-L179
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/pprofile/pprofile.py
ProfileBase.callgrind
def callgrind(self, out, filename=None, commandline=None, relative_path=False): """ Dump statistics in callgrind format. Contains: - per-line hit count, time and time-per-hit - call associations (call tree) Note: hit count is not inclusive, in that it is not the sum of ...
python
def callgrind(self, out, filename=None, commandline=None, relative_path=False): """ Dump statistics in callgrind format. Contains: - per-line hit count, time and time-per-hit - call associations (call tree) Note: hit count is not inclusive, in that it is not the sum of ...
[ "def", "callgrind", "(", "self", ",", "out", ",", "filename", "=", "None", ",", "commandline", "=", "None", ",", "relative_path", "=", "False", ")", ":", "print", ">>", "out", ",", "'version: 1'", "if", "commandline", "is", "not", "None", ":", "print", ...
Dump statistics in callgrind format. Contains: - per-line hit count, time and time-per-hit - call associations (call tree) Note: hit count is not inclusive, in that it is not the sum of all hits inside that call. Time unit: microsecond (1e-6 second). out (file...
[ "Dump", "statistics", "in", "callgrind", "format", ".", "Contains", ":", "-", "per", "-", "line", "hit", "count", "time", "and", "time", "-", "per", "-", "hit", "-", "call", "associations", "(", "call", "tree", ")", "Note", ":", "hit", "count", "is", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/pprofile/pprofile.py#L220-L284
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/pprofile/pprofile.py
ProfileBase.annotate
def annotate(self, out, filename=None, commandline=None, relative_path=False): """ Dump annotated source code with current profiling statistics to "out" file. Time unit: second. out (file-ish opened for writing) Destination of annotated sources. filename (str,...
python
def annotate(self, out, filename=None, commandline=None, relative_path=False): """ Dump annotated source code with current profiling statistics to "out" file. Time unit: second. out (file-ish opened for writing) Destination of annotated sources. filename (str,...
[ "def", "annotate", "(", "self", ",", "out", ",", "filename", "=", "None", ",", "commandline", "=", "None", ",", "relative_path", "=", "False", ")", ":", "file_dict", "=", "self", ".", "file_dict", "total_time", "=", "self", ".", "total_time", "if", "comm...
Dump annotated source code with current profiling statistics to "out" file. Time unit: second. out (file-ish opened for writing) Destination of annotated sources. filename (str, list of str) If provided, dump stats for given source file(s) only. By def...
[ "Dump", "annotated", "source", "code", "with", "current", "profiling", "statistics", "to", "out", "file", ".", "Time", "unit", ":", "second", ".", "out", "(", "file", "-", "ish", "opened", "for", "writing", ")", "Destination", "of", "annotated", "sources", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/pprofile/pprofile.py#L286-L346
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/pprofile/pprofile.py
Profile.disable
def disable(self, threads=True): """ Disable profiling. """ if self.enabled_start: sys.settrace(None) self._disable() else: warn('Duplicate "disable" call')
python
def disable(self, threads=True): """ Disable profiling. """ if self.enabled_start: sys.settrace(None) self._disable() else: warn('Duplicate "disable" call')
[ "def", "disable", "(", "self", ",", "threads", "=", "True", ")", ":", "if", "self", ".", "enabled_start", ":", "sys", ".", "settrace", "(", "None", ")", "self", ".", "_disable", "(", ")", "else", ":", "warn", "(", "'Duplicate \"disable\" call'", ")" ]
Disable profiling.
[ "Disable", "profiling", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/pprofile/pprofile.py#L477-L485
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/pprofile/pprofile.py
Profile.run
def run(self, cmd): """Similar to profile.Profile.run .""" import __main__ dict = __main__.__dict__ return self.runctx(cmd, dict, dict)
python
def run(self, cmd): """Similar to profile.Profile.run .""" import __main__ dict = __main__.__dict__ return self.runctx(cmd, dict, dict)
[ "def", "run", "(", "self", ",", "cmd", ")", ":", "import", "__main__", "dict", "=", "__main__", ".", "__dict__", "return", "self", ".", "runctx", "(", "cmd", ",", "dict", ",", "dict", ")" ]
Similar to profile.Profile.run .
[ "Similar", "to", "profile", ".", "Profile", ".", "run", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/pprofile/pprofile.py#L553-L557
lrq3000/pyFileFixity
pyFileFixity/lib/tee.py
Tee.write
def write(self, data, end="\n", flush=True): """ Output data to stdout and/or file """ if not self.nostdout: self.stdout.write(data+end) if self.file is not None: self.file.write(data+end) if flush: self.flush()
python
def write(self, data, end="\n", flush=True): """ Output data to stdout and/or file """ if not self.nostdout: self.stdout.write(data+end) if self.file is not None: self.file.write(data+end) if flush: self.flush()
[ "def", "write", "(", "self", ",", "data", ",", "end", "=", "\"\\n\"", ",", "flush", "=", "True", ")", ":", "if", "not", "self", ".", "nostdout", ":", "self", ".", "stdout", ".", "write", "(", "data", "+", "end", ")", "if", "self", ".", "file", ...
Output data to stdout and/or file
[ "Output", "data", "to", "stdout", "and", "/", "or", "file" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/tee.py#L27-L34
lrq3000/pyFileFixity
pyFileFixity/lib/tee.py
Tee.flush
def flush(self): """ Force commit changes to the file and stdout """ if not self.nostdout: self.stdout.flush() if self.file is not None: self.file.flush()
python
def flush(self): """ Force commit changes to the file and stdout """ if not self.nostdout: self.stdout.flush() if self.file is not None: self.file.flush()
[ "def", "flush", "(", "self", ")", ":", "if", "not", "self", ".", "nostdout", ":", "self", ".", "stdout", ".", "flush", "(", ")", "if", "self", ".", "file", "is", "not", "None", ":", "self", ".", "file", ".", "flush", "(", ")" ]
Force commit changes to the file and stdout
[ "Force", "commit", "changes", "to", "the", "file", "and", "stdout" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/tee.py#L36-L41
lrq3000/pyFileFixity
pyFileFixity/lib/distance/distance/_levenshtein.py
levenshtein
def levenshtein(seq1, seq2, normalized=False, max_dist=-1): """Compute the absolute Levenshtein distance between the two sequences `seq1` and `seq2`. The Levenshtein distance is the minimum number of edit operations necessary for transforming one sequence into the other. The edit operations allowed are: * del...
python
def levenshtein(seq1, seq2, normalized=False, max_dist=-1): """Compute the absolute Levenshtein distance between the two sequences `seq1` and `seq2`. The Levenshtein distance is the minimum number of edit operations necessary for transforming one sequence into the other. The edit operations allowed are: * del...
[ "def", "levenshtein", "(", "seq1", ",", "seq2", ",", "normalized", "=", "False", ",", "max_dist", "=", "-", "1", ")", ":", "if", "normalized", ":", "return", "nlevenshtein", "(", "seq1", ",", "seq2", ",", "method", "=", "1", ")", "if", "seq1", "==", ...
Compute the absolute Levenshtein distance between the two sequences `seq1` and `seq2`. The Levenshtein distance is the minimum number of edit operations necessary for transforming one sequence into the other. The edit operations allowed are: * deletion: ABC -> BC, AC, AB * insertion: ABC -> ABCD, EABC...
[ "Compute", "the", "absolute", "Levenshtein", "distance", "between", "the", "two", "sequences", "seq1", "and", "seq2", ".", "The", "Levenshtein", "distance", "is", "the", "minimum", "number", "of", "edit", "operations", "necessary", "for", "transforming", "one", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/distance/distance/_levenshtein.py#L6-L69
lrq3000/pyFileFixity
pyFileFixity/lib/distance/distance/_levenshtein.py
nlevenshtein
def nlevenshtein(seq1, seq2, method=1): """Compute the normalized Levenshtein distance between `seq1` and `seq2`. Two normalization methods are provided. For both of them, the normalized distance will be a float between 0 and 1, where 0 means equal and 1 completely different. The computation obeys the following p...
python
def nlevenshtein(seq1, seq2, method=1): """Compute the normalized Levenshtein distance between `seq1` and `seq2`. Two normalization methods are provided. For both of them, the normalized distance will be a float between 0 and 1, where 0 means equal and 1 completely different. The computation obeys the following p...
[ "def", "nlevenshtein", "(", "seq1", ",", "seq2", ",", "method", "=", "1", ")", ":", "if", "seq1", "==", "seq2", ":", "return", "0.0", "len1", ",", "len2", "=", "len", "(", "seq1", ")", ",", "len", "(", "seq2", ")", "if", "len1", "==", "0", "or"...
Compute the normalized Levenshtein distance between `seq1` and `seq2`. Two normalization methods are provided. For both of them, the normalized distance will be a float between 0 and 1, where 0 means equal and 1 completely different. The computation obeys the following patterns: 0.0 if se...
[ "Compute", "the", "normalized", "Levenshtein", "distance", "between", "seq1", "and", "seq2", ".", "Two", "normalization", "methods", "are", "provided", ".", "For", "both", "of", "them", "the", "normalized", "distance", "will", "be", "a", "float", "between", "0...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/distance/distance/_levenshtein.py#L72-L140
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/runsnakerun/pstatsadapter.py
PStatsAdapter.parents
def parents(self, node): """Determine all parents of node in our tree""" return [ parent for parent in getattr( node, 'parents', [] ) if getattr(parent, 'tree', self.TREE) == self.TREE ]
python
def parents(self, node): """Determine all parents of node in our tree""" return [ parent for parent in getattr( node, 'parents', [] ) if getattr(parent, 'tree', self.TREE) == self.TREE ]
[ "def", "parents", "(", "self", ",", "node", ")", ":", "return", "[", "parent", "for", "parent", "in", "getattr", "(", "node", ",", "'parents'", ",", "[", "]", ")", "if", "getattr", "(", "parent", ",", "'tree'", ",", "self", ".", "TREE", ")", "==", ...
Determine all parents of node in our tree
[ "Determine", "all", "parents", "of", "node", "in", "our", "tree" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/runsnakerun/pstatsadapter.py#L37-L43
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/runsnakerun/pstatsadapter.py
PStatsAdapter.filename
def filename( self, node ): """Extension to squaremap api to provide "what file is this" information""" if not node.directory: # TODO: any cases other than built-ins? return None if node.filename == '~': # TODO: look up C/Cython/whatever source??? ...
python
def filename( self, node ): """Extension to squaremap api to provide "what file is this" information""" if not node.directory: # TODO: any cases other than built-ins? return None if node.filename == '~': # TODO: look up C/Cython/whatever source??? ...
[ "def", "filename", "(", "self", ",", "node", ")", ":", "if", "not", "node", ".", "directory", ":", "# TODO: any cases other than built-ins?", "return", "None", "if", "node", ".", "filename", "==", "'~'", ":", "# TODO: look up C/Cython/whatever source???", "return", ...
Extension to squaremap api to provide "what file is this" information
[ "Extension", "to", "squaremap", "api", "to", "provide", "what", "file", "is", "this", "information" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/runsnakerun/pstatsadapter.py#L65-L73
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/web.py
get_ref
def get_ref(obj): """ Get string reference to object. Stores a weak reference in a dictionary using the object's id as the key. If the object cannot be weakly referenced (e.g. dictionaries, frame objects), store a strong references in a classic dictionary. Returns the object's id as a string. ...
python
def get_ref(obj): """ Get string reference to object. Stores a weak reference in a dictionary using the object's id as the key. If the object cannot be weakly referenced (e.g. dictionaries, frame objects), store a strong references in a classic dictionary. Returns the object's id as a string. ...
[ "def", "get_ref", "(", "obj", ")", ":", "oid", "=", "id", "(", "obj", ")", "try", ":", "server", ".", "id2ref", "[", "oid", "]", "=", "obj", "except", "TypeError", ":", "server", ".", "id2obj", "[", "oid", "]", "=", "obj", "return", "str", "(", ...
Get string reference to object. Stores a weak reference in a dictionary using the object's id as the key. If the object cannot be weakly referenced (e.g. dictionaries, frame objects), store a strong references in a classic dictionary. Returns the object's id as a string.
[ "Get", "string", "reference", "to", "object", ".", "Stores", "a", "weak", "reference", "in", "a", "dictionary", "using", "the", "object", "s", "id", "as", "the", "key", ".", "If", "the", "object", "cannot", "be", "weakly", "referenced", "(", "e", ".", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/web.py#L69-L83
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/web.py
get_obj
def get_obj(ref): """Get object from string reference.""" oid = int(ref) return server.id2ref.get(oid) or server.id2obj[oid]
python
def get_obj(ref): """Get object from string reference.""" oid = int(ref) return server.id2ref.get(oid) or server.id2obj[oid]
[ "def", "get_obj", "(", "ref", ")", ":", "oid", "=", "int", "(", "ref", ")", "return", "server", ".", "id2ref", ".", "get", "(", "oid", ")", "or", "server", ".", "id2obj", "[", "oid", "]" ]
Get object from string reference.
[ "Get", "object", "from", "string", "reference", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/web.py#L86-L89
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/web.py
process
def process(): """Get process overview.""" pmi = ProcessMemoryInfo() threads = get_current_threads() return dict(info=pmi, threads=threads)
python
def process(): """Get process overview.""" pmi = ProcessMemoryInfo() threads = get_current_threads() return dict(info=pmi, threads=threads)
[ "def", "process", "(", ")", ":", "pmi", "=", "ProcessMemoryInfo", "(", ")", "threads", "=", "get_current_threads", "(", ")", "return", "dict", "(", "info", "=", "pmi", ",", "threads", "=", "threads", ")" ]
Get process overview.
[ "Get", "process", "overview", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/web.py#L107-L111
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/web.py
tracker_index
def tracker_index(): """Get tracker overview.""" stats = server.stats if stats and stats.snapshots: stats.annotate() timeseries = [] for cls in stats.tracked_classes: series = [] for snapshot in stats.snapshots: series.append(snapshot.classes.g...
python
def tracker_index(): """Get tracker overview.""" stats = server.stats if stats and stats.snapshots: stats.annotate() timeseries = [] for cls in stats.tracked_classes: series = [] for snapshot in stats.snapshots: series.append(snapshot.classes.g...
[ "def", "tracker_index", "(", ")", ":", "stats", "=", "server", ".", "stats", "if", "stats", "and", "stats", ".", "snapshots", ":", "stats", ".", "annotate", "(", ")", "timeseries", "=", "[", "]", "for", "cls", "in", "stats", ".", "tracked_classes", ":"...
Get tracker overview.
[ "Get", "tracker", "overview", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/web.py#L116-L148
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/web.py
tracker_class
def tracker_class(clsname): """Get class instance details.""" stats = server.stats if not stats: bottle.redirect('/tracker') stats.annotate() return dict(stats=stats, clsname=clsname)
python
def tracker_class(clsname): """Get class instance details.""" stats = server.stats if not stats: bottle.redirect('/tracker') stats.annotate() return dict(stats=stats, clsname=clsname)
[ "def", "tracker_class", "(", "clsname", ")", ":", "stats", "=", "server", ".", "stats", "if", "not", "stats", ":", "bottle", ".", "redirect", "(", "'/tracker'", ")", "stats", ".", "annotate", "(", ")", "return", "dict", "(", "stats", "=", "stats", ",",...
Get class instance details.
[ "Get", "class", "instance", "details", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/web.py#L153-L159
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/web.py
garbage_cycle
def garbage_cycle(index): """Get reference cycle details.""" graph = _compute_garbage_graphs()[int(index)] graph.reduce_to_cycles() objects = graph.metadata objects.sort(key=lambda x: -x.size) return dict(objects=objects, index=index)
python
def garbage_cycle(index): """Get reference cycle details.""" graph = _compute_garbage_graphs()[int(index)] graph.reduce_to_cycles() objects = graph.metadata objects.sort(key=lambda x: -x.size) return dict(objects=objects, index=index)
[ "def", "garbage_cycle", "(", "index", ")", ":", "graph", "=", "_compute_garbage_graphs", "(", ")", "[", "int", "(", "index", ")", "]", "graph", ".", "reduce_to_cycles", "(", ")", "objects", "=", "graph", ".", "metadata", "objects", ".", "sort", "(", "key...
Get reference cycle details.
[ "Get", "reference", "cycle", "details", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/web.py#L224-L230
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/web.py
_get_graph
def _get_graph(graph, filename): """Retrieve or render a graph.""" try: rendered = graph.rendered_file except AttributeError: try: graph.render(os.path.join(server.tmpdir, filename), format='png') rendered = filename except OSError: rendered = None...
python
def _get_graph(graph, filename): """Retrieve or render a graph.""" try: rendered = graph.rendered_file except AttributeError: try: graph.render(os.path.join(server.tmpdir, filename), format='png') rendered = filename except OSError: rendered = None...
[ "def", "_get_graph", "(", "graph", ",", "filename", ")", ":", "try", ":", "rendered", "=", "graph", ".", "rendered_file", "except", "AttributeError", ":", "try", ":", "graph", ".", "render", "(", "os", ".", "path", ".", "join", "(", "server", ".", "tmp...
Retrieve or render a graph.
[ "Retrieve", "or", "render", "a", "graph", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/web.py#L233-L244
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/web.py
garbage_graph
def garbage_graph(index): """Get graph representation of reference cycle.""" graph = _compute_garbage_graphs()[int(index)] reduce_graph = bottle.request.GET.get('reduce', '') if reduce_graph: graph = graph.reduce_to_cycles() if not graph: return None filename = 'garbage%so%s.png'...
python
def garbage_graph(index): """Get graph representation of reference cycle.""" graph = _compute_garbage_graphs()[int(index)] reduce_graph = bottle.request.GET.get('reduce', '') if reduce_graph: graph = graph.reduce_to_cycles() if not graph: return None filename = 'garbage%so%s.png'...
[ "def", "garbage_graph", "(", "index", ")", ":", "graph", "=", "_compute_garbage_graphs", "(", ")", "[", "int", "(", "index", ")", "]", "reduce_graph", "=", "bottle", ".", "request", ".", "GET", ".", "get", "(", "'reduce'", ",", "''", ")", "if", "reduce...
Get graph representation of reference cycle.
[ "Get", "graph", "representation", "of", "reference", "cycle", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/web.py#L248-L261
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/web.py
start_profiler
def start_profiler(host='localhost', port=8090, tracker=None, stats=None, debug=False, **kwargs): """ Start the web server to show profiling data. The function suspends the Python application (the current thread) until the web server is stopped. The only way to stop the server is to ...
python
def start_profiler(host='localhost', port=8090, tracker=None, stats=None, debug=False, **kwargs): """ Start the web server to show profiling data. The function suspends the Python application (the current thread) until the web server is stopped. The only way to stop the server is to ...
[ "def", "start_profiler", "(", "host", "=", "'localhost'", ",", "port", "=", "8090", ",", "tracker", "=", "None", ",", "stats", "=", "None", ",", "debug", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "tracker", "and", "not", "stats", ":", ...
Start the web server to show profiling data. The function suspends the Python application (the current thread) until the web server is stopped. The only way to stop the server is to signal the running thread, e.g. press Ctrl+C in the console. If this isn't feasible for your application use `start_in_ba...
[ "Start", "the", "web", "server", "to", "show", "profiling", "data", ".", "The", "function", "suspends", "the", "Python", "application", "(", "the", "current", "thread", ")", "until", "the", "web", "server", "is", "stopped", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/web.py#L277-L310
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/runsnakerun/homedirectory.py
_winreg_getShellFolder
def _winreg_getShellFolder( name ): """Get a shell folder by string name from the registry""" k = _winreg.OpenKey( _winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" ) try: # should check that it's valid? How? return _winreg.Que...
python
def _winreg_getShellFolder( name ): """Get a shell folder by string name from the registry""" k = _winreg.OpenKey( _winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" ) try: # should check that it's valid? How? return _winreg.Que...
[ "def", "_winreg_getShellFolder", "(", "name", ")", ":", "k", "=", "_winreg", ".", "OpenKey", "(", "_winreg", ".", "HKEY_CURRENT_USER", ",", "r\"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\"", ")", "try", ":", "# should check that it's valid? How?", ...
Get a shell folder by string name from the registry
[ "Get", "a", "shell", "folder", "by", "string", "name", "from", "the", "registry" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/runsnakerun/homedirectory.py#L18-L28
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/runsnakerun/homedirectory.py
appdatadirectory
def appdatadirectory( ): """Attempt to retrieve the current user's app-data directory This is the location where application-specific files should be stored. On *nix systems, this will be the ${HOME}/.config directory. On Win32 systems, it will be the "Application Data" directory. Note that for...
python
def appdatadirectory( ): """Attempt to retrieve the current user's app-data directory This is the location where application-specific files should be stored. On *nix systems, this will be the ${HOME}/.config directory. On Win32 systems, it will be the "Application Data" directory. Note that for...
[ "def", "appdatadirectory", "(", ")", ":", "if", "shell", ":", "# on Win32 and have Win32all extensions, best-case", "return", "shell_getShellFolder", "(", "shellcon", ".", "CSIDL_APPDATA", ")", "if", "_winreg", ":", "# on Win32, but no Win32 shell com available, this uses", "...
Attempt to retrieve the current user's app-data directory This is the location where application-specific files should be stored. On *nix systems, this will be the ${HOME}/.config directory. On Win32 systems, it will be the "Application Data" directory. Note that for Win32 systems it is normal t...
[ "Attempt", "to", "retrieve", "the", "current", "user", "s", "app", "-", "data", "directory" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/runsnakerun/homedirectory.py#L40-L66
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/muppy.py
get_objects
def get_objects(remove_dups=True, include_frames=False): """Return a list of all known objects excluding frame objects. If (outer) frame objects shall be included, pass `include_frames=True`. In order to prevent building reference cycles, the current frame object (of the caller of get_objects) is igno...
python
def get_objects(remove_dups=True, include_frames=False): """Return a list of all known objects excluding frame objects. If (outer) frame objects shall be included, pass `include_frames=True`. In order to prevent building reference cycles, the current frame object (of the caller of get_objects) is igno...
[ "def", "get_objects", "(", "remove_dups", "=", "True", ",", "include_frames", "=", "False", ")", ":", "gc", ".", "collect", "(", ")", "# Do not initialize local variables before calling gc.get_objects or those", "# will be included in the list. Furthermore, ignore frame objects t...
Return a list of all known objects excluding frame objects. If (outer) frame objects shall be included, pass `include_frames=True`. In order to prevent building reference cycles, the current frame object (of the caller of get_objects) is ignored. This will not prevent creating reference cycles if the ...
[ "Return", "a", "list", "of", "all", "known", "objects", "excluding", "frame", "objects", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/muppy.py#L17-L55
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/muppy.py
get_size
def get_size(objects): """Compute the total size of all elements in objects.""" res = 0 for o in objects: try: res += _getsizeof(o) except AttributeError: print("IGNORING: type=%s; o=%s" % (str(type(o)), str(o))) return res
python
def get_size(objects): """Compute the total size of all elements in objects.""" res = 0 for o in objects: try: res += _getsizeof(o) except AttributeError: print("IGNORING: type=%s; o=%s" % (str(type(o)), str(o))) return res
[ "def", "get_size", "(", "objects", ")", ":", "res", "=", "0", "for", "o", "in", "objects", ":", "try", ":", "res", "+=", "_getsizeof", "(", "o", ")", "except", "AttributeError", ":", "print", "(", "\"IGNORING: type=%s; o=%s\"", "%", "(", "str", "(", "t...
Compute the total size of all elements in objects.
[ "Compute", "the", "total", "size", "of", "all", "elements", "in", "objects", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/muppy.py#L57-L65
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/muppy.py
get_diff
def get_diff(left, right): """Get the difference of both lists. The result will be a dict with this form {'+': [], '-': []}. Items listed in '+' exist only in the right list, items listed in '-' exist only in the left list. """ res = {'+': [], '-': []} def partition(objects): """P...
python
def get_diff(left, right): """Get the difference of both lists. The result will be a dict with this form {'+': [], '-': []}. Items listed in '+' exist only in the right list, items listed in '-' exist only in the left list. """ res = {'+': [], '-': []} def partition(objects): """P...
[ "def", "get_diff", "(", "left", ",", "right", ")", ":", "res", "=", "{", "'+'", ":", "[", "]", ",", "'-'", ":", "[", "]", "}", "def", "partition", "(", "objects", ")", ":", "\"\"\"Partition the passed object list.\"\"\"", "res", "=", "{", "}", "for", ...
Get the difference of both lists. The result will be a dict with this form {'+': [], '-': []}. Items listed in '+' exist only in the right list, items listed in '-' exist only in the left list.
[ "Get", "the", "difference", "of", "both", "lists", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/muppy.py#L67-L107
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/muppy.py
filter
def filter(objects, Type=None, min=-1, max=-1): #PYCHOK muppy filter """Filter objects. The filter can be by type, minimum size, and/or maximum size. Keyword arguments: Type -- object type to filter by min -- minimum object size max -- maximum object size """ res = [] if min > max...
python
def filter(objects, Type=None, min=-1, max=-1): #PYCHOK muppy filter """Filter objects. The filter can be by type, minimum size, and/or maximum size. Keyword arguments: Type -- object type to filter by min -- minimum object size max -- maximum object size """ res = [] if min > max...
[ "def", "filter", "(", "objects", ",", "Type", "=", "None", ",", "min", "=", "-", "1", ",", "max", "=", "-", "1", ")", ":", "#PYCHOK muppy filter", "res", "=", "[", "]", "if", "min", ">", "max", ":", "raise", "ValueError", "(", "\"minimum must be smal...
Filter objects. The filter can be by type, minimum size, and/or maximum size. Keyword arguments: Type -- object type to filter by min -- minimum object size max -- maximum object size
[ "Filter", "objects", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/muppy.py#L114-L134
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/muppy.py
get_referents
def get_referents(object, level=1): """Get all referents of an object up to a certain level. The referents will not be returned in a specific order and will not contain duplicate objects. Duplicate objects will be removed. Keyword arguments: level -- level of indirection to which referents conside...
python
def get_referents(object, level=1): """Get all referents of an object up to a certain level. The referents will not be returned in a specific order and will not contain duplicate objects. Duplicate objects will be removed. Keyword arguments: level -- level of indirection to which referents conside...
[ "def", "get_referents", "(", "object", ",", "level", "=", "1", ")", ":", "res", "=", "gc", ".", "get_referents", "(", "object", ")", "level", "-=", "1", "if", "level", ">", "0", ":", "for", "o", "in", "res", ":", "res", ".", "extend", "(", "get_r...
Get all referents of an object up to a certain level. The referents will not be returned in a specific order and will not contain duplicate objects. Duplicate objects will be removed. Keyword arguments: level -- level of indirection to which referents considered. This function is recursive.
[ "Get", "all", "referents", "of", "an", "object", "up", "to", "a", "certain", "level", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/muppy.py#L136-L154
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/muppy.py
_get_usage
def _get_usage(function, *args): """Test if more memory is used after the function has been called. The function will be invoked twice and only the second measurement will be considered. Thus, memory used in initialisation (e.g. loading modules) will not be included in the result. The goal is to identi...
python
def _get_usage(function, *args): """Test if more memory is used after the function has been called. The function will be invoked twice and only the second measurement will be considered. Thus, memory used in initialisation (e.g. loading modules) will not be included in the result. The goal is to identi...
[ "def", "_get_usage", "(", "function", ",", "*", "args", ")", ":", "# The usage of a function is calculated by creating one summary of all", "# objects before the function is invoked and afterwards. These summaries", "# are compared and the diff is returned.", "# This function works in a 2-st...
Test if more memory is used after the function has been called. The function will be invoked twice and only the second measurement will be considered. Thus, memory used in initialisation (e.g. loading modules) will not be included in the result. The goal is to identify memory leaks caused by functions ...
[ "Test", "if", "more", "memory", "is", "used", "after", "the", "function", "has", "been", "called", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/muppy.py#L156-L233
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/muppy.py
_remove_duplicates
def _remove_duplicates(objects): """Remove duplicate objects. Inspired by http://www.peterbe.com/plog/uniqifiers-benchmark """ seen = {} result = [] for item in objects: marker = id(item) if marker in seen: continue seen[marker] = 1 result.append(ite...
python
def _remove_duplicates(objects): """Remove duplicate objects. Inspired by http://www.peterbe.com/plog/uniqifiers-benchmark """ seen = {} result = [] for item in objects: marker = id(item) if marker in seen: continue seen[marker] = 1 result.append(ite...
[ "def", "_remove_duplicates", "(", "objects", ")", ":", "seen", "=", "{", "}", "result", "=", "[", "]", "for", "item", "in", "objects", ":", "marker", "=", "id", "(", "item", ")", "if", "marker", "in", "seen", ":", "continue", "seen", "[", "marker", ...
Remove duplicate objects. Inspired by http://www.peterbe.com/plog/uniqifiers-benchmark
[ "Remove", "duplicate", "objects", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/muppy.py#L242-L256
lrq3000/pyFileFixity
pyFileFixity/lib/gooey/gui/action_sorter.py
ActionSorter.get_optionals_without_choices
def get_optionals_without_choices(self, actions): """ All actions which are: (a) Optional, but without required choices (b) Not of a "boolean" type (storeTrue, etc..) (c) Of type _AppendAction e.g. anything which has an argument style like: >>> -f myfilename.txt """ boolean...
python
def get_optionals_without_choices(self, actions): """ All actions which are: (a) Optional, but without required choices (b) Not of a "boolean" type (storeTrue, etc..) (c) Of type _AppendAction e.g. anything which has an argument style like: >>> -f myfilename.txt """ boolean...
[ "def", "get_optionals_without_choices", "(", "self", ",", "actions", ")", ":", "boolean_actions", "=", "(", "_StoreConstAction", ",", "_StoreFalseAction", ",", "_StoreTrueAction", ")", "return", "[", "action", "for", "action", "in", "actions", "if", "action", ".",...
All actions which are: (a) Optional, but without required choices (b) Not of a "boolean" type (storeTrue, etc..) (c) Of type _AppendAction e.g. anything which has an argument style like: >>> -f myfilename.txt
[ "All", "actions", "which", "are", ":", "(", "a", ")", "Optional", "but", "without", "required", "choices", "(", "b", ")", "Not", "of", "a", "boolean", "type", "(", "storeTrue", "etc", "..", ")", "(", "c", ")", "Of", "type", "_AppendAction" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/gooey/gui/action_sorter.py#L91-L111
lrq3000/pyFileFixity
pyFileFixity/lib/gooey/gui/action_sorter.py
ActionSorter.get_flag_style_optionals
def get_flag_style_optionals(self, actions): """ Gets all instances of "flag" type options. i.e. options which either store a const, or store boolean style options (e.g. StoreTrue). Types: _StoreTrueAction _StoreFalseAction _StoreConst """ return [action for act...
python
def get_flag_style_optionals(self, actions): """ Gets all instances of "flag" type options. i.e. options which either store a const, or store boolean style options (e.g. StoreTrue). Types: _StoreTrueAction _StoreFalseAction _StoreConst """ return [action for act...
[ "def", "get_flag_style_optionals", "(", "self", ",", "actions", ")", ":", "return", "[", "action", "for", "action", "in", "actions", "if", "isinstance", "(", "action", ",", "_StoreTrueAction", ")", "or", "isinstance", "(", "action", ",", "_StoreFalseAction", "...
Gets all instances of "flag" type options. i.e. options which either store a const, or store boolean style options (e.g. StoreTrue). Types: _StoreTrueAction _StoreFalseAction _StoreConst
[ "Gets", "all", "instances", "of", "flag", "type", "options", ".", "i", ".", "e", ".", "options", "which", "either", "store", "a", "const", "or", "store", "boolean", "style", "options", "(", "e", ".", "g", ".", "StoreTrue", ")", ".", "Types", ":", "_S...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/gooey/gui/action_sorter.py#L122-L136
lrq3000/pyFileFixity
pyFileFixity/lib/gooey/gui/imageutil.py
resize_bitmap
def resize_bitmap(parent, _bitmap, target_height): ''' Resizes a bitmap to a height of 89 pixels (the size of the top panel), while keeping aspect ratio in tact ''' image = wx.ImageFromBitmap(_bitmap) _width, _height = image.GetSize() if _height < target_height: return wx.StaticBitmap(parent, -1, wx...
python
def resize_bitmap(parent, _bitmap, target_height): ''' Resizes a bitmap to a height of 89 pixels (the size of the top panel), while keeping aspect ratio in tact ''' image = wx.ImageFromBitmap(_bitmap) _width, _height = image.GetSize() if _height < target_height: return wx.StaticBitmap(parent, -1, wx...
[ "def", "resize_bitmap", "(", "parent", ",", "_bitmap", ",", "target_height", ")", ":", "image", "=", "wx", ".", "ImageFromBitmap", "(", "_bitmap", ")", "_width", ",", "_height", "=", "image", ".", "GetSize", "(", ")", "if", "_height", "<", "target_height",...
Resizes a bitmap to a height of 89 pixels (the size of the top panel), while keeping aspect ratio in tact
[ "Resizes", "a", "bitmap", "to", "a", "height", "of", "89", "pixels", "(", "the", "size", "of", "the", "top", "panel", ")", "while", "keeping", "aspect", "ratio", "in", "tact" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/gooey/gui/imageutil.py#L16-L28
lrq3000/pyFileFixity
pyFileFixity/lib/distance/distance/_iterators.py
ilevenshtein
def ilevenshtein(seq1, seqs, max_dist=-1): """Compute the Levenshtein distance between the sequence `seq1` and the series of sequences `seqs`. `seq1`: the reference sequence `seqs`: a series of sequences (can be a generator) `max_dist`: if provided and > 0, only the sequences which distance from the referen...
python
def ilevenshtein(seq1, seqs, max_dist=-1): """Compute the Levenshtein distance between the sequence `seq1` and the series of sequences `seqs`. `seq1`: the reference sequence `seqs`: a series of sequences (can be a generator) `max_dist`: if provided and > 0, only the sequences which distance from the referen...
[ "def", "ilevenshtein", "(", "seq1", ",", "seqs", ",", "max_dist", "=", "-", "1", ")", ":", "for", "seq2", "in", "seqs", ":", "dist", "=", "levenshtein", "(", "seq1", ",", "seq2", ",", "max_dist", "=", "max_dist", ")", "if", "dist", "!=", "-", "1", ...
Compute the Levenshtein distance between the sequence `seq1` and the series of sequences `seqs`. `seq1`: the reference sequence `seqs`: a series of sequences (can be a generator) `max_dist`: if provided and > 0, only the sequences which distance from the reference sequence is lower or equal to this value wil...
[ "Compute", "the", "Levenshtein", "distance", "between", "the", "sequence", "seq1", "and", "the", "series", "of", "sequences", "seqs", ".", "seq1", ":", "the", "reference", "sequence", "seqs", ":", "a", "series", "of", "sequences", "(", "can", "be", "a", "g...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/distance/distance/_iterators.py#L3-L21
lrq3000/pyFileFixity
pyFileFixity/lib/distance/distance/_iterators.py
ifast_comp
def ifast_comp(seq1, seqs, transpositions=False): """Return an iterator over all the sequences in `seqs` which distance from `seq1` is lower or equal to 2. The sequences which distance from the reference sequence is higher than that are dropped. `seq1`: the reference sequence. `seqs`: a series of sequences (ca...
python
def ifast_comp(seq1, seqs, transpositions=False): """Return an iterator over all the sequences in `seqs` which distance from `seq1` is lower or equal to 2. The sequences which distance from the reference sequence is higher than that are dropped. `seq1`: the reference sequence. `seqs`: a series of sequences (ca...
[ "def", "ifast_comp", "(", "seq1", ",", "seqs", ",", "transpositions", "=", "False", ")", ":", "for", "seq2", "in", "seqs", ":", "dist", "=", "fast_comp", "(", "seq1", ",", "seq2", ",", "transpositions", ")", "if", "dist", "!=", "-", "1", ":", "yield"...
Return an iterator over all the sequences in `seqs` which distance from `seq1` is lower or equal to 2. The sequences which distance from the reference sequence is higher than that are dropped. `seq1`: the reference sequence. `seqs`: a series of sequences (can be a generator) `transpositions` has the same sens...
[ "Return", "an", "iterator", "over", "all", "the", "sequences", "in", "seqs", "which", "distance", "from", "seq1", "is", "lower", "or", "equal", "to", "2", ".", "The", "sequences", "which", "distance", "from", "the", "reference", "sequence", "is", "higher", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/distance/distance/_iterators.py#L24-L45
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/summary.py
summarize
def summarize(objects): """Summarize an objects list. Return a list of lists, whereas each row consists of:: [str(type), number of objects of this type, total size of these objects]. No guarantee regarding the order is given. """ count = {} total_size = {} for o in objects: ...
python
def summarize(objects): """Summarize an objects list. Return a list of lists, whereas each row consists of:: [str(type), number of objects of this type, total size of these objects]. No guarantee regarding the order is given. """ count = {} total_size = {} for o in objects: ...
[ "def", "summarize", "(", "objects", ")", ":", "count", "=", "{", "}", "total_size", "=", "{", "}", "for", "o", "in", "objects", ":", "otype", "=", "_repr", "(", "o", ")", "if", "otype", "in", "count", ":", "count", "[", "otype", "]", "+=", "1", ...
Summarize an objects list. Return a list of lists, whereas each row consists of:: [str(type), number of objects of this type, total size of these objects]. No guarantee regarding the order is given.
[ "Summarize", "an", "objects", "list", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/summary.py#L112-L134
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/summary.py
get_diff
def get_diff(left, right): """Get the difference of two summaries. Subtracts the values of the right summary from the values of the left summary. If similar rows appear on both sides, the are included in the summary with 0 for number of elements and total size. If the number of elements of a ro...
python
def get_diff(left, right): """Get the difference of two summaries. Subtracts the values of the right summary from the values of the left summary. If similar rows appear on both sides, the are included in the summary with 0 for number of elements and total size. If the number of elements of a ro...
[ "def", "get_diff", "(", "left", ",", "right", ")", ":", "res", "=", "[", "]", "for", "row_r", "in", "right", ":", "found", "=", "False", "for", "row_l", "in", "left", ":", "if", "row_r", "[", "0", "]", "==", "row_l", "[", "0", "]", ":", "res", ...
Get the difference of two summaries. Subtracts the values of the right summary from the values of the left summary. If similar rows appear on both sides, the are included in the summary with 0 for number of elements and total size. If the number of elements of a row of the diff is 0, but the total ...
[ "Get", "the", "difference", "of", "two", "summaries", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/summary.py#L136-L165
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/summary.py
print_
def print_(rows, limit=15, sort='size', order='descending'): """Print the rows as a summary. Keyword arguments: limit -- the maximum number of elements to be listed sort -- sort elements by 'size', 'type', or '#' order -- sort 'ascending' or 'descending' """ localrows = [] for row in r...
python
def print_(rows, limit=15, sort='size', order='descending'): """Print the rows as a summary. Keyword arguments: limit -- the maximum number of elements to be listed sort -- sort elements by 'size', 'type', or '#' order -- sort 'ascending' or 'descending' """ localrows = [] for row in r...
[ "def", "print_", "(", "rows", ",", "limit", "=", "15", ",", "sort", "=", "'size'", ",", "order", "=", "'descending'", ")", ":", "localrows", "=", "[", "]", "for", "row", "in", "rows", ":", "localrows", ".", "append", "(", "list", "(", "row", ")", ...
Print the rows as a summary. Keyword arguments: limit -- the maximum number of elements to be listed sort -- sort elements by 'size', 'type', or '#' order -- sort 'ascending' or 'descending'
[ "Print", "the", "rows", "as", "a", "summary", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/summary.py#L167-L202
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/summary.py
_print_table
def _print_table(rows, header=True): """Print a list of lists as a pretty table. Keyword arguments: header -- if True the first row is treated as a table header inspired by http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/267662 """ border = "=" # vertical delimiter vdelim = " |...
python
def _print_table(rows, header=True): """Print a list of lists as a pretty table. Keyword arguments: header -- if True the first row is treated as a table header inspired by http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/267662 """ border = "=" # vertical delimiter vdelim = " |...
[ "def", "_print_table", "(", "rows", ",", "header", "=", "True", ")", ":", "border", "=", "\"=\"", "# vertical delimiter", "vdelim", "=", "\" | \"", "# padding nr. of spaces are left around the longest element in the", "# column", "padding", "=", "1", "# may be left,center...
Print a list of lists as a pretty table. Keyword arguments: header -- if True the first row is treated as a table header inspired by http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/267662
[ "Print", "a", "list", "of", "lists", "as", "a", "pretty", "table", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/summary.py#L204-L232
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/summary.py
_repr
def _repr(o, verbosity=1): """Get meaning object representation. This function should be used when the simple str(o) output would result in too general data. E.g. "<type 'instance'" is less meaningful than "instance: Foo". Keyword arguments: verbosity -- if True the first row is treated as a t...
python
def _repr(o, verbosity=1): """Get meaning object representation. This function should be used when the simple str(o) output would result in too general data. E.g. "<type 'instance'" is less meaningful than "instance: Foo". Keyword arguments: verbosity -- if True the first row is treated as a t...
[ "def", "_repr", "(", "o", ",", "verbosity", "=", "1", ")", ":", "res", "=", "\"\"", "t", "=", "type", "(", "o", ")", "if", "(", "verbosity", "==", "0", ")", "or", "(", "t", "not", "in", "representations", ")", ":", "res", "=", "str", "(", "t"...
Get meaning object representation. This function should be used when the simple str(o) output would result in too general data. E.g. "<type 'instance'" is less meaningful than "instance: Foo". Keyword arguments: verbosity -- if True the first row is treated as a table header
[ "Get", "meaning", "object", "representation", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/summary.py#L240-L266
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/summary.py
_traverse
def _traverse(summary, function, *args): """Traverse all objects of a summary and call function with each as a parameter. Using this function, the following objects will be traversed: - the summary - each row - each item of a row """ function(summary, *args) for row in summary: ...
python
def _traverse(summary, function, *args): """Traverse all objects of a summary and call function with each as a parameter. Using this function, the following objects will be traversed: - the summary - each row - each item of a row """ function(summary, *args) for row in summary: ...
[ "def", "_traverse", "(", "summary", ",", "function", ",", "*", "args", ")", ":", "function", "(", "summary", ",", "*", "args", ")", "for", "row", "in", "summary", ":", "function", "(", "row", ",", "*", "args", ")", "for", "item", "in", "row", ":", ...
Traverse all objects of a summary and call function with each as a parameter. Using this function, the following objects will be traversed: - the summary - each row - each item of a row
[ "Traverse", "all", "objects", "of", "a", "summary", "and", "call", "function", "with", "each", "as", "a", "parameter", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/summary.py#L268-L281
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/summary.py
_subtract
def _subtract(summary, o): """Remove object o from the summary by subtracting it's size.""" found = False row = [_repr(o), 1, _getsizeof(o)] for r in summary: if r[0] == row[0]: (r[1], r[2]) = (r[1] - row[1], r[2] - row[2]) found = True if not found: summary.a...
python
def _subtract(summary, o): """Remove object o from the summary by subtracting it's size.""" found = False row = [_repr(o), 1, _getsizeof(o)] for r in summary: if r[0] == row[0]: (r[1], r[2]) = (r[1] - row[1], r[2] - row[2]) found = True if not found: summary.a...
[ "def", "_subtract", "(", "summary", ",", "o", ")", ":", "found", "=", "False", "row", "=", "[", "_repr", "(", "o", ")", ",", "1", ",", "_getsizeof", "(", "o", ")", "]", "for", "r", "in", "summary", ":", "if", "r", "[", "0", "]", "==", "row", ...
Remove object o from the summary by subtracting it's size.
[ "Remove", "object", "o", "from", "the", "summary", "by", "subtracting", "it", "s", "size", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/summary.py#L283-L293
lrq3000/pyFileFixity
pyFileFixity/rfigc.py
check_structure
def check_structure(filepath): """Returns False if the file is okay, None if file format is unsupported by PIL/PILLOW, or returns an error string if the file is corrupt.""" #http://stackoverflow.com/questions/1401527/how-do-i-programmatically-check-whether-an-image-png-jpeg-or-gif-is-corrupted/1401565#1401565 ...
python
def check_structure(filepath): """Returns False if the file is okay, None if file format is unsupported by PIL/PILLOW, or returns an error string if the file is corrupt.""" #http://stackoverflow.com/questions/1401527/how-do-i-programmatically-check-whether-an-image-png-jpeg-or-gif-is-corrupted/1401565#1401565 ...
[ "def", "check_structure", "(", "filepath", ")", ":", "#http://stackoverflow.com/questions/1401527/how-do-i-programmatically-check-whether-an-image-png-jpeg-or-gif-is-corrupted/1401565#1401565", "# Check structure only for images (not supported for other types currently)", "if", "filepath", ".", ...
Returns False if the file is okay, None if file format is unsupported by PIL/PILLOW, or returns an error string if the file is corrupt.
[ "Returns", "False", "if", "the", "file", "is", "okay", "None", "if", "file", "format", "is", "unsupported", "by", "PIL", "/", "PILLOW", "or", "returns", "an", "error", "string", "if", "the", "file", "is", "corrupt", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/rfigc.py#L76-L96
lrq3000/pyFileFixity
pyFileFixity/rfigc.py
generate_hashes
def generate_hashes(filepath, blocksize=65536): '''Generate several hashes (md5 and sha1) in a single sweep of the file. Using two hashes lowers the probability of collision and false negative (file modified but the hash is the same). Supports big files by streaming blocks by blocks to the hasher automatically. Blo...
python
def generate_hashes(filepath, blocksize=65536): '''Generate several hashes (md5 and sha1) in a single sweep of the file. Using two hashes lowers the probability of collision and false negative (file modified but the hash is the same). Supports big files by streaming blocks by blocks to the hasher automatically. Blo...
[ "def", "generate_hashes", "(", "filepath", ",", "blocksize", "=", "65536", ")", ":", "# Init hashers", "hasher_md5", "=", "hashlib", ".", "md5", "(", ")", "hasher_sha1", "=", "hashlib", ".", "sha1", "(", ")", "# Read the file blocks by blocks", "with", "open", ...
Generate several hashes (md5 and sha1) in a single sweep of the file. Using two hashes lowers the probability of collision and false negative (file modified but the hash is the same). Supports big files by streaming blocks by blocks to the hasher automatically. Blocksize can be any multiple of 128.
[ "Generate", "several", "hashes", "(", "md5", "and", "sha1", ")", "in", "a", "single", "sweep", "of", "the", "file", ".", "Using", "two", "hashes", "lowers", "the", "probability", "of", "collision", "and", "false", "negative", "(", "file", "modified", "but"...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/rfigc.py#L98-L112
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/polynomial.py
Polynomial.get_degree
def get_degree(self, poly=None): '''Returns the degree of the polynomial''' if not poly: return self.degree #return len(self.coefficients) - 1 elif poly and hasattr("coefficients", poly): return len(poly.coefficients) - 1 else: while poly a...
python
def get_degree(self, poly=None): '''Returns the degree of the polynomial''' if not poly: return self.degree #return len(self.coefficients) - 1 elif poly and hasattr("coefficients", poly): return len(poly.coefficients) - 1 else: while poly a...
[ "def", "get_degree", "(", "self", ",", "poly", "=", "None", ")", ":", "if", "not", "poly", ":", "return", "self", ".", "degree", "#return len(self.coefficients) - 1", "elif", "poly", "and", "hasattr", "(", "\"coefficients\"", ",", "poly", ")", ":", "return",...
Returns the degree of the polynomial
[ "Returns", "the", "degree", "of", "the", "polynomial" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/polynomial.py#L87-L97
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/polynomial.py
Polynomial.mul_at
def mul_at(self, other, k): '''Compute the multiplication between two polynomials only at the specified coefficient (this is a lot cheaper than doing the full polynomial multiplication and then extract only the required coefficient)''' if k > (self.degree + other.degree) or k > self.degree: return 0 # o...
python
def mul_at(self, other, k): '''Compute the multiplication between two polynomials only at the specified coefficient (this is a lot cheaper than doing the full polynomial multiplication and then extract only the required coefficient)''' if k > (self.degree + other.degree) or k > self.degree: return 0 # o...
[ "def", "mul_at", "(", "self", ",", "other", ",", "k", ")", ":", "if", "k", ">", "(", "self", ".", "degree", "+", "other", ".", "degree", ")", "or", "k", ">", "self", ".", "degree", ":", "return", "0", "# optimization: if the required coefficient is above...
Compute the multiplication between two polynomials only at the specified coefficient (this is a lot cheaper than doing the full polynomial multiplication and then extract only the required coefficient)
[ "Compute", "the", "multiplication", "between", "two", "polynomials", "only", "at", "the", "specified", "coefficient", "(", "this", "is", "a", "lot", "cheaper", "than", "doing", "the", "full", "polynomial", "multiplication", "and", "then", "extract", "only", "the...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/polynomial.py#L132-L143
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/polynomial.py
Polynomial.scale
def scale(self, scalar): '''Multiply a polynomial with a scalar''' return self.__class__([self.coefficients[i] * scalar for i in _range(len(self))])
python
def scale(self, scalar): '''Multiply a polynomial with a scalar''' return self.__class__([self.coefficients[i] * scalar for i in _range(len(self))])
[ "def", "scale", "(", "self", ",", "scalar", ")", ":", "return", "self", ".", "__class__", "(", "[", "self", ".", "coefficients", "[", "i", "]", "*", "scalar", "for", "i", "in", "_range", "(", "len", "(", "self", ")", ")", "]", ")" ]
Multiply a polynomial with a scalar
[ "Multiply", "a", "polynomial", "with", "a", "scalar" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/polynomial.py#L145-L147
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/polynomial.py
Polynomial._fastdivmod
def _fastdivmod(dividend, divisor): '''Fast polynomial division by using Extended Synthetic Division (aka Horner's method). Also works with non-monic polynomials. A nearly exact same code is explained greatly here: http://research.swtch.com/field and you can also check the Wikipedia article and the Khan...
python
def _fastdivmod(dividend, divisor): '''Fast polynomial division by using Extended Synthetic Division (aka Horner's method). Also works with non-monic polynomials. A nearly exact same code is explained greatly here: http://research.swtch.com/field and you can also check the Wikipedia article and the Khan...
[ "def", "_fastdivmod", "(", "dividend", ",", "divisor", ")", ":", "# Note: for RS encoding, you should supply divisor = mprime (not m, you need the padded message)", "msg_out", "=", "list", "(", "dividend", ")", "# Copy the dividend", "normalizer", "=", "divisor", "[", "0", ...
Fast polynomial division by using Extended Synthetic Division (aka Horner's method). Also works with non-monic polynomials. A nearly exact same code is explained greatly here: http://research.swtch.com/field and you can also check the Wikipedia article and the Khan Academy video.
[ "Fast", "polynomial", "division", "by", "using", "Extended", "Synthetic", "Division", "(", "aka", "Horner", "s", "method", ")", ".", "Also", "works", "with", "non", "-", "monic", "polynomials", ".", "A", "nearly", "exact", "same", "code", "is", "explained", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/polynomial.py#L162-L178
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/polynomial.py
Polynomial._gffastdivmod
def _gffastdivmod(dividend, divisor): '''Fast polynomial division by using Extended Synthetic Division and optimized for GF(2^p) computations (so it is not generic, must be used with GF2int). Transposed from the reedsolomon library: https://github.com/tomerfiliba/reedsolomon BEWARE: it works onl...
python
def _gffastdivmod(dividend, divisor): '''Fast polynomial division by using Extended Synthetic Division and optimized for GF(2^p) computations (so it is not generic, must be used with GF2int). Transposed from the reedsolomon library: https://github.com/tomerfiliba/reedsolomon BEWARE: it works onl...
[ "def", "_gffastdivmod", "(", "dividend", ",", "divisor", ")", ":", "msg_out", "=", "list", "(", "dividend", ")", "# Copy the dividend list and pad with 0 where the ecc bytes will be computed", "for", "i", "in", "_range", "(", "len", "(", "dividend", ")", "-", "(", ...
Fast polynomial division by using Extended Synthetic Division and optimized for GF(2^p) computations (so it is not generic, must be used with GF2int). Transposed from the reedsolomon library: https://github.com/tomerfiliba/reedsolomon BEWARE: it works only for monic divisor polynomial! (which is always ...
[ "Fast", "polynomial", "division", "by", "using", "Extended", "Synthetic", "Division", "and", "optimized", "for", "GF", "(", "2^p", ")", "computations", "(", "so", "it", "is", "not", "generic", "must", "be", "used", "with", "GF2int", ")", ".", "Transposed", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/polynomial.py#L180-L196
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/polynomial.py
Polynomial.evaluate
def evaluate(self, x): '''Evaluate this polynomial at value x, returning the result (which is the sum of all evaluations at each term).''' # Holds the sum over each term in the polynomial #c = 0 # Holds the current power of x. This is multiplied by x after each term # in the pol...
python
def evaluate(self, x): '''Evaluate this polynomial at value x, returning the result (which is the sum of all evaluations at each term).''' # Holds the sum over each term in the polynomial #c = 0 # Holds the current power of x. This is multiplied by x after each term # in the pol...
[ "def", "evaluate", "(", "self", ",", "x", ")", ":", "# Holds the sum over each term in the polynomial", "#c = 0", "# Holds the current power of x. This is multiplied by x after each term", "# in the polynomial is added up. Initialized to x^0 = 1", "#p = 1", "#for term in self.coefficients[...
Evaluate this polynomial at value x, returning the result (which is the sum of all evaluations at each term).
[ "Evaluate", "this", "polynomial", "at", "value", "x", "returning", "the", "result", "(", "which", "is", "the", "sum", "of", "all", "evaluations", "at", "each", "term", ")", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/polynomial.py#L331-L349
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/polynomial.py
Polynomial.evaluate_array
def evaluate_array(self, x): '''Simple way of evaluating a polynomial at value x, but here we return both the full array (evaluated at each polynomial position) and the sum''' x_gf = self.coefficients[0].__class__(x) arr = [self.coefficients[-i]*x_gf**(i-1) for i in _range(len(self), 0, -1)] ...
python
def evaluate_array(self, x): '''Simple way of evaluating a polynomial at value x, but here we return both the full array (evaluated at each polynomial position) and the sum''' x_gf = self.coefficients[0].__class__(x) arr = [self.coefficients[-i]*x_gf**(i-1) for i in _range(len(self), 0, -1)] ...
[ "def", "evaluate_array", "(", "self", ",", "x", ")", ":", "x_gf", "=", "self", ".", "coefficients", "[", "0", "]", ".", "__class__", "(", "x", ")", "arr", "=", "[", "self", ".", "coefficients", "[", "-", "i", "]", "*", "x_gf", "**", "(", "i", "...
Simple way of evaluating a polynomial at value x, but here we return both the full array (evaluated at each polynomial position) and the sum
[ "Simple", "way", "of", "evaluating", "a", "polynomial", "at", "value", "x", "but", "here", "we", "return", "both", "the", "full", "array", "(", "evaluated", "at", "each", "polynomial", "position", ")", "and", "the", "sum" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/polynomial.py#L351-L356
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/polynomial.py
Polynomial.derive
def derive(self): '''Compute the formal derivative of the polynomial: sum(i*coeff[i] x^(i-1))''' #res = [0] * (len(self)-1) # pre-allocate the list, it will be one item shorter because the constant coefficient (x^0) will be removed #for i in _range(2, len(self)+1): # start at 2 to skip the first...
python
def derive(self): '''Compute the formal derivative of the polynomial: sum(i*coeff[i] x^(i-1))''' #res = [0] * (len(self)-1) # pre-allocate the list, it will be one item shorter because the constant coefficient (x^0) will be removed #for i in _range(2, len(self)+1): # start at 2 to skip the first...
[ "def", "derive", "(", "self", ")", ":", "#res = [0] * (len(self)-1) # pre-allocate the list, it will be one item shorter because the constant coefficient (x^0) will be removed", "#for i in _range(2, len(self)+1): # start at 2 to skip the first coeff which is useless since it's a constant (x^0) so we +...
Compute the formal derivative of the polynomial: sum(i*coeff[i] x^(i-1))
[ "Compute", "the", "formal", "derivative", "of", "the", "polynomial", ":", "sum", "(", "i", "*", "coeff", "[", "i", "]", "x^", "(", "i", "-", "1", "))" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/polynomial.py#L358-L369
lrq3000/pyFileFixity
pyFileFixity/structural_adaptive_ecc.py
feature_scaling
def feature_scaling(x, xmin, xmax, a=0, b=1): '''Generalized feature scaling (useful for variable error correction rate calculation)''' return a + float(x - xmin) * (b - a) / (xmax - xmin)
python
def feature_scaling(x, xmin, xmax, a=0, b=1): '''Generalized feature scaling (useful for variable error correction rate calculation)''' return a + float(x - xmin) * (b - a) / (xmax - xmin)
[ "def", "feature_scaling", "(", "x", ",", "xmin", ",", "xmax", ",", "a", "=", "0", ",", "b", "=", "1", ")", ":", "return", "a", "+", "float", "(", "x", "-", "xmin", ")", "*", "(", "b", "-", "a", ")", "/", "(", "xmax", "-", "xmin", ")" ]
Generalized feature scaling (useful for variable error correction rate calculation)
[ "Generalized", "feature", "scaling", "(", "useful", "for", "variable", "error", "correction", "rate", "calculation", ")" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/structural_adaptive_ecc.py#L91-L93
lrq3000/pyFileFixity
pyFileFixity/structural_adaptive_ecc.py
entry_fields
def entry_fields(file, entry_pos, field_delim="\xFF"): '''From an ecc entry position (a list with starting and ending positions), extract the metadata fields (filename, filesize, ecc for both), and the starting/ending positions of the ecc stream (containing variably encoded blocks of hash and ecc per blocks of the ...
python
def entry_fields(file, entry_pos, field_delim="\xFF"): '''From an ecc entry position (a list with starting and ending positions), extract the metadata fields (filename, filesize, ecc for both), and the starting/ending positions of the ecc stream (containing variably encoded blocks of hash and ecc per blocks of the ...
[ "def", "entry_fields", "(", "file", ",", "entry_pos", ",", "field_delim", "=", "\"\\xFF\"", ")", ":", "# Read the the beginning of the ecc entry", "blocksize", "=", "65535", "file", ".", "seek", "(", "entry_pos", "[", "0", "]", ")", "entry", "=", "file", ".", ...
From an ecc entry position (a list with starting and ending positions), extract the metadata fields (filename, filesize, ecc for both), and the starting/ending positions of the ecc stream (containing variably encoded blocks of hash and ecc per blocks of the original file's header)
[ "From", "an", "ecc", "entry", "position", "(", "a", "list", "with", "starting", "and", "ending", "positions", ")", "extract", "the", "metadata", "fields", "(", "filename", "filesize", "ecc", "for", "both", ")", "and", "the", "starting", "/", "ending", "pos...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/structural_adaptive_ecc.py#L97-L135
lrq3000/pyFileFixity
pyFileFixity/structural_adaptive_ecc.py
stream_entry_assemble
def stream_entry_assemble(hasher, file, eccfile, entry_fields, max_block_size, header_size, resilience_rates, constantmode=False): '''From an entry with its parameters (filename, filesize), assemble a list of each block from the original file along with the relative hash and ecc for easy processing later.''' # ...
python
def stream_entry_assemble(hasher, file, eccfile, entry_fields, max_block_size, header_size, resilience_rates, constantmode=False): '''From an entry with its parameters (filename, filesize), assemble a list of each block from the original file along with the relative hash and ecc for easy processing later.''' # ...
[ "def", "stream_entry_assemble", "(", "hasher", ",", "file", ",", "eccfile", ",", "entry_fields", ",", "max_block_size", ",", "header_size", ",", "resilience_rates", ",", "constantmode", "=", "False", ")", ":", "# Cut the header and the ecc entry into blocks, and then asse...
From an entry with its parameters (filename, filesize), assemble a list of each block from the original file along with the relative hash and ecc for easy processing later.
[ "From", "an", "entry", "with", "its", "parameters", "(", "filename", "filesize", ")", "assemble", "a", "list", "of", "each", "block", "from", "the", "original", "file", "along", "with", "the", "relative", "hash", "and", "ecc", "for", "easy", "processing", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/structural_adaptive_ecc.py#L137-L165
lrq3000/pyFileFixity
pyFileFixity/structural_adaptive_ecc.py
stream_compute_ecc_hash
def stream_compute_ecc_hash(ecc_manager, hasher, file, max_block_size, header_size, resilience_rates): '''Generate a stream of hash/ecc blocks, of variable encoding rate and size, given a file.''' curpos = file.tell() # init the reading cursor at the beginning of the file # Find the total size to know when ...
python
def stream_compute_ecc_hash(ecc_manager, hasher, file, max_block_size, header_size, resilience_rates): '''Generate a stream of hash/ecc blocks, of variable encoding rate and size, given a file.''' curpos = file.tell() # init the reading cursor at the beginning of the file # Find the total size to know when ...
[ "def", "stream_compute_ecc_hash", "(", "ecc_manager", ",", "hasher", ",", "file", ",", "max_block_size", ",", "header_size", ",", "resilience_rates", ")", ":", "curpos", "=", "file", ".", "tell", "(", ")", "# init the reading cursor at the beginning of the file", "# F...
Generate a stream of hash/ecc blocks, of variable encoding rate and size, given a file.
[ "Generate", "a", "stream", "of", "hash", "/", "ecc", "blocks", "of", "variable", "encoding", "rate", "and", "size", "given", "a", "file", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/structural_adaptive_ecc.py#L167-L196
lrq3000/pyFileFixity
pyFileFixity/structural_adaptive_ecc.py
compute_ecc_hash_from_string
def compute_ecc_hash_from_string(string, ecc_manager, hasher, max_block_size, resilience_rate): '''Generate a concatenated string of ecc stream of hash/ecc blocks, of constant encoding rate, given a string. NOTE: resilience_rate here is constant, you need to supply only one rate, between 0.0 and 1.0. The encodi...
python
def compute_ecc_hash_from_string(string, ecc_manager, hasher, max_block_size, resilience_rate): '''Generate a concatenated string of ecc stream of hash/ecc blocks, of constant encoding rate, given a string. NOTE: resilience_rate here is constant, you need to supply only one rate, between 0.0 and 1.0. The encodi...
[ "def", "compute_ecc_hash_from_string", "(", "string", ",", "ecc_manager", ",", "hasher", ",", "max_block_size", ",", "resilience_rate", ")", ":", "fpfile", "=", "StringIO", "(", "string", ")", "ecc_stream", "=", "''", ".", "join", "(", "[", "str", "(", "x", ...
Generate a concatenated string of ecc stream of hash/ecc blocks, of constant encoding rate, given a string. NOTE: resilience_rate here is constant, you need to supply only one rate, between 0.0 and 1.0. The encoding rate will then be constant, like in header_ecc.py.
[ "Generate", "a", "concatenated", "string", "of", "ecc", "stream", "of", "hash", "/", "ecc", "blocks", "of", "constant", "encoding", "rate", "given", "a", "string", ".", "NOTE", ":", "resilience_rate", "here", "is", "constant", "you", "need", "to", "supply", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/structural_adaptive_ecc.py#L198-L203
lrq3000/pyFileFixity
pyFileFixity/structural_adaptive_ecc.py
ecc_correct_intra_stream
def ecc_correct_intra_stream(ecc_manager_intra, ecc_params_intra, hasher_intra, resilience_rate_intra, field, ecc, enable_erasures=False, erasures_char="\x00", only_erasures=False, max_block_size=65535): """ Correct an intra-field with its corresponding intra-ecc if necessary """ # convert strings to StringIO o...
python
def ecc_correct_intra_stream(ecc_manager_intra, ecc_params_intra, hasher_intra, resilience_rate_intra, field, ecc, enable_erasures=False, erasures_char="\x00", only_erasures=False, max_block_size=65535): """ Correct an intra-field with its corresponding intra-ecc if necessary """ # convert strings to StringIO o...
[ "def", "ecc_correct_intra_stream", "(", "ecc_manager_intra", ",", "ecc_params_intra", ",", "hasher_intra", ",", "resilience_rate_intra", ",", "field", ",", "ecc", ",", "enable_erasures", "=", "False", ",", "erasures_char", "=", "\"\\x00\"", ",", "only_erasures", "=", ...
Correct an intra-field with its corresponding intra-ecc if necessary
[ "Correct", "an", "intra", "-", "field", "with", "its", "corresponding", "intra", "-", "ecc", "if", "necessary" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/structural_adaptive_ecc.py#L205-L240
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/memory_profiler.py
memory_usage
def memory_usage(proc=-1, interval=.1, timeout=None, run_in_place=False): """ Return the memory usage of a process or piece of code Parameters ---------- proc : {int, string, tuple}, optional The process to monitor. Can be given by a PID, by a string containing a filename or by a tu...
python
def memory_usage(proc=-1, interval=.1, timeout=None, run_in_place=False): """ Return the memory usage of a process or piece of code Parameters ---------- proc : {int, string, tuple}, optional The process to monitor. Can be given by a PID, by a string containing a filename or by a tu...
[ "def", "memory_usage", "(", "proc", "=", "-", "1", ",", "interval", "=", ".1", ",", "timeout", "=", "None", ",", "run_in_place", "=", "False", ")", ":", "ret", "=", "[", "]", "if", "timeout", "is", "not", "None", ":", "max_iter", "=", "timeout", "/...
Return the memory usage of a process or piece of code Parameters ---------- proc : {int, string, tuple}, optional The process to monitor. Can be given by a PID, by a string containing a filename or by a tuple. The tuple should contain three values (f, args, kw) specifies to run the ...
[ "Return", "the", "memory", "usage", "of", "a", "process", "or", "piece", "of", "code" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/memory_profiler.py#L49-L134
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/memory_profiler.py
_find_script
def _find_script(script_name): """ Find the script. If the input is not a file, then $PATH will be searched. """ if os.path.isfile(script_name): return script_name path = os.getenv('PATH', os.defpath).split(os.pathsep) for dir in path: if dir == '': continue ...
python
def _find_script(script_name): """ Find the script. If the input is not a file, then $PATH will be searched. """ if os.path.isfile(script_name): return script_name path = os.getenv('PATH', os.defpath).split(os.pathsep) for dir in path: if dir == '': continue ...
[ "def", "_find_script", "(", "script_name", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "script_name", ")", ":", "return", "script_name", "path", "=", "os", ".", "getenv", "(", "'PATH'", ",", "os", ".", "defpath", ")", ".", "split", "(", "o...
Find the script. If the input is not a file, then $PATH will be searched.
[ "Find", "the", "script", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/memory_profiler.py#L140-L156
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/memory_profiler.py
magic_memit
def magic_memit(self, line=''): """Measure memory usage of a Python statement Usage, in line mode: %memit [-ir<R>t<T>] statement Options: -r<R>: repeat the loop iteration <R> times and take the best result. Default: 1 -i: run the code in the current environment, without forking a new pr...
python
def magic_memit(self, line=''): """Measure memory usage of a Python statement Usage, in line mode: %memit [-ir<R>t<T>] statement Options: -r<R>: repeat the loop iteration <R> times and take the best result. Default: 1 -i: run the code in the current environment, without forking a new pr...
[ "def", "magic_memit", "(", "self", ",", "line", "=", "''", ")", ":", "opts", ",", "stmt", "=", "self", ".", "parse_options", "(", "line", ",", "'r:t:i'", ",", "posix", "=", "False", ",", "strict", "=", "False", ")", "repeat", "=", "int", "(", "geta...
Measure memory usage of a Python statement Usage, in line mode: %memit [-ir<R>t<T>] statement Options: -r<R>: repeat the loop iteration <R> times and take the best result. Default: 1 -i: run the code in the current environment, without forking a new process. This is required on some Mac...
[ "Measure", "memory", "usage", "of", "a", "Python", "statement" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/memory_profiler.py#L483-L538
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/memory_profiler.py
LineProfiler.add_function
def add_function(self, func): """ Record line profiling information for the given Python function. """ try: # func_code does not exist in Python3 code = func.__code__ except AttributeError: import warnings warnings.warn("Could not extract a...
python
def add_function(self, func): """ Record line profiling information for the given Python function. """ try: # func_code does not exist in Python3 code = func.__code__ except AttributeError: import warnings warnings.warn("Could not extract a...
[ "def", "add_function", "(", "self", ",", "func", ")", ":", "try", ":", "# func_code does not exist in Python3", "code", "=", "func", ".", "__code__", "except", "AttributeError", ":", "import", "warnings", "warnings", ".", "warn", "(", "\"Could not extract a code obj...
Record line profiling information for the given Python function.
[ "Record", "line", "profiling", "information", "for", "the", "given", "Python", "function", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/memory_profiler.py#L177-L190
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/memory_profiler.py
LineProfiler.wrap_function
def wrap_function(self, func): """ Wrap a function to profile it. """ def f(*args, **kwds): self.enable_by_count() try: result = func(*args, **kwds) finally: self.disable_by_count() return result return f
python
def wrap_function(self, func): """ Wrap a function to profile it. """ def f(*args, **kwds): self.enable_by_count() try: result = func(*args, **kwds) finally: self.disable_by_count() return result return f
[ "def", "wrap_function", "(", "self", ",", "func", ")", ":", "def", "f", "(", "*", "args", ",", "*", "*", "kwds", ")", ":", "self", ".", "enable_by_count", "(", ")", "try", ":", "result", "=", "func", "(", "*", "args", ",", "*", "*", "kwds", ")"...
Wrap a function to profile it.
[ "Wrap", "a", "function", "to", "profile", "it", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/memory_profiler.py#L192-L203
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/memory_profiler.py
LineProfiler.runctx
def runctx(self, cmd, globals, locals): """ Profile a single executable statement in the given namespaces. """ self.enable_by_count() try: exec(cmd, globals, locals) finally: self.disable_by_count() return self
python
def runctx(self, cmd, globals, locals): """ Profile a single executable statement in the given namespaces. """ self.enable_by_count() try: exec(cmd, globals, locals) finally: self.disable_by_count() return self
[ "def", "runctx", "(", "self", ",", "cmd", ",", "globals", ",", "locals", ")", ":", "self", ".", "enable_by_count", "(", ")", "try", ":", "exec", "(", "cmd", ",", "globals", ",", "locals", ")", "finally", ":", "self", ".", "disable_by_count", "(", ")"...
Profile a single executable statement in the given namespaces.
[ "Profile", "a", "single", "executable", "statement", "in", "the", "given", "namespaces", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/memory_profiler.py#L212-L220
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/memory_profiler.py
LineProfiler.runcall
def runcall(self, func, *args, **kw): """ Profile a single function call. """ # XXX where is this used ? can be removed ? self.enable_by_count() try: return func(*args, **kw) finally: self.disable_by_count()
python
def runcall(self, func, *args, **kw): """ Profile a single function call. """ # XXX where is this used ? can be removed ? self.enable_by_count() try: return func(*args, **kw) finally: self.disable_by_count()
[ "def", "runcall", "(", "self", ",", "func", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "# XXX where is this used ? can be removed ?", "self", ".", "enable_by_count", "(", ")", "try", ":", "return", "func", "(", "*", "args", ",", "*", "*", "kw", "...
Profile a single function call.
[ "Profile", "a", "single", "function", "call", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/memory_profiler.py#L222-L230
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/memory_profiler.py
LineProfiler.disable_by_count
def disable_by_count(self): """ Disable the profiler if the number of disable requests matches the number of enable requests. """ if self.enable_count > 0: self.enable_count -= 1 if self.enable_count == 0: self.disable()
python
def disable_by_count(self): """ Disable the profiler if the number of disable requests matches the number of enable requests. """ if self.enable_count > 0: self.enable_count -= 1 if self.enable_count == 0: self.disable()
[ "def", "disable_by_count", "(", "self", ")", ":", "if", "self", ".", "enable_count", ">", "0", ":", "self", ".", "enable_count", "-=", "1", "if", "self", ".", "enable_count", "==", "0", ":", "self", ".", "disable", "(", ")" ]
Disable the profiler if the number of disable requests matches the number of enable requests.
[ "Disable", "the", "profiler", "if", "the", "number", "of", "disable", "requests", "matches", "the", "number", "of", "enable", "requests", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/memory_profiler.py#L239-L246
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/memory_profiler.py
LineProfiler.trace_memory_usage
def trace_memory_usage(self, frame, event, arg): """Callback for sys.settrace""" if event in ('line', 'return') and frame.f_code in self.code_map: lineno = frame.f_lineno if event == 'return': lineno += 1 entry = self.code_map[frame.f_c...
python
def trace_memory_usage(self, frame, event, arg): """Callback for sys.settrace""" if event in ('line', 'return') and frame.f_code in self.code_map: lineno = frame.f_lineno if event == 'return': lineno += 1 entry = self.code_map[frame.f_c...
[ "def", "trace_memory_usage", "(", "self", ",", "frame", ",", "event", ",", "arg", ")", ":", "if", "event", "in", "(", "'line'", ",", "'return'", ")", "and", "frame", ".", "f_code", "in", "self", ".", "code_map", ":", "lineno", "=", "frame", ".", "f_l...
Callback for sys.settrace
[ "Callback", "for", "sys", ".", "settrace" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/memory_profiler.py#L248-L257
lrq3000/pyFileFixity
setup.py
parse_makefile_aliases
def parse_makefile_aliases(filepath): ''' Parse a makefile to find commands and substitute variables. Expects a makefile with only aliases and a line return between each command. Returns a dict, with a list of commands for each alias. ''' # -- Parsing the Makefile using ConfigParser # Addi...
python
def parse_makefile_aliases(filepath): ''' Parse a makefile to find commands and substitute variables. Expects a makefile with only aliases and a line return between each command. Returns a dict, with a list of commands for each alias. ''' # -- Parsing the Makefile using ConfigParser # Addi...
[ "def", "parse_makefile_aliases", "(", "filepath", ")", ":", "# -- Parsing the Makefile using ConfigParser", "# Adding a fake section to make the Makefile a valid Ini file", "ini_str", "=", "'[root]\\n'", "with", "open", "(", "filepath", ",", "'r'", ")", "as", "fd", ":", "in...
Parse a makefile to find commands and substitute variables. Expects a makefile with only aliases and a line return between each command. Returns a dict, with a list of commands for each alias.
[ "Parse", "a", "makefile", "to", "find", "commands", "and", "substitute", "variables", ".", "Expects", "a", "makefile", "with", "only", "aliases", "and", "a", "line", "return", "between", "each", "command", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/setup.py#L30-L101
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/kthread.py
KThread.start
def start(self): """Start the thread.""" self.__run_backup = self.run self.run = self.__run # Force the Thread to install our trace. threading.Thread.start(self)
python
def start(self): """Start the thread.""" self.__run_backup = self.run self.run = self.__run # Force the Thread to install our trace. threading.Thread.start(self)
[ "def", "start", "(", "self", ")", ":", "self", ".", "__run_backup", "=", "self", ".", "run", "self", ".", "run", "=", "self", ".", "__run", "# Force the Thread to install our trace.", "threading", ".", "Thread", ".", "start", "(", "self", ")" ]
Start the thread.
[ "Start", "the", "thread", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/kthread.py#L43-L47
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/kthread.py
KThread.__run
def __run(self): """Hacked run function, which installs the trace.""" sys.settrace(self.globaltrace) self.__run_backup() self.run = self.__run_backup
python
def __run(self): """Hacked run function, which installs the trace.""" sys.settrace(self.globaltrace) self.__run_backup() self.run = self.__run_backup
[ "def", "__run", "(", "self", ")", ":", "sys", ".", "settrace", "(", "self", ".", "globaltrace", ")", "self", ".", "__run_backup", "(", ")", "self", ".", "run", "=", "self", ".", "__run_backup" ]
Hacked run function, which installs the trace.
[ "Hacked", "run", "function", "which", "installs", "the", "trace", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/kthread.py#L49-L53
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/mprofile.py
MProfiler.codepoint_included
def codepoint_included(self, codepoint): """Check if codepoint matches any of the defined codepoints.""" if self.codepoints == None: return True for cp in self.codepoints: mismatch = False for i in range(len(cp)): if (cp[i] is not None) and (cp...
python
def codepoint_included(self, codepoint): """Check if codepoint matches any of the defined codepoints.""" if self.codepoints == None: return True for cp in self.codepoints: mismatch = False for i in range(len(cp)): if (cp[i] is not None) and (cp...
[ "def", "codepoint_included", "(", "self", ",", "codepoint", ")", ":", "if", "self", ".", "codepoints", "==", "None", ":", "return", "True", "for", "cp", "in", "self", ".", "codepoints", ":", "mismatch", "=", "False", "for", "i", "in", "range", "(", "le...
Check if codepoint matches any of the defined codepoints.
[ "Check", "if", "codepoint", "matches", "any", "of", "the", "defined", "codepoints", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/mprofile.py#L49-L61
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/mprofile.py
MProfiler.profile
def profile(self, frame, event, arg): #PYCHOK arg requ. to match signature """Profiling method used to profile matching codepoints and events.""" if (self.events == None) or (event in self.events): frame_info = inspect.getframeinfo(frame) cp = (frame_info[0], frame_info[2], frame...
python
def profile(self, frame, event, arg): #PYCHOK arg requ. to match signature """Profiling method used to profile matching codepoints and events.""" if (self.events == None) or (event in self.events): frame_info = inspect.getframeinfo(frame) cp = (frame_info[0], frame_info[2], frame...
[ "def", "profile", "(", "self", ",", "frame", ",", "event", ",", "arg", ")", ":", "#PYCHOK arg requ. to match signature", "if", "(", "self", ".", "events", "==", "None", ")", "or", "(", "event", "in", "self", ".", "events", ")", ":", "frame_info", "=", ...
Profiling method used to profile matching codepoints and events.
[ "Profiling", "method", "used", "to", "profile", "matching", "codepoints", "and", "events", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/mprofile.py#L63-L81
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/functionprofiler.py
runprofile
def runprofile(mainfunction, output, timeout = 0, calibrate=False): ''' Run the functions profiler and save the result If timeout is greater than 0, the profile will automatically stops after timeout seconds ''' if noprofiler == True: print('ERROR: profiler and/or pstats library missing ...
python
def runprofile(mainfunction, output, timeout = 0, calibrate=False): ''' Run the functions profiler and save the result If timeout is greater than 0, the profile will automatically stops after timeout seconds ''' if noprofiler == True: print('ERROR: profiler and/or pstats library missing ...
[ "def", "runprofile", "(", "mainfunction", ",", "output", ",", "timeout", "=", "0", ",", "calibrate", "=", "False", ")", ":", "if", "noprofiler", "==", "True", ":", "print", "(", "'ERROR: profiler and/or pstats library missing ! Please install it (probably package named ...
Run the functions profiler and save the result If timeout is greater than 0, the profile will automatically stops after timeout seconds
[ "Run", "the", "functions", "profiler", "and", "save", "the", "result", "If", "timeout", "is", "greater", "than", "0", "the", "profile", "will", "automatically", "stops", "after", "timeout", "seconds" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/functionprofiler.py#L52-L89
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/functionprofiler.py
calibrateprofile
def calibrateprofile(): ''' Calibrate the profiler (necessary to have non negative and more exact values) ''' pr = profile.Profile() calib = [] crepeat = 10 for i in range(crepeat): calib.append(pr.calibrate(10000)) final = sum(calib) / crepeat profile.Profile.bias = fina...
python
def calibrateprofile(): ''' Calibrate the profiler (necessary to have non negative and more exact values) ''' pr = profile.Profile() calib = [] crepeat = 10 for i in range(crepeat): calib.append(pr.calibrate(10000)) final = sum(calib) / crepeat profile.Profile.bias = fina...
[ "def", "calibrateprofile", "(", ")", ":", "pr", "=", "profile", ".", "Profile", "(", ")", "calib", "=", "[", "]", "crepeat", "=", "10", "for", "i", "in", "range", "(", "crepeat", ")", ":", "calib", ".", "append", "(", "pr", ".", "calibrate", "(", ...
Calibrate the profiler (necessary to have non negative and more exact values)
[ "Calibrate", "the", "profiler", "(", "necessary", "to", "have", "non", "negative", "and", "more", "exact", "values", ")" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/functionprofiler.py#L91-L102
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/functionprofiler.py
parseprofile
def parseprofile(profilelog, out): ''' Parse a profile log and print the result on screen ''' file = open(out, 'w') # opening the output file print('Opening the profile in %s...' % profilelog) p = pstats.Stats(profilelog, stream=file) # parsing the profile with pstats, and output everything to t...
python
def parseprofile(profilelog, out): ''' Parse a profile log and print the result on screen ''' file = open(out, 'w') # opening the output file print('Opening the profile in %s...' % profilelog) p = pstats.Stats(profilelog, stream=file) # parsing the profile with pstats, and output everything to t...
[ "def", "parseprofile", "(", "profilelog", ",", "out", ")", ":", "file", "=", "open", "(", "out", ",", "'w'", ")", "# opening the output file", "print", "(", "'Opening the profile in %s...'", "%", "profilelog", ")", "p", "=", "pstats", ".", "Stats", "(", "pro...
Parse a profile log and print the result on screen
[ "Parse", "a", "profile", "log", "and", "print", "the", "result", "on", "screen" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/functionprofiler.py#L104-L129
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/functionprofiler.py
browseprofile
def browseprofile(profilelog): ''' Browse interactively a profile log in console ''' print('Starting the pstats profile browser...\n') try: browser = ProfileBrowser(profilelog) print >> browser.stream, "Welcome to the profile statistics browser. Type help to get started." ...
python
def browseprofile(profilelog): ''' Browse interactively a profile log in console ''' print('Starting the pstats profile browser...\n') try: browser = ProfileBrowser(profilelog) print >> browser.stream, "Welcome to the profile statistics browser. Type help to get started." ...
[ "def", "browseprofile", "(", "profilelog", ")", ":", "print", "(", "'Starting the pstats profile browser...\\n'", ")", "try", ":", "browser", "=", "ProfileBrowser", "(", "profilelog", ")", "print", ">>", "browser", ".", "stream", ",", "\"Welcome to the profile statist...
Browse interactively a profile log in console
[ "Browse", "interactively", "a", "profile", "log", "in", "console" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/functionprofiler.py#L131-L142
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/functionprofiler.py
browseprofilegui
def browseprofilegui(profilelog): ''' Browse interactively a profile log in GUI using RunSnakeRun and SquareMap ''' from runsnakerun import runsnake # runsnakerun needs wxPython lib, if it's not available then we can pass if we don't want a GUI. RunSnakeRun is only used for GUI visualisation, not for pr...
python
def browseprofilegui(profilelog): ''' Browse interactively a profile log in GUI using RunSnakeRun and SquareMap ''' from runsnakerun import runsnake # runsnakerun needs wxPython lib, if it's not available then we can pass if we don't want a GUI. RunSnakeRun is only used for GUI visualisation, not for pr...
[ "def", "browseprofilegui", "(", "profilelog", ")", ":", "from", "runsnakerun", "import", "runsnake", "# runsnakerun needs wxPython lib, if it's not available then we can pass if we don't want a GUI. RunSnakeRun is only used for GUI visualisation, not for profiling (and you can still use pstats f...
Browse interactively a profile log in GUI using RunSnakeRun and SquareMap
[ "Browse", "interactively", "a", "profile", "log", "in", "GUI", "using", "RunSnakeRun", "and", "SquareMap" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/functionprofiler.py#L144-L152
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/ff.py
rwh_primes1
def rwh_primes1(n): # http://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188 ''' Returns a list of primes < n ''' sieve = [True] * (n/2) for i in _range(3,int(n**0.5)+1,2): if sieve[i/2]: sieve[i*i/2::i] = [False] * ((n-i*i-1)/(2*...
python
def rwh_primes1(n): # http://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188 ''' Returns a list of primes < n ''' sieve = [True] * (n/2) for i in _range(3,int(n**0.5)+1,2): if sieve[i/2]: sieve[i*i/2::i] = [False] * ((n-i*i-1)/(2*...
[ "def", "rwh_primes1", "(", "n", ")", ":", "# http://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188", "sieve", "=", "[", "True", "]", "*", "(", "n", "/", "2", ")", "for", "i", "in", "_range", "(", "3", ",", "int",...
Returns a list of primes < n
[ "Returns", "a", "list", "of", "primes", "<", "n" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/ff.py#L60-L67
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/ff.py
find_prime_polynomials
def find_prime_polynomials(generator=2, c_exp=8, fast_primes=False, single=False): '''Compute the list of prime polynomials for the given generator and galois field characteristic exponent.''' # fast_primes will output less results but will be significantly faster. # single will output the first prime polyn...
python
def find_prime_polynomials(generator=2, c_exp=8, fast_primes=False, single=False): '''Compute the list of prime polynomials for the given generator and galois field characteristic exponent.''' # fast_primes will output less results but will be significantly faster. # single will output the first prime polyn...
[ "def", "find_prime_polynomials", "(", "generator", "=", "2", ",", "c_exp", "=", "8", ",", "fast_primes", "=", "False", ",", "single", "=", "False", ")", ":", "# fast_primes will output less results but will be significantly faster.", "# single will output the first prime po...
Compute the list of prime polynomials for the given generator and galois field characteristic exponent.
[ "Compute", "the", "list", "of", "prime", "polynomials", "for", "the", "given", "generator", "and", "galois", "field", "characteristic", "exponent", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/ff.py#L69-L121
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/ff.py
init_lut
def init_lut(generator=3, prim=0x11b, c_exp=8): '''Precompute the logarithm and anti-log (look-up) tables for faster computation later, using the provided primitive polynomial. These tables are used for multiplication/division since addition/substraction are simple XOR operations inside GF of characteristic 2. ...
python
def init_lut(generator=3, prim=0x11b, c_exp=8): '''Precompute the logarithm and anti-log (look-up) tables for faster computation later, using the provided primitive polynomial. These tables are used for multiplication/division since addition/substraction are simple XOR operations inside GF of characteristic 2. ...
[ "def", "init_lut", "(", "generator", "=", "3", ",", "prim", "=", "0x11b", ",", "c_exp", "=", "8", ")", ":", "# generator is the generator number (the \"increment\" that will be used to walk through the field by multiplication, this must be a prime number). This is basically the base ...
Precompute the logarithm and anti-log (look-up) tables for faster computation later, using the provided primitive polynomial. These tables are used for multiplication/division since addition/substraction are simple XOR operations inside GF of characteristic 2. The basic idea is quite simple: since b**(log_b(x),...
[ "Precompute", "the", "logarithm", "and", "anti", "-", "log", "(", "look", "-", "up", ")", "tables", "for", "faster", "computation", "later", "using", "the", "provided", "primitive", "polynomial", ".", "These", "tables", "are", "used", "for", "multiplication", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/ff.py#L123-L159
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/ff.py
GF2int._to_binpoly
def _to_binpoly(x): '''Convert a Galois Field's number into a nice polynomial''' if x <= 0: return "0" b = 1 # init to 2^0 = 1 c = [] # stores the degrees of each term of the polynomials i = 0 # counter for b = 2^i while x > 0: b = (1 << i) # generate a number...
python
def _to_binpoly(x): '''Convert a Galois Field's number into a nice polynomial''' if x <= 0: return "0" b = 1 # init to 2^0 = 1 c = [] # stores the degrees of each term of the polynomials i = 0 # counter for b = 2^i while x > 0: b = (1 << i) # generate a number...
[ "def", "_to_binpoly", "(", "x", ")", ":", "if", "x", "<=", "0", ":", "return", "\"0\"", "b", "=", "1", "# init to 2^0 = 1", "c", "=", "[", "]", "# stores the degrees of each term of the polynomials", "i", "=", "0", "# counter for b = 2^i", "while", "x", ">", ...
Convert a Galois Field's number into a nice polynomial
[ "Convert", "a", "Galois", "Field", "s", "number", "into", "a", "nice", "polynomial" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/ff.py#L250-L263
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/ff.py
GF2int.multiply
def multiply(a, b, prim=0x11b, field_charac_full=256, carryless=True): '''A slow multiply method. This method gives the same results as the other __mul__ method but without needing precomputed tables, thus it can be used to generate those tables. If prim is set to 0 and carryless=False,...
python
def multiply(a, b, prim=0x11b, field_charac_full=256, carryless=True): '''A slow multiply method. This method gives the same results as the other __mul__ method but without needing precomputed tables, thus it can be used to generate those tables. If prim is set to 0 and carryless=False,...
[ "def", "multiply", "(", "a", ",", "b", ",", "prim", "=", "0x11b", ",", "field_charac_full", "=", "256", ",", "carryless", "=", "True", ")", ":", "r", "=", "0", "a", "=", "int", "(", "a", ")", "b", "=", "int", "(", "b", ")", "while", "b", ":",...
A slow multiply method. This method gives the same results as the other __mul__ method but without needing precomputed tables, thus it can be used to generate those tables. If prim is set to 0 and carryless=False, the function produces the result of a standard multiplication of integers (outsid...
[ "A", "slow", "multiply", "method", ".", "This", "method", "gives", "the", "same", "results", "as", "the", "other", "__mul__", "method", "but", "without", "needing", "precomputed", "tables", "thus", "it", "can", "be", "used", "to", "generate", "those", "table...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/ff.py#L265-L287
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/ff.py
GF2int.multiply_slow
def multiply_slow(x, y, prim=0x11b): '''Another equivalent (but even slower) way to compute multiplication in Galois Fields without using a precomputed look-up table. This is the form you will most often see in academic literature, by using the standard carry-less multiplication + modular reduction usin...
python
def multiply_slow(x, y, prim=0x11b): '''Another equivalent (but even slower) way to compute multiplication in Galois Fields without using a precomputed look-up table. This is the form you will most often see in academic literature, by using the standard carry-less multiplication + modular reduction usin...
[ "def", "multiply_slow", "(", "x", ",", "y", ",", "prim", "=", "0x11b", ")", ":", "### Define bitwise carry-less operations as inner functions ###", "def", "cl_mult", "(", "x", ",", "y", ")", ":", "'''Bitwise carry-less multiplication on integers'''", "z", "=", "0", ...
Another equivalent (but even slower) way to compute multiplication in Galois Fields without using a precomputed look-up table. This is the form you will most often see in academic literature, by using the standard carry-less multiplication + modular reduction using an irreducible prime polynomial.
[ "Another", "equivalent", "(", "but", "even", "slower", ")", "way", "to", "compute", "multiplication", "in", "Galois", "Fields", "without", "using", "a", "precomputed", "look", "-", "up", "table", ".", "This", "is", "the", "form", "you", "will", "most", "of...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/ff.py#L289-L334
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/runsnakerun/_meliaejson.py
loads
def loads( source ): """Load json structure from meliae from source Supports only the required structures to support loading meliae memory dumps """ source = source.strip() assert source.startswith( '{' ) assert source.endswith( '}' ) source = source[1:-1] result = {} for match ...
python
def loads( source ): """Load json structure from meliae from source Supports only the required structures to support loading meliae memory dumps """ source = source.strip() assert source.startswith( '{' ) assert source.endswith( '}' ) source = source[1:-1] result = {} for match ...
[ "def", "loads", "(", "source", ")", ":", "source", "=", "source", ".", "strip", "(", ")", "assert", "source", ".", "startswith", "(", "'{'", ")", "assert", "source", ".", "endswith", "(", "'}'", ")", "source", "=", "source", "[", "1", ":", "-", "1"...
Load json structure from meliae from source Supports only the required structures to support loading meliae memory dumps
[ "Load", "json", "structure", "from", "meliae", "from", "source", "Supports", "only", "the", "required", "structures", "to", "support", "loading", "meliae", "memory", "dumps" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/runsnakerun/_meliaejson.py#L40-L74
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/rs.py
RSCoder.encode
def encode(self, message, poly=False, k=None, return_string=True): '''Encode a given string or list of values (between 0 and gf2_charac) with reed-solomon encoding. Returns a list of values (or a string if return_string is true) with the k message bytes and n-k parity bytes at the end. ...
python
def encode(self, message, poly=False, k=None, return_string=True): '''Encode a given string or list of values (between 0 and gf2_charac) with reed-solomon encoding. Returns a list of values (or a string if return_string is true) with the k message bytes and n-k parity bytes at the end. ...
[ "def", "encode", "(", "self", ",", "message", ",", "poly", "=", "False", ",", "k", "=", "None", ",", "return_string", "=", "True", ")", ":", "n", "=", "self", ".", "n", "if", "not", "k", ":", "k", "=", "self", ".", "k", "if", "len", "(", "mes...
Encode a given string or list of values (between 0 and gf2_charac) with reed-solomon encoding. Returns a list of values (or a string if return_string is true) with the k message bytes and n-k parity bytes at the end. If a message is < k bytes long, it is assumed to be padded at the fron...
[ "Encode", "a", "given", "string", "or", "list", "of", "values", "(", "between", "0", "and", "gf2_charac", ")", "with", "reed", "-", "solomon", "encoding", ".", "Returns", "a", "list", "of", "values", "(", "or", "a", "string", "if", "return_string", "is",...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/rs.py#L115-L162
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/rs.py
RSCoder.check
def check(self, r, k=None): '''Verifies the codeword is valid by testing that the codeword (message+ecc) as a polynomial code divides g returns True/False ''' n = self.n if not k: k = self.k #h = self.h[k] g = self.g[k] # If we were given a string, conver...
python
def check(self, r, k=None): '''Verifies the codeword is valid by testing that the codeword (message+ecc) as a polynomial code divides g returns True/False ''' n = self.n if not k: k = self.k #h = self.h[k] g = self.g[k] # If we were given a string, conver...
[ "def", "check", "(", "self", ",", "r", ",", "k", "=", "None", ")", ":", "n", "=", "self", ".", "n", "if", "not", "k", ":", "k", "=", "self", ".", "k", "#h = self.h[k]", "g", "=", "self", ".", "g", "[", "k", "]", "# If we were given a string, conv...
Verifies the codeword is valid by testing that the codeword (message+ecc) as a polynomial code divides g returns True/False
[ "Verifies", "the", "codeword", "is", "valid", "by", "testing", "that", "the", "codeword", "(", "message", "+", "ecc", ")", "as", "a", "polynomial", "code", "divides", "g", "returns", "True", "/", "False" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/rs.py#L202-L223
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/rs.py
RSCoder.check_fast
def check_fast(self, r, k=None): '''Fast check if there's any error in a message+ecc. Can be used before decoding, in addition to hashes to detect if the message was tampered, or after decoding to check that the message was fully recovered. returns True/False ''' n = self.n if no...
python
def check_fast(self, r, k=None): '''Fast check if there's any error in a message+ecc. Can be used before decoding, in addition to hashes to detect if the message was tampered, or after decoding to check that the message was fully recovered. returns True/False ''' n = self.n if no...
[ "def", "check_fast", "(", "self", ",", "r", ",", "k", "=", "None", ")", ":", "n", "=", "self", ".", "n", "if", "not", "k", ":", "k", "=", "self", ".", "k", "#h = self.h[k]", "g", "=", "self", ".", "g", "[", "k", "]", "# If we were given a string,...
Fast check if there's any error in a message+ecc. Can be used before decoding, in addition to hashes to detect if the message was tampered, or after decoding to check that the message was fully recovered. returns True/False
[ "Fast", "check", "if", "there", "s", "any", "error", "in", "a", "message", "+", "ecc", ".", "Can", "be", "used", "before", "decoding", "in", "addition", "to", "hashes", "to", "detect", "if", "the", "message", "was", "tampered", "or", "after", "decoding",...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/rs.py#L225-L246