code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def edges(self): canonical_edges = set() for v1, neighbours in self._vertices.items(): for v2 in neighbours: edge = self.canonical_order((v1, v2)) canonical_edges.add(edge) return canonical_edges
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Edges of this graph, in canonical order.
def casperjs_command_kwargs(): kwargs = { 'stdout': subprocess.PIPE, 'stderr': subprocess.PIPE, 'universal_newlines': True } phantom_js_cmd = app_settings['PHANTOMJS_CMD'] if phantom_js_cmd: path = '{0}:{1}'.format( os.getenv('PATH', ''), os.path.dirname(phantom_js_cmd) ) kwargs.update({'env': {'PATH': path}}) return kwargs
module function_definition identifier parameters block expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end true expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end identifier return_statement identifier
will construct kwargs for cmd
def run_queues(self): if self.exception: raise self.exception listeners = self.__listeners_for_thread return sum(l.process() for l in listeners) > 0
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block raise_statement attribute identifier identifier expression_statement assignment identifier attribute identifier identifier return_statement comparison_operator call identifier generator_expression call attribute identifier identifier argument_list for_in_clause identifier identifier integer
Run all queues that have data queued
def update_options(self, **options): _check_options(options) if 'persistence_engine' in options: options['persistence_engine'] = reference_to_path( options['persistence_engine']) if 'id' in options: self._id = options['id'] self._options.update(options)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement call identifier argument_list identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Safely update this async job's configuration options.
def check(self, diff): path = diff.b_path assert any( path.endswith(ext) for ext in importlib.machinery.SOURCE_SUFFIXES )
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier assert_statement call identifier generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier attribute attribute identifier identifier identifier
Check that the new file introduced is a python source file
def check_ast(self): try: tree = compile(''.join(self.lines), '', 'exec', PyCF_ONLY_AST) except (ValueError, SyntaxError, TypeError): return self.report_invalid_syntax() for name, cls, __ in self._ast_checks: checker = cls(tree, self.filename) for lineno, offset, text, check in checker.run(): if not self.lines or not noqa(self.lines[lineno - 1]): self.report_error(lineno, offset, text, check)
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call identifier argument_list call attribute string string_start string_end identifier argument_list attribute identifier identifier string string_start string_end string string_start string_content string_end identifier except_clause tuple identifier identifier identifier block return_statement call attribute identifier identifier argument_list for_statement pattern_list identifier identifier identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier for_statement pattern_list identifier identifier identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator not_operator attribute identifier identifier not_operator call identifier argument_list subscript attribute identifier identifier binary_operator identifier integer block expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier
Build the file's AST and run all AST checks.
def assure_check(fnc): @wraps(fnc) def _wrapped(self, check, *args, **kwargs): if not isinstance(check, CloudMonitorCheck): check = self._check_manager.get(check) return fnc(self, check, *args, **kwargs) return _wrapped
module function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call identifier argument_list identifier identifier list_splat identifier dictionary_splat identifier return_statement identifier
Converts an checkID passed as the check to a CloudMonitorCheck object.
def _reformat(p, buf): if numpy.ndim(buf) != 1: raise ValueError("Buffer ``buf`` must be 1-d.") if hasattr(p, 'keys'): ans = _gvar.BufferDict(p) if ans.size != len(buf): raise ValueError( "p, buf size mismatch: %d, %d"%(ans.size, len(buf))) ans = _gvar.BufferDict(ans, buf=buf) else: if numpy.size(p) != len(buf): raise ValueError( "p, buf size mismatch: %d, %d"%(numpy.size(p), len(buf))) ans = numpy.array(buf).reshape(numpy.shape(p)) return ans
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list identifier integer block raise_statement call identifier argument_list string string_start string_content string_end if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier call identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier else_clause block if_statement comparison_operator call attribute identifier identifier argument_list identifier call identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple call attribute identifier identifier argument_list identifier call identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement identifier
Apply format of ``p`` to data in 1-d array ``buf``.
def md5_hash_file(fh): md5 = hashlib.md5() while True: data = fh.read(8192) if not data: break md5.update(data) return md5.hexdigest()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list integer if_statement not_operator identifier block break_statement expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list
Return the md5 hash of the given file-object
def config_conf(obj): "Extracts the configuration of the underlying ConfigParser from obj" cfg = {} for name in dir(obj): if name in CONFIG_PARSER_CFG: cfg[name] = getattr(obj, name) return cfg
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier dictionary for_statement identifier call identifier argument_list identifier block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier identifier return_statement identifier
Extracts the configuration of the underlying ConfigParser from obj
def add_cache(self, object_type, cache_impl_name, maxsize, **kwargs): if object_type not in ZendeskObjectMapping.class_mapping: raise ZenpyException("No such object type: %s" % object_type) self.cache.mapping[object_type] = ZenpyCache(cache_impl_name, maxsize, **kwargs)
module function_definition identifier parameters identifier identifier identifier identifier dictionary_splat_pattern identifier block if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment subscript attribute attribute identifier identifier identifier identifier call identifier argument_list identifier identifier dictionary_splat identifier
Add a new cache for the named object type and cache implementation
def imagetransformer_cifar_tpu_range(rhp): rhp.set_float("learning_rate", 0.01, 1.0, scale=rhp.LOG_SCALE) rhp.set_discrete("num_decoder_layers", [8, 10, 12, 14, 16]) rhp.set_discrete("hidden_size", [256, 512, 1024]) rhp.set_discrete("block_length", [128, 256, 512]) rhp.set_categorical("dec_attention_type", [ cia.AttentionType.RELATIVE_LOCAL_1D, cia.AttentionType.LOCAL_1D])
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end float float keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end list integer integer integer integer integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end list integer integer integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end list integer integer integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier
Range of hyperparameters for vizier.
def insert_short(self, index, value): format = '!H' self.data.insert(index, struct.pack(format, value)) self.size += 2
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier identifier expression_statement augmented_assignment attribute identifier identifier integer
Inserts an unsigned short in a certain position in the packet
def regex_to_error_msg(regex): return re.sub('([^\\\\])[()]', '\\1', regex) \ .replace('[ \t]*$', '') \ .replace('^', '') \ .replace('$', '') \ .replace('[ \t]*', ' ') \ .replace('[ \t]+', ' ') \ .replace('[0-9]+', 'X') \ \ .replace('\\[', '[') \ .replace('\\]', ']') \ .replace('\\(', '(') \ .replace('\\)', ')') \ .replace('\\.', '.')
module function_definition identifier parameters identifier block return_statement call attribute call attribute call attribute call attribute call attribute call attribute call attribute call attribute call attribute call attribute call attribute call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end string string_start string_content escape_sequence string_end identifier line_continuation identifier argument_list string string_start string_content escape_sequence string_end string string_start string_end line_continuation identifier argument_list string string_start string_content string_end string string_start string_end line_continuation identifier argument_list string string_start string_content string_end string string_start string_end line_continuation identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end line_continuation identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end line_continuation identifier argument_list string string_start string_content string_end string string_start string_content string_end line_continuation line_continuation identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end line_continuation identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end line_continuation identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end line_continuation identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end line_continuation identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end
Format a human-readable error message from a regex
def seaborn_bar_(self, label=None, style=None, opts=None): try: fig = sns.barplot(self.x, self.y, palette="BuGn_d") return fig except Exception as e: self.err(e, self.seaborn_bar_, "Can not get Seaborn bar chart object")
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end return_statement identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier string string_start string_content string_end
Get a Seaborn bar chart
def format_directive(module, package=None): directive = '.. automodule:: %s\n' % makename(package, module) for option in OPTIONS: directive += ' :%s:\n' % option return directive
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier binary_operator string string_start string_content escape_sequence string_end call identifier argument_list identifier identifier for_statement identifier identifier block expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence string_end identifier return_statement identifier
Create the automodule directive and add the options.
def clusters(self): if not hasattr(self, "_clusters"): cs = {} for cr in self.doc["clusters"]: cs[cr["name"]] = c = copy.deepcopy(cr["cluster"]) if "server" not in c: c["server"] = "http://localhost" BytesOrFile.maybe_set(c, "certificate-authority") self._clusters = cs return self._clusters
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier dictionary for_statement identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment subscript identifier subscript identifier string string_start string_content string_end assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier return_statement attribute identifier identifier
Returns known clusters by exposing as a read-only property.
def _get_child_relation(self, child_pid): return PIDRelation.query.filter_by( parent=self._resolved_pid, child=child_pid, relation_type=self.relation_type.id).one()
module function_definition identifier parameters identifier identifier block return_statement call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier identifier argument_list
Retrieve the relation between this node and a child PID.
def convert_caffe_model(model_name, meta_info, dst_dir='./model'): (prototxt, caffemodel, mean) = download_caffe_model(model_name, meta_info, dst_dir) model_name = os.path.join(dst_dir, model_name) convert_model(prototxt, caffemodel, model_name) if isinstance(mean, str): mx_mean = model_name + '-mean.nd' convert_mean(mean, mx_mean) mean = mx_mean return (model_name, mean)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment tuple_pattern identifier identifier identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call identifier argument_list identifier identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier binary_operator identifier string string_start string_content string_end expression_statement call identifier argument_list identifier identifier expression_statement assignment identifier identifier return_statement tuple identifier identifier
Download, convert and save a caffe model
def export(self, timestamp=None, info={}): tval = tuple(time.localtime()) if timestamp is None else timestamp tstamp = time.strftime(self.timestamp_format, tval) info = dict(info, timestamp=tstamp) export_name = self._format(self.export_name, info) files = [((self._format(base, info), ext), val) for ((base, ext), val) in self._files.items()] root = os.path.abspath(self.root) if len(self) > 1 and not self.pack: self._directory_archive(export_name, files, root) elif len(files) == 1: self._single_file_archive(export_name, files, root) elif self.archive_format == 'zip': self._zip_archive(export_name, files, root) elif self.archive_format == 'tar': self._tar_archive(export_name, files, root) if self.flush_archive: self._files = OrderedDict()
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier dictionary block expression_statement assignment identifier conditional_expression call identifier argument_list call attribute identifier identifier argument_list comparison_operator identifier none identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier list_comprehension tuple tuple call attribute identifier identifier argument_list identifier identifier identifier identifier for_in_clause tuple_pattern tuple_pattern identifier identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement boolean_operator comparison_operator call identifier argument_list identifier integer not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier elif_clause comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list identifier identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier identifier identifier if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list
Export the archive, directory or file.
def create(self, name): if not os.path.exists(self.directory): os.makedirs(self.directory) filename = self.get_new_filename(name) with open(os.path.join(self.directory, filename), 'w') as fp: fp.write("def up(db): pass\n\n\n") fp.write("def down(db): pass\n") logger.info(filename)
module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier with_statement with_clause with_item as_pattern call identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence escape_sequence string_end expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list identifier
Create a new empty migration.
def destroy(self): resp = {} for key in self.keys: resp[key] = self.database.xgroup_destroy(key, self.name) return resp
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier return_statement identifier
Destroy the consumer group.
def create_module(clear_target, target): if os.path.exists(target): if clear_target: shutil.rmtree(target) else: log("Target exists! Use --clear to delete it first.", emitter='MANAGE') sys.exit(2) done = False info = None while not done: info = _ask_questionnaire() pprint(info) done = _ask('Is the above correct', default='y', data_type='bool') augmented_info = _augment_info(info) log("Constructing module %(plugin_name)s" % info) _construct_module(augmented_info, target)
module function_definition identifier parameters identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer expression_statement assignment identifier false expression_statement assignment identifier none while_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list expression_statement call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call identifier argument_list identifier identifier
Creates a new template HFOS plugin module
def _metadata_is_invalid(cls, fact): return any(isinstance(token, URIRef) and ' ' in token for token in fact)
module function_definition identifier parameters identifier identifier block return_statement call identifier generator_expression boolean_operator call identifier argument_list identifier identifier comparison_operator string string_start string_content string_end identifier for_in_clause identifier identifier
Determines if the fact is not well formed.
def remove_tag(tag_id): entry = TabPost2Tag.delete().where( TabPost2Tag.tag_id == tag_id ) entry.execute()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list comparison_operator attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list
Delete the records of certain tag.
def periodic_callback(self): if self.stopped: return if not self.scanning and len(self._connections) == 0 and self.connecting_count == 0: self._logger.info("Restarting scan for devices") self.start_scan(self._active_scan) self._logger.info("Finished restarting scan for devices")
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement if_statement boolean_operator boolean_operator not_operator attribute identifier identifier comparison_operator call identifier argument_list attribute identifier identifier integer comparison_operator attribute identifier identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
Periodic cleanup tasks to maintain this adapter, should be called every second
def _getMethodsVoc(self): methods = api.search({ "portal_type": "Method", "is_active": True }, "bika_setup_catalog") items = map(lambda m: (api.get_uid(m), api.get_title(m)), methods) items.sort(lambda x, y: cmp(x[1], y[1])) items.insert(0, ("", _("Not specified"))) return DisplayList(list(items))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end true string string_start string_content string_end expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier tuple call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list lambda lambda_parameters identifier identifier call identifier argument_list subscript identifier integer subscript identifier integer expression_statement call attribute identifier identifier argument_list integer tuple string string_start string_end call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list call identifier argument_list identifier
Return the registered methods as DisplayList
def _on_request(self, name, args): if IS_PYTHON3: name = decode_if_bytes(name) handler = self._request_handlers.get(name, None) if not handler: msg = self._missing_handler_error(name, 'request') error(msg) raise ErrorResponse(msg) debug('calling request handler for "%s", args: "%s"', name, args) rv = handler(*args) debug("request handler for '%s %s' returns: %s", name, args, rv) return rv
module function_definition identifier parameters identifier identifier identifier block if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier none if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement call identifier argument_list identifier raise_statement call identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment identifier call identifier argument_list list_splat identifier expression_statement call identifier argument_list string string_start string_content string_end identifier identifier identifier return_statement identifier
Handle a msgpack-rpc request.
def load_archive(self, args): import warnings warnings.warn("`Task.load_archive()` is deprecated! " "`Catalog.load_url` handles the same functionality.") return self.archived or args.archived
module function_definition identifier parameters identifier identifier block import_statement dotted_name identifier expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end return_statement boolean_operator attribute identifier identifier attribute identifier identifier
Whether previously archived data should be loaded.
def _pys_assert_version(self, line): if float(line.strip()) > 1.0: msg = _("File version {version} unsupported (>1.0).").format( version=line.strip()) raise ValueError(msg)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list call attribute identifier identifier argument_list float block expression_statement assignment identifier call attribute call identifier argument_list string string_start string_content string_end identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list raise_statement call identifier argument_list identifier
Asserts pys file version
def killCells(self, killCellPercent): if killCellPercent <= 0: return numHiddenNeurons = self.net.numHiddenNeurons numDead = round(killCellPercent * numHiddenNeurons) zombiePermutation = numpy.random.permutation(numHiddenNeurons) deadCells = zombiePermutation[0:numDead] liveCells = zombiePermutation[numDead:] self.net.inputWeights = self.net.inputWeights[liveCells, :] self.net.bias = self.net.bias[:, liveCells] self.net.beta = self.net.beta[liveCells, :] self.net.M = self.net.M[liveCells, liveCells] self.net.numHiddenNeurons = numHiddenNeurons - numDead
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier integer block return_statement expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier subscript identifier slice integer identifier expression_statement assignment identifier subscript identifier slice identifier expression_statement assignment attribute attribute identifier identifier identifier subscript attribute attribute identifier identifier identifier identifier slice expression_statement assignment attribute attribute identifier identifier identifier subscript attribute attribute identifier identifier identifier slice identifier expression_statement assignment attribute attribute identifier identifier identifier subscript attribute attribute identifier identifier identifier identifier slice expression_statement assignment attribute attribute identifier identifier identifier subscript attribute attribute identifier identifier identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier binary_operator identifier identifier
kill a fraction of cells from the network
def geigh(H,S): "Solve the generalized eigensystem Hc = ESc" A = cholorth(S) E,U = np.linalg.eigh(simx(H,A)) return E,np.dot(A,U)
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier identifier return_statement expression_list identifier call attribute identifier identifier argument_list identifier identifier
Solve the generalized eigensystem Hc = ESc
def dump_type(self, obj): if not isinstance(obj.relation_type, RelationType): return resolve_relation_type_config(obj.relation_type).name else: return obj.relation_type.name
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list attribute identifier identifier identifier block return_statement attribute call identifier argument_list attribute identifier identifier identifier else_clause block return_statement attribute attribute identifier identifier identifier
Dump the text name of the relation.
def annotated_dataset_path(cls, project, dataset, annotated_dataset): return google.api_core.path_template.expand( "projects/{project}/datasets/{dataset}/annotatedDatasets/{annotated_dataset}", project=project, dataset=dataset, annotated_dataset=annotated_dataset, )
module function_definition identifier parameters identifier identifier identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Return a fully-qualified annotated_dataset string.
def _emit_all(self, tokenlist): if tokenlist and isinstance(tokenlist[0], tokens.Text): self._emit_text(tokenlist.pop(0).text) self._push_textbuffer() self._stack.extend(tokenlist)
module function_definition identifier parameters identifier identifier block if_statement boolean_operator identifier call identifier argument_list subscript identifier integer attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute call attribute identifier identifier argument_list integer identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Write a series of tokens to the current stack at once.
def remove(self, value, _sa_initiator=None): key = self.keyfunc(value) if not self.__contains__(key) or value not in self[key]: raise sa_exc.InvalidRequestError( "Can not remove '%s': collection holds '%s' for key '%s'. " "Possible cause: is the MappedCollection key function " "based on mutable properties or properties that only obtain " "values after flush?" % (value, self[key], key)) self.__getitem__(key, _sa_initiator).remove(value)
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement boolean_operator not_operator call attribute identifier identifier argument_list identifier comparison_operator identifier subscript identifier identifier block raise_statement call attribute identifier identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end tuple identifier subscript identifier identifier identifier expression_statement call attribute call attribute identifier identifier argument_list identifier identifier identifier argument_list identifier
Remove an item by value, consulting the keyfunc for the key.
def _create_record(self, rtype, name, content): existing_records = self._list_records(rtype, name, content) if len(existing_records) >= 1: return True record = { "record_type": rtype, "name": self._relative_name(name), "content": content, } if self._get_lexicon_option("ttl"): record["ttl"] = self._get_lexicon_option("ttl") if self._get_lexicon_option("priority"): record["prio"] = self._get_lexicon_option("priority") payload = self._post( "/v1/domains/{0}/records".format(self.domain), {"record": record}, ) status = "id" in payload.get("record", {}) LOGGER.debug("create_record: %s", status) return status
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block return_statement true expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier pair string string_start string_content string_end identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier comparison_operator string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end dictionary expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement identifier
Create record if doesnt already exist with same content
def _int_generator(descriptor, bitwidth, unsigned): 'Helper to create a basic integer value generator' vals = list(values.get_integers(bitwidth, unsigned)) return gen.IterValueGenerator(descriptor.name, vals)
module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier identifier
Helper to create a basic integer value generator
async def read(cls, id: int): data = await cls._handler.read(id=id) return cls(data)
module function_definition identifier parameters identifier typed_parameter identifier type identifier block expression_statement assignment identifier await call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier return_statement call identifier argument_list identifier
Get `BootResource` by `id`.
def percolate(self, index, doc_types, query): if doc_types is None: raise RuntimeError('percolate() must be supplied with at least one doc_type') path = self._make_path(index, doc_types, '_percolate') body = self._encode_query(query) return self._send_request('GET', path, body)
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier
Match a query with a document
def push(self, value): if self.closed and not self.allow_add_after_close: Log.error("Do not push to closed queue") with self.lock: self._wait_for_queue_space() if not self.closed: self.queue.appendleft(value) return self
module function_definition identifier parameters identifier identifier block if_statement boolean_operator attribute identifier identifier not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end with_statement with_clause with_item attribute identifier identifier block expression_statement call attribute identifier identifier argument_list if_statement not_operator attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
SNEAK value TO FRONT OF THE QUEUE
def mid_point(self): midpoint_angle = self.from_angle + self.sign*self.length_degrees() / 2 return self.angle_as_point(midpoint_angle)
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator attribute identifier identifier binary_operator binary_operator attribute identifier identifier call attribute identifier identifier argument_list integer return_statement call attribute identifier identifier argument_list identifier
Returns the midpoint of the arc as a 1x2 numpy array.
def reports(self): if self._metrics is None: self.__init() self._reports = [] for r in self._metrics: url = self._url + "/%s" % six.moves.urllib.parse.quote_plus(r['reportname']) self._reports.append(UsageReport(url=url, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port, initialize=True)) del url return self._reports
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier binary_operator string string_start string_content string_end call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier true delete_statement identifier return_statement attribute identifier identifier
returns a list of reports on the server
def fstab_mount(mountpoint): cmd_args = ['mount', mountpoint] try: subprocess.check_output(cmd_args) except subprocess.CalledProcessError as e: log('Error unmounting {}\n{}'.format(mountpoint, e.output)) return False return True
module function_definition identifier parameters identifier block expression_statement assignment identifier list string string_start string_content string_end identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier attribute identifier identifier return_statement false return_statement true
Mount filesystem using fstab
def clean_weight_files(cls): deleted = [] for f in cls._files: try: os.remove(f) deleted.append(f) except FileNotFoundError: pass print('Deleted %d weight files' % len(deleted)) cls._files = []
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement expression_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement assignment attribute identifier identifier list
Cleans existing weight files.
def unpack(value): if not isinstance(value, tuple): return value, 200, {} try: data, code, headers = value return data, code, headers except ValueError: pass try: data, code = value return data, code, {} except ValueError: pass return value, 200, {}
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier identifier block return_statement expression_list identifier integer dictionary try_statement block expression_statement assignment pattern_list identifier identifier identifier identifier return_statement expression_list identifier identifier identifier except_clause identifier block pass_statement try_statement block expression_statement assignment pattern_list identifier identifier identifier return_statement expression_list identifier identifier dictionary except_clause identifier block pass_statement return_statement expression_list identifier integer dictionary
Return a three tuple of data, code, and headers
def detect_old(data): "Check for a config file with old schema" if not data: return False ok, errors, warnings = _schema.validate(_OLD_SCHEMA, data) return ok and not (errors or warnings)
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement not_operator identifier block return_statement false expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier identifier return_statement boolean_operator identifier not_operator parenthesized_expression boolean_operator identifier identifier
Check for a config file with old schema
def restart_agent(self, agent_id, **kwargs): host_medium = self.get_medium('host_agent') agent = host_medium.get_agent() d = host_medium.get_document(agent_id) d.addCallback( lambda desc: agent.start_agent(desc.doc_id, **kwargs)) return d
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list lambda lambda_parameters identifier call attribute identifier identifier argument_list attribute identifier identifier dictionary_splat identifier return_statement identifier
tells the host agent running in this agency to restart the agent.
def substitute_timestep(self, regex, timestep): timestep_changed = False while True: matches = re.finditer(regex, self.str, re.MULTILINE | re.DOTALL) none_updated = True for m in matches: if m.group(1) == timestep: continue else: self.str = (self.str[:m.start(1)] + timestep + self.str[m.end(1):]) none_updated = False timestep_changed = True break if none_updated: break if not timestep_changed: sys.stderr.write('WARNING: no update with {0}.\n'.format(regex))
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier false while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier true for_statement identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list integer identifier block continue_statement else_clause block expression_statement assignment attribute identifier identifier parenthesized_expression binary_operator binary_operator subscript attribute identifier identifier slice call attribute identifier identifier argument_list integer identifier subscript attribute identifier identifier slice call attribute identifier identifier argument_list integer expression_statement assignment identifier false expression_statement assignment identifier true break_statement if_statement identifier block break_statement if_statement not_operator identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier
Substitute a new timestep value using regex.
def refresh(self): d = self.rr.table(self.table).get(self.pk_value).run() if d is None: raise KeyError for k in d: dict.__setitem__( self, k, watch(d[k], callback=self._updated, field=k))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier argument_list attribute identifier identifier identifier argument_list if_statement comparison_operator identifier none block raise_statement identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier call identifier argument_list subscript identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier
Refresh the document from the database.
def __geomToStringArray(self, geometries, returnType="str"): listGeoms = [] for g in geometries: if isinstance(g, Point): listGeoms.append(g.asDictionary) elif isinstance(g, Polygon): listGeoms.append(g.asDictionary) elif isinstance(g, Polyline): listGeoms.append({'paths' : g.asDictionary['paths']}) if returnType == "str": return json.dumps(listGeoms) elif returnType == "list": return listGeoms else: return json.dumps(listGeoms)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier list for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement identifier else_clause block return_statement call attribute identifier identifier argument_list identifier
function to convert the geomtries to strings
def convert(self, blob, size=500): file_list = [] with make_temp_file(blob) as in_fn, make_temp_file() as out_fn: try: subprocess.check_call(["pdftoppm", "-jpeg", in_fn, out_fn]) file_list = sorted(glob.glob(f"{out_fn}-*.jpg")) converted_images = [] for fn in file_list: converted = resize(open(fn, "rb").read(), size, size) converted_images.append(converted) return converted_images except Exception as e: raise ConversionError("pdftoppm failed") from e finally: for fn in file_list: try: os.remove(fn) except OSError: pass
module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement assignment identifier list with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier with_item as_pattern call identifier argument_list as_pattern_target identifier block try_statement block expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list string string_start interpolation identifier string_content string_end expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute call identifier argument_list identifier string string_start string_content string_end identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list string string_start string_content string_end identifier finally_clause block for_statement identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement
Size is the maximum horizontal size.
def getComplexFileData(self, fileInfo, data): result = fileInfo[fileInfo.find(data + "</td>") + len(data + "</td>"):] result = result[:result.find("</td>")] result = result[result.rfind(">") + 1:] return result
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript identifier slice binary_operator call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end call identifier argument_list binary_operator identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier slice call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript identifier slice binary_operator call attribute identifier identifier argument_list string string_start string_content string_end integer return_statement identifier
Function to initialize the slightly more complicated data for file info
def tox_addoption(parser): parser.add_argument( '--travis-after', dest='travis_after', action='store_true', help='Exit successfully after all Travis jobs complete successfully.') if 'TRAVIS' in os.environ: pypy_version_monkeypatch() subcommand_test_monkeypatch(tox_subcommand_test_post)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement call identifier argument_list expression_statement call identifier argument_list identifier
Add arguments and needed monkeypatches.
def visit_Name(self, node: ast.Name) -> Any: if not isinstance(node.ctx, ast.Load): raise NotImplementedError("Can only compute a value of Load on a name {}, but got context: {}".format( node.id, node.ctx)) result = None if node.id in self._name_to_value: result = self._name_to_value[node.id] if result is None and hasattr(builtins, node.id): result = getattr(builtins, node.id) if result is None and node.id != "None": return PLACEHOLDER self.recomputed_values[node] = result return result
module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier type identifier block if_statement not_operator call identifier argument_list attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier none if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier if_statement boolean_operator comparison_operator identifier none call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier if_statement boolean_operator comparison_operator identifier none comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement identifier expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement identifier
Load the variable by looking it up in the variable look-up and in the built-ins.
def select_functions(expr): body = Group(expr) return Group( function("timestamp", body, caseless=True) | function("ts", body, caseless=True) | function("utctimestamp", body, caseless=True) | function("utcts", body, caseless=True) | function("now", caseless=True) | function("utcnow", caseless=True) ).setResultsName("function")
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute call identifier argument_list binary_operator binary_operator binary_operator binary_operator binary_operator call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier true call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier true call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier true call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier true call identifier argument_list string string_start string_content string_end keyword_argument identifier true call identifier argument_list string string_start string_content string_end keyword_argument identifier true identifier argument_list string string_start string_content string_end
Create the function expressions for selection
def deepcopy(data): try: return pickle.loads(pickle.dumps(data)) except TypeError: return copy.deepcopy(data)
module function_definition identifier parameters identifier block try_statement block return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier except_clause identifier block return_statement call attribute identifier identifier argument_list identifier
Use pickle to do deep_copy
def hard_delete(self): 'Deletes without possibility to restore' url = 'https://www.jottacloud.com/rest/webrest/%s/action/delete' % self.jfs.username data = {'paths[]': self.path.replace(JFS_ROOT, ''), 'web': 'true', 'ts': int(time.time()), 'authToken': 0} r = self.jfs.post(url, content=data) return r
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier string string_start string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list pair string string_start string_content string_end integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier return_statement identifier
Deletes without possibility to restore
def string_array(self): assert len(self.dimensions) == 2, \ '{}: cannot get value as string array!'.format(self.name) l, n = self.dimensions return [self.bytes[i*l:(i+1)*l].decode('utf-8') for i in range(n)]
module function_definition identifier parameters identifier block assert_statement comparison_operator call identifier argument_list attribute identifier identifier integer call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment pattern_list identifier identifier attribute identifier identifier return_statement list_comprehension call attribute subscript attribute identifier identifier slice binary_operator identifier identifier binary_operator parenthesized_expression binary_operator identifier integer identifier identifier argument_list string string_start string_content string_end for_in_clause identifier call identifier argument_list identifier
Get the param as a array of unicode strings.
def load_datafile(self, name, search_path=None, **kwargs): if not search_path: search_path = self.define_dir self.debug_msg('loading datafile %s from %s' % (name, str(search_path))) return codec.load_datafile(name, search_path, **kwargs)
module function_definition identifier parameters identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier
find datafile and load them from codec
def run_select_calculation(self): inputs = { 'cif': self.ctx.cif, 'code': self.inputs.cif_select, 'parameters': self.inputs.cif_select_parameters, 'metadata': { 'options': self.inputs.options.get_dict(), } } calculation = self.submit(CifSelectCalculation, **inputs) self.report('submitted {}<{}>'.format(CifSelectCalculation.__name__, calculation.uuid)) return ToContext(cif_select=calculation)
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end dictionary pair string string_start string_content string_end call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier return_statement call identifier argument_list keyword_argument identifier identifier
Run the CifSelectCalculation on the CifData output node of the CifFilterCalculation.
def compute_column_width_and_height(self): if not self.rows: return for row in self.rows: max_row_height = max((len(cell.get_cell_lines()) for cell in row.columns)) if row.columns else 1 for cell in row.columns: cell.height = max_row_height max_columns = max([len(row.columns) for row in self.rows]) for column_idx in range(max_columns): row_cell_lines = [row.get_cell_lines(column_idx) for row in self.rows] max_column_width = max((len(line) for line in chain(*row_cell_lines))) for row in self.rows: if len(row.columns) > column_idx: row.columns[column_idx].width = max_column_width
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement for_statement identifier attribute identifier identifier block expression_statement assignment identifier conditional_expression call identifier argument_list generator_expression call identifier argument_list call attribute identifier identifier argument_list for_in_clause identifier attribute identifier identifier attribute identifier identifier integer for_statement identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list list_comprehension call identifier argument_list attribute identifier identifier for_in_clause identifier attribute identifier identifier for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list generator_expression call identifier argument_list identifier for_in_clause identifier call identifier argument_list list_splat identifier for_statement identifier attribute identifier identifier block if_statement comparison_operator call identifier argument_list attribute identifier identifier identifier block expression_statement assignment attribute subscript attribute identifier identifier identifier identifier identifier
compute and set the column width for all colls in the table
def worker_thread(context): queue = context.task_queue parameters = context.worker_parameters if parameters.initializer is not None: if not run_initializer(parameters.initializer, parameters.initargs): context.state = ERROR return for task in get_next_task(context, parameters.max_tasks): execute_next_task(task) queue.task_done()
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block if_statement not_operator call identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier return_statement for_statement identifier call identifier argument_list identifier attribute identifier identifier block expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
The worker thread routines.
def _find_datastream(self, name): for stream in self.data_streams: if stream.name == name: return stream return None
module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block return_statement identifier return_statement none
Find and return if a datastream exists, by name.
def move_phasecenter(d, l1, m1, u, v): logger.info('Rephasing data to (l, m)=(%.4f, %.4f).' % (l1, m1)) data_resamp = numpyview(data_resamp_mem, 'complex64', datashape(d)) rtlib.phaseshift_threaded(data_resamp, d, l1, m1, u, v)
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier
Handler function for phaseshift_threaded
def job_requeue_message(self, job, queue): priority, delayed_until = job.hmget('priority', 'delayed_until') msg = '[%s|%s|%s] requeued with priority %s' args = [queue._cached_name, job.pk.get(), job._cached_identifier, priority] if delayed_until: msg += ', delayed until %s' args.append(delayed_until) return msg % tuple(args)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier list attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier if_statement identifier block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement binary_operator identifier call identifier argument_list identifier
Return the message to log when a job is requeued
def _init_name_core(self, name: str): self.__regex = re.compile(rf'^{self._pattern}$') self.name = name
module function_definition identifier parameters identifier typed_parameter identifier type identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content interpolation attribute identifier identifier string_content string_end expression_statement assignment attribute identifier identifier identifier
Runs whenever a new instance is initialized or `sep` is set.
def masters(self): fut = self.execute(b'MASTERS', encoding='utf-8') return wait_convert(fut, parse_sentinel_masters)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end return_statement call identifier argument_list identifier identifier
Returns a list of dictionaries containing each master's state.
def helper(self, name, *args): py_name = ast.Name("@dessert_ar", ast.Load()) attr = ast.Attribute(py_name, "_" + name, ast.Load()) return ast_Call(attr, list(args), [])
module function_definition identifier parameters identifier identifier list_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier binary_operator string string_start string_content string_end identifier call attribute identifier identifier argument_list return_statement call identifier argument_list identifier call identifier argument_list identifier list
Call a helper in this module.
def _cached(self, dbname, coll, index): cache = self.__index_cache now = datetime.datetime.utcnow() with self.__index_cache_lock: return (dbname in cache and coll in cache[dbname] and index in cache[dbname][coll] and now < cache[dbname][coll][index])
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list with_statement with_clause with_item attribute identifier identifier block return_statement parenthesized_expression boolean_operator boolean_operator boolean_operator comparison_operator identifier identifier comparison_operator identifier subscript identifier identifier comparison_operator identifier subscript subscript identifier identifier identifier comparison_operator identifier subscript subscript subscript identifier identifier identifier identifier
Test if `index` is cached.
def resolve(object): import re sesame_cmd = 'curl -s http://cdsweb.u-strasbg.fr/viz-bin/nph-sesame/-oI?'+string.replace(object,' ','') f = os.popen(sesame_cmd) lines = f.readlines() f.close() for line in lines: if re.search('%J ', line): result2 = line.split() ra_deg = float(result2[1]) dec_deg = float(result2[2]) return (ra_deg, dec_deg) return (0,0)
module function_definition identifier parameters identifier block import_statement dotted_name identifier expression_statement assignment identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list for_statement identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list subscript identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier integer return_statement tuple identifier identifier return_statement tuple integer integer
Look up the name of a source using a resolver
def encrypted_json(self): json = serialize(objects=[self.instance]) encrypted_json = Cryptor().aes_encrypt(json, LOCAL_MODE) return encrypted_json
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier list attribute identifier identifier expression_statement assignment identifier call attribute call identifier argument_list identifier argument_list identifier identifier return_statement identifier
Returns an encrypted json serialized from self.
def updateFromInspectorRegItem(self, inspectorRegItem): library, name = inspectorRegItem.splitName() label = "{} ({})".format(name, library) if library else name self.menuButton.setText(label)
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier conditional_expression call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Updates the label from the full name of the InspectorRegItem
def build_agency(pfeed): return pd.DataFrame({ 'agency_name': pfeed.meta['agency_name'].iat[0], 'agency_url': pfeed.meta['agency_url'].iat[0], 'agency_timezone': pfeed.meta['agency_timezone'].iat[0], }, index=[0])
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end subscript attribute subscript attribute identifier identifier string string_start string_content string_end identifier integer pair string string_start string_content string_end subscript attribute subscript attribute identifier identifier string string_start string_content string_end identifier integer pair string string_start string_content string_end subscript attribute subscript attribute identifier identifier string string_start string_content string_end identifier integer keyword_argument identifier list integer
Given a ProtoFeed, return a DataFrame representing ``agency.txt``
def optimize_rfc(data, targets): def rfc_crossval(n_estimators, min_samples_split, max_features): return rfc_cv( n_estimators=int(n_estimators), min_samples_split=int(min_samples_split), max_features=max(min(max_features, 0.999), 1e-3), data=data, targets=targets, ) optimizer = BayesianOptimization( f=rfc_crossval, pbounds={ "n_estimators": (10, 250), "min_samples_split": (2, 25), "max_features": (0.1, 0.999), }, random_state=1234, verbose=2 ) optimizer.maximize(n_iter=10) print("Final result:", optimizer.max)
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier identifier identifier block return_statement call identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list call identifier argument_list identifier float float keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end tuple integer integer pair string string_start string_content string_end tuple integer integer pair string string_start string_content string_end tuple float float keyword_argument identifier integer keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list keyword_argument identifier integer expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier
Apply Bayesian Optimization to Random Forest parameters.
def contains_shebang(f): first_line = f.readline() if first_line in shebangs.values(): return True return False
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier call attribute identifier identifier argument_list block return_statement true return_statement false
Returns true if any shebang line is present in the first line of the file.
def action_checkbox(self, obj): if self.check_concurrent_action: return helpers.checkbox.render(helpers.ACTION_CHECKBOX_NAME, force_text("%s,%s" % (obj.pk, get_revision_of_object(obj)))) else: return super(ConcurrencyActionMixin, self).action_checkbox(obj)
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier call identifier argument_list identifier else_clause block return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier
A list_display column containing a checkbox widget.
def place_oceans_at_map_borders(world): ocean_border = int(min(30, max(world.width / 5, world.height / 5))) def place_ocean(x, y, i): world.layers['elevation'].data[y, x] = \ (world.layers['elevation'].data[y, x] * i) / ocean_border for x in range(world.width): for i in range(ocean_border): place_ocean(x, i, i) place_ocean(x, world.height - i - 1, i) for y in range(world.height): for i in range(ocean_border): place_ocean(i, y, i) place_ocean(world.width - i - 1, y, i)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list integer call identifier argument_list binary_operator attribute identifier identifier integer binary_operator attribute identifier identifier integer function_definition identifier parameters identifier identifier identifier block expression_statement assignment subscript attribute subscript attribute identifier identifier string string_start string_content string_end identifier identifier identifier line_continuation binary_operator parenthesized_expression binary_operator subscript attribute subscript attribute identifier identifier string string_start string_content string_end identifier identifier identifier identifier identifier for_statement identifier call identifier argument_list attribute identifier identifier block for_statement identifier call identifier argument_list identifier block expression_statement call identifier argument_list identifier identifier identifier expression_statement call identifier argument_list identifier binary_operator binary_operator attribute identifier identifier identifier integer identifier for_statement identifier call identifier argument_list attribute identifier identifier block for_statement identifier call identifier argument_list identifier block expression_statement call identifier argument_list identifier identifier identifier expression_statement call identifier argument_list binary_operator binary_operator attribute identifier identifier identifier integer identifier identifier
Lower the elevation near the border of the map
def load(self, fp): cluster = pickle.load(fp) cluster.repository = self return cluster
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
Load cluster from file descriptor fp
def _set_payoff(self, payoff): if self._selected_action is None: raise ValueError("The action has not been selected yet.") if self._closed: raise ValueError("The payoff for this match set has already" "been applied.") self._payoff = float(payoff)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list string string_start string_content string_end if_statement attribute identifier identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list identifier
Setter method for the payoff property.
def _notify_add_at(self, index, length=1): slice_ = self._slice_at(index, length) self._notify_add(slice_)
module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Notify about an AddChange at a caertain index and length.
def _append_domain(opts): if opts['id'].endswith(opts['append_domain']): return opts['id'] if opts['id'].endswith('.'): return opts['id'] return '{0[id]}.{0[append_domain]}'.format(opts)
module function_definition identifier parameters identifier block if_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end block return_statement subscript identifier string string_start string_content string_end if_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end block return_statement subscript identifier string string_start string_content string_end return_statement call attribute string string_start string_content string_end identifier argument_list identifier
Append a domain to the existing id if it doesn't already exist
def to_naf(self): if self.type == 'KAF': for node_coref in self.__get_corefs_nodes(): node_coref.set('id',node_coref.get('coid')) del node_coref.attrib['coid']
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end delete_statement subscript attribute identifier identifier string string_start string_content string_end
Converts the coreference layer to NAF
def _re_raise_as(NewExc, *args, **kw): etype, val, tb = sys.exc_info() raise NewExc(*args, **kw), None, tb
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list raise_statement expression_list call identifier argument_list list_splat identifier dictionary_splat identifier none identifier
Raise a new exception using the preserved traceback of the last one.
def transform_incoming(self, son, collection): if not "_id" in son: return son transformed = SON({"_id": son["_id"]}) transformed.update(son) return transformed
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator comparison_operator string string_start string_content string_end identifier block return_statement identifier expression_statement assignment identifier call identifier argument_list dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Move _id to the front if it's there.
def getHostsFromSGE(): with open(os.environ["PE_HOSTFILE"], 'r') as hosts: return [(host.split()[0], int(host.split()[1])) for host in hosts]
module function_definition identifier parameters block with_statement with_clause with_item as_pattern call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end as_pattern_target identifier block return_statement list_comprehension tuple subscript call attribute identifier identifier argument_list integer call identifier argument_list subscript call attribute identifier identifier argument_list integer for_in_clause identifier identifier
Return a host list in a SGE environment
def override_ignore_outcome(ini): travis_reader = tox.config.SectionReader("travis", ini) return travis_reader.getbool('unignore_outcomes', False)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end false
Decide whether to override ignore_outcomes.
def _load_github_repo(): if 'TRAVIS' in os.environ: raise RuntimeError('Detected that we are running in Travis. ' 'Stopping to prevent infinite loops.') try: with open(os.path.join(config_dir, 'repo'), 'r') as f: return f.read() except (OSError, IOError): raise RuntimeError('Could not find your repository. ' 'Have you ran `trytravis --repo`?')
module function_definition identifier parameters block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end try_statement block with_statement with_clause with_item as_pattern call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end as_pattern_target identifier block return_statement call attribute identifier identifier argument_list except_clause tuple identifier identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end
Loads the GitHub repository from the users config.
def count(self): sql = u'SELECT count() FROM (%s)' % self.as_sql() raw = self._database.raw(sql) return int(raw) if raw else 0
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement conditional_expression call identifier argument_list identifier identifier integer
Returns the number of rows after aggregation.
def prepare_model(self, attrs): if isinstance(attrs, Model): attrs.client = self.client attrs.collection = self return attrs elif isinstance(attrs, dict): return self.model(attrs=attrs, client=self.client, collection=self) else: raise Exception("Can't create %s from %s" % (self.model.__name__, attrs))
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier elif_clause call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute attribute identifier identifier identifier identifier
Create a model from a set of attributes.
def rewrite_elife_funding_awards(json_content, doi): if doi == "10.7554/eLife.00801": for i, award in enumerate(json_content): if "id" in award and award["id"] == "par-2": del json_content[i] if doi == "10.7554/eLife.04250": recipients_for_04250 = [{"type": "person", "name": {"preferred": "Eric Jonas", "index": "Jonas, Eric"}}] for i, award in enumerate(json_content): if "id" in award and award["id"] in ["par-2", "par-3", "par-4"]: if "recipients" not in award: json_content[i]["recipients"] = recipients_for_04250 if doi == "10.7554/eLife.06412": recipients_for_06412 = [{"type": "person", "name": {"preferred": "Adam J Granger", "index": "Granger, Adam J"}}] for i, award in enumerate(json_content): if "id" in award and award["id"] == "par-1": if "recipients" not in award: json_content[i]["recipients"] = recipients_for_06412 return json_content
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block delete_statement subscript identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier list dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator subscript identifier string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript subscript identifier identifier string string_start string_content string_end identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier list dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript subscript identifier identifier string string_start string_content string_end identifier return_statement identifier
rewrite elife funding awards
def _close(self): if self._process is None: return self.quit() self._process.stdin.close() logger.debug("Waiting for ssh process to finish...") self._process.wait() self._process = None
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block return_statement expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none
Close connection to remote host.
def _reset(self): self.path = '' self.version = '' self.release = '' self.is_signed = False self.is_synced = False self.rpm = False
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier string string_start string_end expression_statement assignment attribute identifier identifier string string_start string_end expression_statement assignment attribute identifier identifier string string_start string_end expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier false
Used during update operations and when initialized.
def split(self, text): text = cleanup(text) return self.sent_detector.tokenize(text.strip())
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list
Splits text and returns a list of the resulting sentences.
def _dt_to_epoch(self, dt): if PY2: time_delta = dt - datetime(1970, 1, 1).replace(tzinfo=dt.tzinfo) return int(time_delta.total_seconds()) else: return int(dt.timestamp())
module function_definition identifier parameters identifier identifier block if_statement identifier block expression_statement assignment identifier binary_operator identifier call attribute call identifier argument_list integer integer integer identifier argument_list keyword_argument identifier attribute identifier identifier return_statement call identifier argument_list call attribute identifier identifier argument_list else_clause block return_statement call identifier argument_list call attribute identifier identifier argument_list
Convert a offset-aware datetime to POSIX time.
def _update_partition_srvc_node_ip(self, tenant_name, srvc_ip, vrf_prof=None, part_name=None): self.dcnm_obj.update_project(tenant_name, part_name, service_node_ip=srvc_ip, vrf_prof=vrf_prof, desc="Service Partition")
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end
Function to update srvc_node address of partition.
def apply(self): subst_re = re.compile(self.subst_pattern) for link in self.document.traverse(nodes.reference): substitutions = link.get('varlinks') if not substitutions: continue replacer = self._replace(substitutions, link.children, 1) link['refuri'] = subst_re.sub(replacer, link['refuri']) content = subst_re.sub(replacer, link[0]) link.clear() del link['varlinks'] link.append(nodes.Text(content)) for link in self.document.traverse(nodes.target): substitutions = link.get('varlinks') if not substitutions: continue replacer = self._replace(substitutions, link.children, 0) link['refuri'] = subst_re.sub(replacer, link['refuri']) link.clear() del link['varlinks']
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier integer expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier subscript identifier integer expression_statement call attribute identifier identifier argument_list delete_statement subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier integer expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list delete_statement subscript identifier string string_start string_content string_end
Replace substitutions in hyperlinks with their contents
def unwrap(node): for child in list(node.childNodes): node.parentNode.insertBefore(child, node) remove_node(node)
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call identifier argument_list identifier
Remove a node, replacing it with its children.
def FlipAllowed(self): if not hasattr(self, 'flipped'): raise errors.ParseError('Not defined.') if not self.flipped: return if self.current_expression.operator: if not self.current_expression.operator.lower() in ( 'is', 'contains', 'inset', 'equals'): raise errors.ParseError( 'Keyword \'not\' does not work against operator: {0:s}'.format( self.current_expression.operator))
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator attribute identifier identifier block return_statement if_statement attribute attribute identifier identifier identifier block if_statement not_operator comparison_operator call attribute attribute attribute identifier identifier identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block raise_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list attribute attribute identifier identifier identifier
Raise an error if the not keyword is used where it is not allowed.
def clone_with_new_dockerfile(self, conf, docker_file): log.info("Copying context to add a different dockerfile") self.close() with a_temp_file() as tmpfile: old_t = os.stat(self.tmpfile.name).st_size > 0 if old_t: shutil.copy(self.tmpfile.name, tmpfile.name) with tarfile.open(tmpfile.name, mode="a") as t: conf.add_docker_file_to_tarfile(docker_file, t) yield ContextWrapper(t, tmpfile)
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list with_statement with_clause with_item as_pattern call identifier argument_list as_pattern_target identifier block expression_statement assignment identifier comparison_operator attribute call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier integer if_statement identifier block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement yield call identifier argument_list identifier identifier
Clone this tarfile and add in another filename before closing the new tar and returning