repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
davidhuser/dhis2.py
dhis2/utils.py
https://github.com/davidhuser/dhis2.py/blob/78cbf1985506db21acdfa0f2e624bc397e455c82/dhis2/utils.py#L132-L139
def is_valid_uid(uid): """ :return: True if it is a valid DHIS2 UID, False if not """ pattern = r'^[A-Za-z][A-Za-z0-9]{10}$' if not isinstance(uid, string_types): return False return bool(re.compile(pattern).match(uid))
[ "def", "is_valid_uid", "(", "uid", ")", ":", "pattern", "=", "r'^[A-Za-z][A-Za-z0-9]{10}$'", "if", "not", "isinstance", "(", "uid", ",", "string_types", ")", ":", "return", "False", "return", "bool", "(", "re", ".", "compile", "(", "pattern", ")", ".", "ma...
:return: True if it is a valid DHIS2 UID, False if not
[ ":", "return", ":", "True", "if", "it", "is", "a", "valid", "DHIS2", "UID", "False", "if", "not" ]
python
train
idlesign/uwsgiconf
uwsgiconf/cli.py
https://github.com/idlesign/uwsgiconf/blob/475407acb44199edbf7e0a66261bfeb51de1afae/uwsgiconf/cli.py#L80-L94
def probe_plugins(): """Runs uWSGI to determine what plugins are available and prints them out. Generic plugins come first then after blank line follow request plugins. """ plugins = UwsgiRunner().get_plugins() for plugin in sorted(plugins.generic): click.secho(plugin) click.secho(''...
[ "def", "probe_plugins", "(", ")", ":", "plugins", "=", "UwsgiRunner", "(", ")", ".", "get_plugins", "(", ")", "for", "plugin", "in", "sorted", "(", "plugins", ".", "generic", ")", ":", "click", ".", "secho", "(", "plugin", ")", "click", ".", "secho", ...
Runs uWSGI to determine what plugins are available and prints them out. Generic plugins come first then after blank line follow request plugins.
[ "Runs", "uWSGI", "to", "determine", "what", "plugins", "are", "available", "and", "prints", "them", "out", "." ]
python
train
nielstron/pysyncthru
pysyncthru/__init__.py
https://github.com/nielstron/pysyncthru/blob/850a85ba0a74cbd5c408102bb02fd005d8b61ffb/pysyncthru/__init__.py#L102-L107
def capability(self) -> Dict[str, Any]: """Return the capabilities of the printer.""" try: return self.data.get('capability', {}) except (KeyError, AttributeError): return {}
[ "def", "capability", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "try", ":", "return", "self", ".", "data", ".", "get", "(", "'capability'", ",", "{", "}", ")", "except", "(", "KeyError", ",", "AttributeError", ")", ":", "retu...
Return the capabilities of the printer.
[ "Return", "the", "capabilities", "of", "the", "printer", "." ]
python
train
alexa/alexa-skills-kit-sdk-for-python
ask-sdk-core/ask_sdk_core/utils/predicate.py
https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/utils/predicate.py#L78-L97
def is_request_type(request_type): # type: (str) -> Callable[[HandlerInput], bool] """A predicate function returning a boolean, when request type is the passed-in type. The function can be applied on a :py:class:`ask_sdk_core.handler_input.HandlerInput`, to check if the input request type is th...
[ "def", "is_request_type", "(", "request_type", ")", ":", "# type: (str) -> Callable[[HandlerInput], bool]", "def", "can_handle_wrapper", "(", "handler_input", ")", ":", "# type: (HandlerInput) -> bool", "return", "(", "handler_input", ".", "request_envelope", ".", "request", ...
A predicate function returning a boolean, when request type is the passed-in type. The function can be applied on a :py:class:`ask_sdk_core.handler_input.HandlerInput`, to check if the input request type is the passed in request type. :param request_type: request type to be matched with the input'...
[ "A", "predicate", "function", "returning", "a", "boolean", "when", "request", "type", "is", "the", "passed", "-", "in", "type", "." ]
python
train
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/tools/MAVExplorer.py#L276-L309
def save_graph(graphdef): '''save a graph as XML''' if graphdef.filename is None: if 'HOME' in os.environ: dname = os.path.join(os.environ['HOME'], '.mavproxy') mp_util.mkdir_p(dname) graphdef.filename = os.path.join(dname, 'mavgraphs.xml') else: g...
[ "def", "save_graph", "(", "graphdef", ")", ":", "if", "graphdef", ".", "filename", "is", "None", ":", "if", "'HOME'", "in", "os", ".", "environ", ":", "dname", "=", "os", ".", "path", ".", "join", "(", "os", ".", "environ", "[", "'HOME'", "]", ",",...
save a graph as XML
[ "save", "a", "graph", "as", "XML" ]
python
train
welbornprod/colr
colr/base.py
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/base.py#L96-L127
def get_indices(s: Union[str, 'ChainedBase']) -> Dict[int, str]: """ Retrieve a dict of characters and escape codes with their real index into the string as the key. """ codes = get_code_indices(s) if not codes: # This function is not for non-escape-code stuff, but okay. return {...
[ "def", "get_indices", "(", "s", ":", "Union", "[", "str", ",", "'ChainedBase'", "]", ")", "->", "Dict", "[", "int", ",", "str", "]", ":", "codes", "=", "get_code_indices", "(", "s", ")", "if", "not", "codes", ":", "# This function is not for non-escape-cod...
Retrieve a dict of characters and escape codes with their real index into the string as the key.
[ "Retrieve", "a", "dict", "of", "characters", "and", "escape", "codes", "with", "their", "real", "index", "into", "the", "string", "as", "the", "key", "." ]
python
train
gmr/queries
queries/pool.py
https://github.com/gmr/queries/blob/a68855013dc6aaf9ed7b6909a4701f8da8796a0a/queries/pool.py#L203-L207
def close(self): """Close the pool by closing and removing all of the connections""" for cid in list(self.connections.keys()): self.remove(self.connections[cid].handle) LOGGER.debug('Pool %s closed', self.id)
[ "def", "close", "(", "self", ")", ":", "for", "cid", "in", "list", "(", "self", ".", "connections", ".", "keys", "(", ")", ")", ":", "self", ".", "remove", "(", "self", ".", "connections", "[", "cid", "]", ".", "handle", ")", "LOGGER", ".", "debu...
Close the pool by closing and removing all of the connections
[ "Close", "the", "pool", "by", "closing", "and", "removing", "all", "of", "the", "connections" ]
python
train
treycucco/pyebnf
pyebnf/compiler.py
https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/compiler.py#L376-L382
def _ast_special_handling_to_code(self, special_handling, **kwargs): """Convert an AST sepcial handling to python source code.""" ident = special_handling.value.svalue if ident in PB_SPECIAL_HANDLING: return ["PB.{0}".format(ident)] else: return ["self.{0}".format(ident)]
[ "def", "_ast_special_handling_to_code", "(", "self", ",", "special_handling", ",", "*", "*", "kwargs", ")", ":", "ident", "=", "special_handling", ".", "value", ".", "svalue", "if", "ident", "in", "PB_SPECIAL_HANDLING", ":", "return", "[", "\"PB.{0}\"", ".", "...
Convert an AST sepcial handling to python source code.
[ "Convert", "an", "AST", "sepcial", "handling", "to", "python", "source", "code", "." ]
python
test
jwodder/doapi
doapi/droplet.py
https://github.com/jwodder/doapi/blob/b1306de86a01d8ae7b9c1fe2699765bb82e4f310/doapi/droplet.py#L234-L244
def fetch_all_kernels(self): r""" Returns a generator that yields all of the kernels available to the droplet :rtype: generator of `Kernel`\ s :raises DOAPIError: if the API endpoint replies with an error """ api = self.doapi_manager for kern in api.pagin...
[ "def", "fetch_all_kernels", "(", "self", ")", ":", "api", "=", "self", ".", "doapi_manager", "for", "kern", "in", "api", ".", "paginate", "(", "self", ".", "url", "+", "'/kernels'", ",", "'kernels'", ")", ":", "yield", "Kernel", "(", "kern", ",", "doap...
r""" Returns a generator that yields all of the kernels available to the droplet :rtype: generator of `Kernel`\ s :raises DOAPIError: if the API endpoint replies with an error
[ "r", "Returns", "a", "generator", "that", "yields", "all", "of", "the", "kernels", "available", "to", "the", "droplet" ]
python
train
rocky/python3-trepan
trepan/lib/sighandler.py
https://github.com/rocky/python3-trepan/blob/14e91bc0acce090d67be145b1ac040cab92ac5f3/trepan/lib/sighandler.py#L63-L82
def canonic_signame(name_num): """Return a signal name for a signal name or signal number. Return None is name_num is an int but not a valid signal number and False if name_num is a not number. If name_num is a signal name or signal number, the canonic if name is returned.""" signum = lookup_signum...
[ "def", "canonic_signame", "(", "name_num", ")", ":", "signum", "=", "lookup_signum", "(", "name_num", ")", "if", "signum", "is", "None", ":", "# Maybe signame is a number?", "try", ":", "num", "=", "int", "(", "name_num", ")", "signame", "=", "lookup_signame",...
Return a signal name for a signal name or signal number. Return None is name_num is an int but not a valid signal number and False if name_num is a not number. If name_num is a signal name or signal number, the canonic if name is returned.
[ "Return", "a", "signal", "name", "for", "a", "signal", "name", "or", "signal", "number", ".", "Return", "None", "is", "name_num", "is", "an", "int", "but", "not", "a", "valid", "signal", "number", "and", "False", "if", "name_num", "is", "a", "not", "nu...
python
test
bcwaldon/warlock
warlock/model.py
https://github.com/bcwaldon/warlock/blob/19b2b3e103ddd753bb5da5b5d96f801c267dad3b/warlock/model.py#L137-L145
def validate(self, obj): """Apply a JSON schema to an object""" try: if self.resolver is not None: jsonschema.validate(obj, self.schema, resolver=self.resolver) else: jsonschema.validate(obj, self.schema) except jsonschema.ValidationError a...
[ "def", "validate", "(", "self", ",", "obj", ")", ":", "try", ":", "if", "self", ".", "resolver", "is", "not", "None", ":", "jsonschema", ".", "validate", "(", "obj", ",", "self", ".", "schema", ",", "resolver", "=", "self", ".", "resolver", ")", "e...
Apply a JSON schema to an object
[ "Apply", "a", "JSON", "schema", "to", "an", "object" ]
python
train
jmgilman/Neolib
neolib/pyamf/__init__.py
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/__init__.py#L629-L655
def remove_error_class(klass): """ Removes a class from the L{ERROR_CLASS_MAP}. An example:: >>> class AuthenticationError(Exception): ... pass ... >>> pyamf.add_error_class(AuthenticationError, 'Auth.Failed') >>> pyamf.remove_error_class(AuthenticationError) @s...
[ "def", "remove_error_class", "(", "klass", ")", ":", "if", "isinstance", "(", "klass", ",", "python", ".", "str_types", ")", ":", "if", "klass", "not", "in", "ERROR_CLASS_MAP", ":", "raise", "ValueError", "(", "'Code %s is not registered'", "%", "(", "klass", ...
Removes a class from the L{ERROR_CLASS_MAP}. An example:: >>> class AuthenticationError(Exception): ... pass ... >>> pyamf.add_error_class(AuthenticationError, 'Auth.Failed') >>> pyamf.remove_error_class(AuthenticationError) @see: L{add_error_class}
[ "Removes", "a", "class", "from", "the", "L", "{", "ERROR_CLASS_MAP", "}", "." ]
python
train
splitkeycoffee/pyhottop
pyhottop/pyhottop.py
https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L195-L217
def _validate_checksum(self, buffer): """Validate the buffer response against the checksum. When reading the serial interface, data will come back in a raw format with an included checksum process. :returns: bool """ self._log.debug("Validating the buffer") if l...
[ "def", "_validate_checksum", "(", "self", ",", "buffer", ")", ":", "self", ".", "_log", ".", "debug", "(", "\"Validating the buffer\"", ")", "if", "len", "(", "buffer", ")", "==", "0", ":", "self", ".", "_log", ".", "debug", "(", "\"Buffer was empty\"", ...
Validate the buffer response against the checksum. When reading the serial interface, data will come back in a raw format with an included checksum process. :returns: bool
[ "Validate", "the", "buffer", "response", "against", "the", "checksum", "." ]
python
train
bwhite/hadoopy
hadoopy/thirdparty/pyinstaller/PyInstaller/lib/altgraph/Graph.py
https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/altgraph/Graph.py#L580-L587
def back_bfs(self, start, end=None): """ Returns a list of nodes in some backward BFS order. Starting from the start node the breadth first search proceeds along incoming edges. """ return [node for node, step in self._iterbfs(start, end, forward=False)]
[ "def", "back_bfs", "(", "self", ",", "start", ",", "end", "=", "None", ")", ":", "return", "[", "node", "for", "node", ",", "step", "in", "self", ".", "_iterbfs", "(", "start", ",", "end", ",", "forward", "=", "False", ")", "]" ]
Returns a list of nodes in some backward BFS order. Starting from the start node the breadth first search proceeds along incoming edges.
[ "Returns", "a", "list", "of", "nodes", "in", "some", "backward", "BFS", "order", "." ]
python
train
genialis/resolwe
resolwe/flow/serializers/data.py
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/serializers/data.py#L132-L141
def get_fields(self): """Dynamically adapt fields based on the current request.""" fields = super(DataSerializer, self).get_fields() # Hide collections/entities fields on list views as fetching them may be expensive. if self.parent is not None: del fields['collections'] ...
[ "def", "get_fields", "(", "self", ")", ":", "fields", "=", "super", "(", "DataSerializer", ",", "self", ")", ".", "get_fields", "(", ")", "# Hide collections/entities fields on list views as fetching them may be expensive.", "if", "self", ".", "parent", "is", "not", ...
Dynamically adapt fields based on the current request.
[ "Dynamically", "adapt", "fields", "based", "on", "the", "current", "request", "." ]
python
train
jreinhardt/handkerchief
handkerchief/handkerchief.py
https://github.com/jreinhardt/handkerchief/blob/450291314ccbbf557b41a30ce9c523587758fe76/handkerchief/handkerchief.py#L248-L286
def collect_reponames(): """ Try to figure out a list of repos to consider by default from the contents of the working directory. """ reponames = [] #try to figure out the repo from git repo in current directory try: with open(os.devnull) as devnull: remote_data = subprocess.check_output(["git","remote","-v...
[ "def", "collect_reponames", "(", ")", ":", "reponames", "=", "[", "]", "#try to figure out the repo from git repo in current directory", "try", ":", "with", "open", "(", "os", ".", "devnull", ")", "as", "devnull", ":", "remote_data", "=", "subprocess", ".", "check...
Try to figure out a list of repos to consider by default from the contents of the working directory.
[ "Try", "to", "figure", "out", "a", "list", "of", "repos", "to", "consider", "by", "default", "from", "the", "contents", "of", "the", "working", "directory", "." ]
python
train
cocagne/txdbus
doc/examples/fd_server.py
https://github.com/cocagne/txdbus/blob/eb424918764b7b93eecd2a4e2e5c2d0b2944407b/doc/examples/fd_server.py#L56-L63
def dbus_readBytesFD(self, fd, byte_count): """ Reads byte_count bytes from fd and returns them. """ f = os.fdopen(fd, 'rb') result = f.read(byte_count) f.close() return bytearray(result)
[ "def", "dbus_readBytesFD", "(", "self", ",", "fd", ",", "byte_count", ")", ":", "f", "=", "os", ".", "fdopen", "(", "fd", ",", "'rb'", ")", "result", "=", "f", ".", "read", "(", "byte_count", ")", "f", ".", "close", "(", ")", "return", "bytearray",...
Reads byte_count bytes from fd and returns them.
[ "Reads", "byte_count", "bytes", "from", "fd", "and", "returns", "them", "." ]
python
train
wandb/client
wandb/summary.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/summary.py#L271-L307
def _encode(self, value, path_from_root): """Normalize, compress, and encode sub-objects for backend storage. value: Object to encode. path_from_root: `tuple` of key strings from the top-level summary to the current `value`. Returns: A new tree of dict's with la...
[ "def", "_encode", "(", "self", ",", "value", ",", "path_from_root", ")", ":", "# Constructs a new `dict` tree in `json_value` that discards and/or", "# encodes objects that aren't JSON serializable.", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "json_value", "=...
Normalize, compress, and encode sub-objects for backend storage. value: Object to encode. path_from_root: `tuple` of key strings from the top-level summary to the current `value`. Returns: A new tree of dict's with large objects replaced with dictionaries wi...
[ "Normalize", "compress", "and", "encode", "sub", "-", "objects", "for", "backend", "storage", "." ]
python
train
bitesofcode/projexui
projexui/widgets/xpopupwidget.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xpopupwidget.py#L641-L655
def handleButtonClick(self, button): """ Handles the button click for this widget. If the Reset button was clicked, then the resetRequested signal will be emitted. All buttons will emit the buttonClicked signal. :param button | <QAbstractButton> """...
[ "def", "handleButtonClick", "(", "self", ",", "button", ")", ":", "if", "(", "self", ".", "signalsBlocked", "(", ")", ")", ":", "return", "if", "(", "button", "==", "self", ".", "_buttonBox", ".", "button", "(", "QDialogButtonBox", ".", "Reset", ")", "...
Handles the button click for this widget. If the Reset button was clicked, then the resetRequested signal will be emitted. All buttons will emit the buttonClicked signal. :param button | <QAbstractButton>
[ "Handles", "the", "button", "click", "for", "this", "widget", ".", "If", "the", "Reset", "button", "was", "clicked", "then", "the", "resetRequested", "signal", "will", "be", "emitted", ".", "All", "buttons", "will", "emit", "the", "buttonClicked", "signal", ...
python
train
imbolc/aiohttp-login
aiohttp_login/sql.py
https://github.com/imbolc/aiohttp-login/blob/43b30d8630ca5c14d4b75c398eb5f6a27ddf0a52/aiohttp_login/sql.py#L80-L88
def delete_sql(table, filter): ''' >>> delete_sql('tbl', {'foo': 10, 'bar': 'baz'}) ('DELETE FROM tbl WHERE bar=$1 AND foo=$2', ['baz', 10]) ''' keys, values = _split_dict(filter) where = _pairs(keys) sql = 'DELETE FROM {} WHERE {}'.format(table, where) return sql, values
[ "def", "delete_sql", "(", "table", ",", "filter", ")", ":", "keys", ",", "values", "=", "_split_dict", "(", "filter", ")", "where", "=", "_pairs", "(", "keys", ")", "sql", "=", "'DELETE FROM {} WHERE {}'", ".", "format", "(", "table", ",", "where", ")", ...
>>> delete_sql('tbl', {'foo': 10, 'bar': 'baz'}) ('DELETE FROM tbl WHERE bar=$1 AND foo=$2', ['baz', 10])
[ ">>>", "delete_sql", "(", "tbl", "{", "foo", ":", "10", "bar", ":", "baz", "}", ")", "(", "DELETE", "FROM", "tbl", "WHERE", "bar", "=", "$1", "AND", "foo", "=", "$2", "[", "baz", "10", "]", ")" ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/core/alias.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/alias.py#L43-L98
def default_aliases(): """Return list of shell aliases to auto-define. """ # Note: the aliases defined here should be safe to use on a kernel # regardless of what frontend it is attached to. Frontends that use a # kernel in-process can define additional aliases that will only work in # their ca...
[ "def", "default_aliases", "(", ")", ":", "# Note: the aliases defined here should be safe to use on a kernel", "# regardless of what frontend it is attached to. Frontends that use a", "# kernel in-process can define additional aliases that will only work in", "# their case. For example, things lik...
Return list of shell aliases to auto-define.
[ "Return", "list", "of", "shell", "aliases", "to", "auto", "-", "define", "." ]
python
test
nameko/nameko
nameko/exceptions.py
https://github.com/nameko/nameko/blob/88d7e5211de4fcc1c34cd7f84d7c77f0619c5f5d/nameko/exceptions.py#L62-L82
def safe_for_serialization(value): """ Transform a value in preparation for serializing as json no-op for strings, mappings and iterables have their entries made safe, and all other values are stringified, with a fallback value if that fails """ if isinstance(value, six.string_types): retu...
[ "def", "safe_for_serialization", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", ":", "return", "value", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "return", "{", "safe_for_serialization", "(", ...
Transform a value in preparation for serializing as json no-op for strings, mappings and iterables have their entries made safe, and all other values are stringified, with a fallback value if that fails
[ "Transform", "a", "value", "in", "preparation", "for", "serializing", "as", "json" ]
python
train
Capitains/MyCapytain
MyCapytain/common/utils/dts.py
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/utils/dts.py#L11-L26
def parse_metadata(metadata_obj: Metadata, metadata_dictionary: dict) -> None: """ Adds to a Metadata object any DublinCore or dts:Extensions object found in the given dictionary :param metadata_obj: :param metadata_dictionary: """ for key, value_set in metadata_dictionary.get("https://w3id.org...
[ "def", "parse_metadata", "(", "metadata_obj", ":", "Metadata", ",", "metadata_dictionary", ":", "dict", ")", "->", "None", ":", "for", "key", ",", "value_set", "in", "metadata_dictionary", ".", "get", "(", "\"https://w3id.org/dts/api#dublincore\"", ",", "[", "{", ...
Adds to a Metadata object any DublinCore or dts:Extensions object found in the given dictionary :param metadata_obj: :param metadata_dictionary:
[ "Adds", "to", "a", "Metadata", "object", "any", "DublinCore", "or", "dts", ":", "Extensions", "object", "found", "in", "the", "given", "dictionary" ]
python
train
roboogle/gtkmvc3
gtkmvco/examples/undo/undo_manager.py
https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/examples/undo/undo_manager.py#L187-L210
def undo_nested_group(self): """ Performs the last group opened, or the top group on the undo stack. Creates a redo group with the same name. """ if self._undoing or self._redoing: raise RuntimeError if self._open: group = self._open.pop() ...
[ "def", "undo_nested_group", "(", "self", ")", ":", "if", "self", ".", "_undoing", "or", "self", ".", "_redoing", ":", "raise", "RuntimeError", "if", "self", ".", "_open", ":", "group", "=", "self", ".", "_open", ".", "pop", "(", ")", "elif", "self", ...
Performs the last group opened, or the top group on the undo stack. Creates a redo group with the same name.
[ "Performs", "the", "last", "group", "opened", "or", "the", "top", "group", "on", "the", "undo", "stack", ".", "Creates", "a", "redo", "group", "with", "the", "same", "name", "." ]
python
train
vertexproject/synapse
synapse/lib/task.py
https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/lib/task.py#L160-L174
def _taskdict(task): ''' Note: No locking is provided. Under normal circumstances, like the other task is not running (e.g. this is running from the same event loop as the task) or task is the current task, this is fine. ''' if task is None: task = asyncio.current_task() assert task ...
[ "def", "_taskdict", "(", "task", ")", ":", "if", "task", "is", "None", ":", "task", "=", "asyncio", ".", "current_task", "(", ")", "assert", "task", "taskvars", "=", "getattr", "(", "task", ",", "'_syn_taskvars'", ",", "None", ")", "if", "taskvars", "i...
Note: No locking is provided. Under normal circumstances, like the other task is not running (e.g. this is running from the same event loop as the task) or task is the current task, this is fine.
[ "Note", ":", "No", "locking", "is", "provided", ".", "Under", "normal", "circumstances", "like", "the", "other", "task", "is", "not", "running", "(", "e", ".", "g", ".", "this", "is", "running", "from", "the", "same", "event", "loop", "as", "the", "tas...
python
train
UCL-INGI/INGInious
inginious/frontend/lti_outcome_manager.py
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/lti_outcome_manager.py#L113-L121
def _increment_attempt(self, mongo_id): """ Increment the number of attempt for an entry and :param mongo_id: :return: """ entry = self._database.lis_outcome_queue.find_one_and_update({"_id": mongo_id}, {"$inc": {"nb_attempt": 1}}) self._add_to_queue(entry)
[ "def", "_increment_attempt", "(", "self", ",", "mongo_id", ")", ":", "entry", "=", "self", ".", "_database", ".", "lis_outcome_queue", ".", "find_one_and_update", "(", "{", "\"_id\"", ":", "mongo_id", "}", ",", "{", "\"$inc\"", ":", "{", "\"nb_attempt\"", ":...
Increment the number of attempt for an entry and :param mongo_id: :return:
[ "Increment", "the", "number", "of", "attempt", "for", "an", "entry", "and", ":", "param", "mongo_id", ":", ":", "return", ":" ]
python
train
unistra/django-rest-framework-custom-exceptions
rest_framework_custom_exceptions/exceptions.py
https://github.com/unistra/django-rest-framework-custom-exceptions/blob/b0fdd5c64146c4f25fb893bc84c58d7774ccb5ef/rest_framework_custom_exceptions/exceptions.py#L9-L39
def simple_error_handler(exc, *args): """ Returns the response that should be used for any given exception. By default we handle the REST framework `APIException`, and also Django's builtin `Http404` and `PermissionDenied` exceptions. Any unhandled exceptions may return `None`, which will cause a ...
[ "def", "simple_error_handler", "(", "exc", ",", "*", "args", ")", ":", "if", "isinstance", "(", "exc", ",", "exceptions", ".", "APIException", ")", ":", "headers", "=", "{", "}", "if", "getattr", "(", "exc", ",", "'auth_header'", ",", "None", ")", ":",...
Returns the response that should be used for any given exception. By default we handle the REST framework `APIException`, and also Django's builtin `Http404` and `PermissionDenied` exceptions. Any unhandled exceptions may return `None`, which will cause a 500 error to be raised.
[ "Returns", "the", "response", "that", "should", "be", "used", "for", "any", "given", "exception", "." ]
python
test
MillionIntegrals/vel
vel/augmentations/random_rotate.py
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/augmentations/random_rotate.py#L27-L29
def create(deg, p=0.75, mode='x', tags=None): """ Vel factory function """ return RandomRotate(deg, p, mode, tags)
[ "def", "create", "(", "deg", ",", "p", "=", "0.75", ",", "mode", "=", "'x'", ",", "tags", "=", "None", ")", ":", "return", "RandomRotate", "(", "deg", ",", "p", ",", "mode", ",", "tags", ")" ]
Vel factory function
[ "Vel", "factory", "function" ]
python
train
lambdalisue/maidenhair
src/maidenhair/statistics/__init__.py
https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/statistics/__init__.py#L37-L64
def mean(x): """ Return a numpy array of column mean. It does not affect if the array is one dimension Parameters ---------- x : ndarray A numpy array instance Returns ------- ndarray A 1 x n numpy array instance of column mean Examples -------- >>> a =...
[ "def", "mean", "(", "x", ")", ":", "if", "x", ".", "ndim", ">", "1", "and", "len", "(", "x", "[", "0", "]", ")", ">", "1", ":", "return", "np", ".", "mean", "(", "x", ",", "axis", "=", "1", ")", "return", "x" ]
Return a numpy array of column mean. It does not affect if the array is one dimension Parameters ---------- x : ndarray A numpy array instance Returns ------- ndarray A 1 x n numpy array instance of column mean Examples -------- >>> a = np.array([[1, 2, 3], [4,...
[ "Return", "a", "numpy", "array", "of", "column", "mean", ".", "It", "does", "not", "affect", "if", "the", "array", "is", "one", "dimension" ]
python
train
venthur/python-debianbts
debianbts/debianbts.py
https://github.com/venthur/python-debianbts/blob/72cf11ae3458a8544142e9f365aaafe25634dd4f/debianbts/debianbts.py#L249-L282
def get_usertag(email, *tags): """Get buglists by usertags. Parameters ---------- email : str tags : tuple of strings If tags are given the dictionary is limited to the matching tags, if no tags are given all available tags are returned. Returns ------- mapping : dict ...
[ "def", "get_usertag", "(", "email", ",", "*", "tags", ")", ":", "reply", "=", "_soap_client_call", "(", "'get_usertag'", ",", "email", ",", "*", "tags", ")", "map_el", "=", "reply", "(", "'s-gensym3'", ")", "mapping", "=", "{", "}", "# element <s-gensys3> ...
Get buglists by usertags. Parameters ---------- email : str tags : tuple of strings If tags are given the dictionary is limited to the matching tags, if no tags are given all available tags are returned. Returns ------- mapping : dict a mapping of usertag -> buglist
[ "Get", "buglists", "by", "usertags", "." ]
python
train
apache/incubator-superset
superset/viz.py
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/viz.py#L1498-L1510
def get_data(self, df): """Returns the chart data""" chart_data = [] if len(self.groupby) > 0: groups = df.groupby(self.groupby) else: groups = [((), df)] for keys, data in groups: chart_data.extend([{ 'key': self.labelify(keys,...
[ "def", "get_data", "(", "self", ",", "df", ")", ":", "chart_data", "=", "[", "]", "if", "len", "(", "self", ".", "groupby", ")", ">", "0", ":", "groups", "=", "df", ".", "groupby", "(", "self", ".", "groupby", ")", "else", ":", "groups", "=", "...
Returns the chart data
[ "Returns", "the", "chart", "data" ]
python
train
bcbio/bcbio-nextgen
bcbio/pipeline/run_info.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L587-L601
def _check_algorithm_values(item): """Check for misplaced inputs in the algorithms. - Identify incorrect boolean values where a choice is required. """ problems = [] for k, v in item.get("algorithm", {}).items(): if v is True and k not in ALG_ALLOW_BOOLEANS: problems.append("%s ...
[ "def", "_check_algorithm_values", "(", "item", ")", ":", "problems", "=", "[", "]", "for", "k", ",", "v", "in", "item", ".", "get", "(", "\"algorithm\"", ",", "{", "}", ")", ".", "items", "(", ")", ":", "if", "v", "is", "True", "and", "k", "not",...
Check for misplaced inputs in the algorithms. - Identify incorrect boolean values where a choice is required.
[ "Check", "for", "misplaced", "inputs", "in", "the", "algorithms", "." ]
python
train
bitesofcode/projexui
projexui/widgets/xorbrecordsetedit/xorbrecordsetedit.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbrecordsetedit/xorbrecordsetedit.py#L340-L351
def setGroupBy( self, groupBy ): """ Sets the group by information for this widget to the inputed grouping options. This can be either a list of strings, or a comma deliminated string. :param groupBy | <str> || [<str>, ..] """ if ( type(grou...
[ "def", "setGroupBy", "(", "self", ",", "groupBy", ")", ":", "if", "(", "type", "(", "groupBy", ")", "in", "(", "list", ",", "tuple", ")", ")", ":", "groupBy", "=", "','", ".", "join", "(", "map", "(", "str", ",", "groupBy", ")", ")", "self", "....
Sets the group by information for this widget to the inputed grouping options. This can be either a list of strings, or a comma deliminated string. :param groupBy | <str> || [<str>, ..]
[ "Sets", "the", "group", "by", "information", "for", "this", "widget", "to", "the", "inputed", "grouping", "options", ".", "This", "can", "be", "either", "a", "list", "of", "strings", "or", "a", "comma", "deliminated", "string", ".", ":", "param", "groupBy"...
python
train
edeposit/marcxml2mods
src/marcxml2mods/xslt_transformer.py
https://github.com/edeposit/marcxml2mods/blob/7b44157e859b4d2a372f79598ddbf77e43d39812/src/marcxml2mods/xslt_transformer.py#L147-L167
def xslt_transformation(xml, template): """ Transform `xml` using XSLT `template`. Args: xml (str): Filename or XML string. Don't use ``\\n`` in case of filename. template (str): Filename or XML string. Don't use ``\\n`` in case of filename. R...
[ "def", "xslt_transformation", "(", "xml", ",", "template", ")", ":", "transformer", "=", "ET", ".", "XSLT", "(", "_read_template", "(", "template", ")", ")", "newdom", "=", "transformer", "(", "_read_marcxml", "(", "xml", ")", ")", "return", "ET", ".", "...
Transform `xml` using XSLT `template`. Args: xml (str): Filename or XML string. Don't use ``\\n`` in case of filename. template (str): Filename or XML string. Don't use ``\\n`` in case of filename. Returns: str: Transformed `xml` as string.
[ "Transform", "xml", "using", "XSLT", "template", "." ]
python
train
maxfischer2781/chainlet
chainlet/concurrency/thread.py
https://github.com/maxfischer2781/chainlet/blob/4e17f9992b4780bd0d9309202e2847df640bffe8/chainlet/concurrency/thread.py#L139-L151
def convert(element): """ Convert a regular :term:`chainlink` to a thread based version :param element: the chainlink to convert :return: a threaded version of ``element`` if possible, or the element itself """ element = linker.LinkPrimitives().convert(element) if isinstance(element, link.C...
[ "def", "convert", "(", "element", ")", ":", "element", "=", "linker", ".", "LinkPrimitives", "(", ")", ".", "convert", "(", "element", ")", "if", "isinstance", "(", "element", ",", "link", ".", "ChainLink", ".", "chain_types", ".", "base_bundle_type", ")",...
Convert a regular :term:`chainlink` to a thread based version :param element: the chainlink to convert :return: a threaded version of ``element`` if possible, or the element itself
[ "Convert", "a", "regular", ":", "term", ":", "chainlink", "to", "a", "thread", "based", "version" ]
python
train
pyviz/holoviews
holoviews/plotting/mpl/element.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/plotting/mpl/element.py#L281-L291
def get_aspect(self, xspan, yspan): """ Computes the aspect ratio of the plot """ if isinstance(self.aspect, (int, float)): return self.aspect elif self.aspect == 'square': return 1 elif self.aspect == 'equal': return xspan/yspan ...
[ "def", "get_aspect", "(", "self", ",", "xspan", ",", "yspan", ")", ":", "if", "isinstance", "(", "self", ".", "aspect", ",", "(", "int", ",", "float", ")", ")", ":", "return", "self", ".", "aspect", "elif", "self", ".", "aspect", "==", "'square'", ...
Computes the aspect ratio of the plot
[ "Computes", "the", "aspect", "ratio", "of", "the", "plot" ]
python
train
bcbio/bcbio-nextgen
bcbio/bam/coverage.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/coverage.py#L25-L50
def _calc_regional_coverage(in_bam, chrom, start, end, samplename, work_dir, data): """ given a BAM and a region, calculate the coverage for each base in that region. returns a pandas dataframe of the format: chrom position coverage name where the samplename column is the coverage at chrom:positio...
[ "def", "_calc_regional_coverage", "(", "in_bam", ",", "chrom", ",", "start", ",", "end", ",", "samplename", ",", "work_dir", ",", "data", ")", ":", "region_bt", "=", "pybedtools", ".", "BedTool", "(", "\"%s\\t%s\\t%s\\n\"", "%", "(", "chrom", ",", "start", ...
given a BAM and a region, calculate the coverage for each base in that region. returns a pandas dataframe of the format: chrom position coverage name where the samplename column is the coverage at chrom:position
[ "given", "a", "BAM", "and", "a", "region", "calculate", "the", "coverage", "for", "each", "base", "in", "that", "region", ".", "returns", "a", "pandas", "dataframe", "of", "the", "format", ":" ]
python
train
mila-iqia/fuel
fuel/converters/base.py
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/base.py#L50-L103
def fill_hdf5_file(h5file, data): """Fills an HDF5 file in a H5PYDataset-compatible manner. Parameters ---------- h5file : :class:`h5py.File` File handle for an HDF5 file. data : tuple of tuple One element per split/source pair. Each element consists of a tuple of (split_nam...
[ "def", "fill_hdf5_file", "(", "h5file", ",", "data", ")", ":", "# Check that all sources for a split have the same length", "split_names", "=", "set", "(", "split_tuple", "[", "0", "]", "for", "split_tuple", "in", "data", ")", "for", "name", "in", "split_names", "...
Fills an HDF5 file in a H5PYDataset-compatible manner. Parameters ---------- h5file : :class:`h5py.File` File handle for an HDF5 file. data : tuple of tuple One element per split/source pair. Each element consists of a tuple of (split_name, source_name, data_array, comment), whe...
[ "Fills", "an", "HDF5", "file", "in", "a", "H5PYDataset", "-", "compatible", "manner", "." ]
python
train
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L402-L414
def _parse_results(self, results, cached_records): """ Parses the given results (in MARCXML format). The given "cached_records" list is a pool of already existing parsed records (in order to avoid keeping several times the same records in memory) """ parser = xml...
[ "def", "_parse_results", "(", "self", ",", "results", ",", "cached_records", ")", ":", "parser", "=", "xml", ".", "sax", ".", "make_parser", "(", ")", "handler", "=", "RecordsHandler", "(", "cached_records", ")", "parser", ".", "setContentHandler", "(", "han...
Parses the given results (in MARCXML format). The given "cached_records" list is a pool of already existing parsed records (in order to avoid keeping several times the same records in memory)
[ "Parses", "the", "given", "results", "(", "in", "MARCXML", "format", ")", "." ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/core/displayhook.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/displayhook.py#L223-L226
def finish_displayhook(self): """Finish up all displayhook activities.""" io.stdout.write(self.shell.separate_out2) io.stdout.flush()
[ "def", "finish_displayhook", "(", "self", ")", ":", "io", ".", "stdout", ".", "write", "(", "self", ".", "shell", ".", "separate_out2", ")", "io", ".", "stdout", ".", "flush", "(", ")" ]
Finish up all displayhook activities.
[ "Finish", "up", "all", "displayhook", "activities", "." ]
python
test
saltstack/salt
salt/modules/boto_vpc.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_vpc.py#L2184-L2233
def associate_route_table(route_table_id=None, subnet_id=None, route_table_name=None, subnet_name=None, region=None, key=None, keyid=None, profile=None): ''' Given a route table and subnet name or id, associates the route table with t...
[ "def", "associate_route_table", "(", "route_table_id", "=", "None", ",", "subnet_id", "=", "None", ",", "route_table_name", "=", "None", ",", "subnet_name", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", ...
Given a route table and subnet name or id, associates the route table with the subnet. CLI Example: .. code-block:: bash salt myminion boto_vpc.associate_route_table 'rtb-1f382e7d' 'subnet-6a1fe403' .. code-block:: bash salt myminion boto_vpc.associate_route_table route_table_name='myrt...
[ "Given", "a", "route", "table", "and", "subnet", "name", "or", "id", "associates", "the", "route", "table", "with", "the", "subnet", "." ]
python
train
Alignak-monitoring/alignak
alignak/objects/timeperiod.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/timeperiod.py#L534-L556
def is_correct(self): """Check if this object configuration is correct :: * Check if dateranges of timeperiod are valid * Call our parent class is_correct checker :return: True if the configuration is correct, otherwise False if at least one daterange is not correct :rt...
[ "def", "is_correct", "(", "self", ")", ":", "state", "=", "True", "for", "daterange", "in", "self", ".", "dateranges", ":", "good", "=", "daterange", ".", "is_correct", "(", ")", "if", "not", "good", ":", "self", ".", "add_error", "(", "\"[timeperiod::%s...
Check if this object configuration is correct :: * Check if dateranges of timeperiod are valid * Call our parent class is_correct checker :return: True if the configuration is correct, otherwise False if at least one daterange is not correct :rtype: bool
[ "Check", "if", "this", "object", "configuration", "is", "correct", "::" ]
python
train
apache/airflow
airflow/hooks/http_hook.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/http_hook.py#L85-L131
def run(self, endpoint, data=None, headers=None, extra_options=None): """ Performs the request :param endpoint: the endpoint to be called i.e. resource/v1/query? :type endpoint: str :param data: payload to be uploaded or request parameters :type data: dict :param...
[ "def", "run", "(", "self", ",", "endpoint", ",", "data", "=", "None", ",", "headers", "=", "None", ",", "extra_options", "=", "None", ")", ":", "extra_options", "=", "extra_options", "or", "{", "}", "session", "=", "self", ".", "get_conn", "(", "header...
Performs the request :param endpoint: the endpoint to be called i.e. resource/v1/query? :type endpoint: str :param data: payload to be uploaded or request parameters :type data: dict :param headers: additional headers to be passed through as a dictionary :type headers: d...
[ "Performs", "the", "request" ]
python
test
capnproto/pycapnp
buildutils/bundle.py
https://github.com/capnproto/pycapnp/blob/cb3f190b955bdb1bfb6e0ac0b2f9306a5c79f7b5/buildutils/bundle.py#L103-L138
def stage_platform_hpp(capnproot): """stage platform.hpp into libcapnp sources Tries ./configure first (except on Windows), then falls back on included platform.hpp previously generated. """ platform_hpp = pjoin(capnproot, 'src', 'platform.hpp') if os.path.exists(platform_hpp): info("a...
[ "def", "stage_platform_hpp", "(", "capnproot", ")", ":", "platform_hpp", "=", "pjoin", "(", "capnproot", ",", "'src'", ",", "'platform.hpp'", ")", "if", "os", ".", "path", ".", "exists", "(", "platform_hpp", ")", ":", "info", "(", "\"already have platform.hpp\...
stage platform.hpp into libcapnp sources Tries ./configure first (except on Windows), then falls back on included platform.hpp previously generated.
[ "stage", "platform", ".", "hpp", "into", "libcapnp", "sources" ]
python
train
yougov/pmxbot
pmxbot/karma.py
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/karma.py#L271-L301
def karma(nick, rest): "Return or change the karma value for some(one|thing)" karmee = rest.strip('++').strip('--').strip('~~') if '++' in rest: Karma.store.change(karmee, 1) elif '--' in rest: Karma.store.change(karmee, -1) elif '~~' in rest: change = random.choice([-1, 0, 1]) Karma.store.change(karmee, c...
[ "def", "karma", "(", "nick", ",", "rest", ")", ":", "karmee", "=", "rest", ".", "strip", "(", "'++'", ")", ".", "strip", "(", "'--'", ")", ".", "strip", "(", "'~~'", ")", "if", "'++'", "in", "rest", ":", "Karma", ".", "store", ".", "change", "(...
Return or change the karma value for some(one|thing)
[ "Return", "or", "change", "the", "karma", "value", "for", "some", "(", "one|thing", ")" ]
python
train
google/grr
grr/server/grr_response_server/timeseries.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/timeseries.py#L46-L62
def Append(self, value, timestamp): """Adds value at timestamp. Values must be added in order of increasing timestamp. Args: value: An observed value. timestamp: The timestamp at which value was observed. Raises: RuntimeError: If timestamp is smaller than the previous timstamp. ...
[ "def", "Append", "(", "self", ",", "value", ",", "timestamp", ")", ":", "timestamp", "=", "self", ".", "_NormalizeTime", "(", "timestamp", ")", "if", "self", ".", "data", "and", "timestamp", "<", "self", ".", "data", "[", "-", "1", "]", "[", "1", "...
Adds value at timestamp. Values must be added in order of increasing timestamp. Args: value: An observed value. timestamp: The timestamp at which value was observed. Raises: RuntimeError: If timestamp is smaller than the previous timstamp.
[ "Adds", "value", "at", "timestamp", "." ]
python
train
PmagPy/PmagPy
programs/eqarea.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/eqarea.py#L12-L92
def main(): """ NAME eqarea.py DESCRIPTION makes equal area projections from declination/inclination data INPUT FORMAT takes dec/inc as first two columns in space delimited file SYNTAX eqarea.py [options] OPTIONS -f FILE, specify file on command line ...
[ "def", "main", "(", ")", ":", "title", "=", "\"\"", "files", ",", "fmt", "=", "{", "}", ",", "'svg'", "sym", "=", "{", "'lower'", ":", "[", "'o'", ",", "'r'", "]", ",", "'upper'", ":", "[", "'o'", ",", "'w'", "]", "}", "plot", "=", "0", "if...
NAME eqarea.py DESCRIPTION makes equal area projections from declination/inclination data INPUT FORMAT takes dec/inc as first two columns in space delimited file SYNTAX eqarea.py [options] OPTIONS -f FILE, specify file on command line -sav save figure and ...
[ "NAME", "eqarea", ".", "py" ]
python
train
rgs1/zk_shell
zk_shell/shell.py
https://github.com/rgs1/zk_shell/blob/bbf34fdfcf1f81100e2a5816fad8af6afc782a54/zk_shell/shell.py#L2068-L2138
def do_json_set(self, params): """ \x1b[1mNAME\x1b[0m json_set - Sets the value for the given (possibly nested) key on a JSON object serialized in the given path \x1b[1mSYNOPSIS\x1b[0m json_set <path> <keys> <value> <value_type> [confirm] \x1b[1mDESCRIPTION\x1b[0m If the key exists and...
[ "def", "do_json_set", "(", "self", ",", "params", ")", ":", "try", ":", "Keys", ".", "validate", "(", "params", ".", "keys", ")", "except", "Keys", ".", "Bad", "as", "ex", ":", "self", ".", "show_output", "(", "str", "(", "ex", ")", ")", "return", ...
\x1b[1mNAME\x1b[0m json_set - Sets the value for the given (possibly nested) key on a JSON object serialized in the given path \x1b[1mSYNOPSIS\x1b[0m json_set <path> <keys> <value> <value_type> [confirm] \x1b[1mDESCRIPTION\x1b[0m If the key exists and the value is different, the znode will be ...
[ "\\", "x1b", "[", "1mNAME", "\\", "x1b", "[", "0m", "json_set", "-", "Sets", "the", "value", "for", "the", "given", "(", "possibly", "nested", ")", "key", "on", "a", "JSON", "object", "serialized", "in", "the", "given", "path" ]
python
train
yyuu/botornado
boto/rds/dbinstance.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/rds/dbinstance.py#L133-L152
def update(self, validate=False): """ Update the DB instance's status information by making a call to fetch the current instance attributes from the service. :type validate: bool :param validate: By default, if EC2 returns no data about the instance the ...
[ "def", "update", "(", "self", ",", "validate", "=", "False", ")", ":", "rs", "=", "self", ".", "connection", ".", "get_all_dbinstances", "(", "self", ".", "id", ")", "if", "len", "(", "rs", ")", ">", "0", ":", "for", "i", "in", "rs", ":", "if", ...
Update the DB instance's status information by making a call to fetch the current instance attributes from the service. :type validate: bool :param validate: By default, if EC2 returns no data about the instance the update method returns quietly. If ...
[ "Update", "the", "DB", "instance", "s", "status", "information", "by", "making", "a", "call", "to", "fetch", "the", "current", "instance", "attributes", "from", "the", "service", "." ]
python
train
softlayer/softlayer-python
SoftLayer/transports.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/transports.py#L45-L56
def get_session(user_agent): """Sets up urllib sessions""" client = requests.Session() client.headers.update({ 'Content-Type': 'application/json', 'User-Agent': user_agent, }) retry = Retry(connect=3, backoff_factor=3) adapter = HTTPAdapter(max_retries=retry) client.mount('h...
[ "def", "get_session", "(", "user_agent", ")", ":", "client", "=", "requests", ".", "Session", "(", ")", "client", ".", "headers", ".", "update", "(", "{", "'Content-Type'", ":", "'application/json'", ",", "'User-Agent'", ":", "user_agent", ",", "}", ")", "...
Sets up urllib sessions
[ "Sets", "up", "urllib", "sessions" ]
python
train
deepmipt/DeepPavlov
deeppavlov/utils/alexa/bot.py
https://github.com/deepmipt/DeepPavlov/blob/f3e4a69a3764d25d2f5bad4f1f1aebc872b00f9c/deeppavlov/utils/alexa/bot.py#L148-L194
def _handle_request(self, request: dict) -> dict: """Processes Alexa requests from skill server and returns responses to Alexa. Args: request: Dict with Alexa request payload and metadata. Returns: result: Alexa formatted or error response. """ request_bo...
[ "def", "_handle_request", "(", "self", ",", "request", ":", "dict", ")", "->", "dict", ":", "request_body", ":", "bytes", "=", "request", "[", "'request_body'", "]", "signature_chain_url", ":", "str", "=", "request", "[", "'signature_chain_url'", "]", "signatu...
Processes Alexa requests from skill server and returns responses to Alexa. Args: request: Dict with Alexa request payload and metadata. Returns: result: Alexa formatted or error response.
[ "Processes", "Alexa", "requests", "from", "skill", "server", "and", "returns", "responses", "to", "Alexa", "." ]
python
test
Crunch-io/crunch-cube
src/cr/cube/crunch_cube.py
https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/crunch_cube.py#L953-L969
def _cube_dict(self): """dict containing raw cube response, parsed from JSON payload.""" try: cube_response = self._cube_response_arg # ---parse JSON to a dict when constructed with JSON--- cube_dict = ( cube_response if isinstance(cube...
[ "def", "_cube_dict", "(", "self", ")", ":", "try", ":", "cube_response", "=", "self", ".", "_cube_response_arg", "# ---parse JSON to a dict when constructed with JSON---", "cube_dict", "=", "(", "cube_response", "if", "isinstance", "(", "cube_response", ",", "dict", "...
dict containing raw cube response, parsed from JSON payload.
[ "dict", "containing", "raw", "cube", "response", "parsed", "from", "JSON", "payload", "." ]
python
train
cloudendpoints/endpoints-management-python
endpoints_management/control/distribution.py
https://github.com/cloudendpoints/endpoints-management-python/blob/ec3c4a330ae9d65738861ce6df4dd6c3cb9f7731/endpoints_management/control/distribution.py#L242-L265
def _buckets_nearly_equal(a_dist, b_dist): """Determines whether two `Distributions` are nearly equal. Args: a_dist (:class:`Distribution`): an instance b_dist (:class:`Distribution`): another instance Return: boolean: `True` if the two instances are approximately equal, otherwise ...
[ "def", "_buckets_nearly_equal", "(", "a_dist", ",", "b_dist", ")", ":", "a_type", ",", "a_buckets", "=", "_detect_bucket_option", "(", "a_dist", ")", "b_type", ",", "b_buckets", "=", "_detect_bucket_option", "(", "b_dist", ")", "if", "a_type", "!=", "b_type", ...
Determines whether two `Distributions` are nearly equal. Args: a_dist (:class:`Distribution`): an instance b_dist (:class:`Distribution`): another instance Return: boolean: `True` if the two instances are approximately equal, otherwise False
[ "Determines", "whether", "two", "Distributions", "are", "nearly", "equal", "." ]
python
train
signaturit/python-sdk
signaturit_sdk/signaturit_client.py
https://github.com/signaturit/python-sdk/blob/2419c6d9675d901244f807ae360dc58aa46109a9/signaturit_sdk/signaturit_client.py#L74-L82
def get_signature(self, signature_id): """ Get a concrete Signature @return Signature data """ connection = Connection(self.token) connection.set_url(self.production, self.SIGNS_ID_URL % signature_id) return connection.get_request()
[ "def", "get_signature", "(", "self", ",", "signature_id", ")", ":", "connection", "=", "Connection", "(", "self", ".", "token", ")", "connection", ".", "set_url", "(", "self", ".", "production", ",", "self", ".", "SIGNS_ID_URL", "%", "signature_id", ")", "...
Get a concrete Signature @return Signature data
[ "Get", "a", "concrete", "Signature" ]
python
train
gitpython-developers/GitPython
git/refs/symbolic.py
https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/refs/symbolic.py#L428-L480
def delete(cls, repo, path): """Delete the reference at the given path :param repo: Repository to delete the reference from :param path: Short or full path pointing to the reference, i.e. refs/myreference or just "myreference", hence 'refs/' is implied. ...
[ "def", "delete", "(", "cls", ",", "repo", ",", "path", ")", ":", "full_ref_path", "=", "cls", ".", "to_full_path", "(", "path", ")", "abs_path", "=", "osp", ".", "join", "(", "repo", ".", "common_dir", ",", "full_ref_path", ")", "if", "osp", ".", "ex...
Delete the reference at the given path :param repo: Repository to delete the reference from :param path: Short or full path pointing to the reference, i.e. refs/myreference or just "myreference", hence 'refs/' is implied. Alternatively the symbolic refer...
[ "Delete", "the", "reference", "at", "the", "given", "path" ]
python
train
numenta/htmresearch
htmresearch/algorithms/union_temporal_pooler.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/algorithms/union_temporal_pooler.py#L283-L304
def _getMostActiveCells(self): """ Gets the most active cells in the Union SDR having at least non-zero activation in sorted order. @return: a list of cell indices """ poolingActivation = self._poolingActivation nonZeroCells = numpy.argwhere(poolingActivation > 0)[:,0] # include a tie-b...
[ "def", "_getMostActiveCells", "(", "self", ")", ":", "poolingActivation", "=", "self", ".", "_poolingActivation", "nonZeroCells", "=", "numpy", ".", "argwhere", "(", "poolingActivation", ">", "0", ")", "[", ":", ",", "0", "]", "# include a tie-breaker before sorti...
Gets the most active cells in the Union SDR having at least non-zero activation in sorted order. @return: a list of cell indices
[ "Gets", "the", "most", "active", "cells", "in", "the", "Union", "SDR", "having", "at", "least", "non", "-", "zero", "activation", "in", "sorted", "order", "." ]
python
train
jonDel/loggers
loggers/loggers.py
https://github.com/jonDel/loggers/blob/f03ff7231535c87bfa5b97fdab5ae201be503dbc/loggers/loggers.py#L85-L111
def set_log_level(self, log_level): '''Configures class log level Arguments: log_level (:obj:`str`): log level ('NOTSET','DEBUG','INFO' 'WARNING', 'ERROR', 'CRITICAL') ''' if log_level == 'DEBUG': self.log.setLevel(logging.DEBUG) self...
[ "def", "set_log_level", "(", "self", ",", "log_level", ")", ":", "if", "log_level", "==", "'DEBUG'", ":", "self", ".", "log", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "self", ".", "log", ".", "debug", "(", "\"Changing log level to \"", "+", "l...
Configures class log level Arguments: log_level (:obj:`str`): log level ('NOTSET','DEBUG','INFO' 'WARNING', 'ERROR', 'CRITICAL')
[ "Configures", "class", "log", "level" ]
python
train
dossier/dossier.models
dossier/models/query.py
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/query.py#L39-L64
def list_projects(folders, folder = None, user = None): '''List all folders or all subfolders of a folder. If folder is provided, this method will output a list of subfolders contained by it. Otherwise, a list of all top-level folders is produced. :param folders: reference to folder.Folders instance ...
[ "def", "list_projects", "(", "folders", ",", "folder", "=", "None", ",", "user", "=", "None", ")", ":", "fid", "=", "None", "if", "folder", "is", "None", "else", "Folders", ".", "name_to_id", "(", "folder", ")", "# List all folders if none provided.", "if", ...
List all folders or all subfolders of a folder. If folder is provided, this method will output a list of subfolders contained by it. Otherwise, a list of all top-level folders is produced. :param folders: reference to folder.Folders instance :param folder: folder name or None :param user: optiona...
[ "List", "all", "folders", "or", "all", "subfolders", "of", "a", "folder", "." ]
python
train
dslackw/slpkg
slpkg/config.py
https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/config.py#L79-L83
def edit(self): """Edit configuration file """ subprocess.call("{0} {1}".format(self.meta.editor, self.config_file), shell=True)
[ "def", "edit", "(", "self", ")", ":", "subprocess", ".", "call", "(", "\"{0} {1}\"", ".", "format", "(", "self", ".", "meta", ".", "editor", ",", "self", ".", "config_file", ")", ",", "shell", "=", "True", ")" ]
Edit configuration file
[ "Edit", "configuration", "file" ]
python
train
etcher-be/epab
epab/utils/_repo.py
https://github.com/etcher-be/epab/blob/024cde74d058281aa66e6e4b7b71dccbe803b1c1/epab/utils/_repo.py#L432-L445
def push(self, set_upstream: bool = True): """ Pushes all refs (branches and tags) to origin """ LOGGER.info('pushing repo to origin') try: self.repo.git.push() except GitCommandError as error: if 'has no upstream branch' in error.stderr and set_u...
[ "def", "push", "(", "self", ",", "set_upstream", ":", "bool", "=", "True", ")", ":", "LOGGER", ".", "info", "(", "'pushing repo to origin'", ")", "try", ":", "self", ".", "repo", ".", "git", ".", "push", "(", ")", "except", "GitCommandError", "as", "er...
Pushes all refs (branches and tags) to origin
[ "Pushes", "all", "refs", "(", "branches", "and", "tags", ")", "to", "origin" ]
python
train
aouyar/PyMunin
pysysinfo/process.py
https://github.com/aouyar/PyMunin/blob/4f58a64b6b37c85a84cc7e1e07aafaa0321b249d/pysysinfo/process.py#L200-L242
def getProcStatStatus(self, threads=False, **kwargs): """Return process counts per status and priority. @param **kwargs: Keyword variables are used for filtering the results depending on the values of the columns. Each keyword must correspond t...
[ "def", "getProcStatStatus", "(", "self", ",", "threads", "=", "False", ",", "*", "*", "kwargs", ")", ":", "procs", "=", "self", ".", "getProcList", "(", "[", "'stat'", ",", "]", ",", "threads", "=", "threads", ",", "*", "*", "kwargs", ")", "status", ...
Return process counts per status and priority. @param **kwargs: Keyword variables are used for filtering the results depending on the values of the columns. Each keyword must correspond to a field name with an optional suffix:...
[ "Return", "process", "counts", "per", "status", "and", "priority", "." ]
python
train
klmitch/turnstile
turnstile/limits.py
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/limits.py#L849-L972
def _filter(self, environ, params): """ Performs final filtering of the request to determine if this limit applies. Returns False if the limit does not apply or if the call should not be limited, or True to apply the limit. """ # Search for required query arguments ...
[ "def", "_filter", "(", "self", ",", "environ", ",", "params", ")", ":", "# Search for required query arguments", "if", "self", ".", "queries", ":", "# No query string available", "if", "'QUERY_STRING'", "not", "in", "environ", ":", "return", "False", "# Extract the ...
Performs final filtering of the request to determine if this limit applies. Returns False if the limit does not apply or if the call should not be limited, or True to apply the limit.
[ "Performs", "final", "filtering", "of", "the", "request", "to", "determine", "if", "this", "limit", "applies", ".", "Returns", "False", "if", "the", "limit", "does", "not", "apply", "or", "if", "the", "call", "should", "not", "be", "limited", "or", "True",...
python
train
saltstack/salt
salt/grains/core.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/core.py#L2115-L2146
def hostname(): ''' Return fqdn, hostname, domainname ''' # This is going to need some work # Provides: # fqdn # host # localhost # domain global __FQDN__ grains = {} if salt.utils.platform.is_proxy(): return grains grains['localhost'] = socket.getho...
[ "def", "hostname", "(", ")", ":", "# This is going to need some work", "# Provides:", "# fqdn", "# host", "# localhost", "# domain", "global", "__FQDN__", "grains", "=", "{", "}", "if", "salt", ".", "utils", ".", "platform", ".", "is_proxy", "(", ")", ":...
Return fqdn, hostname, domainname
[ "Return", "fqdn", "hostname", "domainname" ]
python
train
kata198/indexedredis
IndexedRedis/__init__.py
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/__init__.py#L854-L874
def copy(self, copyPrimaryKey=False, copyValues=False): ''' copy - Copies this object. @param copyPrimaryKey <bool> default False - If True, any changes to the copy will save over-top the existing entry in Redis. If False, only the data is copied, and n...
[ "def", "copy", "(", "self", ",", "copyPrimaryKey", "=", "False", ",", "copyValues", "=", "False", ")", ":", "cpy", "=", "self", ".", "__class__", "(", "*", "*", "self", ".", "asDict", "(", "copyPrimaryKey", ",", "forStorage", "=", "False", ")", ")", ...
copy - Copies this object. @param copyPrimaryKey <bool> default False - If True, any changes to the copy will save over-top the existing entry in Redis. If False, only the data is copied, and nothing is saved. @param copyValues <bool> default False - If True, every fi...
[ "copy", "-", "Copies", "this", "object", "." ]
python
valid
srevenant/onetimejwt
onetimejwt/__init__.py
https://github.com/srevenant/onetimejwt/blob/f3ed561253eb4a8e1522c64f59bf64d275e9d315/onetimejwt/__init__.py#L133-L138
def already_used(self, tok): """has this jwt been used?""" if tok in self.jwts: return True self.jwts[tok] = time.time() return False
[ "def", "already_used", "(", "self", ",", "tok", ")", ":", "if", "tok", "in", "self", ".", "jwts", ":", "return", "True", "self", ".", "jwts", "[", "tok", "]", "=", "time", ".", "time", "(", ")", "return", "False" ]
has this jwt been used?
[ "has", "this", "jwt", "been", "used?" ]
python
test
Kunstmord/datalib
src/dataset.py
https://github.com/Kunstmord/datalib/blob/9d7db3e7c3a5feeeb5d19eb0dbee858bd2b50886/src/dataset.py#L385-L405
def return_single_path_base(dbpath, set_object, object_id): """ Generic function which returns a path (path is relative to the path_to_set stored in the database) of an object specified by the object_id Parameters ---------- dbpath : string, path to SQLite database file set_object : object ...
[ "def", "return_single_path_base", "(", "dbpath", ",", "set_object", ",", "object_id", ")", ":", "engine", "=", "create_engine", "(", "'sqlite:////'", "+", "dbpath", ")", "session_cl", "=", "sessionmaker", "(", "bind", "=", "engine", ")", "session", "=", "sessi...
Generic function which returns a path (path is relative to the path_to_set stored in the database) of an object specified by the object_id Parameters ---------- dbpath : string, path to SQLite database file set_object : object (either TestSet or TrainSet) which is stored in the database object_...
[ "Generic", "function", "which", "returns", "a", "path", "(", "path", "is", "relative", "to", "the", "path_to_set", "stored", "in", "the", "database", ")", "of", "an", "object", "specified", "by", "the", "object_id" ]
python
train
brocade/pynos
pynos/versions/base/bgp.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/bgp.py#L763-L848
def update_source(self, **kwargs): """Set BGP update source property for a neighbor. This method currently only supports loopback interfaces. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be ...
[ "def", "update_source", "(", "self", ",", "*", "*", "kwargs", ")", ":", "callback", "=", "kwargs", ".", "pop", "(", "'callback'", ",", "self", ".", "_callback", ")", "ip_addr", "=", "ip_interface", "(", "unicode", "(", "kwargs", ".", "pop", "(", "'neig...
Set BGP update source property for a neighbor. This method currently only supports loopback interfaces. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. nei...
[ "Set", "BGP", "update", "source", "property", "for", "a", "neighbor", "." ]
python
train
PonteIneptique/collatinus-python
pycollatinus/lemmatiseur.py
https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemmatiseur.py#L189-L209
def _lemmatise_roman_numerals(self, form, pos=False, get_lemma_object=False): """ Lemmatise un mot f si c'est un nombre romain :param form: Mot à lemmatiser :param pos: Récupère la POS :param get_lemma_object: Retrieve Lemma object instead of string representation of lemma """ ...
[ "def", "_lemmatise_roman_numerals", "(", "self", ",", "form", ",", "pos", "=", "False", ",", "get_lemma_object", "=", "False", ")", ":", "if", "estRomain", "(", "form", ")", ":", "_lemma", "=", "Lemme", "(", "cle", "=", "form", ",", "graphie_accentuee", ...
Lemmatise un mot f si c'est un nombre romain :param form: Mot à lemmatiser :param pos: Récupère la POS :param get_lemma_object: Retrieve Lemma object instead of string representation of lemma
[ "Lemmatise", "un", "mot", "f", "si", "c", "est", "un", "nombre", "romain" ]
python
train
cloud-custodian/cloud-custodian
c7n/sqsexec.py
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/sqsexec.py#L56-L78
def submit(self, func, *args, **kwargs): """Submit a function for serialized execution on sqs """ self.op_sequence += 1 self.sqs.send_message( QueueUrl=self.map_queue, MessageBody=utils.dumps({'args': args, 'kwargs': kwargs}), MessageAttributes={ ...
[ "def", "submit", "(", "self", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "op_sequence", "+=", "1", "self", ".", "sqs", ".", "send_message", "(", "QueueUrl", "=", "self", ".", "map_queue", ",", "MessageBody", "=", ...
Submit a function for serialized execution on sqs
[ "Submit", "a", "function", "for", "serialized", "execution", "on", "sqs" ]
python
train
cloudbase/python-hnvclient
hnv/config/options.py
https://github.com/cloudbase/python-hnvclient/blob/b019452af01db22629809b8930357a2ebf6494be/hnv/config/options.py#L26-L34
def get_options(): """Collect all the options info from the other modules.""" options = collections.defaultdict(list) for opt_class in config_factory.get_options(): if not issubclass(opt_class, config_base.Options): continue config_options = opt_class(None) options[config...
[ "def", "get_options", "(", ")", ":", "options", "=", "collections", ".", "defaultdict", "(", "list", ")", "for", "opt_class", "in", "config_factory", ".", "get_options", "(", ")", ":", "if", "not", "issubclass", "(", "opt_class", ",", "config_base", ".", "...
Collect all the options info from the other modules.
[ "Collect", "all", "the", "options", "info", "from", "the", "other", "modules", "." ]
python
train
iotile/coretools
iotilecore/iotile/core/hw/reports/utc_assigner.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/reports/utc_assigner.py#L152-L159
def convert_rtc(cls, timestamp): """Convert a number of seconds since 1/1/2000 to UTC time.""" if timestamp & (1 << 31): timestamp &= ~(1 << 31) delta = datetime.timedelta(seconds=timestamp) return cls._Y2KReference + delta
[ "def", "convert_rtc", "(", "cls", ",", "timestamp", ")", ":", "if", "timestamp", "&", "(", "1", "<<", "31", ")", ":", "timestamp", "&=", "~", "(", "1", "<<", "31", ")", "delta", "=", "datetime", ".", "timedelta", "(", "seconds", "=", "timestamp", "...
Convert a number of seconds since 1/1/2000 to UTC time.
[ "Convert", "a", "number", "of", "seconds", "since", "1", "/", "1", "/", "2000", "to", "UTC", "time", "." ]
python
train
specialunderwear/django-easymode
easymode/i18n/gettext.py
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/gettext.py#L139-L162
def poify(self, model): """turn a django model into a po file.""" if not hasattr(model, 'localized_fields'): return None # create po stream with header po_stream = polibext.PoStream(StringIO.StringIO(self.po_header)).parse() for (name, field) in easymode.tree.intros...
[ "def", "poify", "(", "self", ",", "model", ")", ":", "if", "not", "hasattr", "(", "model", ",", "'localized_fields'", ")", ":", "return", "None", "# create po stream with header", "po_stream", "=", "polibext", ".", "PoStream", "(", "StringIO", ".", "StringIO",...
turn a django model into a po file.
[ "turn", "a", "django", "model", "into", "a", "po", "file", "." ]
python
train
litters/shrew
shrew/utils/auth.py
https://github.com/litters/shrew/blob/ed4b1879321d858d6bc884d14fea7557372a4d41/shrew/utils/auth.py#L133-L147
def unlock_keychain(username): """ If the user is running via SSH, their Keychain must be unlocked first. """ if 'SSH_TTY' not in os.environ: return # Don't unlock if we've already seen this user. if username in _unlocked: return _unlocked.add(username) if sys.platform == 'da...
[ "def", "unlock_keychain", "(", "username", ")", ":", "if", "'SSH_TTY'", "not", "in", "os", ".", "environ", ":", "return", "# Don't unlock if we've already seen this user.", "if", "username", "in", "_unlocked", ":", "return", "_unlocked", ".", "add", "(", "username...
If the user is running via SSH, their Keychain must be unlocked first.
[ "If", "the", "user", "is", "running", "via", "SSH", "their", "Keychain", "must", "be", "unlocked", "first", "." ]
python
train
pavlov99/json-rpc
jsonrpc/utils.py
https://github.com/pavlov99/json-rpc/blob/c6d0f0532575e6e4088f2994f8ad93bc4fc11ecb/jsonrpc/utils.py#L57-L82
def is_invalid_params_py2(func, *args, **kwargs): """ Check, whether function 'func' accepts parameters 'args', 'kwargs'. NOTE: Method is called after funct(*args, **kwargs) generated TypeError, it is aimed to destinguish TypeError because of invalid parameters from TypeError from inside the function. ...
[ "def", "is_invalid_params_py2", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "funcargs", ",", "varargs", ",", "varkwargs", ",", "defaults", "=", "inspect", ".", "getargspec", "(", "func", ")", "unexpected", "=", "set", "(", "kwargs",...
Check, whether function 'func' accepts parameters 'args', 'kwargs'. NOTE: Method is called after funct(*args, **kwargs) generated TypeError, it is aimed to destinguish TypeError because of invalid parameters from TypeError from inside the function. .. versionadded: 1.9.0
[ "Check", "whether", "function", "func", "accepts", "parameters", "args", "kwargs", "." ]
python
train
log2timeline/plaso
plaso/multi_processing/base_process.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/multi_processing/base_process.py#L271-L317
def run(self): """Runs the process.""" # Prevent the KeyboardInterrupt being raised inside the process. # This will prevent a process from generating a traceback when interrupted. signal.signal(signal.SIGINT, signal.SIG_IGN) # A SIGTERM signal handler is necessary to make sure IPC is cleaned up ...
[ "def", "run", "(", "self", ")", ":", "# Prevent the KeyboardInterrupt being raised inside the process.", "# This will prevent a process from generating a traceback when interrupted.", "signal", ".", "signal", "(", "signal", ".", "SIGINT", ",", "signal", ".", "SIG_IGN", ")", "...
Runs the process.
[ "Runs", "the", "process", "." ]
python
train
nir0s/ghost
ghost.py
https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1087-L1095
def delete(self, key_name): """Delete the key. :return: True if it was deleted, False otherwise """ self.client.delete_object( Bucket=self.db_path, Key=key_name) return self.get(key_name) == {}
[ "def", "delete", "(", "self", ",", "key_name", ")", ":", "self", ".", "client", ".", "delete_object", "(", "Bucket", "=", "self", ".", "db_path", ",", "Key", "=", "key_name", ")", "return", "self", ".", "get", "(", "key_name", ")", "==", "{", "}" ]
Delete the key. :return: True if it was deleted, False otherwise
[ "Delete", "the", "key", ".", ":", "return", ":", "True", "if", "it", "was", "deleted", "False", "otherwise" ]
python
valid
Robpol86/sphinxcontrib-versioning
sphinxcontrib/versioning/sphinx_.py
https://github.com/Robpol86/sphinxcontrib-versioning/blob/920edec0ac764081b583a2ecf4e6952762b9dbf2/sphinxcontrib/versioning/sphinx_.py#L47-L62
def builder_inited(app): """Update the Sphinx builder. :param sphinx.application.Sphinx app: Sphinx application object. """ # Add this extension's _templates directory to Sphinx. templates_dir = os.path.join(os.path.dirname(__file__), '_templates') app.builder.templates....
[ "def", "builder_inited", "(", "app", ")", ":", "# Add this extension's _templates directory to Sphinx.", "templates_dir", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'_templates'", ")", "app", ".", "...
Update the Sphinx builder. :param sphinx.application.Sphinx app: Sphinx application object.
[ "Update", "the", "Sphinx", "builder", "." ]
python
train
theosysbio/means
src/means/simulation/trajectory.py
https://github.com/theosysbio/means/blob/fe164916a1d84ab2a4fa039871d38ccdf638b1db/src/means/simulation/trajectory.py#L396-L407
def to_csv(self, file): """ Write all the trajectories of a collection to a csv file with the headers 'description', 'time' and 'value'. :param file: a file object to write to :type file: :class:`file` :return: """ file.write("description,time,value\n") f...
[ "def", "to_csv", "(", "self", ",", "file", ")", ":", "file", ".", "write", "(", "\"description,time,value\\n\"", ")", "for", "traj", "in", "self", ":", "for", "t", ",", "v", "in", "traj", ":", "file", ".", "write", "(", "\"%s,%f,%f\\n\"", "%", "(", "...
Write all the trajectories of a collection to a csv file with the headers 'description', 'time' and 'value'. :param file: a file object to write to :type file: :class:`file` :return:
[ "Write", "all", "the", "trajectories", "of", "a", "collection", "to", "a", "csv", "file", "with", "the", "headers", "description", "time", "and", "value", "." ]
python
train
jjjake/iamine
iamine/api.py
https://github.com/jjjake/iamine/blob/f1fc123a5b40b2247c537382368d38bd744eebe0/iamine/api.py#L59-L79
def mine_urls(urls, params=None, callback=None, **kwargs): """Concurrently retrieve URLs. :param urls: A set of URLs to concurrently retrieve. :type urls: iterable :param params: (optional) The URL parameters to send with each request. :type params: dict :param callback: (o...
[ "def", "mine_urls", "(", "urls", ",", "params", "=", "None", ",", "callback", "=", "None", ",", "*", "*", "kwargs", ")", ":", "miner", "=", "Miner", "(", "*", "*", "kwargs", ")", "try", ":", "miner", ".", "loop", ".", "add_signal_handler", "(", "si...
Concurrently retrieve URLs. :param urls: A set of URLs to concurrently retrieve. :type urls: iterable :param params: (optional) The URL parameters to send with each request. :type params: dict :param callback: (optional) A callback function to be called on each ...
[ "Concurrently", "retrieve", "URLs", "." ]
python
train
SpikeInterface/spikeextractors
spikeextractors/CurationSortingExtractor.py
https://github.com/SpikeInterface/spikeextractors/blob/cbe3b8778a215f0bbd743af8b306856a87e438e1/spikeextractors/CurationSortingExtractor.py#L153-L207
def split_unit(self, unit_id, indices): '''This function splits a root from the curation tree according to the given unit_id and indices. It creates two new unit_ids and roots that have the split root as a child. This function splits the spike train of the root by the given indices. Parameters ...
[ "def", "split_unit", "(", "self", ",", "unit_id", ",", "indices", ")", ":", "root_ids", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "self", ".", "_roots", ")", ")", ":", "root_id", "=", "self", ".", "_roots", "[", "i", "]", ".", ...
This function splits a root from the curation tree according to the given unit_id and indices. It creates two new unit_ids and roots that have the split root as a child. This function splits the spike train of the root by the given indices. Parameters ---------- unit_id: int ...
[ "This", "function", "splits", "a", "root", "from", "the", "curation", "tree", "according", "to", "the", "given", "unit_id", "and", "indices", ".", "It", "creates", "two", "new", "unit_ids", "and", "roots", "that", "have", "the", "split", "root", "as", "a",...
python
train
MediaFire/mediafire-python-open-sdk
mediafire/uploader.py
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/uploader.py#L367-L377
def _upload_none(self, upload_info, check_result): """Dummy upload function for when we don't actually upload""" return UploadResult( action=None, quickkey=check_result['duplicate_quickkey'], hash_=upload_info.hash_info.file, filename=upload_info.name, ...
[ "def", "_upload_none", "(", "self", ",", "upload_info", ",", "check_result", ")", ":", "return", "UploadResult", "(", "action", "=", "None", ",", "quickkey", "=", "check_result", "[", "'duplicate_quickkey'", "]", ",", "hash_", "=", "upload_info", ".", "hash_in...
Dummy upload function for when we don't actually upload
[ "Dummy", "upload", "function", "for", "when", "we", "don", "t", "actually", "upload" ]
python
train
ContextLab/hypertools
hypertools/_externals/srm.py
https://github.com/ContextLab/hypertools/blob/b76c7ac8061998b560e969ff8e4f4c915088e7a0/hypertools/_externals/srm.py#L319-L431
def _srm(self, data): """Expectation-Maximization algorithm for fitting the probabilistic SRM. Parameters ---------- data : list of 2D arrays, element i has shape=[voxels_i, samples] Each element in the list contains the fMRI data of one subject. Returns -...
[ "def", "_srm", "(", "self", ",", "data", ")", ":", "samples", "=", "data", "[", "0", "]", ".", "shape", "[", "1", "]", "subjects", "=", "len", "(", "data", ")", "np", ".", "random", ".", "seed", "(", "self", ".", "rand_seed", ")", "# Initializati...
Expectation-Maximization algorithm for fitting the probabilistic SRM. Parameters ---------- data : list of 2D arrays, element i has shape=[voxels_i, samples] Each element in the list contains the fMRI data of one subject. Returns ------- sigma_s : array, ...
[ "Expectation", "-", "Maximization", "algorithm", "for", "fitting", "the", "probabilistic", "SRM", "." ]
python
train
oceanprotocol/squid-py
squid_py/aquarius/aquarius.py
https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/aquarius/aquarius.py#L168-L200
def text_search(self, text, sort=None, offset=100, page=1): """ Search in aquarius using text query. Given the string aquarius will do a full-text query to search in all documents. Currently implemented are the MongoDB and Elastic Search drivers. For a detailed guide on how to...
[ "def", "text_search", "(", "self", ",", "text", ",", "sort", "=", "None", ",", "offset", "=", "100", ",", "page", "=", "1", ")", ":", "assert", "page", ">=", "1", ",", "f'Invalid page value {page}. Required page >= 1.'", "payload", "=", "{", "\"text\"", ":...
Search in aquarius using text query. Given the string aquarius will do a full-text query to search in all documents. Currently implemented are the MongoDB and Elastic Search drivers. For a detailed guide on how to search, see the MongoDB driver documentation: mongodb driverCurrently i...
[ "Search", "in", "aquarius", "using", "text", "query", "." ]
python
train
softlayer/softlayer-python
SoftLayer/CLI/user/create.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/user/create.py#L91-L100
def generate_password(): """Returns a 23 character random string, with 3 special characters at the end""" if sys.version_info > (3, 6): import secrets # pylint: disable=import-error alphabet = string.ascii_letters + string.digits password = ''.join(secrets.choice(alphabet) for i in rang...
[ "def", "generate_password", "(", ")", ":", "if", "sys", ".", "version_info", ">", "(", "3", ",", "6", ")", ":", "import", "secrets", "# pylint: disable=import-error", "alphabet", "=", "string", ".", "ascii_letters", "+", "string", ".", "digits", "password", ...
Returns a 23 character random string, with 3 special characters at the end
[ "Returns", "a", "23", "character", "random", "string", "with", "3", "special", "characters", "at", "the", "end" ]
python
train
RRZE-HPC/kerncraft
kerncraft/models/benchmark.py
https://github.com/RRZE-HPC/kerncraft/blob/c60baf8043e4da8d8d66da7575021c2f4c6c78af/kerncraft/models/benchmark.py#L279-L341
def perfctr(self, cmd, group='MEM', code_markers=True): """ Run *cmd* with likwid-perfctr and returns result as dict. *group* may be a performance group known to likwid-perfctr or an event string. if CLI argument cores > 1, running with multi-core, otherwise single-core """ ...
[ "def", "perfctr", "(", "self", ",", "cmd", ",", "group", "=", "'MEM'", ",", "code_markers", "=", "True", ")", ":", "# Making sure likwid-perfctr is available:", "if", "find_executable", "(", "'likwid-perfctr'", ")", "is", "None", ":", "print", "(", "\"likwid-per...
Run *cmd* with likwid-perfctr and returns result as dict. *group* may be a performance group known to likwid-perfctr or an event string. if CLI argument cores > 1, running with multi-core, otherwise single-core
[ "Run", "*", "cmd", "*", "with", "likwid", "-", "perfctr", "and", "returns", "result", "as", "dict", "." ]
python
test
flatangle/flatlib
flatlib/aspects.py
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/aspects.py#L298-L315
def getRole(self, ID): """ Returns the role (active or passive) of an object in this aspect. """ if self.active.id == ID: return { 'role': 'active', 'inOrb': self.active.inOrb, 'movement': self.active.movement ...
[ "def", "getRole", "(", "self", ",", "ID", ")", ":", "if", "self", ".", "active", ".", "id", "==", "ID", ":", "return", "{", "'role'", ":", "'active'", ",", "'inOrb'", ":", "self", ".", "active", ".", "inOrb", ",", "'movement'", ":", "self", ".", ...
Returns the role (active or passive) of an object in this aspect.
[ "Returns", "the", "role", "(", "active", "or", "passive", ")", "of", "an", "object", "in", "this", "aspect", "." ]
python
train
alimanfoo/csvvalidator
csvvalidator.py
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L1049-L1100
def write_problems(problems, file, summarize=False, limit=0): """ Write problems as restructured text to a file (or stdout/stderr). """ w = file.write # convenience variable w(""" ================= Validation Report ================= """) counts = dict() # store problem counts per problem code ...
[ "def", "write_problems", "(", "problems", ",", "file", ",", "summarize", "=", "False", ",", "limit", "=", "0", ")", ":", "w", "=", "file", ".", "write", "# convenience variable", "w", "(", "\"\"\"\n=================\nValidation Report\n=================\n\"\"\"", ")...
Write problems as restructured text to a file (or stdout/stderr).
[ "Write", "problems", "as", "restructured", "text", "to", "a", "file", "(", "or", "stdout", "/", "stderr", ")", "." ]
python
valid
Spinmob/spinmob
_data.py
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_data.py#L1842-L1961
def set_data(self, xdata=[1,2,3,4,5], ydata=[1.7,2,3,4,3], eydata=None, **kwargs): """ This will handle the different types of supplied data and put everything in a standard format for processing. Parameters ---------- xdata, ydata These can be a single a...
[ "def", "set_data", "(", "self", ",", "xdata", "=", "[", "1", ",", "2", ",", "3", ",", "4", ",", "5", "]", ",", "ydata", "=", "[", "1.7", ",", "2", ",", "3", ",", "4", ",", "3", "]", ",", "eydata", "=", "None", ",", "*", "*", "kwargs", "...
This will handle the different types of supplied data and put everything in a standard format for processing. Parameters ---------- xdata, ydata These can be a single array of data or a list of data arrays. eydata=None Error bars for ydata. Thes...
[ "This", "will", "handle", "the", "different", "types", "of", "supplied", "data", "and", "put", "everything", "in", "a", "standard", "format", "for", "processing", "." ]
python
train
tensorflow/probability
tensorflow_probability/examples/latent_dirichlet_allocation_edward2.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/examples/latent_dirichlet_allocation_edward2.py#L460-L478
def build_fake_input_fns(batch_size): """Builds fake data for unit testing.""" num_words = 1000 vocabulary = [str(i) for i in range(num_words)] random_sample = np.random.randint( 10, size=(batch_size, num_words)).astype(np.float32) def train_input_fn(): dataset = tf.data.Dataset.from_tensor_slices...
[ "def", "build_fake_input_fns", "(", "batch_size", ")", ":", "num_words", "=", "1000", "vocabulary", "=", "[", "str", "(", "i", ")", "for", "i", "in", "range", "(", "num_words", ")", "]", "random_sample", "=", "np", ".", "random", ".", "randint", "(", "...
Builds fake data for unit testing.
[ "Builds", "fake", "data", "for", "unit", "testing", "." ]
python
test
pdkit/pdkit
pdkit/gait_processor.py
https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/gait_processor.py#L541-L571
def separate_into_sections(self, data_frame, labels_col='anno', labels_to_keep=[1,2], min_labels_in_sequence=100): """ Helper function to separate a time series into multiple sections based on a labeled column. :param data_frame: The data frame. It should have x, y, and z columns. ...
[ "def", "separate_into_sections", "(", "self", ",", "data_frame", ",", "labels_col", "=", "'anno'", ",", "labels_to_keep", "=", "[", "1", ",", "2", "]", ",", "min_labels_in_sequence", "=", "100", ")", ":", "sections", "=", "[", "[", "]", "]", "mask", "=",...
Helper function to separate a time series into multiple sections based on a labeled column. :param data_frame: The data frame. It should have x, y, and z columns. :type data_frame: pandas.DataFrame :param labels_col: The column which has the labels we would like to separate ...
[ "Helper", "function", "to", "separate", "a", "time", "series", "into", "multiple", "sections", "based", "on", "a", "labeled", "column", ".", ":", "param", "data_frame", ":", "The", "data", "frame", ".", "It", "should", "have", "x", "y", "and", "z", "colu...
python
train
QInfer/python-qinfer
src/qinfer/tomography/legacy.py
https://github.com/QInfer/python-qinfer/blob/8170c84a0be1723f8c6b09e0d3c7a40a886f1fe3/src/qinfer/tomography/legacy.py#L317-L341
def likelihood(self, outcomes, modelparams, expparams): """ Calculates the likelihood function at the states specified by modelparams and measurement specified by expparams. This is given by the Born rule and is the probability of outcomes given the state and measurement operato...
[ "def", "likelihood", "(", "self", ",", "outcomes", ",", "modelparams", ",", "expparams", ")", ":", "# By calling the superclass implementation, we can consolidate", "# call counting there.", "super", "(", "MultiQubitStatePauliModel", ",", "self", ")", ".", "likelihood", "...
Calculates the likelihood function at the states specified by modelparams and measurement specified by expparams. This is given by the Born rule and is the probability of outcomes given the state and measurement operator.
[ "Calculates", "the", "likelihood", "function", "at", "the", "states", "specified", "by", "modelparams", "and", "measurement", "specified", "by", "expparams", ".", "This", "is", "given", "by", "the", "Born", "rule", "and", "is", "the", "probability", "of", "out...
python
train
juju/charm-helpers
charmhelpers/contrib/unison/__init__.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/unison/__init__.py#L266-L289
def sync_path_to_host(path, host, user, verbose=False, cmd=None, gid=None, fatal=False): """Sync path to an specific peer host Propagates exception if operation fails and fatal=True. """ cmd = cmd or copy(BASE_CMD) if not verbose: cmd.append('-silent') # removing ...
[ "def", "sync_path_to_host", "(", "path", ",", "host", ",", "user", ",", "verbose", "=", "False", ",", "cmd", "=", "None", ",", "gid", "=", "None", ",", "fatal", "=", "False", ")", ":", "cmd", "=", "cmd", "or", "copy", "(", "BASE_CMD", ")", "if", ...
Sync path to an specific peer host Propagates exception if operation fails and fatal=True.
[ "Sync", "path", "to", "an", "specific", "peer", "host" ]
python
train
inasafe/inasafe
safe/gui/tools/shake_grid/shakemap_converter_dialog.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/shake_grid/shakemap_converter_dialog.py#L322-L332
def on_open_output_tool_clicked(self): """Autoconnect slot activated when open output tool button is clicked. """ output_path = self.output_path.text() if not output_path: output_path = os.path.expanduser('~') # noinspection PyCallByClass,PyTypeChecker filenam...
[ "def", "on_open_output_tool_clicked", "(", "self", ")", ":", "output_path", "=", "self", ".", "output_path", ".", "text", "(", ")", "if", "not", "output_path", ":", "output_path", "=", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", "# noinspection Py...
Autoconnect slot activated when open output tool button is clicked.
[ "Autoconnect", "slot", "activated", "when", "open", "output", "tool", "button", "is", "clicked", "." ]
python
train
zakdoek/django-simple-resizer
simple_resizer/__init__.py
https://github.com/zakdoek/django-simple-resizer/blob/5614eb1717948c65d179c3d1567439a8c90a4d44/simple_resizer/__init__.py#L25-L45
def _normalize_params(image, width, height, crop): """ Normalize params and calculate aspect. """ if width is None and height is None: raise ValueError("Either width or height must be set. Otherwise " "resizing is useless.") if width is None or height is None: ...
[ "def", "_normalize_params", "(", "image", ",", "width", ",", "height", ",", "crop", ")", ":", "if", "width", "is", "None", "and", "height", "is", "None", ":", "raise", "ValueError", "(", "\"Either width or height must be set. Otherwise \"", "\"resizing is useless.\"...
Normalize params and calculate aspect.
[ "Normalize", "params", "and", "calculate", "aspect", "." ]
python
train
spantaleev/sftpman
sftpman/cli.py
https://github.com/spantaleev/sftpman/blob/e4fc3e3e3af975937469e0b8944ba62c01b12a47/sftpman/cli.py#L14-L21
def command_help(self, *args, **kwargs): """Displays this help menu.""" print("Commands available:\n") for name in dir(self): if not name.startswith("command_"): continue name_clean = name[len("command_"):] print("%s:\n - %s\n" % (name_clean, g...
[ "def", "command_help", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "print", "(", "\"Commands available:\\n\"", ")", "for", "name", "in", "dir", "(", "self", ")", ":", "if", "not", "name", ".", "startswith", "(", "\"command_\"", ")...
Displays this help menu.
[ "Displays", "this", "help", "menu", "." ]
python
train
bcbio/bcbio-nextgen
bcbio/variation/genotype.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/genotype.py#L212-L236
def vc_output_record(samples): """Prepare output record from variant calling to feed into downstream analysis. Prep work handles reformatting so we return generated dictionaries. For any shared keys that are calculated only once for a batch, like variant calls for the batch, we assign to every sample....
[ "def", "vc_output_record", "(", "samples", ")", ":", "shared_keys", "=", "[", "[", "\"vrn_file\"", "]", ",", "[", "\"validate\"", ",", "\"summary\"", "]", ",", "[", "\"validate\"", ",", "\"tp\"", "]", ",", "[", "\"validate\"", ",", "\"fp\"", "]", ",", "[...
Prepare output record from variant calling to feed into downstream analysis. Prep work handles reformatting so we return generated dictionaries. For any shared keys that are calculated only once for a batch, like variant calls for the batch, we assign to every sample.
[ "Prepare", "output", "record", "from", "variant", "calling", "to", "feed", "into", "downstream", "analysis", "." ]
python
train
GNS3/gns3-server
gns3server/controller/node.py
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/node.py#L389-L416
def parse_node_response(self, response): """ Update the object with the remote node object """ for key, value in response.items(): if key == "console": self._console = value elif key == "node_directory": self._node_directory = value...
[ "def", "parse_node_response", "(", "self", ",", "response", ")", ":", "for", "key", ",", "value", "in", "response", ".", "items", "(", ")", ":", "if", "key", "==", "\"console\"", ":", "self", ".", "_console", "=", "value", "elif", "key", "==", "\"node_...
Update the object with the remote node object
[ "Update", "the", "object", "with", "the", "remote", "node", "object" ]
python
train
kmmbvnr/django-any
django_any/forms.py
https://github.com/kmmbvnr/django-any/blob/6f64ebd05476e2149e2e71deeefbb10f8edfc412/django_any/forms.py#L168-L179
def datetime_field_data(field, **kwargs): """ Return random value for DateTimeField >>> result = any_form_field(forms.DateTimeField()) >>> type(result) <type 'str'> """ from_date = kwargs.get('from_date', datetime(1990, 1, 1)) to_date = kwargs.get('to_date', datetime.today()) date_f...
[ "def", "datetime_field_data", "(", "field", ",", "*", "*", "kwargs", ")", ":", "from_date", "=", "kwargs", ".", "get", "(", "'from_date'", ",", "datetime", "(", "1990", ",", "1", ",", "1", ")", ")", "to_date", "=", "kwargs", ".", "get", "(", "'to_dat...
Return random value for DateTimeField >>> result = any_form_field(forms.DateTimeField()) >>> type(result) <type 'str'>
[ "Return", "random", "value", "for", "DateTimeField" ]
python
test
odlgroup/odl
odl/space/npy_tensors.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/space/npy_tensors.py#L442-L453
def zero(self): """Return a tensor of all zeros. Examples -------- >>> space = odl.rn(3) >>> x = space.zero() >>> x rn(3).element([ 0., 0., 0.]) """ return self.element(np.zeros(self.shape, dtype=self.dtype, ...
[ "def", "zero", "(", "self", ")", ":", "return", "self", ".", "element", "(", "np", ".", "zeros", "(", "self", ".", "shape", ",", "dtype", "=", "self", ".", "dtype", ",", "order", "=", "self", ".", "default_order", ")", ")" ]
Return a tensor of all zeros. Examples -------- >>> space = odl.rn(3) >>> x = space.zero() >>> x rn(3).element([ 0., 0., 0.])
[ "Return", "a", "tensor", "of", "all", "zeros", "." ]
python
train
mitsei/dlkit
dlkit/services/grading.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/grading.py#L1887-L1895
def use_comparative_gradebook_column_view(self): """Pass through to provider GradebookColumnLookupSession.use_comparative_gradebook_column_view""" self._object_views['gradebook_column'] = COMPARATIVE # self._get_provider_session('gradebook_column_lookup_session') # To make sure the session is tr...
[ "def", "use_comparative_gradebook_column_view", "(", "self", ")", ":", "self", ".", "_object_views", "[", "'gradebook_column'", "]", "=", "COMPARATIVE", "# self._get_provider_session('gradebook_column_lookup_session') # To make sure the session is tracked", "for", "session", "in", ...
Pass through to provider GradebookColumnLookupSession.use_comparative_gradebook_column_view
[ "Pass", "through", "to", "provider", "GradebookColumnLookupSession", ".", "use_comparative_gradebook_column_view" ]
python
train