repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
useblocks/groundwork
groundwork/plugins/gw_signals_info.py
GwSignalsInfo.list_signals
def list_signals(self): """ Prints a list of all registered signals. Including description and plugin name. """ print("Signal list") print("***********\n") for key, signal in self.app.signals.signals.items(): print("%s (%s)\n %s\n" % (signal.name, signal.plug...
python
def list_signals(self): """ Prints a list of all registered signals. Including description and plugin name. """ print("Signal list") print("***********\n") for key, signal in self.app.signals.signals.items(): print("%s (%s)\n %s\n" % (signal.name, signal.plug...
[ "def", "list_signals", "(", "self", ")", ":", "print", "(", "\"Signal list\"", ")", "print", "(", "\"***********\\n\"", ")", "for", "key", ",", "signal", "in", "self", ".", "app", ".", "signals", ".", "signals", ".", "items", "(", ")", ":", "print", "(...
Prints a list of all registered signals. Including description and plugin name.
[ "Prints", "a", "list", "of", "all", "registered", "signals", ".", "Including", "description", "and", "plugin", "name", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/plugins/gw_signals_info.py#L73-L80
train
Prints a list of all registered signals. Including description and plugin name.
useblocks/groundwork
groundwork/plugins/gw_signals_info.py
GwSignalsInfo.list_receivers
def list_receivers(self): """ Prints a list of all registered receivers. Including signal, plugin name and description. """ print("Receiver list") print("*************\n") for key, receiver in self.app.signals.receivers.items(): print("%s <-- %s (%s):\n %s\n"...
python
def list_receivers(self): """ Prints a list of all registered receivers. Including signal, plugin name and description. """ print("Receiver list") print("*************\n") for key, receiver in self.app.signals.receivers.items(): print("%s <-- %s (%s):\n %s\n"...
[ "def", "list_receivers", "(", "self", ")", ":", "print", "(", "\"Receiver list\"", ")", "print", "(", "\"*************\\n\"", ")", "for", "key", ",", "receiver", "in", "self", ".", "app", ".", "signals", ".", "receivers", ".", "items", "(", ")", ":", "pr...
Prints a list of all registered receivers. Including signal, plugin name and description.
[ "Prints", "a", "list", "of", "all", "registered", "receivers", ".", "Including", "signal", "plugin", "name", "and", "description", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/plugins/gw_signals_info.py#L82-L92
train
Prints a list of all registered receivers. Including signal plugin name and description.
ph4r05/monero-serialize
monero_serialize/core/versioning.py
TypeWrapper.is_elementary_type
def is_elementary_type(elem_type): """ Returns True if the type is elementary - not versioned :param elem_type: :return: """ if not oh.is_type(elem_type, bt.XmrType): return False if oh.is_type(elem_type, (bt.UVarintType, bt.IntType, mt.UnicodeType)): ...
python
def is_elementary_type(elem_type): """ Returns True if the type is elementary - not versioned :param elem_type: :return: """ if not oh.is_type(elem_type, bt.XmrType): return False if oh.is_type(elem_type, (bt.UVarintType, bt.IntType, mt.UnicodeType)): ...
[ "def", "is_elementary_type", "(", "elem_type", ")", ":", "if", "not", "oh", ".", "is_type", "(", "elem_type", ",", "bt", ".", "XmrType", ")", ":", "return", "False", "if", "oh", ".", "is_type", "(", "elem_type", ",", "(", "bt", ".", "UVarintType", ",",...
Returns True if the type is elementary - not versioned :param elem_type: :return:
[ "Returns", "True", "if", "the", "type", "is", "elementary", "-", "not", "versioned", ":", "param", "elem_type", ":", ":", "return", ":" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/core/versioning.py#L18-L28
train
Returns True if the type is elementary - not versioned
jenisys/parse_type
bin/toxcmd.py
command_copytree
def command_copytree(args): """ Copy one or more source directory(s) below a destination directory. Parts of the destination directory path are created if needed. Similar to the UNIX command: 'cp -R srcdir destdir' """ for srcdir in args.srcdirs: basename = os.path.basename(srcdir) ...
python
def command_copytree(args): """ Copy one or more source directory(s) below a destination directory. Parts of the destination directory path are created if needed. Similar to the UNIX command: 'cp -R srcdir destdir' """ for srcdir in args.srcdirs: basename = os.path.basename(srcdir) ...
[ "def", "command_copytree", "(", "args", ")", ":", "for", "srcdir", "in", "args", ".", "srcdirs", ":", "basename", "=", "os", ".", "path", ".", "basename", "(", "srcdir", ")", "destdir2", "=", "os", ".", "path", ".", "normpath", "(", "os", ".", "path"...
Copy one or more source directory(s) below a destination directory. Parts of the destination directory path are created if needed. Similar to the UNIX command: 'cp -R srcdir destdir'
[ "Copy", "one", "or", "more", "source", "directory", "(", "s", ")", "below", "a", "destination", "directory", ".", "Parts", "of", "the", "destination", "directory", "path", "are", "created", "if", "needed", ".", "Similar", "to", "the", "UNIX", "command", ":...
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/bin/toxcmd.py#L37-L50
train
Copy one or more source directories below a destination directory.
jenisys/parse_type
bin/toxcmd.py
command_copy
def command_copy(args): """ Copy one or more source-files(s) to a destpath (destfile or destdir). Destdir mode is used if: * More than one srcfile is provided * Last parameter ends with a slash ("/"). * Last parameter is an existing directory Destination directory path is created if n...
python
def command_copy(args): """ Copy one or more source-files(s) to a destpath (destfile or destdir). Destdir mode is used if: * More than one srcfile is provided * Last parameter ends with a slash ("/"). * Last parameter is an existing directory Destination directory path is created if n...
[ "def", "command_copy", "(", "args", ")", ":", "sources", "=", "args", ".", "sources", "destpath", "=", "args", ".", "destpath", "source_files", "=", "[", "]", "for", "file_", "in", "sources", ":", "if", "\"*\"", "in", "file_", ":", "selected", "=", "gl...
Copy one or more source-files(s) to a destpath (destfile or destdir). Destdir mode is used if: * More than one srcfile is provided * Last parameter ends with a slash ("/"). * Last parameter is an existing directory Destination directory path is created if needed. Similar to the UNIX comma...
[ "Copy", "one", "or", "more", "source", "-", "files", "(", "s", ")", "to", "a", "destpath", "(", "destfile", "or", "destdir", ")", ".", "Destdir", "mode", "is", "used", "if", ":", "*", "More", "than", "one", "srcfile", "is", "provided", "*", "Last", ...
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/bin/toxcmd.py#L66-L103
train
Copy one or more source files to a destpath.
jenisys/parse_type
bin/toxcmd.py
command_mkdir
def command_mkdir(args): """ Create a non-existing directory (or more ...). If the directory exists, the step is skipped. Similar to the UNIX command: 'mkdir -p dir' """ errors = 0 for directory in args.dirs: if os.path.exists(directory): if not os.path.isdir(directory): ...
python
def command_mkdir(args): """ Create a non-existing directory (or more ...). If the directory exists, the step is skipped. Similar to the UNIX command: 'mkdir -p dir' """ errors = 0 for directory in args.dirs: if os.path.exists(directory): if not os.path.isdir(directory): ...
[ "def", "command_mkdir", "(", "args", ")", ":", "errors", "=", "0", "for", "directory", "in", "args", ".", "dirs", ":", "if", "os", ".", "path", ".", "exists", "(", "directory", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "directory...
Create a non-existing directory (or more ...). If the directory exists, the step is skipped. Similar to the UNIX command: 'mkdir -p dir'
[ "Create", "a", "non", "-", "existing", "directory", "(", "or", "more", "...", ")", ".", "If", "the", "directory", "exists", "the", "step", "is", "skipped", ".", "Similar", "to", "the", "UNIX", "command", ":", "mkdir", "-", "p", "dir" ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/bin/toxcmd.py#L119-L138
train
Create a non - existing directory.
jenisys/parse_type
bin/toxcmd.py
command_py2to3
def command_py2to3(args): """ Apply '2to3' tool (Python2 to Python3 conversion tool) to Python sources. """ from lib2to3.main import main sys.exit(main("lib2to3.fixes", args=args.sources))
python
def command_py2to3(args): """ Apply '2to3' tool (Python2 to Python3 conversion tool) to Python sources. """ from lib2to3.main import main sys.exit(main("lib2to3.fixes", args=args.sources))
[ "def", "command_py2to3", "(", "args", ")", ":", "from", "lib2to3", ".", "main", "import", "main", "sys", ".", "exit", "(", "main", "(", "\"lib2to3.fixes\"", ",", "args", "=", "args", ".", "sources", ")", ")" ]
Apply '2to3' tool (Python2 to Python3 conversion tool) to Python sources.
[ "Apply", "2to3", "tool", "(", "Python2", "to", "Python3", "conversion", "tool", ")", "to", "Python", "sources", "." ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/bin/toxcmd.py#L151-L156
train
Python 2 to 3 conversion tool.
jenisys/parse_type
bin/toxcmd.py
toxcmd_main
def toxcmd_main(args=None): """Command util with subcommands for tox environments.""" usage = "USAGE: %(prog)s [OPTIONS] COMMAND args..." if args is None: args = sys.argv[1:] # -- STEP: Build command-line parser. parser = argparse.ArgumentParser(description=inspect.getdoc(toxcmd_main), ...
python
def toxcmd_main(args=None): """Command util with subcommands for tox environments.""" usage = "USAGE: %(prog)s [OPTIONS] COMMAND args..." if args is None: args = sys.argv[1:] # -- STEP: Build command-line parser. parser = argparse.ArgumentParser(description=inspect.getdoc(toxcmd_main), ...
[ "def", "toxcmd_main", "(", "args", "=", "None", ")", ":", "usage", "=", "\"USAGE: %(prog)s [OPTIONS] COMMAND args...\"", "if", "args", "is", "None", ":", "args", "=", "sys", ".", "argv", "[", "1", ":", "]", "# -- STEP: Build command-line parser.", "parser", "=",...
Command util with subcommands for tox environments.
[ "Command", "util", "with", "subcommands", "for", "tox", "environments", "." ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/bin/toxcmd.py#L220-L245
train
Command util with subcommands for tox environments.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/bakery/_discharge.py
discharge_all
def discharge_all(m, get_discharge, local_key=None): '''Gathers discharge macaroons for all the third party caveats in m (and any subsequent caveats required by those) using get_discharge to acquire each discharge macaroon. The local_key parameter may optionally hold the key of the client, in which ...
python
def discharge_all(m, get_discharge, local_key=None): '''Gathers discharge macaroons for all the third party caveats in m (and any subsequent caveats required by those) using get_discharge to acquire each discharge macaroon. The local_key parameter may optionally hold the key of the client, in which ...
[ "def", "discharge_all", "(", "m", ",", "get_discharge", ",", "local_key", "=", "None", ")", ":", "primary", "=", "m", ".", "macaroon", "discharges", "=", "[", "primary", "]", "# cav holds the macaroon caveat that needs discharge.", "# encrypted_caveat (bytes) holds encr...
Gathers discharge macaroons for all the third party caveats in m (and any subsequent caveats required by those) using get_discharge to acquire each discharge macaroon. The local_key parameter may optionally hold the key of the client, in which case it will be used to discharge any third party caveats wi...
[ "Gathers", "discharge", "macaroons", "for", "all", "the", "third", "party", "caveats", "in", "m", "(", "and", "any", "subsequent", "caveats", "required", "by", "those", ")", "using", "get_discharge", "to", "acquire", "each", "discharge", "macaroon", ".", "The"...
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_discharge.py#L24-L84
train
Discharge all third party caveats in the given macaroon.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/bakery/_discharge.py
discharge
def discharge(ctx, id, caveat, key, checker, locator): ''' Creates a macaroon to discharge a third party caveat. The given parameters specify the caveat and how it should be checked. The condition implicit in the caveat is checked for validity using checker. If it is valid, a new macaroon is returned w...
python
def discharge(ctx, id, caveat, key, checker, locator): ''' Creates a macaroon to discharge a third party caveat. The given parameters specify the caveat and how it should be checked. The condition implicit in the caveat is checked for validity using checker. If it is valid, a new macaroon is returned w...
[ "def", "discharge", "(", "ctx", ",", "id", ",", "caveat", ",", "key", ",", "checker", ",", "locator", ")", ":", "caveat_id_prefix", "=", "[", "]", "if", "caveat", "is", "None", ":", "# The caveat information is encoded in the id itself.", "caveat", "=", "id", ...
Creates a macaroon to discharge a third party caveat. The given parameters specify the caveat and how it should be checked. The condition implicit in the caveat is checked for validity using checker. If it is valid, a new macaroon is returned which discharges the caveat. The macaroon is created with a ...
[ "Creates", "a", "macaroon", "to", "discharge", "a", "third", "party", "caveat", "." ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_discharge.py#L116-L187
train
Discharge a third party caveat.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/bakery/_discharge.py
local_third_party_caveat
def local_third_party_caveat(key, version): ''' Returns a third-party caveat that, when added to a macaroon with add_caveat, results in a caveat with the location "local", encrypted with the given PublicKey. This can be automatically discharged by discharge_all passing a local key. ''' if versio...
python
def local_third_party_caveat(key, version): ''' Returns a third-party caveat that, when added to a macaroon with add_caveat, results in a caveat with the location "local", encrypted with the given PublicKey. This can be automatically discharged by discharge_all passing a local key. ''' if versio...
[ "def", "local_third_party_caveat", "(", "key", ",", "version", ")", ":", "if", "version", ">=", "VERSION_2", ":", "loc", "=", "'local {} {}'", ".", "format", "(", "version", ",", "key", ")", "else", ":", "loc", "=", "'local {}'", ".", "format", "(", "key...
Returns a third-party caveat that, when added to a macaroon with add_caveat, results in a caveat with the location "local", encrypted with the given PublicKey. This can be automatically discharged by discharge_all passing a local key.
[ "Returns", "a", "third", "-", "party", "caveat", "that", "when", "added", "to", "a", "macaroon", "with", "add_caveat", "results", "in", "a", "caveat", "with", "the", "location", "local", "encrypted", "with", "the", "given", "PublicKey", ".", "This", "can", ...
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_discharge.py#L234-L244
train
Returns a third - party caveat that is added to a macaroon with the given PublicKey.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/checkers/_namespace.py
deserialize_namespace
def deserialize_namespace(data): ''' Deserialize a Namespace object. :param data: bytes or str :return: namespace ''' if isinstance(data, bytes): data = data.decode('utf-8') kvs = data.split() uri_to_prefix = {} for kv in kvs: i = kv.rfind(':') if i == -1: ...
python
def deserialize_namespace(data): ''' Deserialize a Namespace object. :param data: bytes or str :return: namespace ''' if isinstance(data, bytes): data = data.decode('utf-8') kvs = data.split() uri_to_prefix = {} for kv in kvs: i = kv.rfind(':') if i == -1: ...
[ "def", "deserialize_namespace", "(", "data", ")", ":", "if", "isinstance", "(", "data", ",", "bytes", ")", ":", "data", "=", "data", ".", "decode", "(", "'utf-8'", ")", "kvs", "=", "data", ".", "split", "(", ")", "uri_to_prefix", "=", "{", "}", "for"...
Deserialize a Namespace object. :param data: bytes or str :return: namespace
[ "Deserialize", "a", "Namespace", "object", "." ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_namespace.py#L134-L165
train
Deserialize a Namespace object.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/checkers/_namespace.py
Namespace.serialize_text
def serialize_text(self): '''Returns a serialized form of the Namepace. All the elements in the namespace are sorted by URI, joined to the associated prefix with a colon and separated with spaces. :return: bytes ''' if self._uri_to_prefix is None or len(self._uri...
python
def serialize_text(self): '''Returns a serialized form of the Namepace. All the elements in the namespace are sorted by URI, joined to the associated prefix with a colon and separated with spaces. :return: bytes ''' if self._uri_to_prefix is None or len(self._uri...
[ "def", "serialize_text", "(", "self", ")", ":", "if", "self", ".", "_uri_to_prefix", "is", "None", "or", "len", "(", "self", ".", "_uri_to_prefix", ")", "==", "0", ":", "return", "b''", "od", "=", "collections", ".", "OrderedDict", "(", "sorted", "(", ...
Returns a serialized form of the Namepace. All the elements in the namespace are sorted by URI, joined to the associated prefix with a colon and separated with spaces. :return: bytes
[ "Returns", "a", "serialized", "form", "of", "the", "Namepace", "." ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_namespace.py#L33-L47
train
Returns a serialized form of the Namepace.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/checkers/_namespace.py
Namespace.register
def register(self, uri, prefix): '''Registers the given URI and associates it with the given prefix. If the URI has already been registered, this is a no-op. :param uri: string :param prefix: string ''' if not is_valid_schema_uri(uri): raise KeyError( ...
python
def register(self, uri, prefix): '''Registers the given URI and associates it with the given prefix. If the URI has already been registered, this is a no-op. :param uri: string :param prefix: string ''' if not is_valid_schema_uri(uri): raise KeyError( ...
[ "def", "register", "(", "self", ",", "uri", ",", "prefix", ")", ":", "if", "not", "is_valid_schema_uri", "(", "uri", ")", ":", "raise", "KeyError", "(", "'cannot register invalid URI {} (prefix {})'", ".", "format", "(", "uri", ",", "prefix", ")", ")", "if",...
Registers the given URI and associates it with the given prefix. If the URI has already been registered, this is a no-op. :param uri: string :param prefix: string
[ "Registers", "the", "given", "URI", "and", "associates", "it", "with", "the", "given", "prefix", "." ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_namespace.py#L49-L66
train
Registers the given URI and associates it with the given prefix.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/checkers/_namespace.py
Namespace.resolve_caveat
def resolve_caveat(self, cav): ''' Resolves the given caveat(string) by using resolve to map from its schema namespace to the appropriate prefix. If there is no registered prefix for the namespace, it returns an error caveat. If cav.namespace is empty or cav.location is non-empty...
python
def resolve_caveat(self, cav): ''' Resolves the given caveat(string) by using resolve to map from its schema namespace to the appropriate prefix. If there is no registered prefix for the namespace, it returns an error caveat. If cav.namespace is empty or cav.location is non-empty...
[ "def", "resolve_caveat", "(", "self", ",", "cav", ")", ":", "# TODO: If a namespace isn't registered, try to resolve it by", "# resolving it to the latest compatible version that is", "# registered.", "if", "cav", ".", "namespace", "==", "''", "or", "cav", ".", "location", ...
Resolves the given caveat(string) by using resolve to map from its schema namespace to the appropriate prefix. If there is no registered prefix for the namespace, it returns an error caveat. If cav.namespace is empty or cav.location is non-empty, it returns cav unchanged. ...
[ "Resolves", "the", "given", "caveat", "(", "string", ")", "by", "using", "resolve", "to", "map", "from", "its", "schema", "namespace", "to", "the", "appropriate", "prefix", ".", "If", "there", "is", "no", "registered", "prefix", "for", "the", "namespace", ...
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_namespace.py#L77-L108
train
Resolves the given caveat by using resolve to map from its schema namespace to the appropriate prefix.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/checkers/_auth_context.py
AuthContext.with_value
def with_value(self, key, val): ''' Return a copy of the AuthContext object with the given key and value added. ''' new_dict = dict(self._dict) new_dict[key] = val return AuthContext(new_dict)
python
def with_value(self, key, val): ''' Return a copy of the AuthContext object with the given key and value added. ''' new_dict = dict(self._dict) new_dict[key] = val return AuthContext(new_dict)
[ "def", "with_value", "(", "self", ",", "key", ",", "val", ")", ":", "new_dict", "=", "dict", "(", "self", ".", "_dict", ")", "new_dict", "[", "key", "]", "=", "val", "return", "AuthContext", "(", "new_dict", ")" ]
Return a copy of the AuthContext object with the given key and value added.
[ "Return", "a", "copy", "of", "the", "AuthContext", "object", "with", "the", "given", "key", "and", "value", "added", "." ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_auth_context.py#L19-L25
train
Return a copy of the AuthContext object with the given key and val added.
atarashansky/self-assembling-manifold
utilities.py
save_figures
def save_figures(filename, fig_IDs=None, **kwargs): """ Save figures. Parameters ---------- filename - str Name of output file fig_IDs - int, numpy.array, list, optional, default None A list of open figure IDs or a figure ID that will be saved to a pdf/png f...
python
def save_figures(filename, fig_IDs=None, **kwargs): """ Save figures. Parameters ---------- filename - str Name of output file fig_IDs - int, numpy.array, list, optional, default None A list of open figure IDs or a figure ID that will be saved to a pdf/png f...
[ "def", "save_figures", "(", "filename", ",", "fig_IDs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "if", "(", "fig_IDs", "is", "not", "None", ")", ":", "if", "(", "type", "(", "fig_IDs", ")", ...
Save figures. Parameters ---------- filename - str Name of output file fig_IDs - int, numpy.array, list, optional, default None A list of open figure IDs or a figure ID that will be saved to a pdf/png file respectively. **kwargs - Extra keyword arg...
[ "Save", "figures", ".", "Parameters", "----------", "filename", "-", "str", "Name", "of", "output", "file", "fig_IDs", "-", "int", "numpy", ".", "array", "list", "optional", "default", "None", "A", "list", "of", "open", "figure", "IDs", "or", "a", "figure"...
4db4793f65af62047492327716932ba81a67f679
https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/utilities.py#L62-L107
train
Save figures to a single file.
dbarsam/python-vsgen
vsgen/register.py
VSGRegisterCommand.execute
def execute(self): """ Executes the command. """ from vsgen.util.logger import VSGLogger VSGLogger.info(self._logname, self._message) start = time.clock() for i in self._registerables: i.register() end = time.clock() VSGLogger.info(sel...
python
def execute(self): """ Executes the command. """ from vsgen.util.logger import VSGLogger VSGLogger.info(self._logname, self._message) start = time.clock() for i in self._registerables: i.register() end = time.clock() VSGLogger.info(sel...
[ "def", "execute", "(", "self", ")", ":", "from", "vsgen", ".", "util", ".", "logger", "import", "VSGLogger", "VSGLogger", ".", "info", "(", "self", ".", "_logname", ",", "self", ".", "_message", ")", "start", "=", "time", ".", "clock", "(", ")", "for...
Executes the command.
[ "Executes", "the", "command", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/register.py#L84-L96
train
Executes the command.
jenisys/parse_type
parse_type/cardinality.py
Cardinality.make_pattern
def make_pattern(self, pattern, listsep=','): """Make pattern for a data type with the specified cardinality. .. code-block:: python yes_no_pattern = r"yes|no" many_yes_no = Cardinality.one_or_more.make_pattern(yes_no_pattern) :param pattern: Regular expression for ty...
python
def make_pattern(self, pattern, listsep=','): """Make pattern for a data type with the specified cardinality. .. code-block:: python yes_no_pattern = r"yes|no" many_yes_no = Cardinality.one_or_more.make_pattern(yes_no_pattern) :param pattern: Regular expression for ty...
[ "def", "make_pattern", "(", "self", ",", "pattern", ",", "listsep", "=", "','", ")", ":", "if", "self", "is", "Cardinality", ".", "one", ":", "return", "pattern", "elif", "self", "is", "Cardinality", ".", "zero_or_one", ":", "return", "self", ".", "schem...
Make pattern for a data type with the specified cardinality. .. code-block:: python yes_no_pattern = r"yes|no" many_yes_no = Cardinality.one_or_more.make_pattern(yes_no_pattern) :param pattern: Regular expression for type (as string). :param listsep: List separator f...
[ "Make", "pattern", "for", "a", "data", "type", "with", "the", "specified", "cardinality", "." ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/cardinality.py#L48-L65
train
Make a regular expression pattern for a data type with the specified cardinality.
jenisys/parse_type
parse_type/cardinality.py
Cardinality.compute_group_count
def compute_group_count(self, pattern): """Compute the number of regexp match groups when the pattern is provided to the :func:`Cardinality.make_pattern()` method. :param pattern: Item regexp pattern (as string). :return: Number of regexp match groups in the cardinality pattern. ...
python
def compute_group_count(self, pattern): """Compute the number of regexp match groups when the pattern is provided to the :func:`Cardinality.make_pattern()` method. :param pattern: Item regexp pattern (as string). :return: Number of regexp match groups in the cardinality pattern. ...
[ "def", "compute_group_count", "(", "self", ",", "pattern", ")", ":", "group_count", "=", "self", ".", "group_count", "pattern_repeated", "=", "1", "if", "self", ".", "is_many", "(", ")", ":", "pattern_repeated", "=", "2", "return", "group_count", "+", "patte...
Compute the number of regexp match groups when the pattern is provided to the :func:`Cardinality.make_pattern()` method. :param pattern: Item regexp pattern (as string). :return: Number of regexp match groups in the cardinality pattern.
[ "Compute", "the", "number", "of", "regexp", "match", "groups", "when", "the", "pattern", "is", "provided", "to", "the", ":", "func", ":", "Cardinality", ".", "make_pattern", "()", "method", "." ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/cardinality.py#L67-L78
train
Compute the number of regexp match groups when the pattern is provided to the : func:`Cardinality. make_pattern()` method.
jenisys/parse_type
parse_type/cardinality.py
TypeBuilder.with_cardinality
def with_cardinality(cls, cardinality, converter, pattern=None, listsep=','): """Creates a type converter for the specified cardinality by using the type converter for T. :param cardinality: Cardinality to use (0..1, 0..*, 1..*). :param converter: Type converter...
python
def with_cardinality(cls, cardinality, converter, pattern=None, listsep=','): """Creates a type converter for the specified cardinality by using the type converter for T. :param cardinality: Cardinality to use (0..1, 0..*, 1..*). :param converter: Type converter...
[ "def", "with_cardinality", "(", "cls", ",", "cardinality", ",", "converter", ",", "pattern", "=", "None", ",", "listsep", "=", "','", ")", ":", "if", "cardinality", "is", "Cardinality", ".", "one", ":", "return", "converter", "# -- NORMAL-CASE", "builder_func"...
Creates a type converter for the specified cardinality by using the type converter for T. :param cardinality: Cardinality to use (0..1, 0..*, 1..*). :param converter: Type converter (function) for data type T. :param pattern: Regexp pattern for an item (=converter.pattern). :re...
[ "Creates", "a", "type", "converter", "for", "the", "specified", "cardinality", "by", "using", "the", "type", "converter", "for", "T", "." ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/cardinality.py#L95-L113
train
Creates a type converter for the specified cardinality.
jenisys/parse_type
parse_type/cardinality.py
TypeBuilder.with_zero_or_one
def with_zero_or_one(cls, converter, pattern=None): """Creates a type converter for a T with 0..1 times by using the type converter for one item of T. :param converter: Type converter (function) for data type T. :param pattern: Regexp pattern for an item (=converter.pattern). :...
python
def with_zero_or_one(cls, converter, pattern=None): """Creates a type converter for a T with 0..1 times by using the type converter for one item of T. :param converter: Type converter (function) for data type T. :param pattern: Regexp pattern for an item (=converter.pattern). :...
[ "def", "with_zero_or_one", "(", "cls", ",", "converter", ",", "pattern", "=", "None", ")", ":", "cardinality", "=", "Cardinality", ".", "zero_or_one", "if", "not", "pattern", ":", "pattern", "=", "getattr", "(", "converter", ",", "\"pattern\"", ",", "cls", ...
Creates a type converter for a T with 0..1 times by using the type converter for one item of T. :param converter: Type converter (function) for data type T. :param pattern: Regexp pattern for an item (=converter.pattern). :return: type-converter for optional<T> (T or None).
[ "Creates", "a", "type", "converter", "for", "a", "T", "with", "0", "..", "1", "times", "by", "using", "the", "type", "converter", "for", "one", "item", "of", "T", "." ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/cardinality.py#L116-L139
train
Creates a type converter for a T with 0.. 1 times by using the type converter function for one item of T.
jenisys/parse_type
parse_type/cardinality.py
TypeBuilder.with_zero_or_more
def with_zero_or_more(cls, converter, pattern=None, listsep=","): """Creates a type converter function for a list<T> with 0..N items by using the type converter for one item of T. :param converter: Type converter (function) for data type T. :param pattern: Regexp pattern for an item (=...
python
def with_zero_or_more(cls, converter, pattern=None, listsep=","): """Creates a type converter function for a list<T> with 0..N items by using the type converter for one item of T. :param converter: Type converter (function) for data type T. :param pattern: Regexp pattern for an item (=...
[ "def", "with_zero_or_more", "(", "cls", ",", "converter", ",", "pattern", "=", "None", ",", "listsep", "=", "\",\"", ")", ":", "cardinality", "=", "Cardinality", ".", "zero_or_more", "if", "not", "pattern", ":", "pattern", "=", "getattr", "(", "converter", ...
Creates a type converter function for a list<T> with 0..N items by using the type converter for one item of T. :param converter: Type converter (function) for data type T. :param pattern: Regexp pattern for an item (=converter.pattern). :param listsep: Optional list separator between ...
[ "Creates", "a", "type", "converter", "function", "for", "a", "list<T", ">", "with", "0", "..", "N", "items", "by", "using", "the", "type", "converter", "for", "one", "item", "of", "T", "." ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/cardinality.py#L142-L166
train
Creates a type converter function for a list of items with 0.. N items.
jenisys/parse_type
parse_type/cardinality.py
TypeBuilder.with_one_or_more
def with_one_or_more(cls, converter, pattern=None, listsep=","): """Creates a type converter function for a list<T> with 1..N items by using the type converter for one item of T. :param converter: Type converter (function) for data type T. :param pattern: Regexp pattern for an item (=c...
python
def with_one_or_more(cls, converter, pattern=None, listsep=","): """Creates a type converter function for a list<T> with 1..N items by using the type converter for one item of T. :param converter: Type converter (function) for data type T. :param pattern: Regexp pattern for an item (=c...
[ "def", "with_one_or_more", "(", "cls", ",", "converter", ",", "pattern", "=", "None", ",", "listsep", "=", "\",\"", ")", ":", "cardinality", "=", "Cardinality", ".", "one_or_more", "if", "not", "pattern", ":", "pattern", "=", "getattr", "(", "converter", "...
Creates a type converter function for a list<T> with 1..N items by using the type converter for one item of T. :param converter: Type converter (function) for data type T. :param pattern: Regexp pattern for an item (=converter.pattern). :param listsep: Optional list separator between ...
[ "Creates", "a", "type", "converter", "function", "for", "a", "list<T", ">", "with", "1", "..", "N", "items", "by", "using", "the", "type", "converter", "for", "one", "item", "of", "T", "." ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/cardinality.py#L169-L189
train
Creates a type converter function for a list of items with 1.. N items.
jenisys/parse_type
parse_type/cardinality.py
TypeBuilder.with_many
def with_many(cls, converter, pattern=None, listsep=','): """Alias for :py:meth:`with_one_or_more()` method.""" return cls.with_one_or_more(converter, pattern, listsep)
python
def with_many(cls, converter, pattern=None, listsep=','): """Alias for :py:meth:`with_one_or_more()` method.""" return cls.with_one_or_more(converter, pattern, listsep)
[ "def", "with_many", "(", "cls", ",", "converter", ",", "pattern", "=", "None", ",", "listsep", "=", "','", ")", ":", "return", "cls", ".", "with_one_or_more", "(", "converter", ",", "pattern", ",", "listsep", ")" ]
Alias for :py:meth:`with_one_or_more()` method.
[ "Alias", "for", ":", "py", ":", "meth", ":", "with_one_or_more", "()", "method", "." ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/cardinality.py#L198-L200
train
Alias for with_one_or_more method.
jenisys/parse_type
parse_type/cardinality.py
TypeBuilder.with_many0
def with_many0(cls, converter, pattern=None, listsep=','): """Alias for :py:meth:`with_zero_or_more()` method.""" return cls.with_zero_or_more(converter, pattern, listsep)
python
def with_many0(cls, converter, pattern=None, listsep=','): """Alias for :py:meth:`with_zero_or_more()` method.""" return cls.with_zero_or_more(converter, pattern, listsep)
[ "def", "with_many0", "(", "cls", ",", "converter", ",", "pattern", "=", "None", ",", "listsep", "=", "','", ")", ":", "return", "cls", ".", "with_zero_or_more", "(", "converter", ",", "pattern", ",", "listsep", ")" ]
Alias for :py:meth:`with_zero_or_more()` method.
[ "Alias", "for", ":", "py", ":", "meth", ":", "with_zero_or_more", "()", "method", "." ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/cardinality.py#L203-L205
train
Alias for with_zero_or_more method.
ph4r05/monero-serialize
monero_serialize/core/obj_helper.py
eq_obj_slots
def eq_obj_slots(l, r): """ Compares objects with __slots__ defined :param l: :param r: :return: """ for f in l.__slots__: if getattr(l, f, None) != getattr(r, f, None): return False return True
python
def eq_obj_slots(l, r): """ Compares objects with __slots__ defined :param l: :param r: :return: """ for f in l.__slots__: if getattr(l, f, None) != getattr(r, f, None): return False return True
[ "def", "eq_obj_slots", "(", "l", ",", "r", ")", ":", "for", "f", "in", "l", ".", "__slots__", ":", "if", "getattr", "(", "l", ",", "f", ",", "None", ")", "!=", "getattr", "(", "r", ",", "f", ",", "None", ")", ":", "return", "False", "return", ...
Compares objects with __slots__ defined :param l: :param r: :return:
[ "Compares", "objects", "with", "__slots__", "defined", ":", "param", "l", ":", ":", "param", "r", ":", ":", "return", ":" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/core/obj_helper.py#L1-L11
train
Compares objects with __slots__ defined
ph4r05/monero-serialize
monero_serialize/core/obj_helper.py
eq_obj_contents
def eq_obj_contents(l, r): """ Compares object contents, supports slots :param l: :param r: :return: """ if l.__class__ is not r.__class__: return False if hasattr(l, "__slots__"): return eq_obj_slots(l, r) else: return l.__dict__ == r.__dict__
python
def eq_obj_contents(l, r): """ Compares object contents, supports slots :param l: :param r: :return: """ if l.__class__ is not r.__class__: return False if hasattr(l, "__slots__"): return eq_obj_slots(l, r) else: return l.__dict__ == r.__dict__
[ "def", "eq_obj_contents", "(", "l", ",", "r", ")", ":", "if", "l", ".", "__class__", "is", "not", "r", ".", "__class__", ":", "return", "False", "if", "hasattr", "(", "l", ",", "\"__slots__\"", ")", ":", "return", "eq_obj_slots", "(", "l", ",", "r", ...
Compares object contents, supports slots :param l: :param r: :return:
[ "Compares", "object", "contents", "supports", "slots", ":", "param", "l", ":", ":", "param", "r", ":", ":", "return", ":" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/core/obj_helper.py#L14-L26
train
Compares object contents
ph4r05/monero-serialize
monero_serialize/core/obj_helper.py
slot_obj_dict
def slot_obj_dict(o): """ Builds dict for o with __slots__ defined :param o: :return: """ d = {} for f in o.__slots__: d[f] = getattr(o, f, None) return d
python
def slot_obj_dict(o): """ Builds dict for o with __slots__ defined :param o: :return: """ d = {} for f in o.__slots__: d[f] = getattr(o, f, None) return d
[ "def", "slot_obj_dict", "(", "o", ")", ":", "d", "=", "{", "}", "for", "f", "in", "o", ".", "__slots__", ":", "d", "[", "f", "]", "=", "getattr", "(", "o", ",", "f", ",", "None", ")", "return", "d" ]
Builds dict for o with __slots__ defined :param o: :return:
[ "Builds", "dict", "for", "o", "with", "__slots__", "defined", ":", "param", "o", ":", ":", "return", ":" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/core/obj_helper.py#L29-L38
train
Builds a dictionary for o with __slots__ defined
ph4r05/monero-serialize
monero_serialize/core/obj_helper.py
is_type
def is_type(x, types, full=False): """ Returns true if x is of type in types tuple :param x: :param types: :param full: :return: """ types = types if isinstance(types, tuple) else (types,) ins = isinstance(x, types) sub = False try: sub = issubclass(x, types) exce...
python
def is_type(x, types, full=False): """ Returns true if x is of type in types tuple :param x: :param types: :param full: :return: """ types = types if isinstance(types, tuple) else (types,) ins = isinstance(x, types) sub = False try: sub = issubclass(x, types) exce...
[ "def", "is_type", "(", "x", ",", "types", ",", "full", "=", "False", ")", ":", "types", "=", "types", "if", "isinstance", "(", "types", ",", "tuple", ")", "else", "(", "types", ",", ")", "ins", "=", "isinstance", "(", "x", ",", "types", ")", "sub...
Returns true if x is of type in types tuple :param x: :param types: :param full: :return:
[ "Returns", "true", "if", "x", "is", "of", "type", "in", "types", "tuple", ":", "param", "x", ":", ":", "param", "types", ":", ":", "param", "full", ":", ":", "return", ":" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/core/obj_helper.py#L41-L57
train
Returns True if x is of type in types tuple Returns False otherwise
suurjaak/InputScope
inputscope/webui.py
server_static
def server_static(filepath): """Handler for serving static files.""" mimetype = "image/svg+xml" if filepath.endswith(".svg") else "auto" return bottle.static_file(filepath, root=conf.StaticPath, mimetype=mimetype)
python
def server_static(filepath): """Handler for serving static files.""" mimetype = "image/svg+xml" if filepath.endswith(".svg") else "auto" return bottle.static_file(filepath, root=conf.StaticPath, mimetype=mimetype)
[ "def", "server_static", "(", "filepath", ")", ":", "mimetype", "=", "\"image/svg+xml\"", "if", "filepath", ".", "endswith", "(", "\".svg\"", ")", "else", "\"auto\"", "return", "bottle", ".", "static_file", "(", "filepath", ",", "root", "=", "conf", ".", "Sta...
Handler for serving static files.
[ "Handler", "for", "serving", "static", "files", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/webui.py#L32-L35
train
Handler for serving static files.
suurjaak/InputScope
inputscope/webui.py
mouse
def mouse(table, day=None): """Handler for showing mouse statistics for specified type and day.""" where = (("day", day),) if day else () events = db.fetch(table, where=where, order="day") for e in events: e["dt"] = datetime.datetime.fromtimestamp(e["stamp"]) stats, positions, events = stats_mo...
python
def mouse(table, day=None): """Handler for showing mouse statistics for specified type and day.""" where = (("day", day),) if day else () events = db.fetch(table, where=where, order="day") for e in events: e["dt"] = datetime.datetime.fromtimestamp(e["stamp"]) stats, positions, events = stats_mo...
[ "def", "mouse", "(", "table", ",", "day", "=", "None", ")", ":", "where", "=", "(", "(", "\"day\"", ",", "day", ")", ",", ")", "if", "day", "else", "(", ")", "events", "=", "db", ".", "fetch", "(", "table", ",", "where", "=", "where", ",", "o...
Handler for showing mouse statistics for specified type and day.
[ "Handler", "for", "showing", "mouse", "statistics", "for", "specified", "type", "and", "day", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/webui.py#L40-L47
train
Handler for showing mouse statistics for specified type and day.
suurjaak/InputScope
inputscope/webui.py
keyboard
def keyboard(table, day=None): """Handler for showing the keyboard statistics page.""" cols, group = "realkey AS key, COUNT(*) AS count", "realkey" where = (("day", day),) if day else () counts_display = counts = db.fetch(table, cols, where, group, "count DESC") if "combos" == table: c...
python
def keyboard(table, day=None): """Handler for showing the keyboard statistics page.""" cols, group = "realkey AS key, COUNT(*) AS count", "realkey" where = (("day", day),) if day else () counts_display = counts = db.fetch(table, cols, where, group, "count DESC") if "combos" == table: c...
[ "def", "keyboard", "(", "table", ",", "day", "=", "None", ")", ":", "cols", ",", "group", "=", "\"realkey AS key, COUNT(*) AS count\"", ",", "\"realkey\"", "where", "=", "(", "(", "\"day\"", ",", "day", ")", ",", ")", "if", "day", "else", "(", ")", "co...
Handler for showing the keyboard statistics page.
[ "Handler", "for", "showing", "the", "keyboard", "statistics", "page", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/webui.py#L52-L64
train
Handler for showing the keyboard statistics page.
suurjaak/InputScope
inputscope/webui.py
inputindex
def inputindex(input): """Handler for showing keyboard or mouse page with day and total links.""" stats = {} countminmax = "SUM(count) AS count, MIN(day) AS first, MAX(day) AS last" tables = ("moves", "clicks", "scrolls") if "mouse" == input else ("keys", "combos") for table in tables: ...
python
def inputindex(input): """Handler for showing keyboard or mouse page with day and total links.""" stats = {} countminmax = "SUM(count) AS count, MIN(day) AS first, MAX(day) AS last" tables = ("moves", "clicks", "scrolls") if "mouse" == input else ("keys", "combos") for table in tables: ...
[ "def", "inputindex", "(", "input", ")", ":", "stats", "=", "{", "}", "countminmax", "=", "\"SUM(count) AS count, MIN(day) AS first, MAX(day) AS last\"", "tables", "=", "(", "\"moves\"", ",", "\"clicks\"", ",", "\"scrolls\"", ")", "if", "\"mouse\"", "==", "input", ...
Handler for showing keyboard or mouse page with day and total links.
[ "Handler", "for", "showing", "keyboard", "or", "mouse", "page", "with", "day", "and", "total", "links", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/webui.py#L68-L76
train
Handler for showing keyboard or mouse page with day and total links.
suurjaak/InputScope
inputscope/webui.py
index
def index(): """Handler for showing the GUI index page.""" stats = dict((k, {"count": 0}) for k, tt in conf.InputTables) countminmax = "SUM(count) AS count, MIN(day) AS first, MAX(day) AS last" for input, table in [(x, t) for x, tt in conf.InputTables for t in tt]: row = db.fetchone("counts...
python
def index(): """Handler for showing the GUI index page.""" stats = dict((k, {"count": 0}) for k, tt in conf.InputTables) countminmax = "SUM(count) AS count, MIN(day) AS first, MAX(day) AS last" for input, table in [(x, t) for x, tt in conf.InputTables for t in tt]: row = db.fetchone("counts...
[ "def", "index", "(", ")", ":", "stats", "=", "dict", "(", "(", "k", ",", "{", "\"count\"", ":", "0", "}", ")", "for", "k", ",", "tt", "in", "conf", ".", "InputTables", ")", "countminmax", "=", "\"SUM(count) AS count, MIN(day) AS first, MAX(day) AS last\"", ...
Handler for showing the GUI index page.
[ "Handler", "for", "showing", "the", "GUI", "index", "page", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/webui.py#L80-L91
train
Handler for showing the GUI index page.
suurjaak/InputScope
inputscope/webui.py
stats_keyboard
def stats_keyboard(events, table): """Return statistics and collated events for keyboard events.""" if len(events) < 2: return [], [] deltas, prev_dt = [], None sessions, session = [], None UNBROKEN_DELTA = datetime.timedelta(seconds=conf.KeyboardSessionMaxDelta) blank = collections.defaul...
python
def stats_keyboard(events, table): """Return statistics and collated events for keyboard events.""" if len(events) < 2: return [], [] deltas, prev_dt = [], None sessions, session = [], None UNBROKEN_DELTA = datetime.timedelta(seconds=conf.KeyboardSessionMaxDelta) blank = collections.defaul...
[ "def", "stats_keyboard", "(", "events", ",", "table", ")", ":", "if", "len", "(", "events", ")", "<", "2", ":", "return", "[", "]", ",", "[", "]", "deltas", ",", "prev_dt", "=", "[", "]", ",", "None", "sessions", ",", "session", "=", "[", "]", ...
Return statistics and collated events for keyboard events.
[ "Return", "statistics", "and", "collated", "events", "for", "keyboard", "events", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/webui.py#L94-L141
train
Return statistics and collated events for keyboard events.
suurjaak/InputScope
inputscope/webui.py
stats_mouse
def stats_mouse(events, table): """Returns statistics, positions and rescaled events for mouse events.""" if not events: return [], [], [] distance, last, deltas = 0, None, [] HS = conf.MouseHeatmapSize SC = dict(("xy"[i], conf.DefaultScreenSize[i] / float(HS[i])) for i in [0, 1]) xymap = ...
python
def stats_mouse(events, table): """Returns statistics, positions and rescaled events for mouse events.""" if not events: return [], [], [] distance, last, deltas = 0, None, [] HS = conf.MouseHeatmapSize SC = dict(("xy"[i], conf.DefaultScreenSize[i] / float(HS[i])) for i in [0, 1]) xymap = ...
[ "def", "stats_mouse", "(", "events", ",", "table", ")", ":", "if", "not", "events", ":", "return", "[", "]", ",", "[", "]", ",", "[", "]", "distance", ",", "last", ",", "deltas", "=", "0", ",", "None", ",", "[", "]", "HS", "=", "conf", ".", "...
Returns statistics, positions and rescaled events for mouse events.
[ "Returns", "statistics", "positions", "and", "rescaled", "events", "for", "mouse", "events", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/webui.py#L144-L200
train
Returns statistics positions and rescaled events for mouse events.
suurjaak/InputScope
inputscope/webui.py
timedelta_seconds
def timedelta_seconds(timedelta): """Returns the total timedelta duration in seconds.""" return (timedelta.total_seconds() if hasattr(timedelta, "total_seconds") else timedelta.days * 24 * 3600 + timedelta.seconds + timedelta.microseconds / 1000000.)
python
def timedelta_seconds(timedelta): """Returns the total timedelta duration in seconds.""" return (timedelta.total_seconds() if hasattr(timedelta, "total_seconds") else timedelta.days * 24 * 3600 + timedelta.seconds + timedelta.microseconds / 1000000.)
[ "def", "timedelta_seconds", "(", "timedelta", ")", ":", "return", "(", "timedelta", ".", "total_seconds", "(", ")", "if", "hasattr", "(", "timedelta", ",", "\"total_seconds\"", ")", "else", "timedelta", ".", "days", "*", "24", "*", "3600", "+", "timedelta", ...
Returns the total timedelta duration in seconds.
[ "Returns", "the", "total", "timedelta", "duration", "in", "seconds", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/webui.py#L203-L207
train
Returns the total timedelta duration in seconds.
suurjaak/InputScope
inputscope/webui.py
init
def init(): """Initialize configuration and web application.""" global app if app: return app conf.init(), db.init(conf.DbPath, conf.DbStatements) bottle.TEMPLATE_PATH.insert(0, conf.TemplatePath) app = bottle.default_app() bottle.BaseTemplate.defaults.update(get_url=app.get_url) ...
python
def init(): """Initialize configuration and web application.""" global app if app: return app conf.init(), db.init(conf.DbPath, conf.DbStatements) bottle.TEMPLATE_PATH.insert(0, conf.TemplatePath) app = bottle.default_app() bottle.BaseTemplate.defaults.update(get_url=app.get_url) ...
[ "def", "init", "(", ")", ":", "global", "app", "if", "app", ":", "return", "app", "conf", ".", "init", "(", ")", ",", "db", ".", "init", "(", "conf", ".", "DbPath", ",", "conf", ".", "DbStatements", ")", "bottle", ".", "TEMPLATE_PATH", ".", "insert...
Initialize configuration and web application.
[ "Initialize", "configuration", "and", "web", "application", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/webui.py#L210-L219
train
Initialize configuration and web application.
suurjaak/InputScope
inputscope/webui.py
start
def start(): """Starts the web server.""" global app bottle.run(app, host=conf.WebHost, port=conf.WebPort, debug=conf.WebAutoReload, reloader=conf.WebAutoReload, quiet=conf.WebQuiet)
python
def start(): """Starts the web server.""" global app bottle.run(app, host=conf.WebHost, port=conf.WebPort, debug=conf.WebAutoReload, reloader=conf.WebAutoReload, quiet=conf.WebQuiet)
[ "def", "start", "(", ")", ":", "global", "app", "bottle", ".", "run", "(", "app", ",", "host", "=", "conf", ".", "WebHost", ",", "port", "=", "conf", ".", "WebPort", ",", "debug", "=", "conf", ".", "WebAutoReload", ",", "reloader", "=", "conf", "."...
Starts the web server.
[ "Starts", "the", "web", "server", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/webui.py#L222-L227
train
Starts the web server.
Phyks/libbmc
libbmc/fetcher.py
_download_helper
def _download_helper(url): """ Handle the download of an URL, using the proxy currently set in \ :mod:`socks`. :param url: The URL to download. :returns: A tuple of the raw content of the downloaded data and its \ associated content-type. Returns None if it was \ una...
python
def _download_helper(url): """ Handle the download of an URL, using the proxy currently set in \ :mod:`socks`. :param url: The URL to download. :returns: A tuple of the raw content of the downloaded data and its \ associated content-type. Returns None if it was \ una...
[ "def", "_download_helper", "(", "url", ")", ":", "# Try to fetch the URL using the current proxy", "try", ":", "request", "=", "urllib", ".", "request", ".", "urlopen", "(", "url", ")", "try", ":", "size", "=", "int", "(", "dict", "(", "request", ".", "info"...
Handle the download of an URL, using the proxy currently set in \ :mod:`socks`. :param url: The URL to download. :returns: A tuple of the raw content of the downloaded data and its \ associated content-type. Returns None if it was \ unable to download the document.
[ "Handle", "the", "download", "of", "an", "URL", "using", "the", "proxy", "currently", "set", "in", "\\", ":", "mod", ":", "socks", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/fetcher.py#L16-L77
train
Handle the download of an URL using the current proxy currently set in socks.
Phyks/libbmc
libbmc/fetcher.py
download
def download(url, proxies=None): """ Download a PDF or DJVU document from a url, eventually using proxies. :params url: The URL to the PDF/DJVU document to fetch. :params proxies: An optional list of proxies to use. Proxies will be \ used sequentially. Proxies should be a list of proxy stri...
python
def download(url, proxies=None): """ Download a PDF or DJVU document from a url, eventually using proxies. :params url: The URL to the PDF/DJVU document to fetch. :params proxies: An optional list of proxies to use. Proxies will be \ used sequentially. Proxies should be a list of proxy stri...
[ "def", "download", "(", "url", ",", "proxies", "=", "None", ")", ":", "# Handle default argument", "if", "proxies", "is", "None", ":", "proxies", "=", "[", "\"\"", "]", "# Loop over all available connections", "for", "proxy", "in", "proxies", ":", "# Handle no p...
Download a PDF or DJVU document from a url, eventually using proxies. :params url: The URL to the PDF/DJVU document to fetch. :params proxies: An optional list of proxies to use. Proxies will be \ used sequentially. Proxies should be a list of proxy strings. \ Do not forget to include `...
[ "Download", "a", "PDF", "or", "DJVU", "document", "from", "a", "url", "eventually", "using", "proxies", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/fetcher.py#L80-L132
train
Download a PDF or DJVU document from a URL.
jenisys/parse_type
parse_type/parse_util.py
Field.make_format
def make_format(format_spec): """Build format string from a format specification. :param format_spec: Format specification (as FormatSpec object). :return: Composed format (as string). """ fill = '' align = '' zero = '' width = format_spec.width ...
python
def make_format(format_spec): """Build format string from a format specification. :param format_spec: Format specification (as FormatSpec object). :return: Composed format (as string). """ fill = '' align = '' zero = '' width = format_spec.width ...
[ "def", "make_format", "(", "format_spec", ")", ":", "fill", "=", "''", "align", "=", "''", "zero", "=", "''", "width", "=", "format_spec", ".", "width", "if", "format_spec", ".", "align", ":", "align", "=", "format_spec", ".", "align", "[", "0", "]", ...
Build format string from a format specification. :param format_spec: Format specification (as FormatSpec object). :return: Composed format (as string).
[ "Build", "format", "string", "from", "a", "format", "specification", "." ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/parse_util.py#L78-L101
train
Builds a format string from a format specification.
jenisys/parse_type
parse_type/parse_util.py
Field.extract_format_spec
def extract_format_spec(cls, format): """Pull apart the format: [[fill]align][0][width][.precision][type]""" # -- BASED-ON: parse.extract_format() # pylint: disable=redefined-builtin, unsubscriptable-object if not format: raise ValueError("INVALID-FORMAT: %s (empty-string)" %...
python
def extract_format_spec(cls, format): """Pull apart the format: [[fill]align][0][width][.precision][type]""" # -- BASED-ON: parse.extract_format() # pylint: disable=redefined-builtin, unsubscriptable-object if not format: raise ValueError("INVALID-FORMAT: %s (empty-string)" %...
[ "def", "extract_format_spec", "(", "cls", ",", "format", ")", ":", "# -- BASED-ON: parse.extract_format()", "# pylint: disable=redefined-builtin, unsubscriptable-object", "if", "not", "format", ":", "raise", "ValueError", "(", "\"INVALID-FORMAT: %s (empty-string)\"", "%", "form...
Pull apart the format: [[fill]align][0][width][.precision][type]
[ "Pull", "apart", "the", "format", ":", "[[", "fill", "]", "align", "]", "[", "0", "]", "[", "width", "]", "[", ".", "precision", "]", "[", "type", "]" ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/parse_util.py#L105-L150
train
Extract the format spec from a format string.
jenisys/parse_type
parse_type/parse_util.py
FieldParser.extract_fields
def extract_fields(cls, schema): """Extract fields in a parse expression schema. :param schema: Parse expression schema/format to use (as string). :return: Generator for fields in schema (as Field objects). """ # -- BASED-ON: parse.Parser._generate_expression() for part ...
python
def extract_fields(cls, schema): """Extract fields in a parse expression schema. :param schema: Parse expression schema/format to use (as string). :return: Generator for fields in schema (as Field objects). """ # -- BASED-ON: parse.Parser._generate_expression() for part ...
[ "def", "extract_fields", "(", "cls", ",", "schema", ")", ":", "# -- BASED-ON: parse.Parser._generate_expression()", "for", "part", "in", "parse", ".", "PARSE_RE", ".", "split", "(", "schema", ")", ":", "if", "not", "part", "or", "part", "==", "'{{'", "or", "...
Extract fields in a parse expression schema. :param schema: Parse expression schema/format to use (as string). :return: Generator for fields in schema (as Field objects).
[ "Extract", "fields", "in", "a", "parse", "expression", "schema", "." ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/parse_util.py#L175-L187
train
Extract fields in a parse expression schema.
jenisys/parse_type
parse_type/parse_util.py
FieldParser.extract_types
def extract_types(cls, schema): """Extract types (names) for typed fields (with format/type part). :param schema: Parser schema/format to use. :return: Generator for type names (as string). """ for field in cls.extract_fields(schema): if field.has_format: ...
python
def extract_types(cls, schema): """Extract types (names) for typed fields (with format/type part). :param schema: Parser schema/format to use. :return: Generator for type names (as string). """ for field in cls.extract_fields(schema): if field.has_format: ...
[ "def", "extract_types", "(", "cls", ",", "schema", ")", ":", "for", "field", "in", "cls", ".", "extract_fields", "(", "schema", ")", ":", "if", "field", ".", "has_format", ":", "yield", "field", ".", "format_spec", ".", "type" ]
Extract types (names) for typed fields (with format/type part). :param schema: Parser schema/format to use. :return: Generator for type names (as string).
[ "Extract", "types", "(", "names", ")", "for", "typed", "fields", "(", "with", "format", "/", "type", "part", ")", "." ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/parse_util.py#L190-L198
train
Extract types ( names ) for typed fields with format part.
dbarsam/python-vsgen
vsgen/util/logger.py
VSGLogger._registerHandler
def _registerHandler(self, handler): """ Registers a handler. :param handler: A handler object. """ self._logger.addHandler(handler) self._handlers.append(handler)
python
def _registerHandler(self, handler): """ Registers a handler. :param handler: A handler object. """ self._logger.addHandler(handler) self._handlers.append(handler)
[ "def", "_registerHandler", "(", "self", ",", "handler", ")", ":", "self", ".", "_logger", ".", "addHandler", "(", "handler", ")", "self", ".", "_handlers", ".", "append", "(", "handler", ")" ]
Registers a handler. :param handler: A handler object.
[ "Registers", "a", "handler", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/logger.py#L80-L87
train
Registers a handler.
dbarsam/python-vsgen
vsgen/util/logger.py
VSGLogger._unregisterHandler
def _unregisterHandler(self, handler, shutdown=True): """ Unregisters the logging handler. :param handler: A handler previously registered with this loggger. :param shutdown: Flag to shutdown the handler. """ if handler in self._handlers: self._handlers.remo...
python
def _unregisterHandler(self, handler, shutdown=True): """ Unregisters the logging handler. :param handler: A handler previously registered with this loggger. :param shutdown: Flag to shutdown the handler. """ if handler in self._handlers: self._handlers.remo...
[ "def", "_unregisterHandler", "(", "self", ",", "handler", ",", "shutdown", "=", "True", ")", ":", "if", "handler", "in", "self", ".", "_handlers", ":", "self", ".", "_handlers", ".", "remove", "(", "handler", ")", "self", ".", "_logger", ".", "removeHand...
Unregisters the logging handler. :param handler: A handler previously registered with this loggger. :param shutdown: Flag to shutdown the handler.
[ "Unregisters", "the", "logging", "handler", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/logger.py#L89-L106
train
Unregisters the given handler.
dbarsam/python-vsgen
vsgen/util/logger.py
VSGLogger.getLogger
def getLogger(cls, name=None): """ Retrieves the Python native logger :param name: The name of the logger instance in the VSG namespace (VSG.<name>); a None value will use the VSG root. :return: The instacne of the Python logger object. """ return logging.getLo...
python
def getLogger(cls, name=None): """ Retrieves the Python native logger :param name: The name of the logger instance in the VSG namespace (VSG.<name>); a None value will use the VSG root. :return: The instacne of the Python logger object. """ return logging.getLo...
[ "def", "getLogger", "(", "cls", ",", "name", "=", "None", ")", ":", "return", "logging", ".", "getLogger", "(", "\"{0}.{1}\"", ".", "format", "(", "cls", ".", "BASENAME", ",", "name", ")", "if", "name", "else", "cls", ".", "BASENAME", ")" ]
Retrieves the Python native logger :param name: The name of the logger instance in the VSG namespace (VSG.<name>); a None value will use the VSG root. :return: The instacne of the Python logger object.
[ "Retrieves", "the", "Python", "native", "logger" ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/logger.py#L109-L116
train
Returns the Python native logger object.
dbarsam/python-vsgen
vsgen/util/logger.py
VSGLogger.debug
def debug(cls, name, message, *args): """ Convenience function to log a message at the DEBUG level. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: The arguments that are are merged into m...
python
def debug(cls, name, message, *args): """ Convenience function to log a message at the DEBUG level. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: The arguments that are are merged into m...
[ "def", "debug", "(", "cls", ",", "name", ",", "message", ",", "*", "args", ")", ":", "cls", ".", "getLogger", "(", "name", ")", ".", "debug", "(", "message", ",", "*", "args", ")" ]
Convenience function to log a message at the DEBUG level. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: The arguments that are are merged into msg using the string formatting operator. :..note: ...
[ "Convenience", "function", "to", "log", "a", "message", "at", "the", "DEBUG", "level", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/logger.py#L119-L128
train
Convenience function to log a message at the DEBUG level.
dbarsam/python-vsgen
vsgen/util/logger.py
VSGLogger.info
def info(cls, name, message, *args): """ Convenience function to log a message at the INFO level. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: The arguments that are are merged into msg...
python
def info(cls, name, message, *args): """ Convenience function to log a message at the INFO level. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: The arguments that are are merged into msg...
[ "def", "info", "(", "cls", ",", "name", ",", "message", ",", "*", "args", ")", ":", "cls", ".", "getLogger", "(", "name", ")", ".", "info", "(", "message", ",", "*", "args", ")" ]
Convenience function to log a message at the INFO level. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: The arguments that are are merged into msg using the string formatting operator. :..note: ...
[ "Convenience", "function", "to", "log", "a", "message", "at", "the", "INFO", "level", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/logger.py#L131-L140
train
Convenience function to log a message at the INFO level.
dbarsam/python-vsgen
vsgen/util/logger.py
VSGLogger.warning
def warning(cls, name, message, *args): """ Convenience function to log a message at the WARNING level. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: The arguments that are are merged in...
python
def warning(cls, name, message, *args): """ Convenience function to log a message at the WARNING level. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: The arguments that are are merged in...
[ "def", "warning", "(", "cls", ",", "name", ",", "message", ",", "*", "args", ")", ":", "cls", ".", "getLogger", "(", "name", ")", ".", "warning", "(", "message", ",", "*", "args", ")" ]
Convenience function to log a message at the WARNING level. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: The arguments that are are merged into msg using the string formatting operator. :..note...
[ "Convenience", "function", "to", "log", "a", "message", "at", "the", "WARNING", "level", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/logger.py#L143-L152
train
Convenience function to log a message at the WARNING level.
dbarsam/python-vsgen
vsgen/util/logger.py
VSGLogger.error
def error(cls, name, message, *args): """ Convenience function to log a message at the ERROR level. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: The arguments that are are merged into m...
python
def error(cls, name, message, *args): """ Convenience function to log a message at the ERROR level. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: The arguments that are are merged into m...
[ "def", "error", "(", "cls", ",", "name", ",", "message", ",", "*", "args", ")", ":", "cls", ".", "getLogger", "(", "name", ")", ".", "error", "(", "message", ",", "*", "args", ")" ]
Convenience function to log a message at the ERROR level. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: The arguments that are are merged into msg using the string formatting operator. :..note: ...
[ "Convenience", "function", "to", "log", "a", "message", "at", "the", "ERROR", "level", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/logger.py#L155-L164
train
Convenience function to log a message at the ERROR level.
dbarsam/python-vsgen
vsgen/util/logger.py
VSGLogger.critical
def critical(cls, name, message, *args): """ Convenience function to log a message at the CRITICAL level. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: The arguments that are are merged ...
python
def critical(cls, name, message, *args): """ Convenience function to log a message at the CRITICAL level. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: The arguments that are are merged ...
[ "def", "critical", "(", "cls", ",", "name", ",", "message", ",", "*", "args", ")", ":", "cls", ".", "getLogger", "(", "name", ")", ".", "critical", "(", "message", ",", "*", "args", ")" ]
Convenience function to log a message at the CRITICAL level. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: The arguments that are are merged into msg using the string formatting operator. :..not...
[ "Convenience", "function", "to", "log", "a", "message", "at", "the", "CRITICAL", "level", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/logger.py#L167-L176
train
Convenience function to log a message at the CRITICAL level.
dbarsam/python-vsgen
vsgen/util/logger.py
VSGLogger.exception
def exception(cls, name, message, *args): """ Convenience function to log a message at the ERROR level with additonal exception information. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: ...
python
def exception(cls, name, message, *args): """ Convenience function to log a message at the ERROR level with additonal exception information. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: ...
[ "def", "exception", "(", "cls", ",", "name", ",", "message", ",", "*", "args", ")", ":", "cls", ".", "getLogger", "(", "name", ")", ".", "exception", "(", "message", ",", "*", "args", ")" ]
Convenience function to log a message at the ERROR level with additonal exception information. :param name: The name of the logger instance in the VSG namespace (VSG.<name>) :param message: A message format string. :param args: The arguments that are are merged into msg using the string f...
[ "Convenience", "function", "to", "log", "a", "message", "at", "the", "ERROR", "level", "with", "additonal", "exception", "information", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/logger.py#L179-L188
train
Convenience method to log a message at the ERROR level with additonal exception information.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/bakery/_checker.py
AuthChecker.allow
def allow(self, ctx, ops): ''' Checks that the authorizer's request is authorized to perform all the given operations. Note that allow does not check first party caveats - if there is more than one macaroon that may authorize the request, it will choose the first one that does re...
python
def allow(self, ctx, ops): ''' Checks that the authorizer's request is authorized to perform all the given operations. Note that allow does not check first party caveats - if there is more than one macaroon that may authorize the request, it will choose the first one that does re...
[ "def", "allow", "(", "self", ",", "ctx", ",", "ops", ")", ":", "auth_info", ",", "_", "=", "self", ".", "allow_any", "(", "ctx", ",", "ops", ")", "return", "auth_info" ]
Checks that the authorizer's request is authorized to perform all the given operations. Note that allow does not check first party caveats - if there is more than one macaroon that may authorize the request, it will choose the first one that does regardless. If all the operation...
[ "Checks", "that", "the", "authorizer", "s", "request", "is", "authorized", "to", "perform", "all", "the", "given", "operations", ".", "Note", "that", "allow", "does", "not", "check", "first", "party", "caveats", "-", "if", "there", "is", "more", "than", "o...
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_checker.py#L183-L212
train
Checks that the authorizer s request is authorized to perform all the given operations.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/bakery/_checker.py
AuthChecker.allow_any
def allow_any(self, ctx, ops): ''' like allow except that it will authorize as many of the operations as possible without requiring any to be authorized. If all the operations succeeded, the array will be nil. If any the operations failed, the returned error will be the same tha...
python
def allow_any(self, ctx, ops): ''' like allow except that it will authorize as many of the operations as possible without requiring any to be authorized. If all the operations succeeded, the array will be nil. If any the operations failed, the returned error will be the same tha...
[ "def", "allow_any", "(", "self", ",", "ctx", ",", "ops", ")", ":", "authed", ",", "used", "=", "self", ".", "_allow_any", "(", "ctx", ",", "ops", ")", "return", "self", ".", "_new_auth_info", "(", "used", ")", ",", "authed" ]
like allow except that it will authorize as many of the operations as possible without requiring any to be authorized. If all the operations succeeded, the array will be nil. If any the operations failed, the returned error will be the same that allow would return and each element in th...
[ "like", "allow", "except", "that", "it", "will", "authorize", "as", "many", "of", "the", "operations", "as", "possible", "without", "requiring", "any", "to", "be", "authorized", ".", "If", "all", "the", "operations", "succeeded", "the", "array", "will", "be"...
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_checker.py#L214-L234
train
like allow except that it will authorize all of the operations as many of the necessary operations as possible without requiring any to be authorized.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/bakery/_checker.py
AuthChecker.allow_capability
def allow_capability(self, ctx, ops): '''Checks that the user is allowed to perform all the given operations. If not, a discharge error will be raised. If allow_capability succeeds, it returns a list of first party caveat conditions that must be applied to any macaroon granting capabilit...
python
def allow_capability(self, ctx, ops): '''Checks that the user is allowed to perform all the given operations. If not, a discharge error will be raised. If allow_capability succeeds, it returns a list of first party caveat conditions that must be applied to any macaroon granting capabilit...
[ "def", "allow_capability", "(", "self", ",", "ctx", ",", "ops", ")", ":", "nops", "=", "0", "for", "op", "in", "ops", ":", "if", "op", "!=", "LOGIN_OP", ":", "nops", "+=", "1", "if", "nops", "==", "0", ":", "raise", "ValueError", "(", "'no non-logi...
Checks that the user is allowed to perform all the given operations. If not, a discharge error will be raised. If allow_capability succeeds, it returns a list of first party caveat conditions that must be applied to any macaroon granting capability to execute the operations. Those caveat...
[ "Checks", "that", "the", "user", "is", "allowed", "to", "perform", "all", "the", "given", "operations", ".", "If", "not", "a", "discharge", "error", "will", "be", "raised", ".", "If", "allow_capability", "succeeds", "it", "returns", "a", "list", "of", "fir...
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_checker.py#L317-L345
train
Checks that the user is allowed to perform all the given operations. Returns a list of first party caveat entries that must be used to perform all the operations.
useblocks/groundwork
groundwork/patterns/gw_recipes_pattern.py
RecipesListPlugin.__deactivate_recipes
def __deactivate_recipes(self, plugin, *args, **kwargs): """ Deactivates/unregisters all recipes of the current plugin, if this plugin gets deactivated. """ recipes = self.get() for recipe in recipes.keys(): self.unregister(recipe)
python
def __deactivate_recipes(self, plugin, *args, **kwargs): """ Deactivates/unregisters all recipes of the current plugin, if this plugin gets deactivated. """ recipes = self.get() for recipe in recipes.keys(): self.unregister(recipe)
[ "def", "__deactivate_recipes", "(", "self", ",", "plugin", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "recipes", "=", "self", ".", "get", "(", ")", "for", "recipe", "in", "recipes", ".", "keys", "(", ")", ":", "self", ".", "unregister", "...
Deactivates/unregisters all recipes of the current plugin, if this plugin gets deactivated.
[ "Deactivates", "/", "unregisters", "all", "recipes", "of", "the", "current", "plugin", "if", "this", "plugin", "gets", "deactivated", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_recipes_pattern.py#L55-L61
train
Deactivates all recipes of the current plugin and unregisters all recipes of the current plugin.
useblocks/groundwork
groundwork/patterns/gw_recipes_pattern.py
RecipesListPlugin.register
def register(self, name, path, description, final_words=None): """ Registers a new recipe in the context of the current plugin. :param name: Name of the recipe :param path: Absolute path of the recipe folder :param description: A meaningful description of the recipe :par...
python
def register(self, name, path, description, final_words=None): """ Registers a new recipe in the context of the current plugin. :param name: Name of the recipe :param path: Absolute path of the recipe folder :param description: A meaningful description of the recipe :par...
[ "def", "register", "(", "self", ",", "name", ",", "path", ",", "description", ",", "final_words", "=", "None", ")", ":", "return", "self", ".", "__app", ".", "recipes", ".", "register", "(", "name", ",", "path", ",", "self", ".", "_plugin", ",", "des...
Registers a new recipe in the context of the current plugin. :param name: Name of the recipe :param path: Absolute path of the recipe folder :param description: A meaningful description of the recipe :param final_words: A string, which gets printed after the recipe was build.
[ "Registers", "a", "new", "recipe", "in", "the", "context", "of", "the", "current", "plugin", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_recipes_pattern.py#L63-L72
train
Registers a new recipe in the context of the current plugin.
useblocks/groundwork
groundwork/patterns/gw_recipes_pattern.py
RecipesListPlugin.get
def get(self, name=None): """ Gets a list of all recipes, which are registered by the current plugin. If a name is provided, only the requested recipe is returned or None. :param: name: Name of the recipe """ return self.__app.recipes.get(name, self._plugin)
python
def get(self, name=None): """ Gets a list of all recipes, which are registered by the current plugin. If a name is provided, only the requested recipe is returned or None. :param: name: Name of the recipe """ return self.__app.recipes.get(name, self._plugin)
[ "def", "get", "(", "self", ",", "name", "=", "None", ")", ":", "return", "self", ".", "__app", ".", "recipes", ".", "get", "(", "name", ",", "self", ".", "_plugin", ")" ]
Gets a list of all recipes, which are registered by the current plugin. If a name is provided, only the requested recipe is returned or None. :param: name: Name of the recipe
[ "Gets", "a", "list", "of", "all", "recipes", "which", "are", "registered", "by", "the", "current", "plugin", ".", "If", "a", "name", "is", "provided", "only", "the", "requested", "recipe", "is", "returned", "or", "None", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_recipes_pattern.py#L82-L89
train
Get a list of all recipes which are registered by the current plugin. If no name is provided all recipes are returned.
useblocks/groundwork
groundwork/patterns/gw_recipes_pattern.py
RecipesListPlugin.build
def build(self, recipe): """ Builds a recipe :param recipe: Name of the recipe to build. """ return self.__app.recipes.build(recipe, self._plugin)
python
def build(self, recipe): """ Builds a recipe :param recipe: Name of the recipe to build. """ return self.__app.recipes.build(recipe, self._plugin)
[ "def", "build", "(", "self", ",", "recipe", ")", ":", "return", "self", ".", "__app", ".", "recipes", ".", "build", "(", "recipe", ",", "self", ".", "_plugin", ")" ]
Builds a recipe :param recipe: Name of the recipe to build.
[ "Builds", "a", "recipe" ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_recipes_pattern.py#L91-L97
train
Builds a recipe
useblocks/groundwork
groundwork/patterns/gw_recipes_pattern.py
RecipesListApplication.register
def register(self, name, path, plugin, description=None, final_words=None): """ Registers a new recipe. """ if name in self.recipes.keys(): raise RecipeExistsException("Recipe %s was already registered by %s" % (name, self.recipes["name...
python
def register(self, name, path, plugin, description=None, final_words=None): """ Registers a new recipe. """ if name in self.recipes.keys(): raise RecipeExistsException("Recipe %s was already registered by %s" % (name, self.recipes["name...
[ "def", "register", "(", "self", ",", "name", ",", "path", ",", "plugin", ",", "description", "=", "None", ",", "final_words", "=", "None", ")", ":", "if", "name", "in", "self", ".", "recipes", ".", "keys", "(", ")", ":", "raise", "RecipeExistsException...
Registers a new recipe.
[ "Registers", "a", "new", "recipe", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_recipes_pattern.py#L113-L123
train
Registers a new recipe.
useblocks/groundwork
groundwork/patterns/gw_recipes_pattern.py
RecipesListApplication.unregister
def unregister(self, recipe): """ Unregisters an existing recipe, so that this recipe is no longer available. This function is mainly used during plugin deactivation. :param recipe: Name of the recipe """ if recipe not in self.recipes.keys(): self.__log.warn...
python
def unregister(self, recipe): """ Unregisters an existing recipe, so that this recipe is no longer available. This function is mainly used during plugin deactivation. :param recipe: Name of the recipe """ if recipe not in self.recipes.keys(): self.__log.warn...
[ "def", "unregister", "(", "self", ",", "recipe", ")", ":", "if", "recipe", "not", "in", "self", ".", "recipes", ".", "keys", "(", ")", ":", "self", ".", "__log", ".", "warning", "(", "\"Can not unregister recipe %s\"", "%", "recipe", ")", "else", ":", ...
Unregisters an existing recipe, so that this recipe is no longer available. This function is mainly used during plugin deactivation. :param recipe: Name of the recipe
[ "Unregisters", "an", "existing", "recipe", "so", "that", "this", "recipe", "is", "no", "longer", "available", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_recipes_pattern.py#L125-L137
train
Unregisters an existing recipe.
useblocks/groundwork
groundwork/patterns/gw_recipes_pattern.py
RecipesListApplication.get
def get(self, recipe=None, plugin=None): """ Get one or more recipes. :param recipe: Name of the recipe :type recipe: str :param plugin: Plugin object, under which the recipe was registered :type plugin: GwBasePattern """ if plugin is not None: ...
python
def get(self, recipe=None, plugin=None): """ Get one or more recipes. :param recipe: Name of the recipe :type recipe: str :param plugin: Plugin object, under which the recipe was registered :type plugin: GwBasePattern """ if plugin is not None: ...
[ "def", "get", "(", "self", ",", "recipe", "=", "None", ",", "plugin", "=", "None", ")", ":", "if", "plugin", "is", "not", "None", ":", "if", "recipe", "is", "None", ":", "recipes_list", "=", "{", "}", "for", "key", "in", "self", ".", "recipes", "...
Get one or more recipes. :param recipe: Name of the recipe :type recipe: str :param plugin: Plugin object, under which the recipe was registered :type plugin: GwBasePattern
[ "Get", "one", "or", "more", "recipes", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_recipes_pattern.py#L139-L170
train
Get one or more recipes.
useblocks/groundwork
groundwork/patterns/gw_recipes_pattern.py
RecipesListApplication.build
def build(self, recipe, plugin=None): """ Execute a recipe and creates new folder and files. :param recipe: Name of the recipe :param plugin: Name of the plugin, to which the recipe must belong. """ if recipe not in self.recipes.keys(): raise RecipeMissingExc...
python
def build(self, recipe, plugin=None): """ Execute a recipe and creates new folder and files. :param recipe: Name of the recipe :param plugin: Name of the plugin, to which the recipe must belong. """ if recipe not in self.recipes.keys(): raise RecipeMissingExc...
[ "def", "build", "(", "self", ",", "recipe", ",", "plugin", "=", "None", ")", ":", "if", "recipe", "not", "in", "self", ".", "recipes", ".", "keys", "(", ")", ":", "raise", "RecipeMissingException", "(", "\"Recipe %s unknown.\"", "%", "recipe", ")", "reci...
Execute a recipe and creates new folder and files. :param recipe: Name of the recipe :param plugin: Name of the plugin, to which the recipe must belong.
[ "Execute", "a", "recipe", "and", "creates", "new", "folder", "and", "files", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_recipes_pattern.py#L172-L190
train
Execute a recipe and creates new folder and files.
useblocks/groundwork
groundwork/patterns/gw_recipes_pattern.py
Recipe.build
def build(self, output_dir=None, **kwargs): """ Buildes the recipe and creates needed folder and files. May ask the user for some parameter inputs. :param output_dir: Path, where the recipe shall be build. Default is the current working directory :return: location of the install...
python
def build(self, output_dir=None, **kwargs): """ Buildes the recipe and creates needed folder and files. May ask the user for some parameter inputs. :param output_dir: Path, where the recipe shall be build. Default is the current working directory :return: location of the install...
[ "def", "build", "(", "self", ",", "output_dir", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "output_dir", "is", "None", ":", "output_dir", "=", "os", ".", "getcwd", "(", ")", "target", "=", "cookiecutter", "(", "self", ".", "path", ",", "...
Buildes the recipe and creates needed folder and files. May ask the user for some parameter inputs. :param output_dir: Path, where the recipe shall be build. Default is the current working directory :return: location of the installed recipe
[ "Buildes", "the", "recipe", "and", "creates", "needed", "folder", "and", "files", ".", "May", "ask", "the", "user", "for", "some", "parameter", "inputs", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_recipes_pattern.py#L213-L229
train
Builds the recipe and creates needed folders and files.
Phyks/libbmc
libbmc/citations/pdf.py
cermine
def cermine(pdf_file, force_api=False, override_local=None): """ Run `CERMINE <https://github.com/CeON/CERMINE>`_ to extract metadata from \ the given PDF file, to retrieve citations (and more) from the \ provided PDF file. This function returns the raw output of \ CERMINE ca...
python
def cermine(pdf_file, force_api=False, override_local=None): """ Run `CERMINE <https://github.com/CeON/CERMINE>`_ to extract metadata from \ the given PDF file, to retrieve citations (and more) from the \ provided PDF file. This function returns the raw output of \ CERMINE ca...
[ "def", "cermine", "(", "pdf_file", ",", "force_api", "=", "False", ",", "override_local", "=", "None", ")", ":", "try", ":", "# Check if we want to load the local JAR from a specific path", "local", "=", "override_local", "# Else, try to stat the JAR file at the expected loca...
Run `CERMINE <https://github.com/CeON/CERMINE>`_ to extract metadata from \ the given PDF file, to retrieve citations (and more) from the \ provided PDF file. This function returns the raw output of \ CERMINE call. .. note:: Try to use a local CERMINE JAR file, and fall...
[ "Run", "CERMINE", "<https", ":", "//", "github", ".", "com", "/", "CeON", "/", "CERMINE", ">", "_", "to", "extract", "metadata", "from", "\\", "the", "given", "PDF", "file", "to", "retrieve", "citations", "(", "and", "more", ")", "from", "the", "\\", ...
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/citations/pdf.py#L21-L87
train
This function returns the raw output of the CERMINE API for the given PDF file.
Phyks/libbmc
libbmc/citations/pdf.py
cermine_dois
def cermine_dois(pdf_file, force_api=False, override_local=None): """ Run `CERMINE <https://github.com/CeON/CERMINE>`_ to extract DOIs of cited \ papers from a PDF file. .. note:: Try to use a local CERMINE JAR file, and falls back to using the API. \ JAR file is expect...
python
def cermine_dois(pdf_file, force_api=False, override_local=None): """ Run `CERMINE <https://github.com/CeON/CERMINE>`_ to extract DOIs of cited \ papers from a PDF file. .. note:: Try to use a local CERMINE JAR file, and falls back to using the API. \ JAR file is expect...
[ "def", "cermine_dois", "(", "pdf_file", ",", "force_api", "=", "False", ",", "override_local", "=", "None", ")", ":", "# TODO:", "# * Do not convert to plain text, but use the extra metadata from", "# CERMINE", "# Call CERMINE on the PDF file", "cermine_output", "=", ...
Run `CERMINE <https://github.com/CeON/CERMINE>`_ to extract DOIs of cited \ papers from a PDF file. .. note:: Try to use a local CERMINE JAR file, and falls back to using the API. \ JAR file is expected to be found in \ ``libbmc/external/cermine.jar``. You can o...
[ "Run", "CERMINE", "<https", ":", "//", "github", ".", "com", "/", "CeON", "/", "CERMINE", ">", "_", "to", "extract", "DOIs", "of", "cited", "\\", "papers", "from", "a", "PDF", "file", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/citations/pdf.py#L90-L140
train
This function will cermine the DOIs of a PDF file and return a dictionary of cleaned plaintext citations and their associated DOIs.
Phyks/libbmc
libbmc/citations/pdf.py
grobid
def grobid(pdf_folder, grobid_home=None, grobid_jar=None): """ Run `Grobid <https://github.com/kermitt2/grobid>`_ on a given folder to \ extract references. .. note:: Before using this function, you have to download and build Grobid on \ your system. See \ ...
python
def grobid(pdf_folder, grobid_home=None, grobid_jar=None): """ Run `Grobid <https://github.com/kermitt2/grobid>`_ on a given folder to \ extract references. .. note:: Before using this function, you have to download and build Grobid on \ your system. See \ ...
[ "def", "grobid", "(", "pdf_folder", ",", "grobid_home", "=", "None", ",", "grobid_jar", "=", "None", ")", ":", "# TODO: Should be using https://github.com/kermitt2/grobid-example and", "# BibTeX backend.", "if", "grobid_home", "is", "None", "or", "grobid_jar", "is", "No...
Run `Grobid <https://github.com/kermitt2/grobid>`_ on a given folder to \ extract references. .. note:: Before using this function, you have to download and build Grobid on \ your system. See \ `<https://grobid.readthedocs.org/en/latest/Install-Grobid/>`_ \ ...
[ "Run", "Grobid", "<https", ":", "//", "github", ".", "com", "/", "kermitt2", "/", "grobid", ">", "_", "on", "a", "given", "folder", "to", "\\", "extract", "references", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/citations/pdf.py#L143-L178
train
Run Grobid on a given folder and extract the related files.
Phyks/libbmc
libbmc/citations/pdf.py
pdfextract_dois
def pdfextract_dois(pdf_file): """ Extract DOIs of references using \ `pdfextract <https://github.com/CrossRef/pdfextract>`_. .. note:: See ``libbmc.citations.pdf.pdfextract`` function as this one is just \ a wrapper around it. See ``libbmc.citations.plaintext.g...
python
def pdfextract_dois(pdf_file): """ Extract DOIs of references using \ `pdfextract <https://github.com/CrossRef/pdfextract>`_. .. note:: See ``libbmc.citations.pdf.pdfextract`` function as this one is just \ a wrapper around it. See ``libbmc.citations.plaintext.g...
[ "def", "pdfextract_dois", "(", "pdf_file", ")", ":", "# Call pdf-extract on the PDF file", "references", "=", "pdfextract", "(", "pdf_file", ")", "# Parse the resulting XML", "root", "=", "ET", ".", "fromstring", "(", "references", ")", "plaintext_references", "=", "[...
Extract DOIs of references using \ `pdfextract <https://github.com/CrossRef/pdfextract>`_. .. note:: See ``libbmc.citations.pdf.pdfextract`` function as this one is just \ a wrapper around it. See ``libbmc.citations.plaintext.get_cited_dois`` as well for the \ ...
[ "Extract", "DOIs", "of", "references", "using", "\\", "pdfextract", "<https", ":", "//", "github", ".", "com", "/", "CrossRef", "/", "pdfextract", ">", "_", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/citations/pdf.py#L219-L240
train
Extract DOIs of references using \ pdfextract.
acutesoftware/AIKIF
aikif/lib/cls_context.py
where_am_i
def where_am_i(): """ high level function that can estimate where user is based on predefined setups. """ locations = {'Work':0, 'Home':0} for ssid in scan_for_ssids(): #print('checking scanned_ssid ', ssid) for l in logged_ssids: #print('checking logged_ssid ', l) ...
python
def where_am_i(): """ high level function that can estimate where user is based on predefined setups. """ locations = {'Work':0, 'Home':0} for ssid in scan_for_ssids(): #print('checking scanned_ssid ', ssid) for l in logged_ssids: #print('checking logged_ssid ', l) ...
[ "def", "where_am_i", "(", ")", ":", "locations", "=", "{", "'Work'", ":", "0", ",", "'Home'", ":", "0", "}", "for", "ssid", "in", "scan_for_ssids", "(", ")", ":", "#print('checking scanned_ssid ', ssid)", "for", "l", "in", "logged_ssids", ":", "#print('check...
high level function that can estimate where user is based on predefined setups.
[ "high", "level", "function", "that", "can", "estimate", "where", "user", "is", "based", "on", "predefined", "setups", "." ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_context.py#L54-L69
train
high level function that can estimate where user is based on predefined setups.
acutesoftware/AIKIF
aikif/lib/cls_context.py
Context.dump_all
def dump_all(self, silent='NO'): """ prints all attributes and returns them as a dictionary (mainly for testing how it will all integrate) """ all_params = [] all_params.append(dict(name='phone', val=self.transport)) all_params.append(dict(name='username', val=s...
python
def dump_all(self, silent='NO'): """ prints all attributes and returns them as a dictionary (mainly for testing how it will all integrate) """ all_params = [] all_params.append(dict(name='phone', val=self.transport)) all_params.append(dict(name='username', val=s...
[ "def", "dump_all", "(", "self", ",", "silent", "=", "'NO'", ")", ":", "all_params", "=", "[", "]", "all_params", ".", "append", "(", "dict", "(", "name", "=", "'phone'", ",", "val", "=", "self", ".", "transport", ")", ")", "all_params", ".", "append"...
prints all attributes and returns them as a dictionary (mainly for testing how it will all integrate)
[ "prints", "all", "attributes", "and", "returns", "them", "as", "a", "dictionary", "(", "mainly", "for", "testing", "how", "it", "will", "all", "integrate", ")" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_context.py#L106-L125
train
Prints all attributes and returns them as a dictionary
acutesoftware/AIKIF
aikif/lib/cls_context.py
Context.summarise
def summarise(self): """ extrapolate a human readable summary of the contexts """ res = '' if self.user == 'Developer': if self.host == 'Home PC': res += 'At Home' else: res += 'Away from PC' elif self.user == 'Us...
python
def summarise(self): """ extrapolate a human readable summary of the contexts """ res = '' if self.user == 'Developer': if self.host == 'Home PC': res += 'At Home' else: res += 'Away from PC' elif self.user == 'Us...
[ "def", "summarise", "(", "self", ")", ":", "res", "=", "''", "if", "self", ".", "user", "==", "'Developer'", ":", "if", "self", ".", "host", "==", "'Home PC'", ":", "res", "+=", "'At Home'", "else", ":", "res", "+=", "'Away from PC'", "elif", "self", ...
extrapolate a human readable summary of the contexts
[ "extrapolate", "a", "human", "readable", "summary", "of", "the", "contexts" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_context.py#L127-L141
train
returns a human readable summary of the contexts
acutesoftware/AIKIF
aikif/lib/cls_context.py
Context.get_host
def get_host(self): """ returns the host computer running this program """ import socket host_name = socket.gethostname() for h in hosts: if h['name'] == host_name: return h['type'], h['name'] return dict(type='Unknown', name=host_nam...
python
def get_host(self): """ returns the host computer running this program """ import socket host_name = socket.gethostname() for h in hosts: if h['name'] == host_name: return h['type'], h['name'] return dict(type='Unknown', name=host_nam...
[ "def", "get_host", "(", "self", ")", ":", "import", "socket", "host_name", "=", "socket", ".", "gethostname", "(", ")", "for", "h", "in", "hosts", ":", "if", "h", "[", "'name'", "]", "==", "host_name", ":", "return", "h", "[", "'type'", "]", ",", "...
returns the host computer running this program
[ "returns", "the", "host", "computer", "running", "this", "program" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_context.py#L162-L171
train
returns the host computer running this program
acutesoftware/AIKIF
aikif/lib/cls_context.py
Context.inspect_phone
def inspect_phone(self, gps_lat_long = [137.0000,100.0000], moving = False, move_dist_2_mn = 4, on_charge = True, screen_saver = False): """ FUNCTION STUB - TODO The intention is to get data from the mobile in the format: gps_lat = 137.000 gps_lng = 100.00...
python
def inspect_phone(self, gps_lat_long = [137.0000,100.0000], moving = False, move_dist_2_mn = 4, on_charge = True, screen_saver = False): """ FUNCTION STUB - TODO The intention is to get data from the mobile in the format: gps_lat = 137.000 gps_lng = 100.00...
[ "def", "inspect_phone", "(", "self", ",", "gps_lat_long", "=", "[", "137.0000", ",", "100.0000", "]", ",", "moving", "=", "False", ",", "move_dist_2_mn", "=", "4", ",", "on_charge", "=", "True", ",", "screen_saver", "=", "False", ")", ":", "self", ".", ...
FUNCTION STUB - TODO The intention is to get data from the mobile in the format: gps_lat = 137.000 gps_lng = 100.000 moving = True | False move_dist_10_sc = 0 move_dist_2_mn = 4 move_dist_10_mn = 4 move...
[ "FUNCTION", "STUB", "-", "TODO", "The", "intention", "is", "to", "get", "data", "from", "the", "mobile", "in", "the", "format", ":", "gps_lat", "=", "137", ".", "000", "gps_lng", "=", "100", ".", "000", "moving", "=", "True", "|", "False", "move_dist_1...
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_context.py#L185-L227
train
This function returns a string describing the state of the phone.
acutesoftware/AIKIF
aikif/lib/cls_context.py
Context.get_host_usage
def get_host_usage(self): """ get details of CPU, RAM usage of this PC """ import psutil process_names = [proc.name for proc in psutil.process_iter()] cpu_pct = psutil.cpu_percent(interval=1) mem = psutil.virtual_memory() return str(cpu_pct), str(len(pro...
python
def get_host_usage(self): """ get details of CPU, RAM usage of this PC """ import psutil process_names = [proc.name for proc in psutil.process_iter()] cpu_pct = psutil.cpu_percent(interval=1) mem = psutil.virtual_memory() return str(cpu_pct), str(len(pro...
[ "def", "get_host_usage", "(", "self", ")", ":", "import", "psutil", "process_names", "=", "[", "proc", ".", "name", "for", "proc", "in", "psutil", ".", "process_iter", "(", ")", "]", "cpu_pct", "=", "psutil", ".", "cpu_percent", "(", "interval", "=", "1"...
get details of CPU, RAM usage of this PC
[ "get", "details", "of", "CPU", "RAM", "usage", "of", "this", "PC" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_context.py#L229-L237
train
get details of CPU RAM usage of this PC
Nachtfeuer/pipeline
spline/components/config.py
ShellConfig.schema
def schema(): """Provide schema for shell configuration.""" return Schema({ 'script': And(Or(type(' '), type(u' ')), len), Optional('title', default=''): str, Optional('model', default={}): {Optional(And(str, len)): object}, Optional('env', default={}): {O...
python
def schema(): """Provide schema for shell configuration.""" return Schema({ 'script': And(Or(type(' '), type(u' ')), len), Optional('title', default=''): str, Optional('model', default={}): {Optional(And(str, len)): object}, Optional('env', default={}): {O...
[ "def", "schema", "(", ")", ":", "return", "Schema", "(", "{", "'script'", ":", "And", "(", "Or", "(", "type", "(", "' '", ")", ",", "type", "(", "u' '", ")", ")", ",", "len", ")", ",", "Optional", "(", "'title'", ",", "default", "=", "''", ")",...
Provide schema for shell configuration.
[ "Provide", "schema", "for", "shell", "configuration", "." ]
04ca18c4e95e4349532bb45b768206393e1f2c13
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/config.py#L29-L46
train
Provide schema for shell configuration.
HackerEarth/he-sdk-python
hackerearth/result.py
BaseAPIResult._transform_to_attrs
def _transform_to_attrs(self, response): """Sets the key/value pairs in the given dict as attributes of this result object. """ response_dict = self._desiarialize_response(response) self.__dict__.update(response_dict)
python
def _transform_to_attrs(self, response): """Sets the key/value pairs in the given dict as attributes of this result object. """ response_dict = self._desiarialize_response(response) self.__dict__.update(response_dict)
[ "def", "_transform_to_attrs", "(", "self", ",", "response", ")", ":", "response_dict", "=", "self", ".", "_desiarialize_response", "(", "response", ")", "self", ".", "__dict__", ".", "update", "(", "response_dict", ")" ]
Sets the key/value pairs in the given dict as attributes of this result object.
[ "Sets", "the", "key", "/", "value", "pairs", "in", "the", "given", "dict", "as", "attributes", "of", "this", "result", "object", "." ]
ca718afaf70a4239af1adf09ee248a076864b5fe
https://github.com/HackerEarth/he-sdk-python/blob/ca718afaf70a4239af1adf09ee248a076864b5fe/hackerearth/result.py#L13-L18
train
Sets the key - value pairs in the given dict as attributes of this result object.
HackerEarth/he-sdk-python
hackerearth/result.py
RunResult._flatten_dict
def _flatten_dict(self, dict_): """Modifies the given dict into a flat dict consisting of only key/value pairs. """ flattened_dict = {} for (key, value) in dict_.iteritems(): if isinstance(value, dict): flattened_dict.update(self._flatten_dict(value)) ...
python
def _flatten_dict(self, dict_): """Modifies the given dict into a flat dict consisting of only key/value pairs. """ flattened_dict = {} for (key, value) in dict_.iteritems(): if isinstance(value, dict): flattened_dict.update(self._flatten_dict(value)) ...
[ "def", "_flatten_dict", "(", "self", ",", "dict_", ")", ":", "flattened_dict", "=", "{", "}", "for", "(", "key", ",", "value", ")", "in", "dict_", ".", "iteritems", "(", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "flattened_di...
Modifies the given dict into a flat dict consisting of only key/value pairs.
[ "Modifies", "the", "given", "dict", "into", "a", "flat", "dict", "consisting", "of", "only", "key", "/", "value", "pairs", "." ]
ca718afaf70a4239af1adf09ee248a076864b5fe
https://github.com/HackerEarth/he-sdk-python/blob/ca718afaf70a4239af1adf09ee248a076864b5fe/hackerearth/result.py#L42-L52
train
Modifies the given dict into a flat dict consisting of only key - value pairs.
acutesoftware/AIKIF
aikif/project.py
Projects.get_by_name
def get_by_name(self, name): """ returns an object Project which matches name """ for p in self.project_list: if p.nme == name: return p return None
python
def get_by_name(self, name): """ returns an object Project which matches name """ for p in self.project_list: if p.nme == name: return p return None
[ "def", "get_by_name", "(", "self", ",", "name", ")", ":", "for", "p", "in", "self", ".", "project_list", ":", "if", "p", ".", "nme", "==", "name", ":", "return", "p", "return", "None" ]
returns an object Project which matches name
[ "returns", "an", "object", "Project", "which", "matches", "name" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/project.py#L35-L40
train
returns an object Project which matches name
acutesoftware/AIKIF
aikif/project.py
Project.add_source
def add_source(self, name, location, schedule='Daily', op=''): """ handles the data sources used in projects, mainly as an abstract to call the data sources in /lib and /dataTools """ if op == '': op = name + '.log' self.data_sources.append([name, location, s...
python
def add_source(self, name, location, schedule='Daily', op=''): """ handles the data sources used in projects, mainly as an abstract to call the data sources in /lib and /dataTools """ if op == '': op = name + '.log' self.data_sources.append([name, location, s...
[ "def", "add_source", "(", "self", ",", "name", ",", "location", ",", "schedule", "=", "'Daily'", ",", "op", "=", "''", ")", ":", "if", "op", "==", "''", ":", "op", "=", "name", "+", "'.log'", "self", ".", "data_sources", ".", "append", "(", "[", ...
handles the data sources used in projects, mainly as an abstract to call the data sources in /lib and /dataTools
[ "handles", "the", "data", "sources", "used", "in", "projects", "mainly", "as", "an", "abstract", "to", "call", "the", "data", "sources", "in", "/", "lib", "and", "/", "dataTools" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/project.py#L101-L108
train
Adds a source to the list of data sources used in projects.
acutesoftware/AIKIF
aikif/project.py
Project.execute_tasks
def execute_tasks(self): """ run execute on all tasks IFF prior task is successful """ for t in self.tasks: print('RUNNING ' + str(t.task_id) + ' = ' + t.name) t.execute() if t.success != '__IGNORE__RESULT__': print(t) p...
python
def execute_tasks(self): """ run execute on all tasks IFF prior task is successful """ for t in self.tasks: print('RUNNING ' + str(t.task_id) + ' = ' + t.name) t.execute() if t.success != '__IGNORE__RESULT__': print(t) p...
[ "def", "execute_tasks", "(", "self", ")", ":", "for", "t", "in", "self", ".", "tasks", ":", "print", "(", "'RUNNING '", "+", "str", "(", "t", ".", "task_id", ")", "+", "' = '", "+", "t", ".", "name", ")", "t", ".", "execute", "(", ")", "if", "t...
run execute on all tasks IFF prior task is successful
[ "run", "execute", "on", "all", "tasks", "IFF", "prior", "task", "is", "successful" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/project.py#L132-L145
train
execute on all tasks IFF prior task is successful
acutesoftware/AIKIF
aikif/project.py
Project.build_report
def build_report(self, op_file, tpe='md'): """ create a report showing all project details """ if tpe == 'md': res = self.get_report_md() elif tpe == 'rst': res = self.get_report_rst() elif tpe == 'html': res = self.get_report_html() ...
python
def build_report(self, op_file, tpe='md'): """ create a report showing all project details """ if tpe == 'md': res = self.get_report_md() elif tpe == 'rst': res = self.get_report_rst() elif tpe == 'html': res = self.get_report_html() ...
[ "def", "build_report", "(", "self", ",", "op_file", ",", "tpe", "=", "'md'", ")", ":", "if", "tpe", "==", "'md'", ":", "res", "=", "self", ".", "get_report_md", "(", ")", "elif", "tpe", "==", "'rst'", ":", "res", "=", "self", ".", "get_report_rst", ...
create a report showing all project details
[ "create", "a", "report", "showing", "all", "project", "details" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/project.py#L149-L163
train
build a report
acutesoftware/AIKIF
aikif/project.py
Project.get_report_rst
def get_report_rst(self): """ formats the project into a report in RST format """ res = '' res += '-----------------------------------\n' res += self.nme + '\n' res += '-----------------------------------\n\n' res += self.desc + '\n' res += self....
python
def get_report_rst(self): """ formats the project into a report in RST format """ res = '' res += '-----------------------------------\n' res += self.nme + '\n' res += '-----------------------------------\n\n' res += self.desc + '\n' res += self....
[ "def", "get_report_rst", "(", "self", ")", ":", "res", "=", "''", "res", "+=", "'-----------------------------------\\n'", "res", "+=", "self", ".", "nme", "+", "'\\n'", "res", "+=", "'-----------------------------------\\n\\n'", "res", "+=", "self", ".", "desc", ...
formats the project into a report in RST format
[ "formats", "the", "project", "into", "a", "report", "in", "RST", "format" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/project.py#L165-L193
train
returns a RST report
acutesoftware/AIKIF
aikif/project.py
Project.get_report_html
def get_report_html(self): """ formats the project into a report in MD format - WARNING - tables missing BR """ res = '<h2>Project:' + self.nme + '</h2>' res += '<p>' + self.desc + '</p>' res += '<p>' + self.fldr + '</p>' res += '<BR><h3>TABLES</h3>' ...
python
def get_report_html(self): """ formats the project into a report in MD format - WARNING - tables missing BR """ res = '<h2>Project:' + self.nme + '</h2>' res += '<p>' + self.desc + '</p>' res += '<p>' + self.fldr + '</p>' res += '<BR><h3>TABLES</h3>' ...
[ "def", "get_report_html", "(", "self", ")", ":", "res", "=", "'<h2>Project:'", "+", "self", ".", "nme", "+", "'</h2>'", "res", "+=", "'<p>'", "+", "self", ".", "desc", "+", "'</p>'", "res", "+=", "'<p>'", "+", "self", ".", "fldr", "+", "'</p>'", "res...
formats the project into a report in MD format - WARNING - tables missing BR
[ "formats", "the", "project", "into", "a", "report", "in", "MD", "format", "-", "WARNING", "-", "tables", "missing", "BR" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/project.py#L213-L226
train
returns the html report for the current object
acutesoftware/AIKIF
aikif/project.py
Task.add_param
def add_param(self, param_key, param_val): """ adds parameters as key value pairs """ self.params.append([param_key, param_val]) if param_key == '__success_test': self.success = param_val
python
def add_param(self, param_key, param_val): """ adds parameters as key value pairs """ self.params.append([param_key, param_val]) if param_key == '__success_test': self.success = param_val
[ "def", "add_param", "(", "self", ",", "param_key", ",", "param_val", ")", ":", "self", ".", "params", ".", "append", "(", "[", "param_key", ",", "param_val", "]", ")", "if", "param_key", "==", "'__success_test'", ":", "self", ".", "success", "=", "param_...
adds parameters as key value pairs
[ "adds", "parameters", "as", "key", "value", "pairs" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/project.py#L257-L263
train
Adds a parameter to the list of parameters.
acutesoftware/AIKIF
aikif/project.py
Task.execute
def execute(self): """ executes all automatic tasks in order of task id """ func_params = [] exec_str = self.func.__name__ + '(' for p in self.params: if p[0][0:2] != '__': # ignore custom param names exec_str += p[0] + '="' + self._force_st...
python
def execute(self): """ executes all automatic tasks in order of task id """ func_params = [] exec_str = self.func.__name__ + '(' for p in self.params: if p[0][0:2] != '__': # ignore custom param names exec_str += p[0] + '="' + self._force_st...
[ "def", "execute", "(", "self", ")", ":", "func_params", "=", "[", "]", "exec_str", "=", "self", ".", "func", ".", "__name__", "+", "'('", "for", "p", "in", "self", ".", "params", ":", "if", "p", "[", "0", "]", "[", "0", ":", "2", "]", "!=", "...
executes all automatic tasks in order of task id
[ "executes", "all", "automatic", "tasks", "in", "order", "of", "task", "id" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/project.py#L265-L280
train
Executes all automatic tasks in order of task id
cox-labs/perseuspy
perseuspy/io/perseus/matrix.py
read_annotations
def read_annotations(path_or_file, separator='\t', reset=True): """ Read all annotations from the specified file. >>> annotations = read_annotations(path_or_file, separator) >>> colnames = annotations['Column Name'] >>> types = annotations['Type'] >>> annot_row = annotations['Annot. row nam...
python
def read_annotations(path_or_file, separator='\t', reset=True): """ Read all annotations from the specified file. >>> annotations = read_annotations(path_or_file, separator) >>> colnames = annotations['Column Name'] >>> types = annotations['Type'] >>> annot_row = annotations['Annot. row nam...
[ "def", "read_annotations", "(", "path_or_file", ",", "separator", "=", "'\\t'", ",", "reset", "=", "True", ")", ":", "annotations", "=", "OrderedDict", "(", "{", "}", ")", "with", "PathOrFile", "(", "path_or_file", ",", "'r'", ",", "reset", "=", "reset", ...
Read all annotations from the specified file. >>> annotations = read_annotations(path_or_file, separator) >>> colnames = annotations['Column Name'] >>> types = annotations['Type'] >>> annot_row = annotations['Annot. row name'] :param path_or_file: Path or file-like object :param separator:...
[ "Read", "all", "annotations", "from", "the", "specified", "file", ".", ">>>", "annotations", "=", "read_annotations", "(", "path_or_file", "separator", ")", ">>>", "colnames", "=", "annotations", "[", "Column", "Name", "]", ">>>", "types", "=", "annotations", ...
3809c1bd46512605f9e7ca7f97e026e4940ed604
https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/io/perseus/matrix.py#L22-L50
train
Read all annotations from the specified file.
cox-labs/perseuspy
perseuspy/io/perseus/matrix.py
annotation_rows
def annotation_rows(prefix, annotations): """ Helper function to extract N: and C: rows from annotations and pad their values """ ncol = len(annotations['Column Name']) return {name.replace(prefix, '', 1) : values + [''] * (ncol - len(values)) for name, values in annotations.items() if n...
python
def annotation_rows(prefix, annotations): """ Helper function to extract N: and C: rows from annotations and pad their values """ ncol = len(annotations['Column Name']) return {name.replace(prefix, '', 1) : values + [''] * (ncol - len(values)) for name, values in annotations.items() if n...
[ "def", "annotation_rows", "(", "prefix", ",", "annotations", ")", ":", "ncol", "=", "len", "(", "annotations", "[", "'Column Name'", "]", ")", "return", "{", "name", ".", "replace", "(", "prefix", ",", "''", ",", "1", ")", ":", "values", "+", "[", "'...
Helper function to extract N: and C: rows from annotations and pad their values
[ "Helper", "function", "to", "extract", "N", ":", "and", "C", ":", "rows", "from", "annotations", "and", "pad", "their", "values" ]
3809c1bd46512605f9e7ca7f97e026e4940ed604
https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/io/perseus/matrix.py#L52-L58
train
Helper function to extract N and C rows from annotations and pad their values with the specified prefix
cox-labs/perseuspy
perseuspy/io/perseus/matrix.py
create_column_index
def create_column_index(annotations): """ Create a pd.MultiIndex using the column names and any categorical rows. Note that also non-main columns will be assigned a default category ''. """ _column_index = OrderedDict({'Column Name' : annotations['Column Name']}) categorical_rows = annotation_ro...
python
def create_column_index(annotations): """ Create a pd.MultiIndex using the column names and any categorical rows. Note that also non-main columns will be assigned a default category ''. """ _column_index = OrderedDict({'Column Name' : annotations['Column Name']}) categorical_rows = annotation_ro...
[ "def", "create_column_index", "(", "annotations", ")", ":", "_column_index", "=", "OrderedDict", "(", "{", "'Column Name'", ":", "annotations", "[", "'Column Name'", "]", "}", ")", "categorical_rows", "=", "annotation_rows", "(", "'C:'", ",", "annotations", ")", ...
Create a pd.MultiIndex using the column names and any categorical rows. Note that also non-main columns will be assigned a default category ''.
[ "Create", "a", "pd", ".", "MultiIndex", "using", "the", "column", "names", "and", "any", "categorical", "rows", ".", "Note", "that", "also", "non", "-", "main", "columns", "will", "be", "assigned", "a", "default", "category", "." ]
3809c1bd46512605f9e7ca7f97e026e4940ed604
https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/io/perseus/matrix.py#L61-L77
train
Create a pd. MultiIndex using the column names and any categorical rows.
cox-labs/perseuspy
perseuspy/io/perseus/matrix.py
read_perseus
def read_perseus(path_or_file, **kwargs): """ Read a Perseus-formatted matrix into a pd.DataFrame. Annotation rows will be converted into a multi-index. By monkey-patching the returned pd.DataFrame a `to_perseus` method for exporting the pd.DataFrame is made available. :param path_or_file: Fil...
python
def read_perseus(path_or_file, **kwargs): """ Read a Perseus-formatted matrix into a pd.DataFrame. Annotation rows will be converted into a multi-index. By monkey-patching the returned pd.DataFrame a `to_perseus` method for exporting the pd.DataFrame is made available. :param path_or_file: Fil...
[ "def", "read_perseus", "(", "path_or_file", ",", "*", "*", "kwargs", ")", ":", "annotations", "=", "read_annotations", "(", "path_or_file", ",", "separator", ")", "column_index", "=", "create_column_index", "(", "annotations", ")", "if", "'usecols'", "in", "kwar...
Read a Perseus-formatted matrix into a pd.DataFrame. Annotation rows will be converted into a multi-index. By monkey-patching the returned pd.DataFrame a `to_perseus` method for exporting the pd.DataFrame is made available. :param path_or_file: File path or file-like object :param kwargs: Keyword ...
[ "Read", "a", "Perseus", "-", "formatted", "matrix", "into", "a", "pd", ".", "DataFrame", ".", "Annotation", "rows", "will", "be", "converted", "into", "a", "multi", "-", "index", "." ]
3809c1bd46512605f9e7ca7f97e026e4940ed604
https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/io/perseus/matrix.py#L79-L102
train
Read a Perseus - formatted matrix into a pd. DataFrame.
cox-labs/perseuspy
perseuspy/io/perseus/matrix.py
to_perseus
def to_perseus(df, path_or_file, main_columns=None, separator=separator, convert_bool_to_category=True, numerical_annotation_rows = set([])): """ Save pd.DataFrame to Perseus text format. :param df: pd.DataFrame. :param path_or_file: File name or file-like object. :param mai...
python
def to_perseus(df, path_or_file, main_columns=None, separator=separator, convert_bool_to_category=True, numerical_annotation_rows = set([])): """ Save pd.DataFrame to Perseus text format. :param df: pd.DataFrame. :param path_or_file: File name or file-like object. :param mai...
[ "def", "to_perseus", "(", "df", ",", "path_or_file", ",", "main_columns", "=", "None", ",", "separator", "=", "separator", ",", "convert_bool_to_category", "=", "True", ",", "numerical_annotation_rows", "=", "set", "(", "[", "]", ")", ")", ":", "_df", "=", ...
Save pd.DataFrame to Perseus text format. :param df: pd.DataFrame. :param path_or_file: File name or file-like object. :param main_columns: Main columns. Will be infered if set to None. All numeric columns up-until the first non-numeric column are considered main columns. :param separator: For separati...
[ "Save", "pd", ".", "DataFrame", "to", "Perseus", "text", "format", "." ]
3809c1bd46512605f9e7ca7f97e026e4940ed604
https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/io/perseus/matrix.py#L105-L147
train
Save a pd. DataFrame to Perseus text format.
cox-labs/perseuspy
perseuspy/io/perseus/matrix.py
_infer_main_columns
def _infer_main_columns(df, index_level='Column Name', numeric_dtypes=_numeric_dtypes): """ All numeric columns up-until the first non-numeric column are considered main columns. :param df: The pd.DataFrame :param index_level: Name of the index level of the column names. Default 'Column Name' :param...
python
def _infer_main_columns(df, index_level='Column Name', numeric_dtypes=_numeric_dtypes): """ All numeric columns up-until the first non-numeric column are considered main columns. :param df: The pd.DataFrame :param index_level: Name of the index level of the column names. Default 'Column Name' :param...
[ "def", "_infer_main_columns", "(", "df", ",", "index_level", "=", "'Column Name'", ",", "numeric_dtypes", "=", "_numeric_dtypes", ")", ":", "columns", "=", "df", ".", "columns", ".", "get_level_values", "(", "index_level", ")", "main_columns", "=", "[", "]", "...
All numeric columns up-until the first non-numeric column are considered main columns. :param df: The pd.DataFrame :param index_level: Name of the index level of the column names. Default 'Column Name' :param numeric_dtypes: Set of numpy.dtype containing all numeric types. Default int/float. :returns: T...
[ "All", "numeric", "columns", "up", "-", "until", "the", "first", "non", "-", "numeric", "column", "are", "considered", "main", "columns", ".", ":", "param", "df", ":", "The", "pd", ".", "DataFrame", ":", "param", "index_level", ":", "Name", "of", "the", ...
3809c1bd46512605f9e7ca7f97e026e4940ed604
https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/io/perseus/matrix.py#L177-L192
train
Infer the main columns of a single column.
acutesoftware/AIKIF
aikif/web_app/page_search.py
get_page
def get_page(search_text): """ formats the entire search result in a table output """ lst = search_aikif(search_text) txt = '<table class="as-table as-table-zebra as-table-horizontal">' for result in lst: txt += '<TR><TD>' + result + '</TD></TR>' txt += '</TABLE>\n\n' return txt
python
def get_page(search_text): """ formats the entire search result in a table output """ lst = search_aikif(search_text) txt = '<table class="as-table as-table-zebra as-table-horizontal">' for result in lst: txt += '<TR><TD>' + result + '</TD></TR>' txt += '</TABLE>\n\n' return txt
[ "def", "get_page", "(", "search_text", ")", ":", "lst", "=", "search_aikif", "(", "search_text", ")", "txt", "=", "'<table class=\"as-table as-table-zebra as-table-horizontal\">'", "for", "result", "in", "lst", ":", "txt", "+=", "'<TR><TD>'", "+", "result", "+", "...
formats the entire search result in a table output
[ "formats", "the", "entire", "search", "result", "in", "a", "table", "output" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/page_search.py#L12-L21
train
formats the entire search result in a table output
acutesoftware/AIKIF
aikif/web_app/page_search.py
search_aikif
def search_aikif(txt, formatHTML=True): """ search for text - currently this looks in all folders in the root of AIKIF but that also contains binaries so will need to use the agent_filelist.py to specify the list of folders. NOTE - this needs to use indexes rather than full search each time ...
python
def search_aikif(txt, formatHTML=True): """ search for text - currently this looks in all folders in the root of AIKIF but that also contains binaries so will need to use the agent_filelist.py to specify the list of folders. NOTE - this needs to use indexes rather than full search each time ...
[ "def", "search_aikif", "(", "txt", ",", "formatHTML", "=", "True", ")", ":", "results", "=", "[", "]", "num_found", "=", "0", "import", "aikif", ".", "lib", ".", "cls_filelist", "as", "mod_fl", "my_files", "=", "mod_fl", ".", "FileList", "(", "[", "aik...
search for text - currently this looks in all folders in the root of AIKIF but that also contains binaries so will need to use the agent_filelist.py to specify the list of folders. NOTE - this needs to use indexes rather than full search each time
[ "search", "for", "text", "-", "currently", "this", "looks", "in", "all", "folders", "in", "the", "root", "of", "AIKIF", "but", "that", "also", "contains", "binaries", "so", "will", "need", "to", "use", "the", "agent_filelist", ".", "py", "to", "specify", ...
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/page_search.py#L23-L58
train
search for text in AIKIF
acutesoftware/AIKIF
aikif/web_app/page_search.py
format_result
def format_result(line, line_num, txt): """ highlight the search result """ return '&nbsp;&nbsp;' + str(line_num) + ': ' + line.replace(txt, '<span style="background-color: #FFFF00">' + txt + '</span>')
python
def format_result(line, line_num, txt): """ highlight the search result """ return '&nbsp;&nbsp;' + str(line_num) + ': ' + line.replace(txt, '<span style="background-color: #FFFF00">' + txt + '</span>')
[ "def", "format_result", "(", "line", ",", "line_num", ",", "txt", ")", ":", "return", "'&nbsp;&nbsp;'", "+", "str", "(", "line_num", ")", "+", "': '", "+", "line", ".", "replace", "(", "txt", ",", "'<span style=\"background-color: #FFFF00\">'", "+", "txt", "...
highlight the search result
[ "highlight", "the", "search", "result" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/page_search.py#L60-L63
train
format the result of a search
acutesoftware/AIKIF
aikif/environments/happiness.py
TEST
def TEST(): """ Modules for testing happiness of 'persons' in 'worlds' based on simplistic preferences. Just a toy - dont take seriously ----- WORLD SUMMARY for : Mars ----- population = 0 tax_rate = 0.0 tradition = 0.9 equity = 0.0 Preferences for Rov...
python
def TEST(): """ Modules for testing happiness of 'persons' in 'worlds' based on simplistic preferences. Just a toy - dont take seriously ----- WORLD SUMMARY for : Mars ----- population = 0 tax_rate = 0.0 tradition = 0.9 equity = 0.0 Preferences for Rov...
[ "def", "TEST", "(", ")", ":", "w", "=", "World", "(", "'Mars'", ",", "[", "0", ",", "0.0", ",", "0.9", ",", "0.0", "]", ")", "print", "(", "w", ")", "p", "=", "Person", "(", "'Rover'", ",", "{", "'tax_min'", ":", "0.0", ",", "'tax_max'", ":",...
Modules for testing happiness of 'persons' in 'worlds' based on simplistic preferences. Just a toy - dont take seriously ----- WORLD SUMMARY for : Mars ----- population = 0 tax_rate = 0.0 tradition = 0.9 equity = 0.0 Preferences for Rover tax_min = 0....
[ "Modules", "for", "testing", "happiness", "of", "persons", "in", "worlds", "based", "on", "simplistic", "preferences", ".", "Just", "a", "toy", "-", "dont", "take", "seriously" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/environments/happiness.py#L3-L39
train
This test is used to test the happiness of persons in worlds in Mars.
acutesoftware/AIKIF
aikif/environments/happiness.py
WorldFinder.solve
def solve(self, max_worlds=10000, silent=False): """ find the best world to make people happy """ self.num_worlds = 0 num_unhappy = 0 for tax_rate in range(self.tax_range[0],self.tax_range[1]): for equity in range(self.equity_range[0],self.equity_range[1]): ...
python
def solve(self, max_worlds=10000, silent=False): """ find the best world to make people happy """ self.num_worlds = 0 num_unhappy = 0 for tax_rate in range(self.tax_range[0],self.tax_range[1]): for equity in range(self.equity_range[0],self.equity_range[1]): ...
[ "def", "solve", "(", "self", ",", "max_worlds", "=", "10000", ",", "silent", "=", "False", ")", ":", "self", ".", "num_worlds", "=", "0", "num_unhappy", "=", "0", "for", "tax_rate", "in", "range", "(", "self", ".", "tax_range", "[", "0", "]", ",", ...
find the best world to make people happy
[ "find", "the", "best", "world", "to", "make", "people", "happy" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/environments/happiness.py#L129-L153
train
find the best world to make people happy
acutesoftware/AIKIF
aikif/environments/happiness.py
Happiness.show_details
def show_details(self): """ extended print details of happiness parameters """ res = str(self) res += '\nDETAILS\n' for f in self.factors: res += str(f) return res
python
def show_details(self): """ extended print details of happiness parameters """ res = str(self) res += '\nDETAILS\n' for f in self.factors: res += str(f) return res
[ "def", "show_details", "(", "self", ")", ":", "res", "=", "str", "(", "self", ")", "res", "+=", "'\\nDETAILS\\n'", "for", "f", "in", "self", ".", "factors", ":", "res", "+=", "str", "(", "f", ")", "return", "res" ]
extended print details of happiness parameters
[ "extended", "print", "details", "of", "happiness", "parameters" ]
fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/environments/happiness.py#L222-L231
train
show details of happiness parameters