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/sortedcontainers/sortedset.py
SortedSet.add
def add(self, value): """Add the element *value* to the set.""" if value not in self._set: self._set.add(value) self._list.add(value)
python
def add(self, value): """Add the element *value* to the set.""" if value not in self._set: self._set.add(value) self._list.add(value)
[ "def", "add", "(", "self", ",", "value", ")", ":", "if", "value", "not", "in", "self", ".", "_set", ":", "self", ".", "_set", ".", "add", "(", "value", ")", "self", ".", "_list", ".", "add", "(", "value", ")" ]
Add the element *value* to the set.
[ "Add", "the", "element", "*", "value", "*", "to", "the", "set", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedset.py#L144-L148
lrq3000/pyFileFixity
pyFileFixity/lib/sortedcontainers/sortedset.py
SortedSet.copy
def copy(self): """Create a shallow copy of the sorted set.""" return self.__class__(key=self._key, load=self._load, _set=set(self._set))
python
def copy(self): """Create a shallow copy of the sorted set.""" return self.__class__(key=self._key, load=self._load, _set=set(self._set))
[ "def", "copy", "(", "self", ")", ":", "return", "self", ".", "__class__", "(", "key", "=", "self", ".", "_key", ",", "load", "=", "self", ".", "_load", ",", "_set", "=", "set", "(", "self", ".", "_set", ")", ")" ]
Create a shallow copy of the sorted set.
[ "Create", "a", "shallow", "copy", "of", "the", "sorted", "set", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedset.py#L155-L157
lrq3000/pyFileFixity
pyFileFixity/lib/sortedcontainers/sortedset.py
SortedSet.difference
def difference(self, *iterables): """ Return a new set with elements in the set that are not in the *iterables*. """ diff = self._set.difference(*iterables) new_set = self.__class__(key=self._key, load=self._load, _set=diff) return new_set
python
def difference(self, *iterables): """ Return a new set with elements in the set that are not in the *iterables*. """ diff = self._set.difference(*iterables) new_set = self.__class__(key=self._key, load=self._load, _set=diff) return new_set
[ "def", "difference", "(", "self", ",", "*", "iterables", ")", ":", "diff", "=", "self", ".", "_set", ".", "difference", "(", "*", "iterables", ")", "new_set", "=", "self", ".", "__class__", "(", "key", "=", "self", ".", "_key", ",", "load", "=", "s...
Return a new set with elements in the set that are not in the *iterables*.
[ "Return", "a", "new", "set", "with", "elements", "in", "the", "set", "that", "are", "not", "in", "the", "*", "iterables", "*", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedset.py#L192-L199
lrq3000/pyFileFixity
pyFileFixity/lib/sortedcontainers/sortedset.py
SortedSet.intersection
def intersection(self, *iterables): """ Return a new set with elements common to the set and all *iterables*. """ comb = self._set.intersection(*iterables) new_set = self.__class__(key=self._key, load=self._load, _set=comb) return new_set
python
def intersection(self, *iterables): """ Return a new set with elements common to the set and all *iterables*. """ comb = self._set.intersection(*iterables) new_set = self.__class__(key=self._key, load=self._load, _set=comb) return new_set
[ "def", "intersection", "(", "self", ",", "*", "iterables", ")", ":", "comb", "=", "self", ".", "_set", ".", "intersection", "(", "*", "iterables", ")", "new_set", "=", "self", ".", "__class__", "(", "key", "=", "self", ".", "_key", ",", "load", "=", ...
Return a new set with elements common to the set and all *iterables*.
[ "Return", "a", "new", "set", "with", "elements", "common", "to", "the", "set", "and", "all", "*", "iterables", "*", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedset.py#L222-L228
lrq3000/pyFileFixity
pyFileFixity/lib/sortedcontainers/sortedset.py
SortedSet.symmetric_difference
def symmetric_difference(self, that): """ Return a new set with elements in either *self* or *that* but not both. """ diff = self._set.symmetric_difference(that) new_set = self.__class__(key=self._key, load=self._load, _set=diff) return new_set
python
def symmetric_difference(self, that): """ Return a new set with elements in either *self* or *that* but not both. """ diff = self._set.symmetric_difference(that) new_set = self.__class__(key=self._key, load=self._load, _set=diff) return new_set
[ "def", "symmetric_difference", "(", "self", ",", "that", ")", ":", "diff", "=", "self", ".", "_set", ".", "symmetric_difference", "(", "that", ")", "new_set", "=", "self", ".", "__class__", "(", "key", "=", "self", ".", "_key", ",", "load", "=", "self"...
Return a new set with elements in either *self* or *that* but not both.
[ "Return", "a", "new", "set", "with", "elements", "in", "either", "*", "self", "*", "or", "*", "that", "*", "but", "not", "both", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedset.py#L244-L250
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py
cookie_decode
def cookie_decode(data, key): ''' Verify and decode an encoded string. Return an object or None''' if isinstance(data, unicode): data = data.encode('ascii') #2to3 hack if cookie_is_encoded(data): sig, msg = data.split(u'?'.encode('ascii'),1) #2to3 hack if sig[1:] == base64.b64encode(hmac.new...
python
def cookie_decode(data, key): ''' Verify and decode an encoded string. Return an object or None''' if isinstance(data, unicode): data = data.encode('ascii') #2to3 hack if cookie_is_encoded(data): sig, msg = data.split(u'?'.encode('ascii'),1) #2to3 hack if sig[1:] == base64.b64encode(hmac.new...
[ "def", "cookie_decode", "(", "data", ",", "key", ")", ":", "if", "isinstance", "(", "data", ",", "unicode", ")", ":", "data", "=", "data", ".", "encode", "(", "'ascii'", ")", "#2to3 hack", "if", "cookie_is_encoded", "(", "data", ")", ":", "sig", ",", ...
Verify and decode an encoded string. Return an object or None
[ "Verify", "and", "decode", "an", "encoded", "string", ".", "Return", "an", "object", "or", "None" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py#L1013-L1020
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py
cookie_is_encoded
def cookie_is_encoded(data): ''' Verify and decode an encoded string. Return an object or None''' return bool(data.startswith(u'!'.encode('ascii')) and u'?'.encode('ascii') in data)
python
def cookie_is_encoded(data): ''' Verify and decode an encoded string. Return an object or None''' return bool(data.startswith(u'!'.encode('ascii')) and u'?'.encode('ascii') in data)
[ "def", "cookie_is_encoded", "(", "data", ")", ":", "return", "bool", "(", "data", ".", "startswith", "(", "u'!'", ".", "encode", "(", "'ascii'", ")", ")", "and", "u'?'", ".", "encode", "(", "'ascii'", ")", "in", "data", ")" ]
Verify and decode an encoded string. Return an object or None
[ "Verify", "and", "decode", "an", "encoded", "string", ".", "Return", "an", "object", "or", "None" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py#L1023-L1025
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py
tonativefunc
def tonativefunc(enc='utf-8'): ''' Returns a function that turns everything into 'native' strings using enc ''' if sys.version_info >= (3,0,0): return lambda x: x.decode(enc) if isinstance(x, bytes) else str(x) return lambda x: x.encode(enc) if isinstance(x, unicode) else str(x)
python
def tonativefunc(enc='utf-8'): ''' Returns a function that turns everything into 'native' strings using enc ''' if sys.version_info >= (3,0,0): return lambda x: x.decode(enc) if isinstance(x, bytes) else str(x) return lambda x: x.encode(enc) if isinstance(x, unicode) else str(x)
[ "def", "tonativefunc", "(", "enc", "=", "'utf-8'", ")", ":", "if", "sys", ".", "version_info", ">=", "(", "3", ",", "0", ",", "0", ")", ":", "return", "lambda", "x", ":", "x", ".", "decode", "(", "enc", ")", "if", "isinstance", "(", "x", ",", "...
Returns a function that turns everything into 'native' strings using enc
[ "Returns", "a", "function", "that", "turns", "everything", "into", "native", "strings", "using", "enc" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py#L1028-L1032
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py
Router.add
def add(self, *a, **ka): """ Adds a route->target pair or a Route object to the Router. See Route() for details. """ route = a[0] if a and isinstance(a[0], Route) else Route(*a, **ka) self.routes.append(route) if route.name: self.named[route.name] = route....
python
def add(self, *a, **ka): """ Adds a route->target pair or a Route object to the Router. See Route() for details. """ route = a[0] if a and isinstance(a[0], Route) else Route(*a, **ka) self.routes.append(route) if route.name: self.named[route.name] = route....
[ "def", "add", "(", "self", ",", "*", "a", ",", "*", "*", "ka", ")", ":", "route", "=", "a", "[", "0", "]", "if", "a", "and", "isinstance", "(", "a", "[", "0", "]", ",", "Route", ")", "else", "Route", "(", "*", "a", ",", "*", "*", "ka", ...
Adds a route->target pair or a Route object to the Router. See Route() for details.
[ "Adds", "a", "route", "-", ">", "target", "pair", "or", "a", "Route", "object", "to", "the", "Router", ".", "See", "Route", "()", "for", "details", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py#L285-L306
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py
Bottle.mount
def mount(self, app, script_path): ''' Mount a Bottle application to a specific URL prefix ''' if not isinstance(app, Bottle): raise TypeError('Only Bottle instances are supported for now.') script_path = '/'.join(filter(None, script_path.split('/'))) path_depth = script_path...
python
def mount(self, app, script_path): ''' Mount a Bottle application to a specific URL prefix ''' if not isinstance(app, Bottle): raise TypeError('Only Bottle instances are supported for now.') script_path = '/'.join(filter(None, script_path.split('/'))) path_depth = script_path...
[ "def", "mount", "(", "self", ",", "app", ",", "script_path", ")", ":", "if", "not", "isinstance", "(", "app", ",", "Bottle", ")", ":", "raise", "TypeError", "(", "'Only Bottle instances are supported for now.'", ")", "script_path", "=", "'/'", ".", "join", "...
Mount a Bottle application to a specific URL prefix
[ "Mount", "a", "Bottle", "application", "to", "a", "specific", "URL", "prefix" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py#L354-L369
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py
Bottle.handle
def handle(self, url, method): """ Execute the handler bound to the specified url and method and return its output. If catchall is true, exceptions are catched and returned as HTTPError(500) objects. """ if not self.serve: return HTTPError(503, "Server stopped") hand...
python
def handle(self, url, method): """ Execute the handler bound to the specified url and method and return its output. If catchall is true, exceptions are catched and returned as HTTPError(500) objects. """ if not self.serve: return HTTPError(503, "Server stopped") hand...
[ "def", "handle", "(", "self", ",", "url", ",", "method", ")", ":", "if", "not", "self", ".", "serve", ":", "return", "HTTPError", "(", "503", ",", "\"Server stopped\"", ")", "handler", ",", "args", "=", "self", ".", "match_url", "(", "url", ",", "met...
Execute the handler bound to the specified url and method and return its output. If catchall is true, exceptions are catched and returned as HTTPError(500) objects.
[ "Execute", "the", "handler", "bound", "to", "the", "specified", "url", "and", "method", "and", "return", "its", "output", ".", "If", "catchall", "is", "true", "exceptions", "are", "catched", "and", "returned", "as", "HTTPError", "(", "500", ")", "objects", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py#L429-L448
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py
Bottle._cast
def _cast(self, out, request, response, peek=None): """ Try to convert the parameter into something WSGI compatible and set correct HTTP headers when possible. Support: False, str, unicode, dict, HTTPResponse, HTTPError, file-like, iterable of strings and iterable of unicodes """...
python
def _cast(self, out, request, response, peek=None): """ Try to convert the parameter into something WSGI compatible and set correct HTTP headers when possible. Support: False, str, unicode, dict, HTTPResponse, HTTPError, file-like, iterable of strings and iterable of unicodes """...
[ "def", "_cast", "(", "self", ",", "out", ",", "request", ",", "response", ",", "peek", "=", "None", ")", ":", "# Filtered types (recursive, because they may return anything)", "for", "testtype", ",", "filterfunc", "in", "self", ".", "castfilter", ":", "if", "isi...
Try to convert the parameter into something WSGI compatible and set correct HTTP headers when possible. Support: False, str, unicode, dict, HTTPResponse, HTTPError, file-like, iterable of strings and iterable of unicodes
[ "Try", "to", "convert", "the", "parameter", "into", "something", "WSGI", "compatible", "and", "set", "correct", "HTTP", "headers", "when", "possible", ".", "Support", ":", "False", "str", "unicode", "dict", "HTTPResponse", "HTTPError", "file", "-", "like", "it...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py#L450-L512
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py
Request.header
def header(self): ''' :class:`HeaderDict` filled with request headers. HeaderDict keys are case insensitive str.title()d ''' if self._header is None: self._header = HeaderDict() for key, value in self.environ.iteritems(): if key.startswith('HT...
python
def header(self): ''' :class:`HeaderDict` filled with request headers. HeaderDict keys are case insensitive str.title()d ''' if self._header is None: self._header = HeaderDict() for key, value in self.environ.iteritems(): if key.startswith('HT...
[ "def", "header", "(", "self", ")", ":", "if", "self", ".", "_header", "is", "None", ":", "self", ".", "_header", "=", "HeaderDict", "(", ")", "for", "key", ",", "value", "in", "self", ".", "environ", ".", "iteritems", "(", ")", ":", "if", "key", ...
:class:`HeaderDict` filled with request headers. HeaderDict keys are case insensitive str.title()d
[ ":", "class", ":", "HeaderDict", "filled", "with", "request", "headers", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py#L647-L658
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py
Request.GET
def GET(self): """ The QUERY_STRING parsed into a MultiDict. Keys and values are strings. Multiple values per key are possible. See MultiDict for details. """ if self._GET is None: data = parse_qs(self.query_string, keep_blank_values=True) self._G...
python
def GET(self): """ The QUERY_STRING parsed into a MultiDict. Keys and values are strings. Multiple values per key are possible. See MultiDict for details. """ if self._GET is None: data = parse_qs(self.query_string, keep_blank_values=True) self._G...
[ "def", "GET", "(", "self", ")", ":", "if", "self", ".", "_GET", "is", "None", ":", "data", "=", "parse_qs", "(", "self", ".", "query_string", ",", "keep_blank_values", "=", "True", ")", "self", ".", "_GET", "=", "MultiDict", "(", ")", "for", "key", ...
The QUERY_STRING parsed into a MultiDict. Keys and values are strings. Multiple values per key are possible. See MultiDict for details.
[ "The", "QUERY_STRING", "parsed", "into", "a", "MultiDict", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py#L661-L673
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py
Request.COOKIES
def COOKIES(self): """ Cookie information parsed into a dictionary. Secure cookies are NOT decoded automatically. See Request.get_cookie() for details. """ if self._COOKIES is None: raw_dict = SimpleCookie(self.environ.get('HTTP_COOKIE','')) self....
python
def COOKIES(self): """ Cookie information parsed into a dictionary. Secure cookies are NOT decoded automatically. See Request.get_cookie() for details. """ if self._COOKIES is None: raw_dict = SimpleCookie(self.environ.get('HTTP_COOKIE','')) self....
[ "def", "COOKIES", "(", "self", ")", ":", "if", "self", ".", "_COOKIES", "is", "None", ":", "raw_dict", "=", "SimpleCookie", "(", "self", ".", "environ", ".", "get", "(", "'HTTP_COOKIE'", ",", "''", ")", ")", "self", ".", "_COOKIES", "=", "{", "}", ...
Cookie information parsed into a dictionary. Secure cookies are NOT decoded automatically. See Request.get_cookie() for details.
[ "Cookie", "information", "parsed", "into", "a", "dictionary", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py#L740-L751
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py
Response.set_cookie
def set_cookie(self, key, value, **kargs): """ Add a new cookie with various options. If the cookie value is not a string, a secure cookie is created. Possible options are: expires, path, comment, domain, max_age, secure, version, httponly See http://de.wikipedia.org/wi...
python
def set_cookie(self, key, value, **kargs): """ Add a new cookie with various options. If the cookie value is not a string, a secure cookie is created. Possible options are: expires, path, comment, domain, max_age, secure, version, httponly See http://de.wikipedia.org/wi...
[ "def", "set_cookie", "(", "self", ",", "key", ",", "value", ",", "*", "*", "kargs", ")", ":", "if", "not", "isinstance", "(", "value", ",", "basestring", ")", ":", "sec", "=", "self", ".", "app", ".", "config", "[", "'securecookie.key'", "]", "value"...
Add a new cookie with various options. If the cookie value is not a string, a secure cookie is created. Possible options are: expires, path, comment, domain, max_age, secure, version, httponly See http://de.wikipedia.org/wiki/HTTP-Cookie#Aufbau for details
[ "Add", "a", "new", "cookie", "with", "various", "options", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/util/bottle2.py#L809-L823
lrq3000/pyFileFixity
pyFileFixity/filetamper.py
tamper_file_at
def tamper_file_at(path, pos=0, replace_str=None): """ Tamper a file at the given position and using the given string """ if not replace_str: replace_str = "\x00" try: with open(path, "r+b") as fh: if pos < 0: # if negative, we calculate the position backward from the end of file...
python
def tamper_file_at(path, pos=0, replace_str=None): """ Tamper a file at the given position and using the given string """ if not replace_str: replace_str = "\x00" try: with open(path, "r+b") as fh: if pos < 0: # if negative, we calculate the position backward from the end of file...
[ "def", "tamper_file_at", "(", "path", ",", "pos", "=", "0", ",", "replace_str", "=", "None", ")", ":", "if", "not", "replace_str", ":", "replace_str", "=", "\"\\x00\"", "try", ":", "with", "open", "(", "path", ",", "\"r+b\"", ")", "as", "fh", ":", "i...
Tamper a file at the given position and using the given string
[ "Tamper", "a", "file", "at", "the", "given", "position", "and", "using", "the", "given", "string" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/filetamper.py#L58-L76
lrq3000/pyFileFixity
pyFileFixity/filetamper.py
tamper_file
def tamper_file(filepath, mode='e', proba=0.03, block_proba=None, blocksize=65535, burst_length=None, header=None): """ Randomly tamper a file's content """ if header and header > 0: blocksize = header tamper_count = 0 # total number of characters tampered in the file total_size = 0 # total buf...
python
def tamper_file(filepath, mode='e', proba=0.03, block_proba=None, blocksize=65535, burst_length=None, header=None): """ Randomly tamper a file's content """ if header and header > 0: blocksize = header tamper_count = 0 # total number of characters tampered in the file total_size = 0 # total buf...
[ "def", "tamper_file", "(", "filepath", ",", "mode", "=", "'e'", ",", "proba", "=", "0.03", ",", "block_proba", "=", "None", ",", "blocksize", "=", "65535", ",", "burst_length", "=", "None", ",", "header", "=", "None", ")", ":", "if", "header", "and", ...
Randomly tamper a file's content
[ "Randomly", "tamper", "a", "file", "s", "content" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/filetamper.py#L78-L124
lrq3000/pyFileFixity
pyFileFixity/filetamper.py
tamper_dir
def tamper_dir(inputpath, *args, **kwargs): """ Randomly tamper the files content in a directory tree, recursively """ silent = kwargs.get('silent', False) if 'silent' in kwargs: del kwargs['silent'] filescount = 0 for _ in tqdm(recwalk(inputpath), desc='Precomputing', disable=silent): file...
python
def tamper_dir(inputpath, *args, **kwargs): """ Randomly tamper the files content in a directory tree, recursively """ silent = kwargs.get('silent', False) if 'silent' in kwargs: del kwargs['silent'] filescount = 0 for _ in tqdm(recwalk(inputpath), desc='Precomputing', disable=silent): file...
[ "def", "tamper_dir", "(", "inputpath", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "silent", "=", "kwargs", ".", "get", "(", "'silent'", ",", "False", ")", "if", "'silent'", "in", "kwargs", ":", "del", "kwargs", "[", "'silent'", "]", "filesc...
Randomly tamper the files content in a directory tree, recursively
[ "Randomly", "tamper", "the", "files", "content", "in", "a", "directory", "tree", "recursively" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/filetamper.py#L126-L144
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
TrackedObject._save_trace
def _save_trace(self): """ Save current stack trace as formatted string. """ stack_trace = stack() try: self.trace = [] for frm in stack_trace[5:]: # eliminate our own overhead self.trace.insert(0, frm[1:]) finally: del ...
python
def _save_trace(self): """ Save current stack trace as formatted string. """ stack_trace = stack() try: self.trace = [] for frm in stack_trace[5:]: # eliminate our own overhead self.trace.insert(0, frm[1:]) finally: del ...
[ "def", "_save_trace", "(", "self", ")", ":", "stack_trace", "=", "stack", "(", ")", "try", ":", "self", ".", "trace", "=", "[", "]", "for", "frm", "in", "stack_trace", "[", "5", ":", "]", ":", "# eliminate our own overhead", "self", ".", "trace", ".", ...
Save current stack trace as formatted string.
[ "Save", "current", "stack", "trace", "as", "formatted", "string", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L110-L120
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
TrackedObject.track_size
def track_size(self, ts, sizer): """ Store timestamp and current size for later evaluation. The 'sizer' is a stateful sizing facility that excludes other tracked objects. """ obj = self.ref() self.snapshots.append( (ts, sizer.asized(obj, detail=self._r...
python
def track_size(self, ts, sizer): """ Store timestamp and current size for later evaluation. The 'sizer' is a stateful sizing facility that excludes other tracked objects. """ obj = self.ref() self.snapshots.append( (ts, sizer.asized(obj, detail=self._r...
[ "def", "track_size", "(", "self", ",", "ts", ",", "sizer", ")", ":", "obj", "=", "self", ".", "ref", "(", ")", "self", ".", "snapshots", ".", "append", "(", "(", "ts", ",", "sizer", ".", "asized", "(", "obj", ",", "detail", "=", "self", ".", "_...
Store timestamp and current size for later evaluation. The 'sizer' is a stateful sizing facility that excludes other tracked objects.
[ "Store", "timestamp", "and", "current", "size", "for", "later", "evaluation", ".", "The", "sizer", "is", "a", "stateful", "sizing", "facility", "that", "excludes", "other", "tracked", "objects", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L122-L133
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
TrackedObject.get_size_at_time
def get_size_at_time(self, timestamp): """ Get the size of the object at a specific time (snapshot). If the object was not alive/sized at that instant, return 0. """ size = 0 for (t, s) in self.snapshots: if t == timestamp: size = s.size ...
python
def get_size_at_time(self, timestamp): """ Get the size of the object at a specific time (snapshot). If the object was not alive/sized at that instant, return 0. """ size = 0 for (t, s) in self.snapshots: if t == timestamp: size = s.size ...
[ "def", "get_size_at_time", "(", "self", ",", "timestamp", ")", ":", "size", "=", "0", "for", "(", "t", ",", "s", ")", "in", "self", ".", "snapshots", ":", "if", "t", "==", "timestamp", ":", "size", "=", "s", ".", "size", "return", "size" ]
Get the size of the object at a specific time (snapshot). If the object was not alive/sized at that instant, return 0.
[ "Get", "the", "size", "of", "the", "object", "at", "a", "specific", "time", "(", "snapshot", ")", ".", "If", "the", "object", "was", "not", "alive", "/", "sized", "at", "that", "instant", "return", "0", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L141-L150
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
PeriodicThread.run
def run(self): """ Loop until a stop signal is set. """ self.stop = False while not self.stop: self.tracker.create_snapshot() sleep(self.interval)
python
def run(self): """ Loop until a stop signal is set. """ self.stop = False while not self.stop: self.tracker.create_snapshot() sleep(self.interval)
[ "def", "run", "(", "self", ")", ":", "self", ".", "stop", "=", "False", "while", "not", "self", ".", "stop", ":", "self", ".", "tracker", ".", "create_snapshot", "(", ")", "sleep", "(", "self", ".", "interval", ")" ]
Loop until a stop signal is set.
[ "Loop", "until", "a", "stop", "signal", "is", "set", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L193-L200
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
Snapshot.total
def total(self): """ Return the total (virtual) size of the process in bytes. If process information is not available, get the best number available, even if it is a poor approximation of reality. """ if self.system_total.available: return self.system_total.vs...
python
def total(self): """ Return the total (virtual) size of the process in bytes. If process information is not available, get the best number available, even if it is a poor approximation of reality. """ if self.system_total.available: return self.system_total.vs...
[ "def", "total", "(", "self", ")", ":", "if", "self", ".", "system_total", ".", "available", ":", "return", "self", ".", "system_total", ".", "vsz", "elif", "self", ".", "asizeof_total", ":", "# pragma: no cover", "return", "self", ".", "asizeof_total", "else...
Return the total (virtual) size of the process in bytes. If process information is not available, get the best number available, even if it is a poor approximation of reality.
[ "Return", "the", "total", "(", "virtual", ")", "size", "of", "the", "process", "in", "bytes", ".", "If", "process", "information", "is", "not", "available", "get", "the", "best", "number", "available", "even", "if", "it", "is", "a", "poor", "approximation"...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L217-L228
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
Snapshot.label
def label(self): """Return timestamped label for this snapshot, or a raw timestamp.""" if not self.desc: return "%.3fs" % self.timestamp return "%s (%.3fs)" % (self.desc, self.timestamp)
python
def label(self): """Return timestamped label for this snapshot, or a raw timestamp.""" if not self.desc: return "%.3fs" % self.timestamp return "%s (%.3fs)" % (self.desc, self.timestamp)
[ "def", "label", "(", "self", ")", ":", "if", "not", "self", ".", "desc", ":", "return", "\"%.3fs\"", "%", "self", ".", "timestamp", "return", "\"%s (%.3fs)\"", "%", "(", "self", ".", "desc", ",", "self", ".", "timestamp", ")" ]
Return timestamped label for this snapshot, or a raw timestamp.
[ "Return", "timestamped", "label", "for", "this", "snapshot", "or", "a", "raw", "timestamp", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L232-L236
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
ClassTracker._tracker
def _tracker(self, _observer_, _self_, *args, **kwds): """ Injected constructor for tracked classes. Call the actual constructor of the object and track the object. Attach to the object before calling the constructor to track the object with the parameters of the most specialized...
python
def _tracker(self, _observer_, _self_, *args, **kwds): """ Injected constructor for tracked classes. Call the actual constructor of the object and track the object. Attach to the object before calling the constructor to track the object with the parameters of the most specialized...
[ "def", "_tracker", "(", "self", ",", "_observer_", ",", "_self_", ",", "*", "args", ",", "*", "*", "kwds", ")", ":", "self", ".", "track_object", "(", "_self_", ",", "name", "=", "_observer_", ".", "name", ",", "resolution_level", "=", "_observer_", "....
Injected constructor for tracked classes. Call the actual constructor of the object and track the object. Attach to the object before calling the constructor to track the object with the parameters of the most specialized class.
[ "Injected", "constructor", "for", "tracked", "classes", ".", "Call", "the", "actual", "constructor", "of", "the", "object", "and", "track", "the", "object", ".", "Attach", "to", "the", "object", "before", "calling", "the", "constructor", "to", "track", "the", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L283-L295
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
ClassTracker._inject_constructor
def _inject_constructor(self, cls, func, name, resolution_level, keep, trace): """ Modifying Methods in Place - after the recipe 15.7 in the Python Cookbook by Ken Seehof. The original constructors may be restored later. """ try: co...
python
def _inject_constructor(self, cls, func, name, resolution_level, keep, trace): """ Modifying Methods in Place - after the recipe 15.7 in the Python Cookbook by Ken Seehof. The original constructors may be restored later. """ try: co...
[ "def", "_inject_constructor", "(", "self", ",", "cls", ",", "func", ",", "name", ",", "resolution_level", ",", "keep", ",", "trace", ")", ":", "try", ":", "constructor", "=", "cls", ".", "__init__", "except", "AttributeError", ":", "def", "constructor", "(...
Modifying Methods in Place - after the recipe 15.7 in the Python Cookbook by Ken Seehof. The original constructors may be restored later.
[ "Modifying", "Methods", "in", "Place", "-", "after", "the", "recipe", "15", ".", "7", "in", "the", "Python", "Cookbook", "by", "Ken", "Seehof", ".", "The", "original", "constructors", "may", "be", "restored", "later", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L298-L324
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
ClassTracker._track_modify
def _track_modify(self, cls, name, detail, keep, trace): """ Modify settings of a tracked class """ self._observers[cls].modify(name, detail, keep, trace)
python
def _track_modify(self, cls, name, detail, keep, trace): """ Modify settings of a tracked class """ self._observers[cls].modify(name, detail, keep, trace)
[ "def", "_track_modify", "(", "self", ",", "cls", ",", "name", ",", "detail", ",", "keep", ",", "trace", ")", ":", "self", ".", "_observers", "[", "cls", "]", ".", "modify", "(", "name", ",", "detail", ",", "keep", ",", "trace", ")" ]
Modify settings of a tracked class
[ "Modify", "settings", "of", "a", "tracked", "class" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L334-L338
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
ClassTracker._restore_constructor
def _restore_constructor(self, cls): """ Restore the original constructor, lose track of class. """ cls.__init__ = self._observers[cls].init del self._observers[cls]
python
def _restore_constructor(self, cls): """ Restore the original constructor, lose track of class. """ cls.__init__ = self._observers[cls].init del self._observers[cls]
[ "def", "_restore_constructor", "(", "self", ",", "cls", ")", ":", "cls", ".", "__init__", "=", "self", ".", "_observers", "[", "cls", "]", ".", "init", "del", "self", ".", "_observers", "[", "cls", "]" ]
Restore the original constructor, lose track of class.
[ "Restore", "the", "original", "constructor", "lose", "track", "of", "class", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L341-L346
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
ClassTracker.track_change
def track_change(self, instance, resolution_level=0): """ Change tracking options for the already tracked object 'instance'. If instance is not tracked, a KeyError will be raised. """ tobj = self.objects[id(instance)] tobj.set_resolution_level(resolution_level)
python
def track_change(self, instance, resolution_level=0): """ Change tracking options for the already tracked object 'instance'. If instance is not tracked, a KeyError will be raised. """ tobj = self.objects[id(instance)] tobj.set_resolution_level(resolution_level)
[ "def", "track_change", "(", "self", ",", "instance", ",", "resolution_level", "=", "0", ")", ":", "tobj", "=", "self", ".", "objects", "[", "id", "(", "instance", ")", "]", "tobj", ".", "set_resolution_level", "(", "resolution_level", ")" ]
Change tracking options for the already tracked object 'instance'. If instance is not tracked, a KeyError will be raised.
[ "Change", "tracking", "options", "for", "the", "already", "tracked", "object", "instance", ".", "If", "instance", "is", "not", "tracked", "a", "KeyError", "will", "be", "raised", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L349-L355
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
ClassTracker.track_object
def track_object(self, instance, name=None, resolution_level=0, keep=False, trace=False): """ Track object 'instance' and sample size and lifetime information. Not all objects can be tracked; trackable objects are class instances and other objects that can be weakly referenced. When an o...
python
def track_object(self, instance, name=None, resolution_level=0, keep=False, trace=False): """ Track object 'instance' and sample size and lifetime information. Not all objects can be tracked; trackable objects are class instances and other objects that can be weakly referenced. When an o...
[ "def", "track_object", "(", "self", ",", "instance", ",", "name", "=", "None", ",", "resolution_level", "=", "0", ",", "keep", "=", "False", ",", "trace", "=", "False", ")", ":", "# Check if object is already tracked. This happens if track_object is", "# called mult...
Track object 'instance' and sample size and lifetime information. Not all objects can be tracked; trackable objects are class instances and other objects that can be weakly referenced. When an object cannot be tracked, a `TypeError` is raised. :param resolution_level: The recursion dept...
[ "Track", "object", "instance", "and", "sample", "size", "and", "lifetime", "information", ".", "Not", "all", "objects", "can", "be", "tracked", ";", "trackable", "objects", "are", "class", "instances", "and", "other", "objects", "that", "can", "be", "weakly", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L358-L393
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
ClassTracker.track_class
def track_class(self, cls, name=None, resolution_level=0, keep=False, trace=False): """ Track all objects of the class `cls`. Objects of that type that already exist are *not* tracked. If `track_class` is called for a class already tracked, the tracking parameters are modified. Instantia...
python
def track_class(self, cls, name=None, resolution_level=0, keep=False, trace=False): """ Track all objects of the class `cls`. Objects of that type that already exist are *not* tracked. If `track_class` is called for a class already tracked, the tracking parameters are modified. Instantia...
[ "def", "track_class", "(", "self", ",", "cls", ",", "name", "=", "None", ",", "resolution_level", "=", "0", ",", "keep", "=", "False", ",", "trace", "=", "False", ")", ":", "if", "not", "isclass", "(", "cls", ")", ":", "raise", "TypeError", "(", "\...
Track all objects of the class `cls`. Objects of that type that already exist are *not* tracked. If `track_class` is called for a class already tracked, the tracking parameters are modified. Instantiation traces can be generated by setting `trace` to True. A constructor is injected to be...
[ "Track", "all", "objects", "of", "the", "class", "cls", ".", "Objects", "of", "that", "type", "that", "already", "exist", "are", "*", "not", "*", "tracked", ".", "If", "track_class", "is", "called", "for", "a", "class", "already", "tracked", "the", "trac...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L396-L423
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
ClassTracker.detach_all_classes
def detach_all_classes(self): """ Detach from all tracked classes. """ classes = list(self._observers.keys()) for cls in classes: self.detach_class(cls)
python
def detach_all_classes(self): """ Detach from all tracked classes. """ classes = list(self._observers.keys()) for cls in classes: self.detach_class(cls)
[ "def", "detach_all_classes", "(", "self", ")", ":", "classes", "=", "list", "(", "self", ".", "_observers", ".", "keys", "(", ")", ")", "for", "cls", "in", "classes", ":", "self", ".", "detach_class", "(", "cls", ")" ]
Detach from all tracked classes.
[ "Detach", "from", "all", "tracked", "classes", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L434-L440
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
ClassTracker.detach_all
def detach_all(self): """ Detach from all tracked classes and objects. Restore the original constructors and cleanse the tracking lists. """ self.detach_all_classes() self.objects.clear() self.index.clear() self._keepalive[:] = []
python
def detach_all(self): """ Detach from all tracked classes and objects. Restore the original constructors and cleanse the tracking lists. """ self.detach_all_classes() self.objects.clear() self.index.clear() self._keepalive[:] = []
[ "def", "detach_all", "(", "self", ")", ":", "self", ".", "detach_all_classes", "(", ")", "self", ".", "objects", ".", "clear", "(", ")", "self", ".", "index", ".", "clear", "(", ")", "self", ".", "_keepalive", "[", ":", "]", "=", "[", "]" ]
Detach from all tracked classes and objects. Restore the original constructors and cleanse the tracking lists.
[ "Detach", "from", "all", "tracked", "classes", "and", "objects", ".", "Restore", "the", "original", "constructors", "and", "cleanse", "the", "tracking", "lists", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L443-L451
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
ClassTracker.start_periodic_snapshots
def start_periodic_snapshots(self, interval=1.0): """ Start a thread which takes snapshots periodically. The `interval` specifies the time in seconds the thread waits between taking snapshots. The thread is started as a daemon allowing the program to exit. If periodic snapshots are ...
python
def start_periodic_snapshots(self, interval=1.0): """ Start a thread which takes snapshots periodically. The `interval` specifies the time in seconds the thread waits between taking snapshots. The thread is started as a daemon allowing the program to exit. If periodic snapshots are ...
[ "def", "start_periodic_snapshots", "(", "self", ",", "interval", "=", "1.0", ")", ":", "if", "not", "self", ".", "_periodic_thread", ":", "self", ".", "_periodic_thread", "=", "PeriodicThread", "(", "self", ",", "interval", ",", "name", "=", "'BackgroundMonito...
Start a thread which takes snapshots periodically. The `interval` specifies the time in seconds the thread waits between taking snapshots. The thread is started as a daemon allowing the program to exit. If periodic snapshots are already active, the interval is updated.
[ "Start", "a", "thread", "which", "takes", "snapshots", "periodically", ".", "The", "interval", "specifies", "the", "time", "in", "seconds", "the", "thread", "waits", "between", "taking", "snapshots", ".", "The", "thread", "is", "started", "as", "a", "daemon", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L465-L477
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
ClassTracker.stop_periodic_snapshots
def stop_periodic_snapshots(self): """ Post a stop signal to the thread that takes the periodic snapshots. The function waits for the thread to terminate which can take some time depending on the configured interval. """ if self._periodic_thread and self._periodic_thread....
python
def stop_periodic_snapshots(self): """ Post a stop signal to the thread that takes the periodic snapshots. The function waits for the thread to terminate which can take some time depending on the configured interval. """ if self._periodic_thread and self._periodic_thread....
[ "def", "stop_periodic_snapshots", "(", "self", ")", ":", "if", "self", ".", "_periodic_thread", "and", "self", ".", "_periodic_thread", ".", "isAlive", "(", ")", ":", "self", ".", "_periodic_thread", ".", "stop", "=", "True", "self", ".", "_periodic_thread", ...
Post a stop signal to the thread that takes the periodic snapshots. The function waits for the thread to terminate which can take some time depending on the configured interval.
[ "Post", "a", "stop", "signal", "to", "the", "thread", "that", "takes", "the", "periodic", "snapshots", ".", "The", "function", "waits", "for", "the", "thread", "to", "terminate", "which", "can", "take", "some", "time", "depending", "on", "the", "configured",...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L479-L488
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
ClassTracker.create_snapshot
def create_snapshot(self, description='', compute_total=False): """ Collect current per instance statistics and saves total amount of memory associated with the Python process. If `compute_total` is `True`, the total consumption of all objects known to *asizeof* is computed. The...
python
def create_snapshot(self, description='', compute_total=False): """ Collect current per instance statistics and saves total amount of memory associated with the Python process. If `compute_total` is `True`, the total consumption of all objects known to *asizeof* is computed. The...
[ "def", "create_snapshot", "(", "self", ",", "description", "=", "''", ",", "compute_total", "=", "False", ")", ":", "try", ":", "# TODO: It is not clear what happens when memory is allocated or", "# released while this function is executed but it will likely lead", "# to inconsis...
Collect current per instance statistics and saves total amount of memory associated with the Python process. If `compute_total` is `True`, the total consumption of all objects known to *asizeof* is computed. The latter might be very slow if many objects are mapped into memory at the tim...
[ "Collect", "current", "per", "instance", "statistics", "and", "saves", "total", "amount", "of", "memory", "associated", "with", "the", "Python", "process", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L496-L552
lrq3000/pyFileFixity
pyFileFixity/lib/gooey/python_bindings/argparse_to_json.py
is_required
def is_required(action): '''_actions which are positional or possessing the `required` flag ''' return not action.option_strings and not isinstance(action, _SubParsersAction) or action.required == True
python
def is_required(action): '''_actions which are positional or possessing the `required` flag ''' return not action.option_strings and not isinstance(action, _SubParsersAction) or action.required == True
[ "def", "is_required", "(", "action", ")", ":", "return", "not", "action", ".", "option_strings", "and", "not", "isinstance", "(", "action", ",", "_SubParsersAction", ")", "or", "action", ".", "required", "==", "True" ]
_actions which are positional or possessing the `required` flag
[ "_actions", "which", "are", "positional", "or", "possessing", "the", "required", "flag" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/gooey/python_bindings/argparse_to_json.py#L97-L99
lrq3000/pyFileFixity
pyFileFixity/header_ecc.py
entry_fields
def entry_fields(entry, field_delim="\xFF"): '''From a raw ecc entry (a string), extract the metadata fields (filename, filesize, ecc for both), and the rest being blocks of hash and ecc per blocks of the original file's header''' entry = entry.lstrip(field_delim) # if there was some slight adjustment error (ex...
python
def entry_fields(entry, field_delim="\xFF"): '''From a raw ecc entry (a string), extract the metadata fields (filename, filesize, ecc for both), and the rest being blocks of hash and ecc per blocks of the original file's header''' entry = entry.lstrip(field_delim) # if there was some slight adjustment error (ex...
[ "def", "entry_fields", "(", "entry", ",", "field_delim", "=", "\"\\xFF\"", ")", ":", "entry", "=", "entry", ".", "lstrip", "(", "field_delim", ")", "# if there was some slight adjustment error (example: the last ecc block of the last file was the field_delim, then we will start w...
From a raw ecc entry (a string), extract the metadata fields (filename, filesize, ecc for both), and the rest being blocks of hash and ecc per blocks of the original file's header
[ "From", "a", "raw", "ecc", "entry", "(", "a", "string", ")", "extract", "the", "metadata", "fields", "(", "filename", "filesize", "ecc", "for", "both", ")", "and", "the", "rest", "being", "blocks", "of", "hash", "and", "ecc", "per", "blocks", "of", "th...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/header_ecc.py#L92-L124
lrq3000/pyFileFixity
pyFileFixity/header_ecc.py
entry_assemble
def entry_assemble(entry_fields, ecc_params, header_size, filepath, fileheader=None): '''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.''' # Extract the header from the file if fileh...
python
def entry_assemble(entry_fields, ecc_params, header_size, filepath, fileheader=None): '''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.''' # Extract the header from the file if fileh...
[ "def", "entry_assemble", "(", "entry_fields", ",", "ecc_params", ",", "header_size", ",", "filepath", ",", "fileheader", "=", "None", ")", ":", "# Extract the header from the file", "if", "fileheader", "is", "None", ":", "with", "open", "(", "filepath", ",", "'r...
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/header_ecc.py#L126-L147
lrq3000/pyFileFixity
pyFileFixity/header_ecc.py
compute_ecc_hash
def compute_ecc_hash(ecc_manager, hasher, buf, max_block_size, rate, message_size=None, as_string=False): '''Split a string in blocks given max_block_size and compute the hash and ecc for each block, and then return a nice list with both for easy processing.''' result = [] # If required parameters were not ...
python
def compute_ecc_hash(ecc_manager, hasher, buf, max_block_size, rate, message_size=None, as_string=False): '''Split a string in blocks given max_block_size and compute the hash and ecc for each block, and then return a nice list with both for easy processing.''' result = [] # If required parameters were not ...
[ "def", "compute_ecc_hash", "(", "ecc_manager", ",", "hasher", ",", "buf", ",", "max_block_size", ",", "rate", ",", "message_size", "=", "None", ",", "as_string", "=", "False", ")", ":", "result", "=", "[", "]", "# If required parameters were not provided, we compu...
Split a string in blocks given max_block_size and compute the hash and ecc for each block, and then return a nice list with both for easy processing.
[ "Split", "a", "string", "in", "blocks", "given", "max_block_size", "and", "compute", "the", "hash", "and", "ecc", "for", "each", "block", "and", "then", "return", "a", "nice", "list", "with", "both", "for", "easy", "processing", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/header_ecc.py#L149-L172
lrq3000/pyFileFixity
pyFileFixity/header_ecc.py
ecc_correct_intra
def ecc_correct_intra(ecc_manager_intra, ecc_params_intra, field, ecc, enable_erasures=False, erasures_char="\x00", only_erasures=False): """ Correct an intra-field with its corresponding intra-ecc if necessary """ fentry_fields = {"ecc_field": ecc} field_correct = [] # will store each block of the correcte...
python
def ecc_correct_intra(ecc_manager_intra, ecc_params_intra, field, ecc, enable_erasures=False, erasures_char="\x00", only_erasures=False): """ Correct an intra-field with its corresponding intra-ecc if necessary """ fentry_fields = {"ecc_field": ecc} field_correct = [] # will store each block of the correcte...
[ "def", "ecc_correct_intra", "(", "ecc_manager_intra", ",", "ecc_params_intra", ",", "field", ",", "ecc", ",", "enable_erasures", "=", "False", ",", "erasures_char", "=", "\"\\x00\"", ",", "only_erasures", "=", "False", ")", ":", "fentry_fields", "=", "{", "\"ecc...
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/header_ecc.py#L174-L205
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/refgraph.py
ReferenceGraph._eliminate_leafs
def _eliminate_leafs(self, graph): """ Eliminate leaf objects - that are objects not referencing any other objects in the list `graph`. Returns the list of objects without the objects identified as leafs. """ result = [] idset = set([id(x) for x in graph]) ...
python
def _eliminate_leafs(self, graph): """ Eliminate leaf objects - that are objects not referencing any other objects in the list `graph`. Returns the list of objects without the objects identified as leafs. """ result = [] idset = set([id(x) for x in graph]) ...
[ "def", "_eliminate_leafs", "(", "self", ",", "graph", ")", ":", "result", "=", "[", "]", "idset", "=", "set", "(", "[", "id", "(", "x", ")", "for", "x", "in", "graph", "]", ")", "for", "n", "in", "graph", ":", "refset", "=", "set", "(", "[", ...
Eliminate leaf objects - that are objects not referencing any other objects in the list `graph`. Returns the list of objects without the objects identified as leafs.
[ "Eliminate", "leaf", "objects", "-", "that", "are", "objects", "not", "referencing", "any", "other", "objects", "in", "the", "list", "graph", ".", "Returns", "the", "list", "of", "objects", "without", "the", "objects", "identified", "as", "leafs", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/refgraph.py#L92-L104
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/refgraph.py
ReferenceGraph._reduce_to_cycles
def _reduce_to_cycles(self): """ Iteratively eliminate leafs to reduce the set of objects to only those that build cycles. Return the number of objects involved in reference cycles. If there are no cycles, `self.objects` will be an empty list and this method returns 0. ""...
python
def _reduce_to_cycles(self): """ Iteratively eliminate leafs to reduce the set of objects to only those that build cycles. Return the number of objects involved in reference cycles. If there are no cycles, `self.objects` will be an empty list and this method returns 0. ""...
[ "def", "_reduce_to_cycles", "(", "self", ")", ":", "cycles", "=", "self", ".", "objects", "[", ":", "]", "cnt", "=", "0", "while", "cnt", "!=", "len", "(", "cycles", ")", ":", "cnt", "=", "len", "(", "cycles", ")", "cycles", "=", "self", ".", "_e...
Iteratively eliminate leafs to reduce the set of objects to only those that build cycles. Return the number of objects involved in reference cycles. If there are no cycles, `self.objects` will be an empty list and this method returns 0.
[ "Iteratively", "eliminate", "leafs", "to", "reduce", "the", "set", "of", "objects", "to", "only", "those", "that", "build", "cycles", ".", "Return", "the", "number", "of", "objects", "involved", "in", "reference", "cycles", ".", "If", "there", "are", "no", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/refgraph.py#L107-L120
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/refgraph.py
ReferenceGraph.reduce_to_cycles
def reduce_to_cycles(self): """ Iteratively eliminate leafs to reduce the set of objects to only those that build cycles. Return the reduced graph. If there are no cycles, None is returned. """ if not self._reduced: reduced = copy(self) reduced.obj...
python
def reduce_to_cycles(self): """ Iteratively eliminate leafs to reduce the set of objects to only those that build cycles. Return the reduced graph. If there are no cycles, None is returned. """ if not self._reduced: reduced = copy(self) reduced.obj...
[ "def", "reduce_to_cycles", "(", "self", ")", ":", "if", "not", "self", ".", "_reduced", ":", "reduced", "=", "copy", "(", "self", ")", "reduced", ".", "objects", "=", "self", ".", "objects", "[", ":", "]", "reduced", ".", "metadata", "=", "[", "]", ...
Iteratively eliminate leafs to reduce the set of objects to only those that build cycles. Return the reduced graph. If there are no cycles, None is returned.
[ "Iteratively", "eliminate", "leafs", "to", "reduce", "the", "set", "of", "objects", "to", "only", "those", "that", "build", "cycles", ".", "Return", "the", "reduced", "graph", ".", "If", "there", "are", "no", "cycles", "None", "is", "returned", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/refgraph.py#L123-L144
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/refgraph.py
ReferenceGraph._get_edges
def _get_edges(self): """ Compute the edges for the reference graph. The function returns a set of tuples (id(a), id(b), ref) if a references b with the referent 'ref'. """ idset = set([id(x) for x in self.objects]) self.edges = set([]) for n in self.objec...
python
def _get_edges(self): """ Compute the edges for the reference graph. The function returns a set of tuples (id(a), id(b), ref) if a references b with the referent 'ref'. """ idset = set([id(x) for x in self.objects]) self.edges = set([]) for n in self.objec...
[ "def", "_get_edges", "(", "self", ")", ":", "idset", "=", "set", "(", "[", "id", "(", "x", ")", "for", "x", "in", "self", ".", "objects", "]", ")", "self", ".", "edges", "=", "set", "(", "[", "]", ")", "for", "n", "in", "self", ".", "objects"...
Compute the edges for the reference graph. The function returns a set of tuples (id(a), id(b), ref) if a references b with the referent 'ref'.
[ "Compute", "the", "edges", "for", "the", "reference", "graph", ".", "The", "function", "returns", "a", "set", "of", "tuples", "(", "id", "(", "a", ")", "id", "(", "b", ")", "ref", ")", "if", "a", "references", "b", "with", "the", "referent", "ref", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/refgraph.py#L147-L168
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/refgraph.py
ReferenceGraph._annotate_groups
def _annotate_groups(self): """ Annotate the objects belonging to separate (non-connected) graphs with individual indices. """ g = {} for x in self.metadata: g[x.id] = x idx = 0 for x in self.metadata: if not hasattr(x, 'group'): ...
python
def _annotate_groups(self): """ Annotate the objects belonging to separate (non-connected) graphs with individual indices. """ g = {} for x in self.metadata: g[x.id] = x idx = 0 for x in self.metadata: if not hasattr(x, 'group'): ...
[ "def", "_annotate_groups", "(", "self", ")", ":", "g", "=", "{", "}", "for", "x", "in", "self", ".", "metadata", ":", "g", "[", "x", ".", "id", "]", "=", "x", "idx", "=", "0", "for", "x", "in", "self", ".", "metadata", ":", "if", "not", "hasa...
Annotate the objects belonging to separate (non-connected) graphs with individual indices.
[ "Annotate", "the", "objects", "belonging", "to", "separate", "(", "non", "-", "connected", ")", "graphs", "with", "individual", "indices", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/refgraph.py#L171-L199
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/refgraph.py
ReferenceGraph._filter_group
def _filter_group(self, group): """ Eliminate all objects but those which belong to `group`. ``self.objects``, ``self.metadata`` and ``self.edges`` are modified. Returns `True` if the group is non-empty. Otherwise returns `False`. """ self.metadata = [x for x in self.meta...
python
def _filter_group(self, group): """ Eliminate all objects but those which belong to `group`. ``self.objects``, ``self.metadata`` and ``self.edges`` are modified. Returns `True` if the group is non-empty. Otherwise returns `False`. """ self.metadata = [x for x in self.meta...
[ "def", "_filter_group", "(", "self", ",", "group", ")", ":", "self", ".", "metadata", "=", "[", "x", "for", "x", "in", "self", ".", "metadata", "if", "x", ".", "group", "==", "group", "]", "group_set", "=", "set", "(", "[", "x", ".", "id", "for",...
Eliminate all objects but those which belong to `group`. ``self.objects``, ``self.metadata`` and ``self.edges`` are modified. Returns `True` if the group is non-empty. Otherwise returns `False`.
[ "Eliminate", "all", "objects", "but", "those", "which", "belong", "to", "group", ".", "self", ".", "objects", "self", ".", "metadata", "and", "self", ".", "edges", "are", "modified", ".", "Returns", "True", "if", "the", "group", "is", "non", "-", "empty"...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/refgraph.py#L202-L219
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/refgraph.py
ReferenceGraph.split
def split(self): """ Split the graph into sub-graphs. Only connected objects belong to the same graph. `split` yields copies of the Graph object. Shallow copies are used that only replicate the meta-information, but share the same object list ``self.objects``. >>> from p...
python
def split(self): """ Split the graph into sub-graphs. Only connected objects belong to the same graph. `split` yields copies of the Graph object. Shallow copies are used that only replicate the meta-information, but share the same object list ``self.objects``. >>> from p...
[ "def", "split", "(", "self", ")", ":", "self", ".", "_annotate_groups", "(", ")", "index", "=", "0", "for", "group", "in", "range", "(", "self", ".", "_max_group", ")", ":", "subgraph", "=", "copy", "(", "self", ")", "subgraph", ".", "metadata", "=",...
Split the graph into sub-graphs. Only connected objects belong to the same graph. `split` yields copies of the Graph object. Shallow copies are used that only replicate the meta-information, but share the same object list ``self.objects``. >>> from pympler.refgraph import ReferenceGraph...
[ "Split", "the", "graph", "into", "sub", "-", "graphs", ".", "Only", "connected", "objects", "belong", "to", "the", "same", "graph", ".", "split", "yields", "copies", "of", "the", "Graph", "object", ".", "Shallow", "copies", "are", "used", "that", "only", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/refgraph.py#L222-L252
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/refgraph.py
ReferenceGraph.split_and_sort
def split_and_sort(self): """ Split the graphs into sub graphs and return a list of all graphs sorted by the number of nodes. The graph with most nodes is returned first. """ graphs = list(self.split()) graphs.sort(key=lambda x: -len(x.metadata)) for index, graph ...
python
def split_and_sort(self): """ Split the graphs into sub graphs and return a list of all graphs sorted by the number of nodes. The graph with most nodes is returned first. """ graphs = list(self.split()) graphs.sort(key=lambda x: -len(x.metadata)) for index, graph ...
[ "def", "split_and_sort", "(", "self", ")", ":", "graphs", "=", "list", "(", "self", ".", "split", "(", ")", ")", "graphs", ".", "sort", "(", "key", "=", "lambda", "x", ":", "-", "len", "(", "x", ".", "metadata", ")", ")", "for", "index", ",", "...
Split the graphs into sub graphs and return a list of all graphs sorted by the number of nodes. The graph with most nodes is returned first.
[ "Split", "the", "graphs", "into", "sub", "graphs", "and", "return", "a", "list", "of", "all", "graphs", "sorted", "by", "the", "number", "of", "nodes", ".", "The", "graph", "with", "most", "nodes", "is", "returned", "first", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/refgraph.py#L255-L264
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/refgraph.py
ReferenceGraph._annotate_objects
def _annotate_objects(self): """ Extract meta-data describing the stored objects. """ self.metadata = [] sizer = Asizer() sizes = sizer.asizesof(*self.objects) self.total_size = sizer.total for obj, sz in zip(self.objects, sizes): md = _MetaObj...
python
def _annotate_objects(self): """ Extract meta-data describing the stored objects. """ self.metadata = [] sizer = Asizer() sizes = sizer.asizesof(*self.objects) self.total_size = sizer.total for obj, sz in zip(self.objects, sizes): md = _MetaObj...
[ "def", "_annotate_objects", "(", "self", ")", ":", "self", ".", "metadata", "=", "[", "]", "sizer", "=", "Asizer", "(", ")", "sizes", "=", "sizer", ".", "asizesof", "(", "*", "self", ".", "objects", ")", "self", ".", "total_size", "=", "sizer", ".", ...
Extract meta-data describing the stored objects.
[ "Extract", "meta", "-", "data", "describing", "the", "stored", "objects", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/refgraph.py#L267-L284
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/refgraph.py
ReferenceGraph._get_graphviz_data
def _get_graphviz_data(self): """ Emit a graph representing the connections between the objects described within the metadata list. The text representation can be transformed to a graph with graphviz. Returns a string. """ s = [] header = '// Process this file wit...
python
def _get_graphviz_data(self): """ Emit a graph representing the connections between the objects described within the metadata list. The text representation can be transformed to a graph with graphviz. Returns a string. """ s = [] header = '// Process this file wit...
[ "def", "_get_graphviz_data", "(", "self", ")", ":", "s", "=", "[", "]", "header", "=", "'// Process this file with graphviz\\n'", "s", ".", "append", "(", "header", ")", "s", ".", "append", "(", "'digraph G {\\n'", ")", "s", ".", "append", "(", "' node [s...
Emit a graph representing the connections between the objects described within the metadata list. The text representation can be transformed to a graph with graphviz. Returns a string.
[ "Emit", "a", "graph", "representing", "the", "connections", "between", "the", "objects", "described", "within", "the", "metadata", "list", ".", "The", "text", "representation", "can", "be", "transformed", "to", "a", "graph", "with", "graphviz", ".", "Returns", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/refgraph.py#L287-L315
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/refgraph.py
ReferenceGraph.render
def render(self, filename, cmd='dot', format='ps', unflatten=False): """ Render the graph to `filename` using graphviz. The graphviz invocation command may be overriden by specifying `cmd`. The `format` may be any specifier recognized by the graph renderer ('-Txxx' command). The graph ...
python
def render(self, filename, cmd='dot', format='ps', unflatten=False): """ Render the graph to `filename` using graphviz. The graphviz invocation command may be overriden by specifying `cmd`. The `format` may be any specifier recognized by the graph renderer ('-Txxx' command). The graph ...
[ "def", "render", "(", "self", ",", "filename", ",", "cmd", "=", "'dot'", ",", "format", "=", "'ps'", ",", "unflatten", "=", "False", ")", ":", "if", "self", ".", "objects", "==", "[", "]", ":", "return", "False", "data", "=", "self", ".", "_get_gra...
Render the graph to `filename` using graphviz. The graphviz invocation command may be overriden by specifying `cmd`. The `format` may be any specifier recognized by the graph renderer ('-Txxx' command). The graph can be preprocessed by the *unflatten* tool if the `unflatten` parameter i...
[ "Render", "the", "graph", "to", "filename", "using", "graphviz", ".", "The", "graphviz", "invocation", "command", "may", "be", "overriden", "by", "specifying", "cmd", ".", "The", "format", "may", "be", "any", "specifier", "recognized", "by", "the", "graph", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/refgraph.py#L318-L352
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/refgraph.py
ReferenceGraph.write_graph
def write_graph(self, filename): """ Write raw graph data which can be post-processed using graphviz. """ f = open(filename, 'w') f.write(self._get_graphviz_data()) f.close()
python
def write_graph(self, filename): """ Write raw graph data which can be post-processed using graphviz. """ f = open(filename, 'w') f.write(self._get_graphviz_data()) f.close()
[ "def", "write_graph", "(", "self", ",", "filename", ")", ":", "f", "=", "open", "(", "filename", ",", "'w'", ")", "f", ".", "write", "(", "self", ".", "_get_graphviz_data", "(", ")", ")", "f", ".", "close", "(", ")" ]
Write raw graph data which can be post-processed using graphviz.
[ "Write", "raw", "graph", "data", "which", "can", "be", "post", "-", "processed", "using", "graphviz", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/refgraph.py#L355-L361
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/pyinstrument/profiler.py
Profiler.root_frame
def root_frame(self): """ Returns the parsed results in the form of a tree of Frame objects """ if not hasattr(self, '_root_frame'): self._root_frame = Frame() # define a recursive function that builds the hierarchy of frames given the # stack of fram...
python
def root_frame(self): """ Returns the parsed results in the form of a tree of Frame objects """ if not hasattr(self, '_root_frame'): self._root_frame = Frame() # define a recursive function that builds the hierarchy of frames given the # stack of fram...
[ "def", "root_frame", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_root_frame'", ")", ":", "self", ".", "_root_frame", "=", "Frame", "(", ")", "# define a recursive function that builds the hierarchy of frames given the", "# stack of frame identifi...
Returns the parsed results in the form of a tree of Frame objects
[ "Returns", "the", "parsed", "results", "in", "the", "form", "of", "a", "tree", "of", "Frame", "objects" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/pyinstrument/profiler.py#L109-L133
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pycallgraph.py
reset_trace
def reset_trace(): """Resets all collected statistics. This is run automatically by start_trace(reset=True) and when the module is loaded. """ global call_dict global call_stack global func_count global func_count_max global func_time global func_time_max global call_stack_timer ...
python
def reset_trace(): """Resets all collected statistics. This is run automatically by start_trace(reset=True) and when the module is loaded. """ global call_dict global call_stack global func_count global func_count_max global func_time global func_time_max global call_stack_timer ...
[ "def", "reset_trace", "(", ")", ":", "global", "call_dict", "global", "call_stack", "global", "func_count", "global", "func_count_max", "global", "func_time", "global", "func_time_max", "global", "call_stack_timer", "call_dict", "=", "{", "}", "# current call stack", ...
Resets all collected statistics. This is run automatically by start_trace(reset=True) and when the module is loaded.
[ "Resets", "all", "collected", "statistics", ".", "This", "is", "run", "automatically", "by", "start_trace", "(", "reset", "=", "True", ")", "and", "when", "the", "module", "is", "loaded", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pycallgraph.py#L92-L118
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pycallgraph.py
is_module_stdlib
def is_module_stdlib(file_name): """Returns True if the file_name is in the lib directory.""" # TODO: Move these calls away from this function so it doesn't have to run # every time. lib_path = sysconfig.get_python_lib() path = os.path.split(lib_path) if path[1] == 'site-packages': lib_p...
python
def is_module_stdlib(file_name): """Returns True if the file_name is in the lib directory.""" # TODO: Move these calls away from this function so it doesn't have to run # every time. lib_path = sysconfig.get_python_lib() path = os.path.split(lib_path) if path[1] == 'site-packages': lib_p...
[ "def", "is_module_stdlib", "(", "file_name", ")", ":", "# TODO: Move these calls away from this function so it doesn't have to run", "# every time.", "lib_path", "=", "sysconfig", ".", "get_python_lib", "(", ")", "path", "=", "os", ".", "path", ".", "split", "(", "lib_p...
Returns True if the file_name is in the lib directory.
[ "Returns", "True", "if", "the", "file_name", "is", "in", "the", "lib", "directory", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pycallgraph.py#L169-L177
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pycallgraph.py
start_trace
def start_trace(reset=True, filter_func=None, time_filter_func=None): """Begins a trace. Setting reset to True will reset all previously recorded trace data. filter_func needs to point to a callable function that accepts the parameters (call_stack, module_name, class_name, func_name, full_name). Every c...
python
def start_trace(reset=True, filter_func=None, time_filter_func=None): """Begins a trace. Setting reset to True will reset all previously recorded trace data. filter_func needs to point to a callable function that accepts the parameters (call_stack, module_name, class_name, func_name, full_name). Every c...
[ "def", "start_trace", "(", "reset", "=", "True", ",", "filter_func", "=", "None", ",", "time_filter_func", "=", "None", ")", ":", "global", "trace_filter", "global", "time_filter", "if", "reset", ":", "reset_trace", "(", ")", "if", "filter_func", ":", "trace...
Begins a trace. Setting reset to True will reset all previously recorded trace data. filter_func needs to point to a callable function that accepts the parameters (call_stack, module_name, class_name, func_name, full_name). Every call will be passed into this function and it is up to the function to dec...
[ "Begins", "a", "trace", ".", "Setting", "reset", "to", "True", "will", "reset", "all", "previously", "recorded", "trace", "data", ".", "filter_func", "needs", "to", "point", "to", "a", "callable", "function", "that", "accepts", "the", "parameters", "(", "cal...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pycallgraph.py#L180-L203
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pycallgraph.py
tracer
def tracer(frame, event, arg): """This is an internal function that is called every time a call is made during a trace. It keeps track of relationships between calls. """ global func_count_max global func_count global trace_filter global time_filter global call_stack global func_time...
python
def tracer(frame, event, arg): """This is an internal function that is called every time a call is made during a trace. It keeps track of relationships between calls. """ global func_count_max global func_count global trace_filter global time_filter global call_stack global func_time...
[ "def", "tracer", "(", "frame", ",", "event", ",", "arg", ")", ":", "global", "func_count_max", "global", "func_count", "global", "trace_filter", "global", "time_filter", "global", "call_stack", "global", "func_time", "global", "func_time_max", "if", "event", "==",...
This is an internal function that is called every time a call is made during a trace. It keeps track of relationships between calls.
[ "This", "is", "an", "internal", "function", "that", "is", "called", "every", "time", "a", "call", "is", "made", "during", "a", "trace", ".", "It", "keeps", "track", "of", "relationships", "between", "calls", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pycallgraph.py#L211-L308
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pycallgraph.py
get_dot
def get_dot(stop=True): """Returns a string containing a DOT file. Setting stop to True will cause the trace to stop. """ defaults = [] nodes = [] edges = [] # define default attributes for comp, comp_attr in graph_attributes.items(): attr = ', '.join( '%s = "%s"' % (attr...
python
def get_dot(stop=True): """Returns a string containing a DOT file. Setting stop to True will cause the trace to stop. """ defaults = [] nodes = [] edges = [] # define default attributes for comp, comp_attr in graph_attributes.items(): attr = ', '.join( '%s = "%s"' % (attr...
[ "def", "get_dot", "(", "stop", "=", "True", ")", ":", "defaults", "=", "[", "]", "nodes", "=", "[", "]", "edges", "=", "[", "]", "# define default attributes", "for", "comp", ",", "comp_attr", "in", "graph_attributes", ".", "items", "(", ")", ":", "att...
Returns a string containing a DOT file. Setting stop to True will cause the trace to stop.
[ "Returns", "a", "string", "containing", "a", "DOT", "file", ".", "Setting", "stop", "to", "True", "will", "cause", "the", "trace", "to", "stop", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pycallgraph.py#L327-L369
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pycallgraph.py
get_gdf
def get_gdf(stop=True): """Returns a string containing a GDF file. Setting stop to True will cause the trace to stop. """ ret = ['nodedef>name VARCHAR, label VARCHAR, hits INTEGER, ' + \ 'calls_frac DOUBLE, total_time_frac DOUBLE, ' + \ 'total_time DOUBLE, color VARCHAR, width DO...
python
def get_gdf(stop=True): """Returns a string containing a GDF file. Setting stop to True will cause the trace to stop. """ ret = ['nodedef>name VARCHAR, label VARCHAR, hits INTEGER, ' + \ 'calls_frac DOUBLE, total_time_frac DOUBLE, ' + \ 'total_time DOUBLE, color VARCHAR, width DO...
[ "def", "get_gdf", "(", "stop", "=", "True", ")", ":", "ret", "=", "[", "'nodedef>name VARCHAR, label VARCHAR, hits INTEGER, '", "+", "'calls_frac DOUBLE, total_time_frac DOUBLE, '", "+", "'total_time DOUBLE, color VARCHAR, width DOUBLE'", "]", "for", "func", ",", "hits", "i...
Returns a string containing a GDF file. Setting stop to True will cause the trace to stop.
[ "Returns", "a", "string", "containing", "a", "GDF", "file", ".", "Setting", "stop", "to", "True", "will", "cause", "the", "trace", "to", "stop", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pycallgraph.py#L372-L397
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pycallgraph.py
make_dot_graph
def make_dot_graph(filename, format='png', tool='dot', stop=True): """Creates a graph using a Graphviz tool that supports the dot language. It will output into a file specified by filename with the format specified. Setting stop to True will stop the current trace. """ if stop: stop_trace() ...
python
def make_dot_graph(filename, format='png', tool='dot', stop=True): """Creates a graph using a Graphviz tool that supports the dot language. It will output into a file specified by filename with the format specified. Setting stop to True will stop the current trace. """ if stop: stop_trace() ...
[ "def", "make_dot_graph", "(", "filename", ",", "format", "=", "'png'", ",", "tool", "=", "'dot'", ",", "stop", "=", "True", ")", ":", "if", "stop", ":", "stop_trace", "(", ")", "dot_data", "=", "get_dot", "(", ")", "# normalize filename", "regex_user_expan...
Creates a graph using a Graphviz tool that supports the dot language. It will output into a file specified by filename with the format specified. Setting stop to True will stop the current trace.
[ "Creates", "a", "graph", "using", "a", "Graphviz", "tool", "that", "supports", "the", "dot", "language", ".", "It", "will", "output", "into", "a", "file", "specified", "by", "filename", "with", "the", "format", "specified", ".", "Setting", "stop", "to", "T...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pycallgraph.py#L416-L452
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pycallgraph.py
make_gdf_graph
def make_gdf_graph(filename, stop=True): """Create a graph in simple GDF format, suitable for feeding into Gephi, or some other graph manipulation and display tool. Setting stop to True will stop the current trace. """ if stop: stop_trace() try: f = open(filename, 'w') f...
python
def make_gdf_graph(filename, stop=True): """Create a graph in simple GDF format, suitable for feeding into Gephi, or some other graph manipulation and display tool. Setting stop to True will stop the current trace. """ if stop: stop_trace() try: f = open(filename, 'w') f...
[ "def", "make_gdf_graph", "(", "filename", ",", "stop", "=", "True", ")", ":", "if", "stop", ":", "stop_trace", "(", ")", "try", ":", "f", "=", "open", "(", "filename", ",", "'w'", ")", "f", ".", "write", "(", "get_gdf", "(", ")", ")", "finally", ...
Create a graph in simple GDF format, suitable for feeding into Gephi, or some other graph manipulation and display tool. Setting stop to True will stop the current trace.
[ "Create", "a", "graph", "in", "simple", "GDF", "format", "suitable", "for", "feeding", "into", "Gephi", "or", "some", "other", "graph", "manipulation", "and", "display", "tool", ".", "Setting", "stop", "to", "True", "will", "stop", "the", "current", "trace",...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pycallgraph.py#L455-L467
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pycallgraph.py
simple_memoize
def simple_memoize(callable_object): """Simple memoization for functions without keyword arguments. This is useful for mapping code objects to module in this context. inspect.getmodule() requires a number of system calls, which may slow down the tracing considerably. Caching the mapping from code objec...
python
def simple_memoize(callable_object): """Simple memoization for functions without keyword arguments. This is useful for mapping code objects to module in this context. inspect.getmodule() requires a number of system calls, which may slow down the tracing considerably. Caching the mapping from code objec...
[ "def", "simple_memoize", "(", "callable_object", ")", ":", "cache", "=", "dict", "(", ")", "def", "wrapper", "(", "*", "rest", ")", ":", "if", "rest", "not", "in", "cache", ":", "cache", "[", "rest", "]", "=", "callable_object", "(", "*", "rest", ")"...
Simple memoization for functions without keyword arguments. This is useful for mapping code objects to module in this context. inspect.getmodule() requires a number of system calls, which may slow down the tracing considerably. Caching the mapping from code objects (there is *one* code object for each ...
[ "Simple", "memoization", "for", "functions", "without", "keyword", "arguments", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pycallgraph.py#L470-L490
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/runsnakerun/macshim.py
macshim
def macshim(): """Shim to run 32-bit on 64-bit mac as a sub-process""" import subprocess, sys subprocess.call([ sys.argv[0] + '32' ]+sys.argv[1:], env={"VERSIONER_PYTHON_PREFER_32_BIT":"yes"} )
python
def macshim(): """Shim to run 32-bit on 64-bit mac as a sub-process""" import subprocess, sys subprocess.call([ sys.argv[0] + '32' ]+sys.argv[1:], env={"VERSIONER_PYTHON_PREFER_32_BIT":"yes"} )
[ "def", "macshim", "(", ")", ":", "import", "subprocess", ",", "sys", "subprocess", ".", "call", "(", "[", "sys", ".", "argv", "[", "0", "]", "+", "'32'", "]", "+", "sys", ".", "argv", "[", "1", ":", "]", ",", "env", "=", "{", "\"VERSIONER_PYTHON_...
Shim to run 32-bit on 64-bit mac as a sub-process
[ "Shim", "to", "run", "32", "-", "bit", "on", "64", "-", "bit", "mac", "as", "a", "sub", "-", "process" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/runsnakerun/macshim.py#L1-L8
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/pyinstrument/__main__.py
file_supports_color
def file_supports_color(file_obj): """ Returns True if the running system's terminal supports color, and False otherwise. Borrowed from Django https://github.com/django/django/blob/master/django/core/management/color.py """ plat = sys.platform supported_platform = plat != 'Pocket PC' an...
python
def file_supports_color(file_obj): """ Returns True if the running system's terminal supports color, and False otherwise. Borrowed from Django https://github.com/django/django/blob/master/django/core/management/color.py """ plat = sys.platform supported_platform = plat != 'Pocket PC' an...
[ "def", "file_supports_color", "(", "file_obj", ")", ":", "plat", "=", "sys", ".", "platform", "supported_platform", "=", "plat", "!=", "'Pocket PC'", "and", "(", "plat", "!=", "'win32'", "or", "'ANSICON'", "in", "os", ".", "environ", ")", "is_a_tty", "=", ...
Returns True if the running system's terminal supports color, and False otherwise. Borrowed from Django https://github.com/django/django/blob/master/django/core/management/color.py
[ "Returns", "True", "if", "the", "running", "system", "s", "terminal", "supports", "color", "and", "False", "otherwise", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/pyinstrument/__main__.py#L129-L144
lrq3000/pyFileFixity
pyFileFixity/lib/eccman.py
compute_ecc_params
def compute_ecc_params(max_block_size, rate, hasher): '''Compute the ecc parameters (size of the message, size of the hash, size of the ecc). This is an helper function to easily compute the parameters from a resilience rate to instanciate an ECCMan object.''' #message_size = max_block_size - int(round(max_bloc...
python
def compute_ecc_params(max_block_size, rate, hasher): '''Compute the ecc parameters (size of the message, size of the hash, size of the ecc). This is an helper function to easily compute the parameters from a resilience rate to instanciate an ECCMan object.''' #message_size = max_block_size - int(round(max_bloc...
[ "def", "compute_ecc_params", "(", "max_block_size", ",", "rate", ",", "hasher", ")", ":", "#message_size = max_block_size - int(round(max_block_size * rate * 2, 0)) # old way to compute, wasn't really correct because we applied the rate on the total message+ecc size, when we should apply the rat...
Compute the ecc parameters (size of the message, size of the hash, size of the ecc). This is an helper function to easily compute the parameters from a resilience rate to instanciate an ECCMan object.
[ "Compute", "the", "ecc", "parameters", "(", "size", "of", "the", "message", "size", "of", "the", "hash", "size", "of", "the", "ecc", ")", ".", "This", "is", "an", "helper", "function", "to", "easily", "compute", "the", "parameters", "from", "a", "resilie...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/eccman.py#L48-L54
lrq3000/pyFileFixity
pyFileFixity/lib/eccman.py
detect_reedsolomon_parameters
def detect_reedsolomon_parameters(message, mesecc_orig, gen_list=[2, 3, 5], c_exp=8): '''Use an exhaustive search to automatically find the correct parameters for the ReedSolomon codec from a sample message and its encoded RS code. Arguments: message is the sample message, eg, "hello world" ; mesecc_orig is the...
python
def detect_reedsolomon_parameters(message, mesecc_orig, gen_list=[2, 3, 5], c_exp=8): '''Use an exhaustive search to automatically find the correct parameters for the ReedSolomon codec from a sample message and its encoded RS code. Arguments: message is the sample message, eg, "hello world" ; mesecc_orig is the...
[ "def", "detect_reedsolomon_parameters", "(", "message", ",", "mesecc_orig", ",", "gen_list", "=", "[", "2", ",", "3", ",", "5", "]", ",", "c_exp", "=", "8", ")", ":", "# Description: this is basically an exhaustive search where we will try every possible RS parameter, the...
Use an exhaustive search to automatically find the correct parameters for the ReedSolomon codec from a sample message and its encoded RS code. Arguments: message is the sample message, eg, "hello world" ; mesecc_orig is the message variable encoded with RS block appended at the end.
[ "Use", "an", "exhaustive", "search", "to", "automatically", "find", "the", "correct", "parameters", "for", "the", "ReedSolomon", "codec", "from", "a", "sample", "message", "and", "its", "encoded", "RS", "code", ".", "Arguments", ":", "message", "is", "the", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/eccman.py#L56-L112
lrq3000/pyFileFixity
pyFileFixity/lib/eccman.py
ECCMan.encode
def encode(self, message, k=None): '''Encode one message block (up to 255) into an ecc''' if not k: k = self.k message, _ = self.pad(message, k=k) if self.algo == 1: mesecc = self.ecc_manager.encode(message, k=k) elif self.algo == 2: mesecc = self.ecc_mana...
python
def encode(self, message, k=None): '''Encode one message block (up to 255) into an ecc''' if not k: k = self.k message, _ = self.pad(message, k=k) if self.algo == 1: mesecc = self.ecc_manager.encode(message, k=k) elif self.algo == 2: mesecc = self.ecc_mana...
[ "def", "encode", "(", "self", ",", "message", ",", "k", "=", "None", ")", ":", "if", "not", "k", ":", "k", "=", "self", ".", "k", "message", ",", "_", "=", "self", ".", "pad", "(", "message", ",", "k", "=", "k", ")", "if", "self", ".", "alg...
Encode one message block (up to 255) into an ecc
[ "Encode", "one", "message", "block", "(", "up", "to", "255", ")", "into", "an", "ecc" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/eccman.py#L153-L166
lrq3000/pyFileFixity
pyFileFixity/lib/eccman.py
ECCMan.decode
def decode(self, message, ecc, k=None, enable_erasures=False, erasures_char="\x00", only_erasures=False): '''Repair a message and its ecc also, given the message and its ecc (both can be corrupted, we will still try to fix both of them)''' if not k: k = self.k # Optimization, use bytearray ...
python
def decode(self, message, ecc, k=None, enable_erasures=False, erasures_char="\x00", only_erasures=False): '''Repair a message and its ecc also, given the message and its ecc (both can be corrupted, we will still try to fix both of them)''' if not k: k = self.k # Optimization, use bytearray ...
[ "def", "decode", "(", "self", ",", "message", ",", "ecc", ",", "k", "=", "None", ",", "enable_erasures", "=", "False", ",", "erasures_char", "=", "\"\\x00\"", ",", "only_erasures", "=", "False", ")", ":", "if", "not", "k", ":", "k", "=", "self", ".",...
Repair a message and its ecc also, given the message and its ecc (both can be corrupted, we will still try to fix both of them)
[ "Repair", "a", "message", "and", "its", "ecc", "also", "given", "the", "message", "and", "its", "ecc", "(", "both", "can", "be", "corrupted", "we", "will", "still", "try", "to", "fix", "both", "of", "them", ")" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/eccman.py#L168-L216
lrq3000/pyFileFixity
pyFileFixity/lib/eccman.py
ECCMan.pad
def pad(self, message, k=None): '''Automatically left pad with null bytes a message if too small, or leave unchanged if not necessary. This allows to keep track of padding and strip the null bytes after decoding reliably with binary data. Equivalent to shortening (shortened reed-solomon code).''' if not...
python
def pad(self, message, k=None): '''Automatically left pad with null bytes a message if too small, or leave unchanged if not necessary. This allows to keep track of padding and strip the null bytes after decoding reliably with binary data. Equivalent to shortening (shortened reed-solomon code).''' if not...
[ "def", "pad", "(", "self", ",", "message", ",", "k", "=", "None", ")", ":", "if", "not", "k", ":", "k", "=", "self", ".", "k", "pad", "=", "None", "if", "len", "(", "message", ")", "<", "k", ":", "#pad = \"\\x00\" * (k-len(message))", "pad", "=", ...
Automatically left pad with null bytes a message if too small, or leave unchanged if not necessary. This allows to keep track of padding and strip the null bytes after decoding reliably with binary data. Equivalent to shortening (shortened reed-solomon code).
[ "Automatically", "left", "pad", "with", "null", "bytes", "a", "message", "if", "too", "small", "or", "leave", "unchanged", "if", "not", "necessary", ".", "This", "allows", "to", "keep", "track", "of", "padding", "and", "strip", "the", "null", "bytes", "aft...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/eccman.py#L218-L226
lrq3000/pyFileFixity
pyFileFixity/lib/eccman.py
ECCMan.rpad
def rpad(self, ecc, k=None): '''Automatically right pad with null bytes an ecc to fill for missing bytes if too small, or leave unchanged if not necessary. This can be used as a workaround for field delimiter misdetection. Equivalent to puncturing (punctured reed-solomon code).''' if not k: k = self.k ...
python
def rpad(self, ecc, k=None): '''Automatically right pad with null bytes an ecc to fill for missing bytes if too small, or leave unchanged if not necessary. This can be used as a workaround for field delimiter misdetection. Equivalent to puncturing (punctured reed-solomon code).''' if not k: k = self.k ...
[ "def", "rpad", "(", "self", ",", "ecc", ",", "k", "=", "None", ")", ":", "if", "not", "k", ":", "k", "=", "self", ".", "k", "pad", "=", "None", "if", "len", "(", "ecc", ")", "<", "self", ".", "n", "-", "k", ":", "print", "(", "\"Warning: th...
Automatically right pad with null bytes an ecc to fill for missing bytes if too small, or leave unchanged if not necessary. This can be used as a workaround for field delimiter misdetection. Equivalent to puncturing (punctured reed-solomon code).
[ "Automatically", "right", "pad", "with", "null", "bytes", "an", "ecc", "to", "fill", "for", "missing", "bytes", "if", "too", "small", "or", "leave", "unchanged", "if", "not", "necessary", ".", "This", "can", "be", "used", "as", "a", "workaround", "for", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/eccman.py#L228-L237
lrq3000/pyFileFixity
pyFileFixity/lib/eccman.py
ECCMan.check
def check(self, message, ecc, k=None): '''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.''' if not k: k = self.k message, _ = self.pad(message,...
python
def check(self, message, ecc, k=None): '''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.''' if not k: k = self.k message, _ = self.pad(message,...
[ "def", "check", "(", "self", ",", "message", ",", "ecc", ",", "k", "=", "None", ")", ":", "if", "not", "k", ":", "k", "=", "self", ".", "k", "message", ",", "_", "=", "self", ".", "pad", "(", "message", ",", "k", "=", "k", ")", "ecc", ",", ...
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.
[ "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", ...
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/eccman.py#L239-L247
lrq3000/pyFileFixity
pyFileFixity/lib/eccman.py
ECCMan.description
def description(self): '''Provide a description for each algorithm available, useful to print in ecc file''' if 0 < self.algo <= 3: return "Reed-Solomon with polynomials in Galois field of characteristic %i (2^%i) with generator=%s, prime poly=%s and first consecutive root=%s." % (self.field...
python
def description(self): '''Provide a description for each algorithm available, useful to print in ecc file''' if 0 < self.algo <= 3: return "Reed-Solomon with polynomials in Galois field of characteristic %i (2^%i) with generator=%s, prime poly=%s and first consecutive root=%s." % (self.field...
[ "def", "description", "(", "self", ")", ":", "if", "0", "<", "self", ".", "algo", "<=", "3", ":", "return", "\"Reed-Solomon with polynomials in Galois field of characteristic %i (2^%i) with generator=%s, prime poly=%s and first consecutive root=%s.\"", "%", "(", "self", ".", ...
Provide a description for each algorithm available, useful to print in ecc file
[ "Provide", "a", "description", "for", "each", "algorithm", "available", "useful", "to", "print", "in", "ecc", "file" ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/eccman.py#L249-L256
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/profilehooks.py
profile
def profile(fn=None, skip=0, filename=None, immediate=False, dirs=False, sort=None, entries=40, profiler=('cProfile', 'profile', 'hotshot')): """Mark `fn` for profiling. If `skip` is > 0, first `skip` calls to `fn` will not be profiled. If `immediate` is False, profiling results wi...
python
def profile(fn=None, skip=0, filename=None, immediate=False, dirs=False, sort=None, entries=40, profiler=('cProfile', 'profile', 'hotshot')): """Mark `fn` for profiling. If `skip` is > 0, first `skip` calls to `fn` will not be profiled. If `immediate` is False, profiling results wi...
[ "def", "profile", "(", "fn", "=", "None", ",", "skip", "=", "0", ",", "filename", "=", "None", ",", "immediate", "=", "False", ",", "dirs", "=", "False", ",", "sort", "=", "None", ",", "entries", "=", "40", ",", "profiler", "=", "(", "'cProfile'", ...
Mark `fn` for profiling. If `skip` is > 0, first `skip` calls to `fn` will not be profiled. If `immediate` is False, profiling results will be printed to sys.stdout on program termination. Otherwise results will be printed after each call. If `dirs` is False only the name of the file will be pri...
[ "Mark", "fn", "for", "profiling", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/profilehooks.py#L137-L224
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/profilehooks.py
coverage
def coverage(fn): """Mark `fn` for line coverage analysis. Results will be printed to sys.stdout on program termination. Usage:: def fn(...): ... fn = coverage(fn) If you are using Python 2.4, you should be able to use the decorator syntax:: @coverage ...
python
def coverage(fn): """Mark `fn` for line coverage analysis. Results will be printed to sys.stdout on program termination. Usage:: def fn(...): ... fn = coverage(fn) If you are using Python 2.4, you should be able to use the decorator syntax:: @coverage ...
[ "def", "coverage", "(", "fn", ")", ":", "fp", "=", "TraceFuncCoverage", "(", "fn", ")", "# or HotShotFuncCoverage", "# We cannot return fp or fp.__call__ directly as that would break method", "# definitions, instead we need to return a plain function.", "def", "new_fn", "(", "*",...
Mark `fn` for line coverage analysis. Results will be printed to sys.stdout on program termination. Usage:: def fn(...): ... fn = coverage(fn) If you are using Python 2.4, you should be able to use the decorator syntax:: @coverage def fn(...): ...
[ "Mark", "fn", "for", "line", "coverage", "analysis", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/profilehooks.py#L227-L255
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/profilehooks.py
coverage_with_hotshot
def coverage_with_hotshot(fn): """Mark `fn` for line coverage analysis. Uses the 'hotshot' module for fast coverage analysis. BUG: Produces inaccurate results. See the docstring of `coverage` for usage examples. """ fp = HotShotFuncCoverage(fn) # We cannot return fp or fp.__call__ directl...
python
def coverage_with_hotshot(fn): """Mark `fn` for line coverage analysis. Uses the 'hotshot' module for fast coverage analysis. BUG: Produces inaccurate results. See the docstring of `coverage` for usage examples. """ fp = HotShotFuncCoverage(fn) # We cannot return fp or fp.__call__ directl...
[ "def", "coverage_with_hotshot", "(", "fn", ")", ":", "fp", "=", "HotShotFuncCoverage", "(", "fn", ")", "# We cannot return fp or fp.__call__ directly as that would break method", "# definitions, instead we need to return a plain function.", "def", "new_fn", "(", "*", "args", ",...
Mark `fn` for line coverage analysis. Uses the 'hotshot' module for fast coverage analysis. BUG: Produces inaccurate results. See the docstring of `coverage` for usage examples.
[ "Mark", "fn", "for", "line", "coverage", "analysis", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/profilehooks.py#L258-L276
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/profilehooks.py
timecall
def timecall(fn=None, immediate=True, timer=time.time): """Wrap `fn` and print its execution time. Example:: @timecall def somefunc(x, y): time.sleep(x * y) somefunc(2, 3) will print the time taken by somefunc on every call. If you want just a summary at program ...
python
def timecall(fn=None, immediate=True, timer=time.time): """Wrap `fn` and print its execution time. Example:: @timecall def somefunc(x, y): time.sleep(x * y) somefunc(2, 3) will print the time taken by somefunc on every call. If you want just a summary at program ...
[ "def", "timecall", "(", "fn", "=", "None", ",", "immediate", "=", "True", ",", "timer", "=", "time", ".", "time", ")", ":", "if", "fn", "is", "None", ":", "# @timecall() syntax -- we are a decorator maker", "def", "decorator", "(", "fn", ")", ":", "return"...
Wrap `fn` and print its execution time. Example:: @timecall def somefunc(x, y): time.sleep(x * y) somefunc(2, 3) will print the time taken by somefunc on every call. If you want just a summary at program termination, use @timecall(immediate=False) You c...
[ "Wrap", "fn", "and", "print", "its", "execution", "time", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/profilehooks.py#L655-L691
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/profilehooks.py
FuncProfile.print_stats
def print_stats(self): """Print profile information to sys.stdout.""" funcname = self.fn.__name__ filename = self.fn.__code__.co_filename lineno = self.fn.__code__.co_firstlineno print("") print("*** PROFILER RESULTS ***") print("%s (%s:%s)" % (funcname, filename,...
python
def print_stats(self): """Print profile information to sys.stdout.""" funcname = self.fn.__name__ filename = self.fn.__code__.co_filename lineno = self.fn.__code__.co_firstlineno print("") print("*** PROFILER RESULTS ***") print("%s (%s:%s)" % (funcname, filename,...
[ "def", "print_stats", "(", "self", ")", ":", "funcname", "=", "self", ".", "fn", ".", "__name__", "filename", "=", "self", ".", "fn", ".", "__code__", ".", "co_filename", "lineno", "=", "self", ".", "fn", ".", "__code__", ".", "co_firstlineno", "print", ...
Print profile information to sys.stdout.
[ "Print", "profile", "information", "to", "sys", ".", "stdout", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/profilehooks.py#L332-L352
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/profilehooks.py
FuncProfile.reset_stats
def reset_stats(self): """Reset accumulated profiler statistics.""" # Note: not using self.Profile, since pstats.Stats() fails then self.stats = pstats.Stats(Profile()) self.ncalls = 0 self.skipped = 0
python
def reset_stats(self): """Reset accumulated profiler statistics.""" # Note: not using self.Profile, since pstats.Stats() fails then self.stats = pstats.Stats(Profile()) self.ncalls = 0 self.skipped = 0
[ "def", "reset_stats", "(", "self", ")", ":", "# Note: not using self.Profile, since pstats.Stats() fails then", "self", ".", "stats", "=", "pstats", ".", "Stats", "(", "Profile", "(", ")", ")", "self", ".", "ncalls", "=", "0", "self", ".", "skipped", "=", "0" ...
Reset accumulated profiler statistics.
[ "Reset", "accumulated", "profiler", "statistics", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/profilehooks.py#L354-L359
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/profilehooks.py
TraceFuncCoverage.atexit
def atexit(self): """Stop profiling and print profile information to sys.stderr. This function is registered as an atexit hook. """ funcname = self.fn.__name__ filename = self.fn.__code__.co_filename lineno = self.fn.__code__.co_firstlineno print("") prin...
python
def atexit(self): """Stop profiling and print profile information to sys.stderr. This function is registered as an atexit hook. """ funcname = self.fn.__name__ filename = self.fn.__code__.co_filename lineno = self.fn.__code__.co_firstlineno print("") prin...
[ "def", "atexit", "(", "self", ")", ":", "funcname", "=", "self", ".", "fn", ".", "__name__", "filename", "=", "self", ".", "fn", ".", "__code__", ".", "co_filename", "lineno", "=", "self", ".", "fn", ".", "__code__", ".", "co_firstlineno", "print", "("...
Stop profiling and print profile information to sys.stderr. This function is registered as an atexit hook.
[ "Stop", "profiling", "and", "print", "profile", "information", "to", "sys", ".", "stderr", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/profilehooks.py#L569-L590
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/profilehooks.py
FuncSource.find_source_lines
def find_source_lines(self): """Mark all executable source lines in fn as executed 0 times.""" strs = trace.find_strings(self.filename) lines = trace.find_lines_from_code(self.fn.__code__, strs) self.firstcodelineno = sys.maxint for lineno in lines: self.firstcodeline...
python
def find_source_lines(self): """Mark all executable source lines in fn as executed 0 times.""" strs = trace.find_strings(self.filename) lines = trace.find_lines_from_code(self.fn.__code__, strs) self.firstcodelineno = sys.maxint for lineno in lines: self.firstcodeline...
[ "def", "find_source_lines", "(", "self", ")", ":", "strs", "=", "trace", ".", "find_strings", "(", "self", ".", "filename", ")", "lines", "=", "trace", ".", "find_lines_from_code", "(", "self", ".", "fn", ".", "__code__", ",", "strs", ")", "self", ".", ...
Mark all executable source lines in fn as executed 0 times.
[ "Mark", "all", "executable", "source", "lines", "in", "fn", "as", "executed", "0", "times", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/profilehooks.py#L606-L615
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/profilehooks.py
FuncSource.mark
def mark(self, lineno, count=1): """Mark a given source line as executed count times. Multiple calls to mark for the same lineno add up. """ self.sourcelines[lineno] = self.sourcelines.get(lineno, 0) + count
python
def mark(self, lineno, count=1): """Mark a given source line as executed count times. Multiple calls to mark for the same lineno add up. """ self.sourcelines[lineno] = self.sourcelines.get(lineno, 0) + count
[ "def", "mark", "(", "self", ",", "lineno", ",", "count", "=", "1", ")", ":", "self", ".", "sourcelines", "[", "lineno", "]", "=", "self", ".", "sourcelines", ".", "get", "(", "lineno", ",", "0", ")", "+", "count" ]
Mark a given source line as executed count times. Multiple calls to mark for the same lineno add up.
[ "Mark", "a", "given", "source", "line", "as", "executed", "count", "times", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/profilehooks.py#L617-L622
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/profilehooks.py
FuncSource.count_never_executed
def count_never_executed(self): """Count statements that were never executed.""" lineno = self.firstlineno counter = 0 for line in self.source: if self.sourcelines.get(lineno) == 0: if not self.blank_rx.match(line): counter += 1 ...
python
def count_never_executed(self): """Count statements that were never executed.""" lineno = self.firstlineno counter = 0 for line in self.source: if self.sourcelines.get(lineno) == 0: if not self.blank_rx.match(line): counter += 1 ...
[ "def", "count_never_executed", "(", "self", ")", ":", "lineno", "=", "self", ".", "firstlineno", "counter", "=", "0", "for", "line", "in", "self", ".", "source", ":", "if", "self", ".", "sourcelines", ".", "get", "(", "lineno", ")", "==", "0", ":", "...
Count statements that were never executed.
[ "Count", "statements", "that", "were", "never", "executed", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/profilehooks.py#L624-L633
lrq3000/pyFileFixity
pyFileFixity/lib/sortedcontainers/sortedlist.py
SortedList.add
def add(self, val): """Add the element *val* to the list.""" _maxes, _lists = self._maxes, self._lists if _maxes: pos = bisect_right(_maxes, val) if pos == len(_maxes): pos -= 1 _maxes[pos] = val _lists[pos].append(val) ...
python
def add(self, val): """Add the element *val* to the list.""" _maxes, _lists = self._maxes, self._lists if _maxes: pos = bisect_right(_maxes, val) if pos == len(_maxes): pos -= 1 _maxes[pos] = val _lists[pos].append(val) ...
[ "def", "add", "(", "self", ",", "val", ")", ":", "_maxes", ",", "_lists", "=", "self", ".", "_maxes", ",", "self", ".", "_lists", "if", "_maxes", ":", "pos", "=", "bisect_right", "(", "_maxes", ",", "val", ")", "if", "pos", "==", "len", "(", "_ma...
Add the element *val* to the list.
[ "Add", "the", "element", "*", "val", "*", "to", "the", "list", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlist.py#L113-L132
lrq3000/pyFileFixity
pyFileFixity/lib/sortedcontainers/sortedlist.py
SortedList.remove
def remove(self, val): """ Remove first occurrence of *val*. Raises ValueError if *val* is not present. """ _maxes = self._maxes if not _maxes: raise ValueError('{0} not in list'.format(repr(val))) pos = bisect_left(_maxes, val) if pos == l...
python
def remove(self, val): """ Remove first occurrence of *val*. Raises ValueError if *val* is not present. """ _maxes = self._maxes if not _maxes: raise ValueError('{0} not in list'.format(repr(val))) pos = bisect_left(_maxes, val) if pos == l...
[ "def", "remove", "(", "self", ",", "val", ")", ":", "_maxes", "=", "self", ".", "_maxes", "if", "not", "_maxes", ":", "raise", "ValueError", "(", "'{0} not in list'", ".", "format", "(", "repr", "(", "val", ")", ")", ")", "pos", "=", "bisect_left", "...
Remove first occurrence of *val*. Raises ValueError if *val* is not present.
[ "Remove", "first", "occurrence", "of", "*", "val", "*", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlist.py#L221-L242
lrq3000/pyFileFixity
pyFileFixity/lib/sortedcontainers/sortedlist.py
SortedList._delete
def _delete(self, pos, idx): """Delete the item at the given (pos, idx). Combines lists that are less than half the load level. Updates the index when the sublist length is more than half the load level. This requires decrementing the nodes in a traversal from the leaf node to ...
python
def _delete(self, pos, idx): """Delete the item at the given (pos, idx). Combines lists that are less than half the load level. Updates the index when the sublist length is more than half the load level. This requires decrementing the nodes in a traversal from the leaf node to ...
[ "def", "_delete", "(", "self", ",", "pos", ",", "idx", ")", ":", "_maxes", ",", "_lists", ",", "_index", "=", "self", ".", "_maxes", ",", "self", ".", "_lists", ",", "self", ".", "_index", "lists_pos", "=", "_lists", "[", "pos", "]", "del", "lists_...
Delete the item at the given (pos, idx). Combines lists that are less than half the load level. Updates the index when the sublist length is more than half the load level. This requires decrementing the nodes in a traversal from the leaf node to the root. For an example traversal see s...
[ "Delete", "the", "item", "at", "the", "given", "(", "pos", "idx", ")", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlist.py#L244-L296
lrq3000/pyFileFixity
pyFileFixity/lib/sortedcontainers/sortedlist.py
SortedList.extend
def extend(self, values): """ Extend the list by appending all elements from the *values*. Raises a ValueError if the sort order would be violated. """ _maxes, _lists, _load = self._maxes, self._lists, self._load if not isinstance(values, list): values = list...
python
def extend(self, values): """ Extend the list by appending all elements from the *values*. Raises a ValueError if the sort order would be violated. """ _maxes, _lists, _load = self._maxes, self._lists, self._load if not isinstance(values, list): values = list...
[ "def", "extend", "(", "self", ",", "values", ")", ":", "_maxes", ",", "_lists", ",", "_load", "=", "self", ".", "_maxes", ",", "self", ".", "_lists", ",", "self", ".", "_load", "if", "not", "isinstance", "(", "values", ",", "list", ")", ":", "value...
Extend the list by appending all elements from the *values*. Raises a ValueError if the sort order would be violated.
[ "Extend", "the", "list", "by", "appending", "all", "elements", "from", "the", "*", "values", "*", ".", "Raises", "a", "ValueError", "if", "the", "sort", "order", "would", "be", "violated", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlist.py#L1035-L1081
lrq3000/pyFileFixity
pyFileFixity/lib/sortedcontainers/sortedlist.py
SortedList.insert
def insert(self, idx, val): """ Insert the element *val* into the list at *idx*. Raises a ValueError if the *val* at *idx* would violate the sort order. """ _maxes, _lists, _len = self._maxes, self._lists, self._len if idx < 0: idx += _len if idx < 0:...
python
def insert(self, idx, val): """ Insert the element *val* into the list at *idx*. Raises a ValueError if the *val* at *idx* would violate the sort order. """ _maxes, _lists, _len = self._maxes, self._lists, self._len if idx < 0: idx += _len if idx < 0:...
[ "def", "insert", "(", "self", ",", "idx", ",", "val", ")", ":", "_maxes", ",", "_lists", ",", "_len", "=", "self", ".", "_maxes", ",", "self", ".", "_lists", ",", "self", ".", "_len", "if", "idx", "<", "0", ":", "idx", "+=", "_len", "if", "idx"...
Insert the element *val* into the list at *idx*. Raises a ValueError if the *val* at *idx* would violate the sort order.
[ "Insert", "the", "element", "*", "val", "*", "into", "the", "list", "at", "*", "idx", "*", ".", "Raises", "a", "ValueError", "if", "the", "*", "val", "*", "at", "*", "idx", "*", "would", "violate", "the", "sort", "order", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlist.py#L1083-L1141
lrq3000/pyFileFixity
pyFileFixity/lib/sortedcontainers/sortedlist.py
SortedListWithKey.update
def update(self, iterable): """Update the list by adding all elements from *iterable*.""" _maxes, _lists, _keys = self._maxes, self._lists, self._keys values = sorted(iterable, key=self._key) if _maxes: if len(values) * 4 >= self._len: values.extend(chain.fro...
python
def update(self, iterable): """Update the list by adding all elements from *iterable*.""" _maxes, _lists, _keys = self._maxes, self._lists, self._keys values = sorted(iterable, key=self._key) if _maxes: if len(values) * 4 >= self._len: values.extend(chain.fro...
[ "def", "update", "(", "self", ",", "iterable", ")", ":", "_maxes", ",", "_lists", ",", "_keys", "=", "self", ".", "_maxes", ",", "self", ".", "_lists", ",", "self", ".", "_keys", "values", "=", "sorted", "(", "iterable", ",", "key", "=", "self", "....
Update the list by adding all elements from *iterable*.
[ "Update", "the", "list", "by", "adding", "all", "elements", "from", "*", "iterable", "*", "." ]
train
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlist.py#L1517-L1539
aalireza/SimpleAudioIndexer
SimpleAudioIndexer/__init__.py
SimpleAudioIndexer.set_username_ibm
def set_username_ibm(self, username_ibm): """ Parameters ---------- username_ibm : str Raises ------ Exception If mode is not `ibm` """ if self.get_mode() == "ibm": self.__username_ibm = username_ibm else: ...
python
def set_username_ibm(self, username_ibm): """ Parameters ---------- username_ibm : str Raises ------ Exception If mode is not `ibm` """ if self.get_mode() == "ibm": self.__username_ibm = username_ibm else: ...
[ "def", "set_username_ibm", "(", "self", ",", "username_ibm", ")", ":", "if", "self", ".", "get_mode", "(", ")", "==", "\"ibm\"", ":", "self", ".", "__username_ibm", "=", "username_ibm", "else", ":", "raise", "Exception", "(", "\"Mode is {}, whereas it must be `i...
Parameters ---------- username_ibm : str Raises ------ Exception If mode is not `ibm`
[ "Parameters", "----------", "username_ibm", ":", "str" ]
train
https://github.com/aalireza/SimpleAudioIndexer/blob/73f9d75897d785bdaea9d28dde5fa48104428164/SimpleAudioIndexer/__init__.py#L325-L341
aalireza/SimpleAudioIndexer
SimpleAudioIndexer/__init__.py
SimpleAudioIndexer.set_password_ibm
def set_password_ibm(self, password_ibm): """ Parameters ---------- password_ibm : str Raises ------ Exception If mode is not `ibm` """ if self.get_mode() == "ibm": self.__password_ibm = password_ibm else: ...
python
def set_password_ibm(self, password_ibm): """ Parameters ---------- password_ibm : str Raises ------ Exception If mode is not `ibm` """ if self.get_mode() == "ibm": self.__password_ibm = password_ibm else: ...
[ "def", "set_password_ibm", "(", "self", ",", "password_ibm", ")", ":", "if", "self", ".", "get_mode", "(", ")", "==", "\"ibm\"", ":", "self", ".", "__password_ibm", "=", "password_ibm", "else", ":", "raise", "Exception", "(", "\"Mode is {}, whereas it must be `i...
Parameters ---------- password_ibm : str Raises ------ Exception If mode is not `ibm`
[ "Parameters", "----------", "password_ibm", ":", "str" ]
train
https://github.com/aalireza/SimpleAudioIndexer/blob/73f9d75897d785bdaea9d28dde5fa48104428164/SimpleAudioIndexer/__init__.py#L352-L367
aalireza/SimpleAudioIndexer
SimpleAudioIndexer/__init__.py
SimpleAudioIndexer._list_audio_files
def _list_audio_files(self, sub_dir=""): """ Parameters ---------- sub_dir : one of `needed_directories`, optional Default is "", which means it'll look through all of subdirs. Returns ------- audio_files : [str] A list whose elements are ...
python
def _list_audio_files(self, sub_dir=""): """ Parameters ---------- sub_dir : one of `needed_directories`, optional Default is "", which means it'll look through all of subdirs. Returns ------- audio_files : [str] A list whose elements are ...
[ "def", "_list_audio_files", "(", "self", ",", "sub_dir", "=", "\"\"", ")", ":", "audio_files", "=", "list", "(", ")", "for", "possibly_audio_file", "in", "os", ".", "listdir", "(", "\"{}/{}\"", ".", "format", "(", "self", ".", "src_dir", ",", "sub_dir", ...
Parameters ---------- sub_dir : one of `needed_directories`, optional Default is "", which means it'll look through all of subdirs. Returns ------- audio_files : [str] A list whose elements are basenames of the present audiofiles whose formats...
[ "Parameters", "----------", "sub_dir", ":", "one", "of", "needed_directories", "optional", "Default", "is", "which", "means", "it", "ll", "look", "through", "all", "of", "subdirs", "." ]
train
https://github.com/aalireza/SimpleAudioIndexer/blob/73f9d75897d785bdaea9d28dde5fa48104428164/SimpleAudioIndexer/__init__.py#L418-L437
aalireza/SimpleAudioIndexer
SimpleAudioIndexer/__init__.py
SimpleAudioIndexer._get_audio_channels
def _get_audio_channels(self, audio_abs_path): """ Parameters ---------- audio_abs_path : str Returns ------- channel_num : int """ channel_num = int( subprocess.check_output( ("""sox --i {} | grep "{}" | awk -F " : " '...
python
def _get_audio_channels(self, audio_abs_path): """ Parameters ---------- audio_abs_path : str Returns ------- channel_num : int """ channel_num = int( subprocess.check_output( ("""sox --i {} | grep "{}" | awk -F " : " '...
[ "def", "_get_audio_channels", "(", "self", ",", "audio_abs_path", ")", ":", "channel_num", "=", "int", "(", "subprocess", ".", "check_output", "(", "(", "\"\"\"sox --i {} | grep \"{}\" | awk -F \" : \" '{{print $2}}'\"\"\"", ")", ".", "format", "(", "audio_abs_path", ",...
Parameters ---------- audio_abs_path : str Returns ------- channel_num : int
[ "Parameters", "----------", "audio_abs_path", ":", "str" ]
train
https://github.com/aalireza/SimpleAudioIndexer/blob/73f9d75897d785bdaea9d28dde5fa48104428164/SimpleAudioIndexer/__init__.py#L439-L454
aalireza/SimpleAudioIndexer
SimpleAudioIndexer/__init__.py
SimpleAudioIndexer._get_audio_sample_rate
def _get_audio_sample_rate(self, audio_abs_path): """ Parameters ---------- audio_abs_path : str Returns ------- sample_rate : int """ sample_rate = int( subprocess.check_output( ("""sox --i {} | grep "{}" | awk -F " : " ...
python
def _get_audio_sample_rate(self, audio_abs_path): """ Parameters ---------- audio_abs_path : str Returns ------- sample_rate : int """ sample_rate = int( subprocess.check_output( ("""sox --i {} | grep "{}" | awk -F " : " ...
[ "def", "_get_audio_sample_rate", "(", "self", ",", "audio_abs_path", ")", ":", "sample_rate", "=", "int", "(", "subprocess", ".", "check_output", "(", "(", "\"\"\"sox --i {} | grep \"{}\" | awk -F \" : \" '{{print $2}}'\"\"\"", ")", ".", "format", "(", "audio_abs_path", ...
Parameters ---------- audio_abs_path : str Returns ------- sample_rate : int
[ "Parameters", "----------", "audio_abs_path", ":", "str" ]
train
https://github.com/aalireza/SimpleAudioIndexer/blob/73f9d75897d785bdaea9d28dde5fa48104428164/SimpleAudioIndexer/__init__.py#L456-L471
aalireza/SimpleAudioIndexer
SimpleAudioIndexer/__init__.py
SimpleAudioIndexer._get_audio_sample_bit
def _get_audio_sample_bit(self, audio_abs_path): """ Parameters ---------- audio_abs_path : str Returns ------- sample_bit : int """ sample_bit = int( subprocess.check_output( ("""sox --i {} | grep "{}" | awk -F " : " '{{...
python
def _get_audio_sample_bit(self, audio_abs_path): """ Parameters ---------- audio_abs_path : str Returns ------- sample_bit : int """ sample_bit = int( subprocess.check_output( ("""sox --i {} | grep "{}" | awk -F " : " '{{...
[ "def", "_get_audio_sample_bit", "(", "self", ",", "audio_abs_path", ")", ":", "sample_bit", "=", "int", "(", "subprocess", ".", "check_output", "(", "(", "\"\"\"sox --i {} | grep \"{}\" | awk -F \" : \" '{{print $2}}' | \"\"\"", "\"\"\"grep -oh \"^[^-]*\" \"\"\"", ")", ".", ...
Parameters ---------- audio_abs_path : str Returns ------- sample_bit : int
[ "Parameters", "----------", "audio_abs_path", ":", "str" ]
train
https://github.com/aalireza/SimpleAudioIndexer/blob/73f9d75897d785bdaea9d28dde5fa48104428164/SimpleAudioIndexer/__init__.py#L473-L488
aalireza/SimpleAudioIndexer
SimpleAudioIndexer/__init__.py
SimpleAudioIndexer._get_audio_duration_seconds
def _get_audio_duration_seconds(self, audio_abs_path): """ Parameters ---------- audio_abs_path : str Returns ------- total_seconds : int """ HHMMSS_duration = subprocess.check_output( ("""sox --i {} | grep "{}" | awk -F " : " '{{print...
python
def _get_audio_duration_seconds(self, audio_abs_path): """ Parameters ---------- audio_abs_path : str Returns ------- total_seconds : int """ HHMMSS_duration = subprocess.check_output( ("""sox --i {} | grep "{}" | awk -F " : " '{{print...
[ "def", "_get_audio_duration_seconds", "(", "self", ",", "audio_abs_path", ")", ":", "HHMMSS_duration", "=", "subprocess", ".", "check_output", "(", "(", "\"\"\"sox --i {} | grep \"{}\" | awk -F \" : \" '{{print $2}}' | \"\"\"", "\"\"\"grep -oh \"^[^=]*\" \"\"\"", ")", ".", "for...
Parameters ---------- audio_abs_path : str Returns ------- total_seconds : int
[ "Parameters", "----------", "audio_abs_path", ":", "str" ]
train
https://github.com/aalireza/SimpleAudioIndexer/blob/73f9d75897d785bdaea9d28dde5fa48104428164/SimpleAudioIndexer/__init__.py#L490-L508
aalireza/SimpleAudioIndexer
SimpleAudioIndexer/__init__.py
SimpleAudioIndexer._get_audio_bit_rate
def _get_audio_bit_rate(self, audio_abs_path): """ Parameters ----------- audio_abs_path : str Returns ------- bit_rate : int """ bit_Rate_formatted = subprocess.check_output( """sox --i {} | grep "{}" | awk -F " : " '{{print $2}}'"""....
python
def _get_audio_bit_rate(self, audio_abs_path): """ Parameters ----------- audio_abs_path : str Returns ------- bit_rate : int """ bit_Rate_formatted = subprocess.check_output( """sox --i {} | grep "{}" | awk -F " : " '{{print $2}}'"""....
[ "def", "_get_audio_bit_rate", "(", "self", ",", "audio_abs_path", ")", ":", "bit_Rate_formatted", "=", "subprocess", ".", "check_output", "(", "\"\"\"sox --i {} | grep \"{}\" | awk -F \" : \" '{{print $2}}'\"\"\"", ".", "format", "(", "audio_abs_path", ",", "\"Bit Rate\"", ...
Parameters ----------- audio_abs_path : str Returns ------- bit_rate : int
[ "Parameters", "-----------", "audio_abs_path", ":", "str" ]
train
https://github.com/aalireza/SimpleAudioIndexer/blob/73f9d75897d785bdaea9d28dde5fa48104428164/SimpleAudioIndexer/__init__.py#L510-L529
aalireza/SimpleAudioIndexer
SimpleAudioIndexer/__init__.py
SimpleAudioIndexer._seconds_to_HHMMSS
def _seconds_to_HHMMSS(seconds): """ Retuns a string which is the hour, minute, second(milli) representation of the intput `seconds` Parameters ---------- seconds : float Returns ------- str Has the form <int>H<int>M<int>S.<float> ...
python
def _seconds_to_HHMMSS(seconds): """ Retuns a string which is the hour, minute, second(milli) representation of the intput `seconds` Parameters ---------- seconds : float Returns ------- str Has the form <int>H<int>M<int>S.<float> ...
[ "def", "_seconds_to_HHMMSS", "(", "seconds", ")", ":", "less_than_second", "=", "seconds", "-", "floor", "(", "seconds", ")", "minutes", ",", "seconds", "=", "divmod", "(", "floor", "(", "seconds", ")", ",", "60", ")", "hours", ",", "minutes", "=", "divm...
Retuns a string which is the hour, minute, second(milli) representation of the intput `seconds` Parameters ---------- seconds : float Returns ------- str Has the form <int>H<int>M<int>S.<float>
[ "Retuns", "a", "string", "which", "is", "the", "hour", "minute", "second", "(", "milli", ")", "representation", "of", "the", "intput", "seconds" ]
train
https://github.com/aalireza/SimpleAudioIndexer/blob/73f9d75897d785bdaea9d28dde5fa48104428164/SimpleAudioIndexer/__init__.py#L531-L548
aalireza/SimpleAudioIndexer
SimpleAudioIndexer/__init__.py
SimpleAudioIndexer._audio_segment_extractor
def _audio_segment_extractor(self, audio_abs_path, segment_abs_path, starting_second, duration): """ Parameters ----------- audio_abs_path : str segment_abs_path : str starting_second : int duration : int """ subpr...
python
def _audio_segment_extractor(self, audio_abs_path, segment_abs_path, starting_second, duration): """ Parameters ----------- audio_abs_path : str segment_abs_path : str starting_second : int duration : int """ subpr...
[ "def", "_audio_segment_extractor", "(", "self", ",", "audio_abs_path", ",", "segment_abs_path", ",", "starting_second", ",", "duration", ")", ":", "subprocess", ".", "Popen", "(", "[", "\"sox\"", ",", "str", "(", "audio_abs_path", ")", ",", "str", "(", "segmen...
Parameters ----------- audio_abs_path : str segment_abs_path : str starting_second : int duration : int
[ "Parameters", "-----------", "audio_abs_path", ":", "str", "segment_abs_path", ":", "str", "starting_second", ":", "int", "duration", ":", "int" ]
train
https://github.com/aalireza/SimpleAudioIndexer/blob/73f9d75897d785bdaea9d28dde5fa48104428164/SimpleAudioIndexer/__init__.py#L550-L563