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
bcbio/bcbio-nextgen
bcbio/pipeline/datadict.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/datadict.py#L351-L365
def update_summary_qc(data, key, base=None, secondary=None): """ updates summary_qc with a new section, keyed by key. stick files into summary_qc if you want them propagated forward and available for multiqc """ summary = get_summary_qc(data, {}) if base and secondary: summary[key] =...
[ "def", "update_summary_qc", "(", "data", ",", "key", ",", "base", "=", "None", ",", "secondary", "=", "None", ")", ":", "summary", "=", "get_summary_qc", "(", "data", ",", "{", "}", ")", "if", "base", "and", "secondary", ":", "summary", "[", "key", "...
updates summary_qc with a new section, keyed by key. stick files into summary_qc if you want them propagated forward and available for multiqc
[ "updates", "summary_qc", "with", "a", "new", "section", "keyed", "by", "key", ".", "stick", "files", "into", "summary_qc", "if", "you", "want", "them", "propagated", "forward", "and", "available", "for", "multiqc" ]
python
train
theislab/scanpy
scanpy/plotting/_utils.py
https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/plotting/_utils.py#L635-L640
def scale_to_zero_one(x): """Take some 1d data and scale it so that min matches 0 and max 1. """ xscaled = x - np.min(x) xscaled /= np.max(xscaled) return xscaled
[ "def", "scale_to_zero_one", "(", "x", ")", ":", "xscaled", "=", "x", "-", "np", ".", "min", "(", "x", ")", "xscaled", "/=", "np", ".", "max", "(", "xscaled", ")", "return", "xscaled" ]
Take some 1d data and scale it so that min matches 0 and max 1.
[ "Take", "some", "1d", "data", "and", "scale", "it", "so", "that", "min", "matches", "0", "and", "max", "1", "." ]
python
train
pypa/pipenv
pipenv/vendor/pyparsing.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pyparsing.py#L6161-L6183
def convertToDatetime(fmt="%Y-%m-%dT%H:%M:%S.%f"): """Helper to create a parse action for converting parsed datetime string to Python datetime.datetime Params - - fmt - format to be passed to datetime.strptime (default= ``"%Y-%m-%dT%H:%M:%S.%f"``) Example:: dt_exp...
[ "def", "convertToDatetime", "(", "fmt", "=", "\"%Y-%m-%dT%H:%M:%S.%f\"", ")", ":", "def", "cvt_fn", "(", "s", ",", "l", ",", "t", ")", ":", "try", ":", "return", "datetime", ".", "strptime", "(", "t", "[", "0", "]", ",", "fmt", ")", "except", "ValueE...
Helper to create a parse action for converting parsed datetime string to Python datetime.datetime Params - - fmt - format to be passed to datetime.strptime (default= ``"%Y-%m-%dT%H:%M:%S.%f"``) Example:: dt_expr = pyparsing_common.iso8601_datetime.copy() dt_ex...
[ "Helper", "to", "create", "a", "parse", "action", "for", "converting", "parsed", "datetime", "string", "to", "Python", "datetime", ".", "datetime" ]
python
train
aouyar/PyMunin
pysysinfo/system.py
https://github.com/aouyar/PyMunin/blob/4f58a64b6b37c85a84cc7e1e07aafaa0321b249d/pysysinfo/system.py#L164-L181
def getVMstats(self): """Return stats for Virtual Memory Subsystem. @return: Dictionary of stats. """ info_dict = {} try: fp = open(vmstatFile, 'r') data = fp.read() fp.close() except: raise IOError('Failed...
[ "def", "getVMstats", "(", "self", ")", ":", "info_dict", "=", "{", "}", "try", ":", "fp", "=", "open", "(", "vmstatFile", ",", "'r'", ")", "data", "=", "fp", ".", "read", "(", ")", "fp", ".", "close", "(", ")", "except", ":", "raise", "IOError", ...
Return stats for Virtual Memory Subsystem. @return: Dictionary of stats.
[ "Return", "stats", "for", "Virtual", "Memory", "Subsystem", "." ]
python
train
priestc/moneywagon
moneywagon/bip38.py
https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/bip38.py#L50-L59
def uncompress(payload): """ Given a compressed ec key in bytes, uncompress it using math and return (x, y) """ payload = hexlify(payload) even = payload[:2] == b"02" x = int(payload[2:], 16) beta = pow(int(x ** 3 + A * x + B), int((P + 1) // 4), int(P)) y = (P-beta) if even else beta ...
[ "def", "uncompress", "(", "payload", ")", ":", "payload", "=", "hexlify", "(", "payload", ")", "even", "=", "payload", "[", ":", "2", "]", "==", "b\"02\"", "x", "=", "int", "(", "payload", "[", "2", ":", "]", ",", "16", ")", "beta", "=", "pow", ...
Given a compressed ec key in bytes, uncompress it using math and return (x, y)
[ "Given", "a", "compressed", "ec", "key", "in", "bytes", "uncompress", "it", "using", "math", "and", "return", "(", "x", "y", ")" ]
python
train
genialis/resolwe
resolwe/elastic/builder.py
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L397-L416
def _connect_signal(self, index): """Create signals for building indexes.""" post_save_signal = ElasticSignal(index, 'build') post_save_signal.connect(post_save, sender=index.object_type) self.signals.append(post_save_signal) post_delete_signal = ElasticSignal(index, 'remove_obj...
[ "def", "_connect_signal", "(", "self", ",", "index", ")", ":", "post_save_signal", "=", "ElasticSignal", "(", "index", ",", "'build'", ")", "post_save_signal", ".", "connect", "(", "post_save", ",", "sender", "=", "index", ".", "object_type", ")", "self", "....
Create signals for building indexes.
[ "Create", "signals", "for", "building", "indexes", "." ]
python
train
SBRG/ssbio
ssbio/pipeline/atlas2.py
https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas2.py#L312-L334
def _write_strain_functional_genes(self, strain_id, ref_functional_genes, orth_matrix, force_rerun=False): """Create strain functional genes json file""" func_genes_path = op.join(self.model_dir, '{}_funcgenes.json'.format(strain_id)) if ssbio.utils.force_rerun(flag=force_rerun, outfile=func_ge...
[ "def", "_write_strain_functional_genes", "(", "self", ",", "strain_id", ",", "ref_functional_genes", ",", "orth_matrix", ",", "force_rerun", "=", "False", ")", ":", "func_genes_path", "=", "op", ".", "join", "(", "self", ".", "model_dir", ",", "'{}_funcgenes.json'...
Create strain functional genes json file
[ "Create", "strain", "functional", "genes", "json", "file" ]
python
train
PyCQA/pydocstyle
src/pydocstyle/checker.py
https://github.com/PyCQA/pydocstyle/blob/2549847f9efad225789f931e83dfe782418ca13e/src/pydocstyle/checker.py#L339-L348
def check_ends_with_period(self, definition, docstring): """D400: First line should end with a period. The [first line of a] docstring is a phrase ending in a period. """ if docstring: summary_line = ast.literal_eval(docstring).strip().split('\n')[0] if not summ...
[ "def", "check_ends_with_period", "(", "self", ",", "definition", ",", "docstring", ")", ":", "if", "docstring", ":", "summary_line", "=", "ast", ".", "literal_eval", "(", "docstring", ")", ".", "strip", "(", ")", ".", "split", "(", "'\\n'", ")", "[", "0"...
D400: First line should end with a period. The [first line of a] docstring is a phrase ending in a period.
[ "D400", ":", "First", "line", "should", "end", "with", "a", "period", "." ]
python
train
JnyJny/Geometry
Geometry/triangle.py
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L560-L571
def altitudes(self): ''' A list of the altitudes of each vertex [AltA, AltB, AltC], list of floats. An altitude is the shortest distance from a vertex to the side opposite of it. ''' a = self.area * 2 return [a / self.a, a / self.b, a / self.c]
[ "def", "altitudes", "(", "self", ")", ":", "a", "=", "self", ".", "area", "*", "2", "return", "[", "a", "/", "self", ".", "a", ",", "a", "/", "self", ".", "b", ",", "a", "/", "self", ".", "c", "]" ]
A list of the altitudes of each vertex [AltA, AltB, AltC], list of floats. An altitude is the shortest distance from a vertex to the side opposite of it.
[ "A", "list", "of", "the", "altitudes", "of", "each", "vertex", "[", "AltA", "AltB", "AltC", "]", "list", "of", "floats", "." ]
python
train
dims/etcd3-gateway
etcd3gw/client.py
https://github.com/dims/etcd3-gateway/blob/ad566c29cbde135aee20cfd32e0a4815ca3b5ee6/etcd3gw/client.py#L369-L373
def watch_prefix(self, key_prefix, **kwargs): """The same as ``watch``, but watches a range of keys with a prefix.""" kwargs['range_end'] = \ _increment_last_byte(key_prefix) return self.watch(key_prefix, **kwargs)
[ "def", "watch_prefix", "(", "self", ",", "key_prefix", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'range_end'", "]", "=", "_increment_last_byte", "(", "key_prefix", ")", "return", "self", ".", "watch", "(", "key_prefix", ",", "*", "*", "kwargs", ...
The same as ``watch``, but watches a range of keys with a prefix.
[ "The", "same", "as", "watch", "but", "watches", "a", "range", "of", "keys", "with", "a", "prefix", "." ]
python
train
tensorflow/tensorboard
tensorboard/util/tensor_util.py
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/util/tensor_util.py#L134-L141
def _GetDenseDimensions(list_of_lists): """Returns the inferred dense dimensions of a list of lists.""" if not isinstance(list_of_lists, (list, tuple)): return [] elif not list_of_lists: return [0] else: return [len(list_of_lists)] + _GetDenseDimensions(list_of_lists[0])
[ "def", "_GetDenseDimensions", "(", "list_of_lists", ")", ":", "if", "not", "isinstance", "(", "list_of_lists", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "[", "]", "elif", "not", "list_of_lists", ":", "return", "[", "0", "]", "else", ":", ...
Returns the inferred dense dimensions of a list of lists.
[ "Returns", "the", "inferred", "dense", "dimensions", "of", "a", "list", "of", "lists", "." ]
python
train
sanger-pathogens/pymummer
pymummer/alignment.py
https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L52-L58
def _swap(self): '''Swaps the alignment so that the reference becomes the query and vice-versa. Swaps their names, coordinates etc. The frame is not changed''' self.ref_start, self.qry_start = self.qry_start, self.ref_start self.ref_end, self.qry_end = self.qry_end, self.ref_end self.hit...
[ "def", "_swap", "(", "self", ")", ":", "self", ".", "ref_start", ",", "self", ".", "qry_start", "=", "self", ".", "qry_start", ",", "self", ".", "ref_start", "self", ".", "ref_end", ",", "self", ".", "qry_end", "=", "self", ".", "qry_end", ",", "self...
Swaps the alignment so that the reference becomes the query and vice-versa. Swaps their names, coordinates etc. The frame is not changed
[ "Swaps", "the", "alignment", "so", "that", "the", "reference", "becomes", "the", "query", "and", "vice", "-", "versa", ".", "Swaps", "their", "names", "coordinates", "etc", ".", "The", "frame", "is", "not", "changed" ]
python
train
ayust/kitnirc
kitnirc/client.py
https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L529-L544
def handle(self, event): """Decorator for adding a handler function for a particular event. Usage: my_client = Client() @my_client.handle("WELCOME") def welcome_handler(client, *params): # Do something with the event. pass ""...
[ "def", "handle", "(", "self", ",", "event", ")", ":", "def", "dec", "(", "func", ")", ":", "self", ".", "add_handler", "(", "event", ",", "func", ")", "return", "func", "return", "dec" ]
Decorator for adding a handler function for a particular event. Usage: my_client = Client() @my_client.handle("WELCOME") def welcome_handler(client, *params): # Do something with the event. pass
[ "Decorator", "for", "adding", "a", "handler", "function", "for", "a", "particular", "event", "." ]
python
train
saltstack/salt
salt/modules/systemd_service.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/systemd_service.py#L272-L291
def _get_service_exec(): ''' Returns the path to the sysv service manager (either update-rc.d or chkconfig) ''' contextkey = 'systemd._get_service_exec' if contextkey not in __context__: executables = ('update-rc.d', 'chkconfig') for executable in executables: service...
[ "def", "_get_service_exec", "(", ")", ":", "contextkey", "=", "'systemd._get_service_exec'", "if", "contextkey", "not", "in", "__context__", ":", "executables", "=", "(", "'update-rc.d'", ",", "'chkconfig'", ")", "for", "executable", "in", "executables", ":", "ser...
Returns the path to the sysv service manager (either update-rc.d or chkconfig)
[ "Returns", "the", "path", "to", "the", "sysv", "service", "manager", "(", "either", "update", "-", "rc", ".", "d", "or", "chkconfig", ")" ]
python
train
costastf/toonlib
toonlib/toonlib.py
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/toonlib/toonlib.py#L162-L188
def _state(self): """The internal state of the object. The api responses are not consistent so a retry is performed on every call with information updating the internally saved state refreshing the data. The info is cached for STATE_CACHING_SECONDS. :return: The current state o...
[ "def", "_state", "(", "self", ")", ":", "state", "=", "{", "}", "required_keys", "=", "(", "'deviceStatusInfo'", ",", "'gasUsage'", ",", "'powerUsage'", ",", "'thermostatInfo'", ",", "'thermostatStates'", ")", "try", ":", "for", "_", "in", "range", "(", "s...
The internal state of the object. The api responses are not consistent so a retry is performed on every call with information updating the internally saved state refreshing the data. The info is cached for STATE_CACHING_SECONDS. :return: The current state of the toons' information stat...
[ "The", "internal", "state", "of", "the", "object", "." ]
python
train
sorgerlab/indra
indra/databases/lincs_client.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/lincs_client.py#L82-L106
def get_protein_refs(self, hms_lincs_id): """Get the refs for a protein from the LINCs protein metadata. Parameters ---------- hms_lincs_id : str The HMS LINCS ID for the protein Returns ------- dict A dictionary of protein references. ...
[ "def", "get_protein_refs", "(", "self", ",", "hms_lincs_id", ")", ":", "# TODO: We could get phosphorylation states from the protein data.", "refs", "=", "{", "'HMS-LINCS'", ":", "hms_lincs_id", "}", "entry", "=", "self", ".", "_get_entry_by_id", "(", "self", ".", "_p...
Get the refs for a protein from the LINCs protein metadata. Parameters ---------- hms_lincs_id : str The HMS LINCS ID for the protein Returns ------- dict A dictionary of protein references.
[ "Get", "the", "refs", "for", "a", "protein", "from", "the", "LINCs", "protein", "metadata", "." ]
python
train
thecynic/pylutron
pylutron/__init__.py
https://github.com/thecynic/pylutron/blob/4d9222c96ef7ac7ac458031c058ad93ec31cebbf/pylutron/__init__.py#L346-L353
def register_id(self, cmd_type, obj): """Registers an object (through its integration id) to receive update notifications. This is the core mechanism how Output and Keypad objects get notified when the controller sends status updates.""" ids = self._ids.setdefault(cmd_type, {}) if obj.id in ids: ...
[ "def", "register_id", "(", "self", ",", "cmd_type", ",", "obj", ")", ":", "ids", "=", "self", ".", "_ids", ".", "setdefault", "(", "cmd_type", ",", "{", "}", ")", "if", "obj", ".", "id", "in", "ids", ":", "raise", "IntegrationIdExistsError", "self", ...
Registers an object (through its integration id) to receive update notifications. This is the core mechanism how Output and Keypad objects get notified when the controller sends status updates.
[ "Registers", "an", "object", "(", "through", "its", "integration", "id", ")", "to", "receive", "update", "notifications", ".", "This", "is", "the", "core", "mechanism", "how", "Output", "and", "Keypad", "objects", "get", "notified", "when", "the", "controller"...
python
train
angr/angr
angr/analyses/vfg.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/vfg.py#L1682-L1703
def _save_function_final_state(self, function_key, function_address, state): """ Save the final state of a function, and merge it with existing ones if there are any. :param FunctionKey function_key: The key to this function. :param int function_address: Address of the function. ...
[ "def", "_save_function_final_state", "(", "self", ",", "function_key", ",", "function_address", ",", "state", ")", ":", "l", ".", "debug", "(", "'Saving the final state for function %#08x with function key %s'", ",", "function_address", ",", "function_key", ")", "if", "...
Save the final state of a function, and merge it with existing ones if there are any. :param FunctionKey function_key: The key to this function. :param int function_address: Address of the function. :param SimState state: Initial state of the function. :return: None
[ "Save", "the", "final", "state", "of", "a", "function", "and", "merge", "it", "with", "existing", "ones", "if", "there", "are", "any", "." ]
python
train
frmdstryr/enamlx
enamlx/qt/qt_abstract_item_view.py
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_abstract_item_view.py#L211-L226
def init_signals(self): """ Connect signals """ self.widget.activated.connect(self.on_item_activated) self.widget.clicked.connect(self.on_item_clicked) self.widget.doubleClicked.connect(self.on_item_double_clicked) self.widget.entered.connect(self.on_item_entered) self.wi...
[ "def", "init_signals", "(", "self", ")", ":", "self", ".", "widget", ".", "activated", ".", "connect", "(", "self", ".", "on_item_activated", ")", "self", ".", "widget", ".", "clicked", ".", "connect", "(", "self", ".", "on_item_clicked", ")", "self", "....
Connect signals
[ "Connect", "signals" ]
python
train
helixyte/everest
everest/traversal.py
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/traversal.py#L595-L644
def traverse_many(self, attribute, source_sequence, target_sequence, visitor): """ Traverses the given source and target sequences and makes appropriate calls to :method:`traverse_one`. Algorithm: 1) Build a map target item ID -> target data item from the t...
[ "def", "traverse_many", "(", "self", ",", "attribute", ",", "source_sequence", ",", "target_sequence", ",", "visitor", ")", ":", "target_map", "=", "{", "}", "if", "not", "target_sequence", "is", "None", ":", "for", "target", "in", "target_sequence", ":", "t...
Traverses the given source and target sequences and makes appropriate calls to :method:`traverse_one`. Algorithm: 1) Build a map target item ID -> target data item from the target sequence; 2) For each source data item in the source sequence check if it has a not-N...
[ "Traverses", "the", "given", "source", "and", "target", "sequences", "and", "makes", "appropriate", "calls", "to", ":", "method", ":", "traverse_one", "." ]
python
train
sloria/doitlive
doitlive/keyboard.py
https://github.com/sloria/doitlive/blob/baf43f8ad3f2e4593fe21f6af42aedd34ef1efee/doitlive/keyboard.py#L202-L227
def magicrun( text, shell, prompt_template="default", aliases=None, envvars=None, extra_commands=None, speed=1, test_mode=False, commentecho=False, ): """Echo out each character in ``text`` as keyboard characters are pressed, wait for a RETURN keypress, then run the ``text`` ...
[ "def", "magicrun", "(", "text", ",", "shell", ",", "prompt_template", "=", "\"default\"", ",", "aliases", "=", "None", ",", "envvars", "=", "None", ",", "extra_commands", "=", "None", ",", "speed", "=", "1", ",", "test_mode", "=", "False", ",", "commente...
Echo out each character in ``text`` as keyboard characters are pressed, wait for a RETURN keypress, then run the ``text`` in a shell context.
[ "Echo", "out", "each", "character", "in", "text", "as", "keyboard", "characters", "are", "pressed", "wait", "for", "a", "RETURN", "keypress", "then", "run", "the", "text", "in", "a", "shell", "context", "." ]
python
train
tensorflow/datasets
tensorflow_datasets/core/features/feature.py
https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/features/feature.py#L627-L651
def decode_single_feature_from_dict( feature_k, feature, tfexample_dict): """Decode the given feature from the tfexample_dict. Args: feature_k (str): Feature key in the tfexample_dict feature (FeatureConnector): Connector object to use to decode the field tfexample_dict (dict): Dict contain...
[ "def", "decode_single_feature_from_dict", "(", "feature_k", ",", "feature", ",", "tfexample_dict", ")", ":", "# Singleton case", "if", "not", "feature", ".", "serialized_keys", ":", "data_to_decode", "=", "tfexample_dict", "[", "feature_k", "]", "# Feature contains sub ...
Decode the given feature from the tfexample_dict. Args: feature_k (str): Feature key in the tfexample_dict feature (FeatureConnector): Connector object to use to decode the field tfexample_dict (dict): Dict containing the data to decode. Returns: decoded_feature: The output of the feature.decode_e...
[ "Decode", "the", "given", "feature", "from", "the", "tfexample_dict", "." ]
python
train
pytroll/satpy
satpy/readers/file_handlers.py
https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/file_handlers.py#L69-L110
def combine_info(self, all_infos): """Combine metadata for multiple datasets. When loading data from multiple files it can be non-trivial to combine things like start_time, end_time, start_orbit, end_orbit, etc. By default this method will produce a dictionary containing all values ...
[ "def", "combine_info", "(", "self", ",", "all_infos", ")", ":", "combined_info", "=", "combine_metadata", "(", "*", "all_infos", ")", "new_dict", "=", "self", ".", "_combine", "(", "all_infos", ",", "min", ",", "'start_time'", ",", "'start_orbit'", ")", "new...
Combine metadata for multiple datasets. When loading data from multiple files it can be non-trivial to combine things like start_time, end_time, start_orbit, end_orbit, etc. By default this method will produce a dictionary containing all values that were equal across **all** provided i...
[ "Combine", "metadata", "for", "multiple", "datasets", "." ]
python
train
gamechanger/mongothon
mongothon/model.py
https://github.com/gamechanger/mongothon/blob/5305bdae8e38d09bfe7881f1edc99ac0a2e6b96b/mongothon/model.py#L195-L200
def reload(self): """Reloads the current model's data from the underlying database record, updating it in-place.""" self.emit('will_reload') self.populate(self.collection.find_one(type(self)._id_spec(self['_id']))) self.emit('did_reload')
[ "def", "reload", "(", "self", ")", ":", "self", ".", "emit", "(", "'will_reload'", ")", "self", ".", "populate", "(", "self", ".", "collection", ".", "find_one", "(", "type", "(", "self", ")", ".", "_id_spec", "(", "self", "[", "'_id'", "]", ")", "...
Reloads the current model's data from the underlying database record, updating it in-place.
[ "Reloads", "the", "current", "model", "s", "data", "from", "the", "underlying", "database", "record", "updating", "it", "in", "-", "place", "." ]
python
train
kmike/opencorpora-tools
opencorpora/reader.py
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader.py#L349-L355
def _get_doc_by_raw_offset(self, doc_id): """ Load document from xml using bytes offset information. XXX: this is not tested under Windows. """ bounds = self._get_meta()[str(doc_id)].bounds return xml_utils.load_chunk(self.filename, bounds)
[ "def", "_get_doc_by_raw_offset", "(", "self", ",", "doc_id", ")", ":", "bounds", "=", "self", ".", "_get_meta", "(", ")", "[", "str", "(", "doc_id", ")", "]", ".", "bounds", "return", "xml_utils", ".", "load_chunk", "(", "self", ".", "filename", ",", "...
Load document from xml using bytes offset information. XXX: this is not tested under Windows.
[ "Load", "document", "from", "xml", "using", "bytes", "offset", "information", ".", "XXX", ":", "this", "is", "not", "tested", "under", "Windows", "." ]
python
train
wandb/client
wandb/vendor/prompt_toolkit/key_binding/registry.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/key_binding/registry.py#L195-L217
def get_bindings_starting_with_keys(self, keys): """ Return a list of key bindings that handle a key sequence starting with `keys`. (It does only return bindings for which the sequences are longer than `keys`. And like `get_bindings_for_keys`, it also includes inactive bindings.)...
[ "def", "get_bindings_starting_with_keys", "(", "self", ",", "keys", ")", ":", "def", "get", "(", ")", ":", "result", "=", "[", "]", "for", "b", "in", "self", ".", "key_bindings", ":", "if", "len", "(", "keys", ")", "<", "len", "(", "b", ".", "keys"...
Return a list of key bindings that handle a key sequence starting with `keys`. (It does only return bindings for which the sequences are longer than `keys`. And like `get_bindings_for_keys`, it also includes inactive bindings.) :param keys: tuple of keys.
[ "Return", "a", "list", "of", "key", "bindings", "that", "handle", "a", "key", "sequence", "starting", "with", "keys", ".", "(", "It", "does", "only", "return", "bindings", "for", "which", "the", "sequences", "are", "longer", "than", "keys", ".", "And", "...
python
train
ryanpetrello/python-zombie
zombie/browser.py
https://github.com/ryanpetrello/python-zombie/blob/638916572d8ee5ebbdb2dcfc5000a952e99f280f/zombie/browser.py#L562-L571
def fire(self, event): """ Fires a specified DOM event on the current node. :param event: the name of the event to fire (e.g., 'click'). Returns the :class:`zombie.dom.DOMNode` to allow function chaining. """ self.browser.fire(self.element, event) return self
[ "def", "fire", "(", "self", ",", "event", ")", ":", "self", ".", "browser", ".", "fire", "(", "self", ".", "element", ",", "event", ")", "return", "self" ]
Fires a specified DOM event on the current node. :param event: the name of the event to fire (e.g., 'click'). Returns the :class:`zombie.dom.DOMNode` to allow function chaining.
[ "Fires", "a", "specified", "DOM", "event", "on", "the", "current", "node", "." ]
python
train
gijzelaerr/python-snap7
snap7/client.py
https://github.com/gijzelaerr/python-snap7/blob/a6db134c7a3a2ef187b9eca04669221d6fc634c3/snap7/client.py#L280-L289
def read_multi_vars(self, items): """This function read multiple variables from the PLC. :param items: list of S7DataItem objects :returns: a tuple with the return code and a list of data items """ result = self.library.Cli_ReadMultiVars(self.pointer, byref(items), ...
[ "def", "read_multi_vars", "(", "self", ",", "items", ")", ":", "result", "=", "self", ".", "library", ".", "Cli_ReadMultiVars", "(", "self", ".", "pointer", ",", "byref", "(", "items", ")", ",", "c_int32", "(", "len", "(", "items", ")", ")", ")", "ch...
This function read multiple variables from the PLC. :param items: list of S7DataItem objects :returns: a tuple with the return code and a list of data items
[ "This", "function", "read", "multiple", "variables", "from", "the", "PLC", "." ]
python
train
urinieto/msaf
msaf/input_output.py
https://github.com/urinieto/msaf/blob/9dbb57d77a1310465a65cc40f1641d083ca74385/msaf/input_output.py#L322-L335
def get_all_label_algorithms(): """Gets all the possible label (structural grouping) algorithms in MSAF. Returns ------- algo_ids : list List of all the IDs of label algorithms (strings). """ algo_ids = [] for name in msaf.algorithms.__all__: module = eval(msaf.algorithms.__...
[ "def", "get_all_label_algorithms", "(", ")", ":", "algo_ids", "=", "[", "]", "for", "name", "in", "msaf", ".", "algorithms", ".", "__all__", ":", "module", "=", "eval", "(", "msaf", ".", "algorithms", ".", "__name__", "+", "\".\"", "+", "name", ")", "i...
Gets all the possible label (structural grouping) algorithms in MSAF. Returns ------- algo_ids : list List of all the IDs of label algorithms (strings).
[ "Gets", "all", "the", "possible", "label", "(", "structural", "grouping", ")", "algorithms", "in", "MSAF", "." ]
python
test
numenta/htmresearch
htmresearch/frameworks/layers/physical_objects.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/frameworks/layers/physical_objects.py#L412-L419
def contains(self, location): """ A location is on the box if one of the dimension is "satured"). """ for i, coord in enumerate(location): if self.almostEqual(abs(coord), self.dimensions[i] / 2.): return True return False
[ "def", "contains", "(", "self", ",", "location", ")", ":", "for", "i", ",", "coord", "in", "enumerate", "(", "location", ")", ":", "if", "self", ".", "almostEqual", "(", "abs", "(", "coord", ")", ",", "self", ".", "dimensions", "[", "i", "]", "/", ...
A location is on the box if one of the dimension is "satured").
[ "A", "location", "is", "on", "the", "box", "if", "one", "of", "the", "dimension", "is", "satured", ")", "." ]
python
train
odlgroup/odl
odl/tomo/backends/astra_setup.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/tomo/backends/astra_setup.py#L577-L664
def astra_projector(vol_interp, astra_vol_geom, astra_proj_geom, ndim, impl): """Create an ASTRA projector configuration dictionary. Parameters ---------- vol_interp : {'nearest', 'linear'} Interpolation type of the volume discretization. This determines the projection model that is cho...
[ "def", "astra_projector", "(", "vol_interp", ",", "astra_vol_geom", ",", "astra_proj_geom", ",", "ndim", ",", "impl", ")", ":", "if", "vol_interp", "not", "in", "(", "'nearest'", ",", "'linear'", ")", ":", "raise", "ValueError", "(", "\"`vol_interp` '{}' not und...
Create an ASTRA projector configuration dictionary. Parameters ---------- vol_interp : {'nearest', 'linear'} Interpolation type of the volume discretization. This determines the projection model that is chosen. astra_vol_geom : dict ASTRA volume geometry. astra_proj_geom : d...
[ "Create", "an", "ASTRA", "projector", "configuration", "dictionary", "." ]
python
train
saltstack/salt
salt/master.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L179-L212
def _post_fork_init(self): ''' Some things need to be init'd after the fork has completed The easiest example is that one of these module types creates a thread in the parent process, then once the fork happens you'll start getting errors like "WARNING: Mixing fork() and threads ...
[ "def", "_post_fork_init", "(", "self", ")", ":", "# Load Runners", "ropts", "=", "dict", "(", "self", ".", "opts", ")", "ropts", "[", "'quiet'", "]", "=", "True", "runner_client", "=", "salt", ".", "runner", ".", "RunnerClient", "(", "ropts", ")", "# Loa...
Some things need to be init'd after the fork has completed The easiest example is that one of these module types creates a thread in the parent process, then once the fork happens you'll start getting errors like "WARNING: Mixing fork() and threads detected; memory leaked."
[ "Some", "things", "need", "to", "be", "init", "d", "after", "the", "fork", "has", "completed", "The", "easiest", "example", "is", "that", "one", "of", "these", "module", "types", "creates", "a", "thread", "in", "the", "parent", "process", "then", "once", ...
python
train
PyCQA/astroid
astroid/scoped_nodes.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/scoped_nodes.py#L115-L127
def builtin_lookup(name): """lookup a name into the builtin module return the list of matching statements and the astroid for the builtin module """ builtin_astroid = MANAGER.ast_from_module(builtins) if name == "__dict__": return builtin_astroid, () try: stmts = builtin_astr...
[ "def", "builtin_lookup", "(", "name", ")", ":", "builtin_astroid", "=", "MANAGER", ".", "ast_from_module", "(", "builtins", ")", "if", "name", "==", "\"__dict__\"", ":", "return", "builtin_astroid", ",", "(", ")", "try", ":", "stmts", "=", "builtin_astroid", ...
lookup a name into the builtin module return the list of matching statements and the astroid for the builtin module
[ "lookup", "a", "name", "into", "the", "builtin", "module", "return", "the", "list", "of", "matching", "statements", "and", "the", "astroid", "for", "the", "builtin", "module" ]
python
train
pavoni/pyvera
pyvera/__init__.py
https://github.com/pavoni/pyvera/blob/e05e3d13f76153444787d31948feb5419d77a8c8/pyvera/__init__.py#L811-L830
def set_color(self, rgb): """Set dimmer color. """ target = ','.join([str(c) for c in rgb]) self.set_service_value( self.color_service, 'ColorRGB', 'newColorRGBTarget', target) rgbi = self.get_color_index(['R', 'G', 'B']) ...
[ "def", "set_color", "(", "self", ",", "rgb", ")", ":", "target", "=", "','", ".", "join", "(", "[", "str", "(", "c", ")", "for", "c", "in", "rgb", "]", ")", "self", ".", "set_service_value", "(", "self", ".", "color_service", ",", "'ColorRGB'", ","...
Set dimmer color.
[ "Set", "dimmer", "color", "." ]
python
train
LogicalDash/LiSE
ELiDE/ELiDE/board/board.py
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L317-L339
def on_parent(self, *args): """Create some subwidgets and trigger the first update.""" if not self.parent or hasattr(self, '_parented'): return if not self.wallpaper_path: Logger.debug("Board: waiting for wallpaper_path") Clock.schedule_once(self.on_parent, 0)...
[ "def", "on_parent", "(", "self", ",", "*", "args", ")", ":", "if", "not", "self", ".", "parent", "or", "hasattr", "(", "self", ",", "'_parented'", ")", ":", "return", "if", "not", "self", ".", "wallpaper_path", ":", "Logger", ".", "debug", "(", "\"Bo...
Create some subwidgets and trigger the first update.
[ "Create", "some", "subwidgets", "and", "trigger", "the", "first", "update", "." ]
python
train
jciskey/pygraph
pygraph/classes/directed_graph.py
https://github.com/jciskey/pygraph/blob/037bb2f32503fecb60d62921f9766d54109f15e2/pygraph/classes/directed_graph.py#L168-L181
def delete_edge_by_nodes(self, node_a, node_b): """Removes all the edges from node_a to node_b from the graph.""" node = self.get_node(node_a) # Determine the edge ids edge_ids = [] for e_id in node['edges']: edge = self.get_edge(e_id) if edge['vertices']...
[ "def", "delete_edge_by_nodes", "(", "self", ",", "node_a", ",", "node_b", ")", ":", "node", "=", "self", ".", "get_node", "(", "node_a", ")", "# Determine the edge ids", "edge_ids", "=", "[", "]", "for", "e_id", "in", "node", "[", "'edges'", "]", ":", "e...
Removes all the edges from node_a to node_b from the graph.
[ "Removes", "all", "the", "edges", "from", "node_a", "to", "node_b", "from", "the", "graph", "." ]
python
train
CalebBell/thermo
thermo/eos_mix.py
https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/eos_mix.py#L1058-L1062
def cleanup_a_alpha_and_derivatives(self): r'''Removes properties set by `setup_a_alpha_and_derivatives`; run by `GCEOSMIX.a_alpha_and_derivatives` after `a_alpha` is calculated for every component''' del(self.a, self.kappa, self.kappa0, self.kappa1, self.Tc)
[ "def", "cleanup_a_alpha_and_derivatives", "(", "self", ")", ":", "del", "(", "self", ".", "a", ",", "self", ".", "kappa", ",", "self", ".", "kappa0", ",", "self", ".", "kappa1", ",", "self", ".", "Tc", ")" ]
r'''Removes properties set by `setup_a_alpha_and_derivatives`; run by `GCEOSMIX.a_alpha_and_derivatives` after `a_alpha` is calculated for every component
[ "r", "Removes", "properties", "set", "by", "setup_a_alpha_and_derivatives", ";", "run", "by", "GCEOSMIX", ".", "a_alpha_and_derivatives", "after", "a_alpha", "is", "calculated", "for", "every", "component" ]
python
valid
IdentityPython/pysaml2
src/saml2/sigver.py
https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/sigver.py#L1410-L1437
def verify_signature(self, signedtext, cert_file=None, cert_type='pem', node_name=NODE_NAME, node_id=None, id_attr=''): """ Verifies the signature of a XML document. :param signedtext: The XML document as a string :param cert_file: The public key that was used to sign the document :para...
[ "def", "verify_signature", "(", "self", ",", "signedtext", ",", "cert_file", "=", "None", ",", "cert_type", "=", "'pem'", ",", "node_name", "=", "NODE_NAME", ",", "node_id", "=", "None", ",", "id_attr", "=", "''", ")", ":", "# This is only for testing purposes...
Verifies the signature of a XML document. :param signedtext: The XML document as a string :param cert_file: The public key that was used to sign the document :param cert_type: The file type of the certificate :param node_name: The name of the class that is signed :param node_id:...
[ "Verifies", "the", "signature", "of", "a", "XML", "document", "." ]
python
train
soimort/you-get
src/you_get/extractors/dailymotion.py
https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/dailymotion.py#L13-L35
def dailymotion_download(url, output_dir='.', merge=True, info_only=False, **kwargs): """Downloads Dailymotion videos by URL. """ html = get_content(rebuilt_url(url)) info = json.loads(match1(html, r'qualities":({.+?}),"')) title = match1(html, r'"video_title"\s*:\s*"([^"]+)"') or \ mat...
[ "def", "dailymotion_download", "(", "url", ",", "output_dir", "=", "'.'", ",", "merge", "=", "True", ",", "info_only", "=", "False", ",", "*", "*", "kwargs", ")", ":", "html", "=", "get_content", "(", "rebuilt_url", "(", "url", ")", ")", "info", "=", ...
Downloads Dailymotion videos by URL.
[ "Downloads", "Dailymotion", "videos", "by", "URL", "." ]
python
test
maxpumperla/elephas
elephas/parameter/server.py
https://github.com/maxpumperla/elephas/blob/84605acdc9564673c487637dcb27f5def128bcc7/elephas/parameter/server.py#L92-L138
def start_flask_service(self): """Define Flask parameter server service. This HTTP server can do two things: get the current model parameters and update model parameters. After registering the `parameters` and `update` routes, the service will get started. """ a...
[ "def", "start_flask_service", "(", "self", ")", ":", "app", "=", "Flask", "(", "__name__", ")", "self", ".", "app", "=", "app", "@", "app", ".", "route", "(", "'/'", ")", "def", "home", "(", ")", ":", "return", "'Elephas'", "@", "app", ".", "route"...
Define Flask parameter server service. This HTTP server can do two things: get the current model parameters and update model parameters. After registering the `parameters` and `update` routes, the service will get started.
[ "Define", "Flask", "parameter", "server", "service", "." ]
python
train
jgillick/LendingClub
lendingclub/session.py
https://github.com/jgillick/LendingClub/blob/4495f99fd869810f39c00e02b0f4112c6b210384/lendingclub/session.py#L292-L296
def post(self, path, query=None, data=None, redirects=True): """ POST request wrapper for :func:`request()` """ return self.request('POST', path, query, data, redirects)
[ "def", "post", "(", "self", ",", "path", ",", "query", "=", "None", ",", "data", "=", "None", ",", "redirects", "=", "True", ")", ":", "return", "self", ".", "request", "(", "'POST'", ",", "path", ",", "query", ",", "data", ",", "redirects", ")" ]
POST request wrapper for :func:`request()`
[ "POST", "request", "wrapper", "for", ":", "func", ":", "request", "()" ]
python
train
csparpa/pyowm
pyowm/utils/weatherutils.py
https://github.com/csparpa/pyowm/blob/cdd59eb72f32f7238624ceef9b2e2329a5ebd472/pyowm/utils/weatherutils.py#L48-L67
def filter_by_status(weather_list, status, weather_code_registry): """ Filters out from the provided list of *Weather* objects a sublist of items having a status corresponding to the provided one. The lookup is performed against the provided *WeatherCodeRegistry* object. :param weathers: a list of ...
[ "def", "filter_by_status", "(", "weather_list", ",", "status", ",", "weather_code_registry", ")", ":", "result", "=", "[", "]", "for", "weather", "in", "weather_list", ":", "if", "status_is", "(", "weather", ",", "status", ",", "weather_code_registry", ")", ":...
Filters out from the provided list of *Weather* objects a sublist of items having a status corresponding to the provided one. The lookup is performed against the provided *WeatherCodeRegistry* object. :param weathers: a list of *Weather* objects :type weathers: list :param status: a string indicati...
[ "Filters", "out", "from", "the", "provided", "list", "of", "*", "Weather", "*", "objects", "a", "sublist", "of", "items", "having", "a", "status", "corresponding", "to", "the", "provided", "one", ".", "The", "lookup", "is", "performed", "against", "the", "...
python
train
websauna/pyramid_notebook
pyramid_notebook/notebookmanager.py
https://github.com/websauna/pyramid_notebook/blob/8a7ecfa0259810de1a818e4b415a62811a7b077a/pyramid_notebook/notebookmanager.py#L71-L75
def get_manager_cmd(self): """Get our daemon script path.""" cmd = os.path.abspath(os.path.join(os.path.dirname(__file__), "server", "notebook_daemon.py")) assert os.path.exists(cmd) return cmd
[ "def", "get_manager_cmd", "(", "self", ")", ":", "cmd", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "\"server\"", ",", "\"notebook_daemon.py\"", ")", ...
Get our daemon script path.
[ "Get", "our", "daemon", "script", "path", "." ]
python
train
buriburisuri/sugartensor
sugartensor/sg_transform.py
https://github.com/buriburisuri/sugartensor/blob/d2c039954777c7fbe3eb0c2ae40c45c9854deb40/sugartensor/sg_transform.py#L261-L277
def sg_to_sparse(tensor, opt): r"""Converts a dense tensor into a sparse tensor. See `tf.SparseTensor()` in tensorflow. Args: tensor: A `Tensor` with zero-padding (automatically given by chain). opt: name: If provided, replace current tensor's name. Returns: A `SparseT...
[ "def", "sg_to_sparse", "(", "tensor", ",", "opt", ")", ":", "indices", "=", "tf", ".", "where", "(", "tf", ".", "not_equal", "(", "tensor", ".", "sg_float", "(", ")", ",", "0.", ")", ")", "return", "tf", ".", "SparseTensor", "(", "indices", "=", "i...
r"""Converts a dense tensor into a sparse tensor. See `tf.SparseTensor()` in tensorflow. Args: tensor: A `Tensor` with zero-padding (automatically given by chain). opt: name: If provided, replace current tensor's name. Returns: A `SparseTensor`.
[ "r", "Converts", "a", "dense", "tensor", "into", "a", "sparse", "tensor", ".", "See", "tf", ".", "SparseTensor", "()", "in", "tensorflow", "." ]
python
train
shoebot/shoebot
shoebot/core/canvas.py
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/canvas.py#L124-L134
def set_size(self, size): ''' Size is only set the first time it is called Size that is set is returned ''' if self.size is None: self.size = size return size else: return self.size
[ "def", "set_size", "(", "self", ",", "size", ")", ":", "if", "self", ".", "size", "is", "None", ":", "self", ".", "size", "=", "size", "return", "size", "else", ":", "return", "self", ".", "size" ]
Size is only set the first time it is called Size that is set is returned
[ "Size", "is", "only", "set", "the", "first", "time", "it", "is", "called" ]
python
valid
sernst/cauldron
cauldron/cli/sync/sync_io.py
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/sync/sync_io.py#L12-L25
def pack_chunk(source_data: bytes) -> str: """ Packs the specified binary source data by compressing it with the Zlib library and then converting the bytes to a base64 encoded string for non-binary transmission. :param source_data: The data to be converted to a compressed, base64 string ...
[ "def", "pack_chunk", "(", "source_data", ":", "bytes", ")", "->", "str", ":", "if", "not", "source_data", ":", "return", "''", "chunk_compressed", "=", "zlib", ".", "compress", "(", "source_data", ")", "return", "binascii", ".", "b2a_base64", "(", "chunk_com...
Packs the specified binary source data by compressing it with the Zlib library and then converting the bytes to a base64 encoded string for non-binary transmission. :param source_data: The data to be converted to a compressed, base64 string
[ "Packs", "the", "specified", "binary", "source", "data", "by", "compressing", "it", "with", "the", "Zlib", "library", "and", "then", "converting", "the", "bytes", "to", "a", "base64", "encoded", "string", "for", "non", "-", "binary", "transmission", "." ]
python
train
twilio/twilio-python
twilio/rest/authy/v1/__init__.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/authy/v1/__init__.py#L38-L44
def forms(self): """ :rtype: twilio.rest.authy.v1.form.FormList """ if self._forms is None: self._forms = FormList(self) return self._forms
[ "def", "forms", "(", "self", ")", ":", "if", "self", ".", "_forms", "is", "None", ":", "self", ".", "_forms", "=", "FormList", "(", "self", ")", "return", "self", ".", "_forms" ]
:rtype: twilio.rest.authy.v1.form.FormList
[ ":", "rtype", ":", "twilio", ".", "rest", ".", "authy", ".", "v1", ".", "form", ".", "FormList" ]
python
train
JNRowe/upoints
upoints/gpx.py
https://github.com/JNRowe/upoints/blob/1e4b7a53ed2a06cd854523d54c36aabdccea3830/upoints/gpx.py#L329-L402
def togpx(self): """Generate a GPX metadata element subtree. Returns: etree.Element: GPX metadata element """ metadata = create_elem('metadata') if self.name: metadata.append(create_elem('name', text=self.name)) if self.desc: metadata....
[ "def", "togpx", "(", "self", ")", ":", "metadata", "=", "create_elem", "(", "'metadata'", ")", "if", "self", ".", "name", ":", "metadata", ".", "append", "(", "create_elem", "(", "'name'", ",", "text", "=", "self", ".", "name", ")", ")", "if", "self"...
Generate a GPX metadata element subtree. Returns: etree.Element: GPX metadata element
[ "Generate", "a", "GPX", "metadata", "element", "subtree", "." ]
python
train
mozilla-releng/signtool
signtool/util/archives.py
https://github.com/mozilla-releng/signtool/blob/0a778778a181cb9cab424b29fa104b70345f53c2/signtool/util/archives.py#L36-L83
def packexe(exefile, srcdir): """Pack the files in srcdir into exefile using 7z. Requires that stub files are available in checkouts/stubs""" exefile = cygpath(os.path.abspath(exefile)) appbundle = exefile + ".app.7z" # Make sure that appbundle doesn't already exist # We don't want to risk app...
[ "def", "packexe", "(", "exefile", ",", "srcdir", ")", ":", "exefile", "=", "cygpath", "(", "os", ".", "path", ".", "abspath", "(", "exefile", ")", ")", "appbundle", "=", "exefile", "+", "\".app.7z\"", "# Make sure that appbundle doesn't already exist", "# We don...
Pack the files in srcdir into exefile using 7z. Requires that stub files are available in checkouts/stubs
[ "Pack", "the", "files", "in", "srcdir", "into", "exefile", "using", "7z", "." ]
python
train
Kozea/pygal
pygal/style.py
https://github.com/Kozea/pygal/blob/5e25c98a59a0642eecd9fcc5dbfeeb2190fbb5e7/pygal/style.py#L181-L189
def to_dict(self): """Convert instance to a serializable mapping.""" config = {} for attr in dir(self): if not attr.startswith('_'): value = getattr(self, attr) if not hasattr(value, '__call__'): config[attr] = value return ...
[ "def", "to_dict", "(", "self", ")", ":", "config", "=", "{", "}", "for", "attr", "in", "dir", "(", "self", ")", ":", "if", "not", "attr", ".", "startswith", "(", "'_'", ")", ":", "value", "=", "getattr", "(", "self", ",", "attr", ")", "if", "no...
Convert instance to a serializable mapping.
[ "Convert", "instance", "to", "a", "serializable", "mapping", "." ]
python
train
mardix/Mocha
mocha/decorators.py
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/decorators.py#L81-L100
def headers(params={}): """This decorator adds the headers passed in to the response http://flask.pocoo.org/snippets/100/ """ def decorator(f): if inspect.isclass(f): h = headers(params) apply_function_to_members(f, h) return f @functools.wraps(f) ...
[ "def", "headers", "(", "params", "=", "{", "}", ")", ":", "def", "decorator", "(", "f", ")", ":", "if", "inspect", ".", "isclass", "(", "f", ")", ":", "h", "=", "headers", "(", "params", ")", "apply_function_to_members", "(", "f", ",", "h", ")", ...
This decorator adds the headers passed in to the response http://flask.pocoo.org/snippets/100/
[ "This", "decorator", "adds", "the", "headers", "passed", "in", "to", "the", "response", "http", ":", "//", "flask", ".", "pocoo", ".", "org", "/", "snippets", "/", "100", "/" ]
python
train
jupyterhub/kubespawner
kubespawner/clients.py
https://github.com/jupyterhub/kubespawner/blob/46a4b109c5e657a4c3d5bfa8ea4731ec6564ea13/kubespawner/clients.py#L25-L46
def shared_client(ClientType, *args, **kwargs): """Return a single shared kubernetes client instance A weak reference to the instance is cached, so that concurrent calls to shared_client will all return the same instance until all references to the client are cleared. """ kwarg_key = tuple(...
[ "def", "shared_client", "(", "ClientType", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwarg_key", "=", "tuple", "(", "(", "key", ",", "kwargs", "[", "key", "]", ")", "for", "key", "in", "sorted", "(", "kwargs", ")", ")", "cache_key", "="...
Return a single shared kubernetes client instance A weak reference to the instance is cached, so that concurrent calls to shared_client will all return the same instance until all references to the client are cleared.
[ "Return", "a", "single", "shared", "kubernetes", "client", "instance" ]
python
train
acorg/dark-matter
dark/proteins.py
https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/proteins.py#L257-L327
def addFile(self, filename, fp): """ Read and record protein information for a sample. @param filename: A C{str} file name. @param fp: An open file pointer to read the file's data from. @raise ValueError: If information for a pathogen/protein/sample combination is gi...
[ "def", "addFile", "(", "self", ",", "filename", ",", "fp", ")", ":", "if", "self", ".", "_sampleName", ":", "sampleName", "=", "self", ".", "_sampleName", "elif", "self", ".", "_sampleNameRegex", ":", "match", "=", "self", ".", "_sampleNameRegex", ".", "...
Read and record protein information for a sample. @param filename: A C{str} file name. @param fp: An open file pointer to read the file's data from. @raise ValueError: If information for a pathogen/protein/sample combination is given more than once.
[ "Read", "and", "record", "protein", "information", "for", "a", "sample", "." ]
python
train
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/collectionseditor.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L1652-L1659
def show_image(self, name): """Show image (item is a PIL image)""" command = "%s.show()" % name sw = self.shellwidget if sw._reading: sw.kernel_client.input(command) else: sw.execute(command)
[ "def", "show_image", "(", "self", ",", "name", ")", ":", "command", "=", "\"%s.show()\"", "%", "name", "sw", "=", "self", ".", "shellwidget", "if", "sw", ".", "_reading", ":", "sw", ".", "kernel_client", ".", "input", "(", "command", ")", "else", ":", ...
Show image (item is a PIL image)
[ "Show", "image", "(", "item", "is", "a", "PIL", "image", ")" ]
python
train
QUANTAXIS/QUANTAXIS
QUANTAXIS/QAIndicator/indicators.py
https://github.com/QUANTAXIS/QUANTAXIS/blob/bb1fe424e4108b62a1f712b81a05cf829297a5c0/QUANTAXIS/QAIndicator/indicators.py#L216-L224
def QA_indicator_BIAS(DataFrame, N1, N2, N3): '乖离率' CLOSE = DataFrame['close'] BIAS1 = (CLOSE - MA(CLOSE, N1)) / MA(CLOSE, N1) * 100 BIAS2 = (CLOSE - MA(CLOSE, N2)) / MA(CLOSE, N2) * 100 BIAS3 = (CLOSE - MA(CLOSE, N3)) / MA(CLOSE, N3) * 100 DICT = {'BIAS1': BIAS1, 'BIAS2': BIAS2, 'BIAS3': BIAS3}...
[ "def", "QA_indicator_BIAS", "(", "DataFrame", ",", "N1", ",", "N2", ",", "N3", ")", ":", "CLOSE", "=", "DataFrame", "[", "'close'", "]", "BIAS1", "=", "(", "CLOSE", "-", "MA", "(", "CLOSE", ",", "N1", ")", ")", "/", "MA", "(", "CLOSE", ",", "N1",...
乖离率
[ "乖离率" ]
python
train
bcbio/bcbio-nextgen
bcbio/ngsalign/rtg.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/rtg.py#L45-L54
def calculate_splits(sdf_file, split_size): """Retrieve """ counts = _sdfstats(sdf_file)["counts"] splits = [] cur = 0 for i in range(counts // split_size + (0 if counts % split_size == 0 else 1)): splits.append("%s-%s" % (cur, min(counts, cur + split_size))) cur += split_size ...
[ "def", "calculate_splits", "(", "sdf_file", ",", "split_size", ")", ":", "counts", "=", "_sdfstats", "(", "sdf_file", ")", "[", "\"counts\"", "]", "splits", "=", "[", "]", "cur", "=", "0", "for", "i", "in", "range", "(", "counts", "//", "split_size", "...
Retrieve
[ "Retrieve" ]
python
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L272-L279
def Mx(mt, x): """ Return the Mx """ n = len(mt.Cx) sum1 = 0 for j in range(x, n): k = mt.Cx[j] sum1 += k return sum1
[ "def", "Mx", "(", "mt", ",", "x", ")", ":", "n", "=", "len", "(", "mt", ".", "Cx", ")", "sum1", "=", "0", "for", "j", "in", "range", "(", "x", ",", "n", ")", ":", "k", "=", "mt", ".", "Cx", "[", "j", "]", "sum1", "+=", "k", "return", ...
Return the Mx
[ "Return", "the", "Mx" ]
python
train
dpmcmlxxvi/pixelscan
pixelscan/pixelscan.py
https://github.com/dpmcmlxxvi/pixelscan/blob/d641207b13a8fc5bf7ac9964b982971652bb0a7e/pixelscan/pixelscan.py#L606-L635
def snakescan(xi, yi, xf, yf): """Scan pixels in a snake pattern along the x-coordinate then y-coordinate :param xi: Initial x-coordinate :type xi: int :param yi: Initial y-coordinate :type yi: int :param xf: Final x-coordinate :type xf: int :param yf: Final y-coordinate :type yf: i...
[ "def", "snakescan", "(", "xi", ",", "yi", ",", "xf", ",", "yf", ")", ":", "# Determine direction to move", "dx", "=", "1", "if", "xf", ">=", "xi", "else", "-", "1", "dy", "=", "1", "if", "yf", ">=", "yi", "else", "-", "1", "# Scan pixels first along ...
Scan pixels in a snake pattern along the x-coordinate then y-coordinate :param xi: Initial x-coordinate :type xi: int :param yi: Initial y-coordinate :type yi: int :param xf: Final x-coordinate :type xf: int :param yf: Final y-coordinate :type yf: int :returns: Coordinate generator ...
[ "Scan", "pixels", "in", "a", "snake", "pattern", "along", "the", "x", "-", "coordinate", "then", "y", "-", "coordinate" ]
python
train
juju/python-libjuju
juju/client/_client1.py
https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/_client1.py#L5211-L5226
async def ImportKeys(self, ssh_keys, user): ''' ssh_keys : typing.Sequence[str] user : str Returns -> typing.Sequence[~ErrorResult] ''' # map input types to rpc msg _params = dict() msg = dict(type='KeyManager', request='ImportKeys', ...
[ "async", "def", "ImportKeys", "(", "self", ",", "ssh_keys", ",", "user", ")", ":", "# map input types to rpc msg", "_params", "=", "dict", "(", ")", "msg", "=", "dict", "(", "type", "=", "'KeyManager'", ",", "request", "=", "'ImportKeys'", ",", "version", ...
ssh_keys : typing.Sequence[str] user : str Returns -> typing.Sequence[~ErrorResult]
[ "ssh_keys", ":", "typing", ".", "Sequence", "[", "str", "]", "user", ":", "str", "Returns", "-", ">", "typing", ".", "Sequence", "[", "~ErrorResult", "]" ]
python
train
Garee/pytodoist
pytodoist/todoist.py
https://github.com/Garee/pytodoist/blob/3359cbff485ebdbbb4ffbd58d71e21a817874dd7/pytodoist/todoist.py#L602-L623
def add_label(self, name, color=None): """Create a new label. .. warning:: Requires Todoist premium. :param name: The name of the label. :type name: str :param color: The color of the label. :type color: str :return: The newly created label. :rtype: :cla...
[ "def", "add_label", "(", "self", ",", "name", ",", "color", "=", "None", ")", ":", "args", "=", "{", "'name'", ":", "name", ",", "'color'", ":", "color", "}", "_perform_command", "(", "self", ",", "'label_register'", ",", "args", ")", "return", "self",...
Create a new label. .. warning:: Requires Todoist premium. :param name: The name of the label. :type name: str :param color: The color of the label. :type color: str :return: The newly created label. :rtype: :class:`pytodoist.todoist.Label` >>> from pyt...
[ "Create", "a", "new", "label", "." ]
python
train
Alignak-monitoring/alignak
alignak/satellite.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/satellite.py#L462-L502
def manage_action_return(self, action): """Manage action return from Workers We just put them into the corresponding sched and we clean unused properties like my_scheduler :param action: the action to manage :type action: alignak.action.Action :return: None """ ...
[ "def", "manage_action_return", "(", "self", ",", "action", ")", ":", "# Maybe our workers send us something else than an action", "# if so, just add this in other queues and return", "# todo: test a class instance", "if", "action", ".", "__class__", ".", "my_type", "not", "in", ...
Manage action return from Workers We just put them into the corresponding sched and we clean unused properties like my_scheduler :param action: the action to manage :type action: alignak.action.Action :return: None
[ "Manage", "action", "return", "from", "Workers", "We", "just", "put", "them", "into", "the", "corresponding", "sched", "and", "we", "clean", "unused", "properties", "like", "my_scheduler" ]
python
train
ikegami-yukino/shellinford-python
shellinford/shellinford.py
https://github.com/ikegami-yukino/shellinford-python/blob/ea4d4280e05a15543aa5cd405f90b2c503916dc9/shellinford/shellinford.py#L450-L485
def search(self, query, _or=False, ignores=[]): """Search word from FM-index Params: <str> | <Sequential> query <bool> _or <list <str> > ignores Return: <list>SEARCH_RESULT(<int> document_id, <list <int> > counts ...
[ "def", "search", "(", "self", ",", "query", ",", "_or", "=", "False", ",", "ignores", "=", "[", "]", ")", ":", "if", "isinstance", "(", "query", ",", "str", ")", ":", "dids", "=", "MapIntInt", "(", "{", "}", ")", "self", ".", "fm", ".", "search...
Search word from FM-index Params: <str> | <Sequential> query <bool> _or <list <str> > ignores Return: <list>SEARCH_RESULT(<int> document_id, <list <int> > counts <str> doc)
[ "Search", "word", "from", "FM", "-", "index", "Params", ":", "<str", ">", "|", "<Sequential", ">", "query", "<bool", ">", "_or", "<list", "<str", ">", ">", "ignores", "Return", ":", "<list", ">", "SEARCH_RESULT", "(", "<int", ">", "document_id", "<list",...
python
train
spdx/tools-python
spdx/parsers/rdfbuilders.py
https://github.com/spdx/tools-python/blob/301d72f6ae57c832c1da7f6402fa49b192de6810/spdx/parsers/rdfbuilders.py#L293-L307
def set_file_chksum(self, doc, chk_sum): """Sets the file check sum, if not already set. chk_sum - A string Raises CardinalityError if already defined. Raises OrderError if no package previously defined. """ if self.has_package(doc) and self.has_file(doc): if ...
[ "def", "set_file_chksum", "(", "self", ",", "doc", ",", "chk_sum", ")", ":", "if", "self", ".", "has_package", "(", "doc", ")", "and", "self", ".", "has_file", "(", "doc", ")", ":", "if", "not", "self", ".", "file_chksum_set", ":", "self", ".", "file...
Sets the file check sum, if not already set. chk_sum - A string Raises CardinalityError if already defined. Raises OrderError if no package previously defined.
[ "Sets", "the", "file", "check", "sum", "if", "not", "already", "set", ".", "chk_sum", "-", "A", "string", "Raises", "CardinalityError", "if", "already", "defined", ".", "Raises", "OrderError", "if", "no", "package", "previously", "defined", "." ]
python
valid
tophatmonocle/ims_lti_py
ims_lti_py/request_validator.py
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/request_validator.py#L74-L81
def parse_request(self, request, parameters=None, fake_method=None): ''' Parse Flask request ''' return (request.method, request.url, request.headers, request.form.copy())
[ "def", "parse_request", "(", "self", ",", "request", ",", "parameters", "=", "None", ",", "fake_method", "=", "None", ")", ":", "return", "(", "request", ".", "method", ",", "request", ".", "url", ",", "request", ".", "headers", ",", "request", ".", "f...
Parse Flask request
[ "Parse", "Flask", "request" ]
python
train
contains-io/rcli
rcli/dispatcher.py
https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/dispatcher.py#L34-L58
def main(): # type: () -> typing.Any """Parse the command line options and launch the requested command. If the command is 'help' then print the help message for the subcommand; if no subcommand is given, print the standard help message. """ colorama.init(wrap=six.PY3) doc = usage.get_prima...
[ "def", "main", "(", ")", ":", "# type: () -> typing.Any", "colorama", ".", "init", "(", "wrap", "=", "six", ".", "PY3", ")", "doc", "=", "usage", ".", "get_primary_command_usage", "(", ")", "allow_subcommands", "=", "'<command>'", "in", "doc", "args", "=", ...
Parse the command line options and launch the requested command. If the command is 'help' then print the help message for the subcommand; if no subcommand is given, print the standard help message.
[ "Parse", "the", "command", "line", "options", "and", "launch", "the", "requested", "command", "." ]
python
train
pycontribs/pyrax
pyrax/identity/rax_identity.py
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/identity/rax_identity.py#L121-L127
def _parse_response(self, resp): """Gets the authentication information from the returned JSON.""" super(RaxIdentity, self)._parse_response(resp) user = resp["access"]["user"] defreg = user.get("RAX-AUTH:defaultRegion") if defreg: self._default_region = defreg
[ "def", "_parse_response", "(", "self", ",", "resp", ")", ":", "super", "(", "RaxIdentity", ",", "self", ")", ".", "_parse_response", "(", "resp", ")", "user", "=", "resp", "[", "\"access\"", "]", "[", "\"user\"", "]", "defreg", "=", "user", ".", "get",...
Gets the authentication information from the returned JSON.
[ "Gets", "the", "authentication", "information", "from", "the", "returned", "JSON", "." ]
python
train
davidcarboni/Flask-B3
b3/__init__.py
https://github.com/davidcarboni/Flask-B3/blob/55092cb1070568aeecfd2c07c5ad6122e15ca345/b3/__init__.py#L227-L235
def _generate_identifier(): """ Generates a new, random identifier in B3 format. :return: A 64-bit random identifier, rendered as a hex String. """ bit_length = 64 byte_length = int(bit_length / 8) identifier = os.urandom(byte_length) return hexlify(identifier).decode('ascii')
[ "def", "_generate_identifier", "(", ")", ":", "bit_length", "=", "64", "byte_length", "=", "int", "(", "bit_length", "/", "8", ")", "identifier", "=", "os", ".", "urandom", "(", "byte_length", ")", "return", "hexlify", "(", "identifier", ")", ".", "decode"...
Generates a new, random identifier in B3 format. :return: A 64-bit random identifier, rendered as a hex String.
[ "Generates", "a", "new", "random", "identifier", "in", "B3", "format", ".", ":", "return", ":", "A", "64", "-", "bit", "random", "identifier", "rendered", "as", "a", "hex", "String", "." ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/parallel/client/magics.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/parallel/client/magics.py#L190-L215
def result(self, line=''): """Print the result of the last asynchronous %px command. This lets you recall the results of %px computations after asynchronous submission (block=False). Examples -------- :: In [23]: %px os.getpid() Async pa...
[ "def", "result", "(", "self", ",", "line", "=", "''", ")", ":", "args", "=", "magic_arguments", ".", "parse_argstring", "(", "self", ".", "result", ",", "line", ")", "if", "self", ".", "last_result", "is", "None", ":", "raise", "UsageError", "(", "NO_L...
Print the result of the last asynchronous %px command. This lets you recall the results of %px computations after asynchronous submission (block=False). Examples -------- :: In [23]: %px os.getpid() Async parallel execution on engine(s): all ...
[ "Print", "the", "result", "of", "the", "last", "asynchronous", "%px", "command", ".", "This", "lets", "you", "recall", "the", "results", "of", "%px", "computations", "after", "asynchronous", "submission", "(", "block", "=", "False", ")", "." ]
python
test
tensorlayer/tensorlayer
tensorlayer/db.py
https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/db.py#L242-L252
def delete_model(self, **kwargs): """Delete model. Parameters ----------- kwargs : logging information Find items to delete, leave it empty to delete all log. """ self._fill_project_info(kwargs) self.db.Model.delete_many(kwargs) logging.info("...
[ "def", "delete_model", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_fill_project_info", "(", "kwargs", ")", "self", ".", "db", ".", "Model", ".", "delete_many", "(", "kwargs", ")", "logging", ".", "info", "(", "\"[Database] Delete Model S...
Delete model. Parameters ----------- kwargs : logging information Find items to delete, leave it empty to delete all log.
[ "Delete", "model", "." ]
python
valid
pyblish/pyblish-qml
pyblish_qml/vendor/mock.py
https://github.com/pyblish/pyblish-qml/blob/6095d18b2ec0afd0409a9b1a17e53b0658887283/pyblish_qml/vendor/mock.py#L1743-L1748
def _get_method(name, func): "Turns a callable object (like a mock) into a real function" def method(self, *args, **kw): return func(self, *args, **kw) method.__name__ = name return method
[ "def", "_get_method", "(", "name", ",", "func", ")", ":", "def", "method", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "return", "func", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", "method", ".", "__name__", "=", ...
Turns a callable object (like a mock) into a real function
[ "Turns", "a", "callable", "object", "(", "like", "a", "mock", ")", "into", "a", "real", "function" ]
python
train
bykof/billomapy
billomapy/billomapy.py
https://github.com/bykof/billomapy/blob/a28ba69fd37654fa145d0411d52c200e7f8984ab/billomapy/billomapy.py#L1104-L1118
def get_items_of_invoice_per_page(self, invoice_id, per_page=1000, page=1): """ Get invoice items of invoice per page :param invoice_id: the invoice id :param per_page: How many objects per page. Default: 1000 :param page: Which page. Default: 1 :return: list """...
[ "def", "get_items_of_invoice_per_page", "(", "self", ",", "invoice_id", ",", "per_page", "=", "1000", ",", "page", "=", "1", ")", ":", "return", "self", ".", "_get_resource_per_page", "(", "resource", "=", "INVOICE_ITEMS", ",", "per_page", "=", "per_page", ","...
Get invoice items of invoice per page :param invoice_id: the invoice id :param per_page: How many objects per page. Default: 1000 :param page: Which page. Default: 1 :return: list
[ "Get", "invoice", "items", "of", "invoice", "per", "page" ]
python
train
ph4r05/monero-serialize
monero_serialize/core/int_serialize.py
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/core/int_serialize.py#L4-L18
async def load_uint(reader, width): """ Constant-width integer serialization :param reader: :param width: :return: """ buffer = _UINT_BUFFER result = 0 shift = 0 for _ in range(width): await reader.areadinto(buffer) result += buffer[0] << shift shift += 8 ...
[ "async", "def", "load_uint", "(", "reader", ",", "width", ")", ":", "buffer", "=", "_UINT_BUFFER", "result", "=", "0", "shift", "=", "0", "for", "_", "in", "range", "(", "width", ")", ":", "await", "reader", ".", "areadinto", "(", "buffer", ")", "res...
Constant-width integer serialization :param reader: :param width: :return:
[ "Constant", "-", "width", "integer", "serialization", ":", "param", "reader", ":", ":", "param", "width", ":", ":", "return", ":" ]
python
train
softlayer/softlayer-python
SoftLayer/managers/sshkey.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/sshkey.py#L26-L40
def add_key(self, key, label, notes=None): """Adds a new SSH key to the account. :param string key: The SSH key to add :param string label: The label for the key :param string notes: Additional notes for the key :returns: A dictionary of the new key's information. """ ...
[ "def", "add_key", "(", "self", ",", "key", ",", "label", ",", "notes", "=", "None", ")", ":", "order", "=", "{", "'key'", ":", "key", ",", "'label'", ":", "label", ",", "'notes'", ":", "notes", ",", "}", "return", "self", ".", "sshkey", ".", "cre...
Adds a new SSH key to the account. :param string key: The SSH key to add :param string label: The label for the key :param string notes: Additional notes for the key :returns: A dictionary of the new key's information.
[ "Adds", "a", "new", "SSH", "key", "to", "the", "account", "." ]
python
train
theelous3/asks
asks/cookie_utils.py
https://github.com/theelous3/asks/blob/ea522ea971ecb031d488a6301dc2718516cadcd6/asks/cookie_utils.py#L47-L70
def parse_cookies(response, host): """ Sticks cookies to a response. """ cookie_pie = [] try: for cookie in response.headers['set-cookie']: cookie_jar = {} name_val, *rest = cookie.split(';') name, value = name_val.split('=', 1) cookie_jar['nam...
[ "def", "parse_cookies", "(", "response", ",", "host", ")", ":", "cookie_pie", "=", "[", "]", "try", ":", "for", "cookie", "in", "response", ".", "headers", "[", "'set-cookie'", "]", ":", "cookie_jar", "=", "{", "}", "name_val", ",", "", "*", "rest", ...
Sticks cookies to a response.
[ "Sticks", "cookies", "to", "a", "response", "." ]
python
train
trec-kba/streamcorpus-pipeline
streamcorpus_pipeline/_taggers.py
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_taggers.py#L123-L140
def ANY_mentions(target_mentions, chain_mentions): ''' For each name string in the target_mentions list, searches through all chain_mentions looking for any cleansed Token.token that contains the name. Returns True if any of the target_mention strings appeared as substrings of any cleansed Token.to...
[ "def", "ANY_mentions", "(", "target_mentions", ",", "chain_mentions", ")", ":", "for", "name", "in", "target_mentions", ":", "for", "chain_ment", "in", "chain_mentions", ":", "if", "name", "in", "chain_ment", ":", "return", "True", "return", "False" ]
For each name string in the target_mentions list, searches through all chain_mentions looking for any cleansed Token.token that contains the name. Returns True if any of the target_mention strings appeared as substrings of any cleansed Token.token. Otherwise, returns False. :type target_mentions: ...
[ "For", "each", "name", "string", "in", "the", "target_mentions", "list", "searches", "through", "all", "chain_mentions", "looking", "for", "any", "cleansed", "Token", ".", "token", "that", "contains", "the", "name", ".", "Returns", "True", "if", "any", "of", ...
python
test
bretth/woven
woven/decorators.py
https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/decorators.py#L7-L34
def run_once_per_node(func): """ Decorator preventing wrapped function from running more than once per host (not just interpreter session). Using env.patch = True will allow the wrapped function to be run if it has been previously executed, but not otherwise Stores the result of a function...
[ "def", "run_once_per_node", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "decorated", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "hasattr", "(", "env", ",", "'patch'", ")", ":", "env", ".", "patch", "=", "F...
Decorator preventing wrapped function from running more than once per host (not just interpreter session). Using env.patch = True will allow the wrapped function to be run if it has been previously executed, but not otherwise Stores the result of a function as server state
[ "Decorator", "preventing", "wrapped", "function", "from", "running", "more", "than", "once", "per", "host", "(", "not", "just", "interpreter", "session", ")", "." ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/core/inputsplitter.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/inputsplitter.py#L622-L634
def transform_help_end(line): """Translate lines with ?/?? at the end""" m = _help_end_re.search(line) if m is None or has_comment(line): return line target = m.group(1) esc = m.group(3) lspace = _initial_space_re.match(line).group(0) # If we're mid-command, put it back on the n...
[ "def", "transform_help_end", "(", "line", ")", ":", "m", "=", "_help_end_re", ".", "search", "(", "line", ")", "if", "m", "is", "None", "or", "has_comment", "(", "line", ")", ":", "return", "line", "target", "=", "m", ".", "group", "(", "1", ")", "...
Translate lines with ?/?? at the end
[ "Translate", "lines", "with", "?", "/", "??", "at", "the", "end" ]
python
test
Pytwitcher/pytwitcherapi
src/pytwitcherapi/models.py
https://github.com/Pytwitcher/pytwitcherapi/blob/d53ac5ad5ca113ecb7da542e8cdcbbf8c762b336/src/pytwitcherapi/models.py#L51-L70
def wrap_json(cls, json, viewers=None, channels=None): """Create a Game instance for the given json :param json: the dict with the information of the game :type json: :class:`dict` :param viewers: The viewer count :type viewers: :class:`int` :param channels: The viewer c...
[ "def", "wrap_json", "(", "cls", ",", "json", ",", "viewers", "=", "None", ",", "channels", "=", "None", ")", ":", "g", "=", "Game", "(", "name", "=", "json", ".", "get", "(", "'name'", ")", ",", "box", "=", "json", ".", "get", "(", "'box'", ")"...
Create a Game instance for the given json :param json: the dict with the information of the game :type json: :class:`dict` :param viewers: The viewer count :type viewers: :class:`int` :param channels: The viewer count :type channels: :class:`int` :returns: the ne...
[ "Create", "a", "Game", "instance", "for", "the", "given", "json" ]
python
train
pantsbuild/pants
src/python/pants/goal/goal.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/goal/goal.py#L82-L89
def by_name(cls, name): """Returns the unique object representing the goal of the specified name. :API: public """ if name not in cls._goal_by_name: cls._goal_by_name[name] = _Goal(name) return cls._goal_by_name[name]
[ "def", "by_name", "(", "cls", ",", "name", ")", ":", "if", "name", "not", "in", "cls", ".", "_goal_by_name", ":", "cls", ".", "_goal_by_name", "[", "name", "]", "=", "_Goal", "(", "name", ")", "return", "cls", ".", "_goal_by_name", "[", "name", "]" ]
Returns the unique object representing the goal of the specified name. :API: public
[ "Returns", "the", "unique", "object", "representing", "the", "goal", "of", "the", "specified", "name", "." ]
python
train
log2timeline/dfvfs
dfvfs/mount/manager.py
https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/mount/manager.py#L33-L45
def DeregisterMountPoint(cls, mount_point): """Deregisters a path specification mount point. Args: mount_point (str): mount point identifier. Raises: KeyError: if the corresponding mount point is not set. """ if mount_point not in cls._mount_points: raise KeyError('Mount point: {...
[ "def", "DeregisterMountPoint", "(", "cls", ",", "mount_point", ")", ":", "if", "mount_point", "not", "in", "cls", ".", "_mount_points", ":", "raise", "KeyError", "(", "'Mount point: {0:s} not set.'", ".", "format", "(", "mount_point", ")", ")", "del", "cls", "...
Deregisters a path specification mount point. Args: mount_point (str): mount point identifier. Raises: KeyError: if the corresponding mount point is not set.
[ "Deregisters", "a", "path", "specification", "mount", "point", "." ]
python
train
quiltdata/quilt
compiler/quilt/imports.py
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/imports.py#L81-L94
def load_module(self, fullname): """ Returns an object that lazily looks up tables and groups. """ mod = sys.modules.get(fullname) if mod is not None: return mod # We're creating an object rather than a module. It's a hack, but it's approved by Guido: ...
[ "def", "load_module", "(", "self", ",", "fullname", ")", ":", "mod", "=", "sys", ".", "modules", ".", "get", "(", "fullname", ")", "if", "mod", "is", "not", "None", ":", "return", "mod", "# We're creating an object rather than a module. It's a hack, but it's appro...
Returns an object that lazily looks up tables and groups.
[ "Returns", "an", "object", "that", "lazily", "looks", "up", "tables", "and", "groups", "." ]
python
train
FactoryBoy/factory_boy
factory/base.py
https://github.com/FactoryBoy/factory_boy/blob/edaa7c7f5a14065b229927903bd7989cc93cd069/factory/base.py#L246-L259
def _initialize_counter(self): """Initialize our counter pointer. If we're the top-level factory, instantiate a new counter Otherwise, point to the top-level factory's counter. """ if self._counter is not None: return if self.counter_reference is self: ...
[ "def", "_initialize_counter", "(", "self", ")", ":", "if", "self", ".", "_counter", "is", "not", "None", ":", "return", "if", "self", ".", "counter_reference", "is", "self", ":", "self", ".", "_counter", "=", "_Counter", "(", "seq", "=", "self", ".", "...
Initialize our counter pointer. If we're the top-level factory, instantiate a new counter Otherwise, point to the top-level factory's counter.
[ "Initialize", "our", "counter", "pointer", "." ]
python
train
helixyte/everest
everest/repositories/rdb/utils.py
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/rdb/utils.py#L176-L183
def synonym(name): """ Utility function mimicking the behavior of the old SA synonym function with the new hybrid property semantics. """ return hybrid_property(lambda inst: getattr(inst, name), lambda inst, value: setattr(inst, name, value), exp...
[ "def", "synonym", "(", "name", ")", ":", "return", "hybrid_property", "(", "lambda", "inst", ":", "getattr", "(", "inst", ",", "name", ")", ",", "lambda", "inst", ",", "value", ":", "setattr", "(", "inst", ",", "name", ",", "value", ")", ",", "expr",...
Utility function mimicking the behavior of the old SA synonym function with the new hybrid property semantics.
[ "Utility", "function", "mimicking", "the", "behavior", "of", "the", "old", "SA", "synonym", "function", "with", "the", "new", "hybrid", "property", "semantics", "." ]
python
train
inveniosoftware/invenio-assets
invenio_assets/ext.py
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/ext.py#L41-L60
def init_app(self, app, entry_point_group='invenio_assets.bundles', **kwargs): """Initialize application object. :param app: An instance of :class:`~flask.Flask`. :param entry_point_group: A name of entry point group used to load ``webassets`` bundles. .. v...
[ "def", "init_app", "(", "self", ",", "app", ",", "entry_point_group", "=", "'invenio_assets.bundles'", ",", "*", "*", "kwargs", ")", ":", "self", ".", "init_config", "(", "app", ")", "self", ".", "env", ".", "init_app", "(", "app", ")", "self", ".", "c...
Initialize application object. :param app: An instance of :class:`~flask.Flask`. :param entry_point_group: A name of entry point group used to load ``webassets`` bundles. .. versionchanged:: 1.0.0b2 The *entrypoint* has been renamed to *entry_point_group*.
[ "Initialize", "application", "object", "." ]
python
train
jaredLunde/vital-tools
vital/debug/__init__.py
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L425-L458
def get_parent_name(obj): """ Gets the name of the object containing @obj and returns as a string @obj: any python object -> #str parent object name or None .. from vital.debug import get_parent_name get_parent_name(get_parent_name) # -> 'vital.debug' ...
[ "def", "get_parent_name", "(", "obj", ")", ":", "parent_obj", "=", "get_parent_obj", "(", "obj", ")", "parent_name", "=", "get_obj_name", "(", "parent_obj", ")", "if", "parent_obj", "else", "None", "n", "=", "0", "while", "parent_obj", "and", "n", "<", "25...
Gets the name of the object containing @obj and returns as a string @obj: any python object -> #str parent object name or None .. from vital.debug import get_parent_name get_parent_name(get_parent_name) # -> 'vital.debug' get_parent_name(vital....
[ "Gets", "the", "name", "of", "the", "object", "containing", "@obj", "and", "returns", "as", "a", "string" ]
python
train
liip/taxi
taxi/timesheet/parser.py
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/parser.py#L262-L290
def create_date_from_text(self, text): """ Parse a text in the form dd/mm/yyyy, dd/mm/yy or yyyy/mm/dd and return a corresponding :class:`datetime.date` object. If no date can be extracted from the given text, a :exc:`ValueError` will be raised. """ # Try to match dd/mm/yyyy form...
[ "def", "create_date_from_text", "(", "self", ",", "text", ")", ":", "# Try to match dd/mm/yyyy format", "date_matches", "=", "re", ".", "match", "(", "self", ".", "DATE_LINE_REGEXP", ",", "text", ")", "# If no match, try with yyyy/mm/dd format", "if", "date_matches", ...
Parse a text in the form dd/mm/yyyy, dd/mm/yy or yyyy/mm/dd and return a corresponding :class:`datetime.date` object. If no date can be extracted from the given text, a :exc:`ValueError` will be raised.
[ "Parse", "a", "text", "in", "the", "form", "dd", "/", "mm", "/", "yyyy", "dd", "/", "mm", "/", "yy", "or", "yyyy", "/", "mm", "/", "dd", "and", "return", "a", "corresponding", ":", "class", ":", "datetime", ".", "date", "object", ".", "If", "no",...
python
train
gem/oq-engine
openquake/hazardlib/gsim/gmpe_table.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/gmpe_table.py#L482-L518
def _return_tables(self, mag, imt, val_type): """ Returns the vector of ground motions or standard deviations corresponding to the specific magnitude and intensity measure type. :param val_type: String indicating the type of data {"IMLs", "Total", "Inter" etc} """ ...
[ "def", "_return_tables", "(", "self", ",", "mag", ",", "imt", ",", "val_type", ")", ":", "if", "imt", ".", "name", "in", "'PGA PGV'", ":", "# Get scalar imt", "if", "val_type", "==", "\"IMLs\"", ":", "iml_table", "=", "self", ".", "imls", "[", "imt", "...
Returns the vector of ground motions or standard deviations corresponding to the specific magnitude and intensity measure type. :param val_type: String indicating the type of data {"IMLs", "Total", "Inter" etc}
[ "Returns", "the", "vector", "of", "ground", "motions", "or", "standard", "deviations", "corresponding", "to", "the", "specific", "magnitude", "and", "intensity", "measure", "type", "." ]
python
train
Esri/ArcREST
src/arcrest/agol/services.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/agol/services.py#L1858-L1947
def query_related_records(self, objectIds, relationshipId, outFields="*", definitionExpression=None, returnGeometry=True, maxAllowableOffset...
[ "def", "query_related_records", "(", "self", ",", "objectIds", ",", "relationshipId", ",", "outFields", "=", "\"*\"", ",", "definitionExpression", "=", "None", ",", "returnGeometry", "=", "True", ",", "maxAllowableOffset", "=", "None", ",", "geometryPrecision", "=...
The Query operation is performed on a feature service layer resource. The result of this operation are feature sets grouped by source layer/table object IDs. Each feature set contains Feature objects including the values for the fields requested by the user. For related layer...
[ "The", "Query", "operation", "is", "performed", "on", "a", "feature", "service", "layer", "resource", ".", "The", "result", "of", "this", "operation", "are", "feature", "sets", "grouped", "by", "source", "layer", "/", "table", "object", "IDs", ".", "Each", ...
python
train
aouyar/PyMunin
pysysinfo/phpapc.py
https://github.com/aouyar/PyMunin/blob/4f58a64b6b37c85a84cc7e1e07aafaa0321b249d/pysysinfo/phpapc.py#L71-L92
def initStats(self, extras=None): """Query and parse Web Server Status Page. @param extras: Include extra metrics, which can be computationally more expensive. """ if extras is not None: self._extras = extras if self._extras: ...
[ "def", "initStats", "(", "self", ",", "extras", "=", "None", ")", ":", "if", "extras", "is", "not", "None", ":", "self", ".", "_extras", "=", "extras", "if", "self", ".", "_extras", ":", "detail", "=", "1", "else", ":", "detail", "=", "0", "url", ...
Query and parse Web Server Status Page. @param extras: Include extra metrics, which can be computationally more expensive.
[ "Query", "and", "parse", "Web", "Server", "Status", "Page", "." ]
python
train
Alignak-monitoring/alignak
alignak/eventhandler.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/eventhandler.py#L90-L106
def get_return_from(self, e_handler): """Setter of the following attributes:: * exit_status * output * long_output * check_time * execution_time * perf_data :param e_handler: event handler to get data from :type e_handler: alignak.eventhandler.Ev...
[ "def", "get_return_from", "(", "self", ",", "e_handler", ")", ":", "for", "prop", "in", "[", "'exit_status'", ",", "'output'", ",", "'long_output'", ",", "'check_time'", ",", "'execution_time'", ",", "'perf_data'", "]", ":", "setattr", "(", "self", ",", "pro...
Setter of the following attributes:: * exit_status * output * long_output * check_time * execution_time * perf_data :param e_handler: event handler to get data from :type e_handler: alignak.eventhandler.EventHandler :return: None
[ "Setter", "of", "the", "following", "attributes", "::" ]
python
train
swimlane/swimlane-python
swimlane/core/adapters/record.py
https://github.com/swimlane/swimlane-python/blob/588fc503a76799bcdb5aecdf2f64a6ee05e3922d/swimlane/core/adapters/record.py#L42-L98
def search(self, *filters, **kwargs): """Shortcut to generate a new temporary search report using provided filters and return the resulting records Args: *filters (tuple): Zero or more filter tuples of (field_name, operator, field_value) Keyword Args: keywords (list(str...
[ "def", "search", "(", "self", ",", "*", "filters", ",", "*", "*", "kwargs", ")", ":", "report", "=", "self", ".", "_app", ".", "reports", ".", "build", "(", "'search-'", "+", "random_string", "(", "8", ")", ",", "keywords", "=", "kwargs", ".", "pop...
Shortcut to generate a new temporary search report using provided filters and return the resulting records Args: *filters (tuple): Zero or more filter tuples of (field_name, operator, field_value) Keyword Args: keywords (list(str)): List of strings of keywords to use in report ...
[ "Shortcut", "to", "generate", "a", "new", "temporary", "search", "report", "using", "provided", "filters", "and", "return", "the", "resulting", "records" ]
python
train
postlund/pyatv
pyatv/airplay/srp.py
https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/airplay/srp.py#L114-L137
def verify2(self, atv_public_key, data): """Last device verification step.""" self._check_initialized() log_binary(_LOGGER, 'Verify', PublicSecret=atv_public_key, Data=data) # Generate a shared secret key public = curve25519.Public(atv_public_key) shared = self._verify_p...
[ "def", "verify2", "(", "self", ",", "atv_public_key", ",", "data", ")", ":", "self", ".", "_check_initialized", "(", ")", "log_binary", "(", "_LOGGER", ",", "'Verify'", ",", "PublicSecret", "=", "atv_public_key", ",", "Data", "=", "data", ")", "# Generate a ...
Last device verification step.
[ "Last", "device", "verification", "step", "." ]
python
train
release-engineering/productmd
productmd/common.py
https://github.com/release-engineering/productmd/blob/49256bf2e8c84124f42346241140b986ad7bfc38/productmd/common.py#L254-L263
def load(self, f): """ Load data from a file. :param f: file-like object or path to file :type f: file or str """ with _open_file_obj(f) as f: parser = self.parse_file(f) self.deserialize(parser)
[ "def", "load", "(", "self", ",", "f", ")", ":", "with", "_open_file_obj", "(", "f", ")", "as", "f", ":", "parser", "=", "self", ".", "parse_file", "(", "f", ")", "self", ".", "deserialize", "(", "parser", ")" ]
Load data from a file. :param f: file-like object or path to file :type f: file or str
[ "Load", "data", "from", "a", "file", "." ]
python
train
Fantomas42/django-app-namespace-template-loader
app_namespace/loader.py
https://github.com/Fantomas42/django-app-namespace-template-loader/blob/9d56e8eef25082e126549be97856582d28d1e84d/app_namespace/loader.py#L120-L130
def load_template_source(self, *ka): """ Backward compatible method for Django < 2.0. """ template_name = ka[0] for origin in self.get_template_sources(template_name): try: return self.get_contents(origin), origin.name except TemplateDoesNo...
[ "def", "load_template_source", "(", "self", ",", "*", "ka", ")", ":", "template_name", "=", "ka", "[", "0", "]", "for", "origin", "in", "self", ".", "get_template_sources", "(", "template_name", ")", ":", "try", ":", "return", "self", ".", "get_contents", ...
Backward compatible method for Django < 2.0.
[ "Backward", "compatible", "method", "for", "Django", "<", "2", ".", "0", "." ]
python
train
ARMmbed/icetea
icetea_lib/enhancedserial.py
https://github.com/ARMmbed/icetea/blob/b2b97ac607429830cf7d62dae2e3903692c7c778/icetea_lib/enhancedserial.py#L144-L156
def readlines(self, timeout=1): """ read all lines that are available. abort after timeout when no more data arrives. """ lines = [] while 1: line = self.readline(timeout=timeout) if line: lines.append(line) if not line ...
[ "def", "readlines", "(", "self", ",", "timeout", "=", "1", ")", ":", "lines", "=", "[", "]", "while", "1", ":", "line", "=", "self", ".", "readline", "(", "timeout", "=", "timeout", ")", "if", "line", ":", "lines", ".", "append", "(", "line", ")"...
read all lines that are available. abort after timeout when no more data arrives.
[ "read", "all", "lines", "that", "are", "available", ".", "abort", "after", "timeout", "when", "no", "more", "data", "arrives", "." ]
python
train
yougov/pmxbot
pmxbot/quotes.py
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/quotes.py#L199-L220
def quote(rest): """ If passed with nothing then get a random quote. If passed with some string then search for that. If prepended with "add:" then add it to the db, eg "!quote add: drivers: I only work here because of pmxbot!". Delete an individual quote by prepending "del:" and passing a search matching exactly...
[ "def", "quote", "(", "rest", ")", ":", "rest", "=", "rest", ".", "strip", "(", ")", "if", "rest", ".", "startswith", "(", "'add: '", ")", "or", "rest", ".", "startswith", "(", "'add '", ")", ":", "quote_to_add", "=", "rest", ".", "split", "(", "' '...
If passed with nothing then get a random quote. If passed with some string then search for that. If prepended with "add:" then add it to the db, eg "!quote add: drivers: I only work here because of pmxbot!". Delete an individual quote by prepending "del:" and passing a search matching exactly one query.
[ "If", "passed", "with", "nothing", "then", "get", "a", "random", "quote", ".", "If", "passed", "with", "some", "string", "then", "search", "for", "that", ".", "If", "prepended", "with", "add", ":", "then", "add", "it", "to", "the", "db", "eg", "!quote"...
python
train
cloudsmith-io/cloudsmith-cli
cloudsmith_cli/cli/commands/check.py
https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/check.py#L84-L130
def service(ctx, opts): """Check the status of the Cloudsmith service.""" click.echo("Retrieving service status ... ", nl=False) context_msg = "Failed to retrieve status!" with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg): with maybe_spinner(opts): status, version ...
[ "def", "service", "(", "ctx", ",", "opts", ")", ":", "click", ".", "echo", "(", "\"Retrieving service status ... \"", ",", "nl", "=", "False", ")", "context_msg", "=", "\"Failed to retrieve status!\"", "with", "handle_api_exceptions", "(", "ctx", ",", "opts", "=...
Check the status of the Cloudsmith service.
[ "Check", "the", "status", "of", "the", "Cloudsmith", "service", "." ]
python
train
titusjan/argos
argos/config/abstractcti.py
https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/config/abstractcti.py#L704-L712
def paintEvent(self, event): """ Reimplementation of paintEvent to allow for style sheets See: http://qt-project.org/wiki/How_to_Change_the_Background_Color_of_QWidget """ opt = QtWidgets.QStyleOption() opt.initFrom(self) painter = QtGui.QPainter(self) self.st...
[ "def", "paintEvent", "(", "self", ",", "event", ")", ":", "opt", "=", "QtWidgets", ".", "QStyleOption", "(", ")", "opt", ".", "initFrom", "(", "self", ")", "painter", "=", "QtGui", ".", "QPainter", "(", "self", ")", "self", ".", "style", "(", ")", ...
Reimplementation of paintEvent to allow for style sheets See: http://qt-project.org/wiki/How_to_Change_the_Background_Color_of_QWidget
[ "Reimplementation", "of", "paintEvent", "to", "allow", "for", "style", "sheets", "See", ":", "http", ":", "//", "qt", "-", "project", ".", "org", "/", "wiki", "/", "How_to_Change_the_Background_Color_of_QWidget" ]
python
train
PyCQA/astroid
astroid/as_string.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/as_string.py#L291-L300
def visit_for(self, node): """return an astroid.For node as string""" fors = "for %s in %s:\n%s" % ( node.target.accept(self), node.iter.accept(self), self._stmt_list(node.body), ) if node.orelse: fors = "%s\nelse:\n%s" % (fors, self._stmt_...
[ "def", "visit_for", "(", "self", ",", "node", ")", ":", "fors", "=", "\"for %s in %s:\\n%s\"", "%", "(", "node", ".", "target", ".", "accept", "(", "self", ")", ",", "node", ".", "iter", ".", "accept", "(", "self", ")", ",", "self", ".", "_stmt_list"...
return an astroid.For node as string
[ "return", "an", "astroid", ".", "For", "node", "as", "string" ]
python
train
klen/muffin-session
muffin_session.py
https://github.com/klen/muffin-session/blob/f1d14d12b7d09d8cc40be14b0dfa0b1e2f4ae8e9/muffin_session.py#L174-L189
def load(self, cookies, **kwargs): """Load session from cookies.""" value = cookies.get(self.key, None) if value is None: return False value = self.decrypt(value) if not value: return False data = json.loads(value) if not isinstance(data,...
[ "def", "load", "(", "self", ",", "cookies", ",", "*", "*", "kwargs", ")", ":", "value", "=", "cookies", ".", "get", "(", "self", ".", "key", ",", "None", ")", "if", "value", "is", "None", ":", "return", "False", "value", "=", "self", ".", "decryp...
Load session from cookies.
[ "Load", "session", "from", "cookies", "." ]
python
train