code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def abort(message, *args): if args: raise _AbortException(message.format(*args)) raise _AbortException(message)
module function_definition identifier parameters identifier list_splat_pattern identifier block if_statement identifier block raise_statement call identifier argument_list call attribute identifier identifier argument_list list_splat identifier raise_statement call identifier argument_list identifier
Raise an AbortException, halting task execution and exiting.
def _get_gid(name): if getgrnam is None or name is None: return None try: result = getgrnam(name) except KeyError: result = None if result is not None: return result[2] return None
module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator identifier none comparison_operator identifier none block return_statement none try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block expression_statement assignment identifier none if_statement comparison_operator identifier none block return_statement subscript identifier integer return_statement none
Returns a gid, given a group name.
def map_to_precursor_biopython(seqs, names, loci, args): precursor = precursor_sequence(loci, args.ref).upper() dat = dict() for s, n in itertools.izip(seqs, names): res = _align(str(s), precursor) if res: dat[n] = res logger.debug("mapped in %s: %s out of %s" % (loci, len(dat), len(seqs))) return dat
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier identifier if_statement identifier block expression_statement assignment subscript identifier 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 call identifier argument_list identifier return_statement identifier
map the sequences using biopython package
def get(self): namespaces = db.ConfigNamespace.order_by( ConfigNamespace.sort_order, ConfigNamespace.name ).all() return self.make_response({ 'message': None, 'namespaces': namespaces }, HTTP.OK)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier identifier argument_list return_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end none pair string string_start string_content string_end identifier attribute identifier identifier
List existing config namespaces and their items
def create_index(group, chunk_size, compression=None, compression_opts=None): dtype = np.int64 if chunk_size == 'auto': chunks = True else: chunks = (nb_per_chunk(np.dtype(dtype).itemsize, 1, chunk_size),) group.create_dataset( 'index', (0,), dtype=dtype, chunks=chunks, maxshape=(None,), compression=compression, compression_opts=compression_opts)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier true else_clause block expression_statement assignment identifier tuple call identifier argument_list attribute call attribute identifier identifier argument_list identifier identifier integer identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end tuple integer keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier tuple none keyword_argument identifier identifier keyword_argument identifier identifier
Create an empty index dataset in the given group.
def _notification_callback(method, params): def callback(future): try: future.result() log.debug("Successfully handled async notification %s %s", method, params) except Exception: log.exception("Failed to handle async notification %s %s", method, params) return callback
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier block try_statement block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier return_statement identifier
Construct a notification callback for the given request ID.
def _run_cmdfinalization_hooks(self, stop: bool, statement: Optional[Statement]) -> bool: with self.sigint_protection: if not sys.platform.startswith('win') and self.stdout.isatty(): import subprocess proc = subprocess.Popen(['stty', 'sane']) proc.communicate() try: data = plugin.CommandFinalizationData(stop, statement) for func in self._cmdfinalization_hooks: data = func(data) return data.stop except Exception as ex: self.perror(ex)
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier block with_statement with_clause with_item attribute identifier identifier block if_statement boolean_operator not_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list block import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier
Run the command finalization hooks
def _distance_matrix_generic(x, centering, exponent=1): _check_valid_dcov_exponent(exponent) x = _transform_to_2d(x) a = distances.pairwise_distances(x, exponent=exponent) a = centering(a, out=a) return a
module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier return_statement identifier
Compute a centered distance matrix given a matrix.
def ensure_default_namespace(self) -> Namespace: namespace = self.get_namespace_by_keyword_version(BEL_DEFAULT_NAMESPACE, BEL_DEFAULT_NAMESPACE_VERSION) if namespace is None: namespace = Namespace( name='BEL Default Namespace', contact='charles.hoyt@scai.fraunhofer.de', keyword=BEL_DEFAULT_NAMESPACE, version=BEL_DEFAULT_NAMESPACE_VERSION, url=BEL_DEFAULT_NAMESPACE_URL, ) for name in set(chain(pmod_mappings, gmod_mappings, activity_mapping, compartment_mapping)): entry = NamespaceEntry(name=name, namespace=namespace) self.session.add(entry) self.session.add(namespace) self.session.commit() return namespace
module function_definition identifier parameters identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier for_statement identifier call identifier argument_list call identifier argument_list identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list return_statement identifier
Get or create the BEL default namespace.
def deprecated(message=None): def _decorator(func, message=message): if message is None: message = '%s is deprecated' % func.__name__ def newfunc(*args, **kwds): warnings.warn(message, DeprecationWarning, stacklevel=2) return func(*args, **kwds) return newfunc return _decorator
module function_definition identifier parameters default_parameter identifier none block function_definition identifier parameters identifier default_parameter identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier integer return_statement call identifier argument_list list_splat identifier dictionary_splat identifier return_statement identifier return_statement identifier
A decorator for deprecated functions
def assign_perm(perm, group): if not isinstance(perm, Permission): try: app_label, codename = perm.split('.', 1) except ValueError: raise ValueError("For global permissions, first argument must be in" " format: 'app_label.codename' (is %r)" % perm) perm = Permission.objects.get(content_type__app_label=app_label, codename=codename) group.permissions.add(perm) return perm
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block try_statement block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end integer except_clause identifier block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
Assigns a permission to a group
def regular_subset(spikes, n_spikes_max=None, offset=0): assert spikes is not None if n_spikes_max is None or len(spikes) <= n_spikes_max: return spikes step = math.ceil(np.clip(1. / n_spikes_max * len(spikes), 1, len(spikes))) step = int(step) my_spikes = spikes[offset::step][:n_spikes_max] assert len(my_spikes) <= len(spikes) assert len(my_spikes) <= n_spikes_max return my_spikes
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier integer block assert_statement comparison_operator identifier none if_statement boolean_operator comparison_operator identifier none comparison_operator call identifier argument_list identifier identifier block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list binary_operator binary_operator float identifier call identifier argument_list identifier integer call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier subscript subscript identifier slice identifier identifier slice identifier assert_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier assert_statement comparison_operator call identifier argument_list identifier identifier return_statement identifier
Prune the current selection to get at most n_spikes_max spikes.
def do_edit(self, line): self._split_args(line, 0, 0) self._command_processor.get_operation_queue().edit() self._print_info_if_verbose("The write operation queue was successfully edited")
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier integer integer expression_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
edit Edit the queue of write operations.
def _calc_size_stats(self): self.total_records = 0 self.total_length = 0 self.total_nodes = 0 if type(self.content['data']) is dict: self.total_length += len(str(self.content['data'])) self.total_records += 1 self.total_nodes = sum(len(x) for x in self.content['data'].values()) elif hasattr(self.content['data'], '__iter__') and type(self.content['data']) is not str: self._get_size_recursive(self.content['data']) else: self.total_records += 1 self.total_length += len(str(self.content['data'])) return str(self.total_records) + ' records [or ' + str(self.total_nodes) + ' nodes], taking ' + str(self.total_length) + ' bytes'
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer if_statement comparison_operator call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end identifier block expression_statement augmented_assignment attribute identifier identifier call identifier argument_list call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement augmented_assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier call identifier generator_expression call identifier argument_list identifier for_in_clause identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list elif_clause boolean_operator call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end comparison_operator call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end else_clause block expression_statement augmented_assignment attribute identifier identifier integer expression_statement augmented_assignment attribute identifier identifier call identifier argument_list call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end return_statement binary_operator binary_operator binary_operator binary_operator binary_operator call identifier argument_list attribute identifier identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier string string_start string_content string_end
get the size in bytes and num records of the content
def _loadChildRules(context, xmlElement, attributeToFormatMap): rules = [] for ruleElement in xmlElement.getchildren(): if not ruleElement.tag in _ruleClassDict: raise ValueError("Not supported rule '%s'" % ruleElement.tag) rule = _ruleClassDict[ruleElement.tag](context, ruleElement, attributeToFormatMap) rules.append(rule) return rules
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list block if_statement not_operator comparison_operator attribute identifier identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call subscript identifier attribute identifier identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Extract rules from Context or Rule xml element
def _get_request_fields_from_parent(self): if not self.parent: return None if not getattr(self.parent, 'request_fields'): return None if not isinstance(self.parent.request_fields, dict): return None return self.parent.request_fields.get(self.field_name)
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement none if_statement not_operator call identifier argument_list attribute identifier identifier string string_start string_content string_end block return_statement none if_statement not_operator call identifier argument_list attribute attribute identifier identifier identifier identifier block return_statement none return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier
Get request fields from the parent serializer.
def save(self, commit=True, **kwargs): if self.post: for form in self.forms: form.instance.post = self.post super().save(commit)
module function_definition identifier parameters identifier default_parameter identifier true dictionary_splat_pattern identifier block if_statement attribute identifier identifier block for_statement identifier attribute identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier expression_statement call attribute call identifier argument_list identifier argument_list identifier
Saves the considered instances.
def detach_model(vmssvm_model, lun): data_disks = vmssvm_model['properties']['storageProfile']['dataDisks'] data_disks[:] = [disk for disk in data_disks if disk.get('lun') != lun] vmssvm_model['properties']['storageProfile']['dataDisks'] = data_disks return vmssvm_model
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier slice list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier return_statement identifier
Detach a data disk from a VMSS VM model
def list_lbaas_l7rules(self, l7policy, retrieve_all=True, **_params): return self.list('rules', self.lbaas_l7rules_path % l7policy, retrieve_all, **_params)
module function_definition identifier parameters identifier identifier default_parameter identifier true dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end binary_operator attribute identifier identifier identifier identifier dictionary_splat identifier
Fetches a list of all rules for L7 policy.
def list_webhooks(self, scaling_group, policy): uri = "/%s/%s/policies/%s/webhooks" % (self.uri_base, utils.get_id(scaling_group), utils.get_id(policy)) resp, resp_body = self.api.method_get(uri) return [AutoScaleWebhook(self, data, policy, scaling_group) for data in resp_body.get("webhooks", [])]
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement list_comprehension call identifier argument_list identifier identifier identifier identifier for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end list
Returns a list of all webhooks for the specified policy.
def _finalize_cwl_in(data, work_dir, passed_keys, output_cwl_keys, runtime): data["dirs"] = {"work": work_dir} if not tz.get_in(["config", "algorithm"], data): if "config" not in data: data["config"] = {} data["config"]["algorithm"] = {} if "rgnames" not in data and "description" in data: data["rgnames"] = {"sample": data["description"]} data["cwl_keys"] = passed_keys data["output_cwl_keys"] = output_cwl_keys data = _add_resources(data, runtime) data = cwlutils.normalize_missing(data) data = run_info.normalize_world(data) return data
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end identifier if_statement not_operator call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end identifier block 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 dictionary expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end dictionary if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
Finalize data object with inputs from CWL.
def package_name(self, PACKAGES_TXT): packages = [] for line in PACKAGES_TXT.splitlines(): if line.startswith("PACKAGE NAME:"): packages.append(split_package(line[14:].strip())[0]) return packages
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript call identifier argument_list call attribute subscript identifier slice integer identifier argument_list integer return_statement identifier
Returns list with all the names of packages repository
def create_directory(self, filename): path = os.path.join(self.path, filename) makedirs(path) return path
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier expression_statement call identifier argument_list identifier return_statement identifier
Create a subdirectory in the temporary directory.
def render_filefield(field, attrs): field.field.widget.attrs["style"] = "display:none" if not "_no_label" in attrs: attrs["_no_label"] = True return wrappers.FILE_WRAPPER % { "field": field, "id": "id_" + field.name, "style": pad(attrs.get("_style", "")), "text": escape(attrs.get("_text", "Select File")), "icon": format_html(wrappers.ICON_TEMPLATE, attrs.get("_icon", "file outline")) }
module function_definition identifier parameters identifier identifier block expression_statement assignment subscript attribute attribute attribute identifier identifier identifier identifier string string_start string_content string_end string string_start string_content string_end if_statement not_operator comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end true return_statement binary_operator attribute identifier identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end binary_operator string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end pair string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list 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 attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end
Render a typical File Field.
def render_word(self,word,size,color): pygame.font.init() font = pygame.font.Font(None,size) self.rendered_word = font.render(word,0,color) self.word_size = font.size(word)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list none identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier integer identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier
Creates a surface that contains a word.
def fmtval(value, colorstr=None, precision=None, spacing=True, trunc=True, end=' '): colwidth = opts.colwidth if precision is None: precision = opts.precision fmt = '%%.%sf' % precision result = locale.format(fmt, value, True) if spacing: result = '%%%ss' % colwidth % result if trunc: if len(result) > colwidth: result = truncstr(result, colwidth) if opts.incolor and colorstr: return colorstr % result + end else: return result + end
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier true default_parameter identifier true default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier true if_statement identifier block expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end identifier identifier if_statement identifier block if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement boolean_operator attribute identifier identifier identifier block return_statement binary_operator binary_operator identifier identifier identifier else_clause block return_statement binary_operator identifier identifier
Formats and returns a given number according to specifications.
def _add_link(self, edge): edge_data = self.data['probnet']['edges'][edge] if isinstance(edge, six.string_types): edge = eval(edge) link = etree.SubElement(self.links, 'Link', attrib={'var1': edge[0], 'var2': edge[1], 'directed': edge_data['directed']}) try: etree.SubElement(link, 'Comment').text = edge_data['Comment'] except KeyError: pass try: etree.SubElement(link, 'Label').text = edge_data['Label'] except KeyError: pass try: self._add_additional_properties(link, edge_data['AdditionalProperties']) except KeyError: etree.SubElement(link, 'AdditionalProperties')
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end keyword_argument identifier dictionary pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier string string_start string_content string_end try_statement block expression_statement assignment attribute call attribute identifier identifier argument_list identifier string string_start string_content string_end identifier subscript identifier string string_start string_content string_end except_clause identifier block pass_statement try_statement block expression_statement assignment attribute call attribute identifier identifier argument_list identifier string string_start string_content string_end identifier subscript identifier string string_start string_content string_end except_clause identifier block pass_statement try_statement block expression_statement call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end except_clause identifier block expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end
Adds an edge to the ProbModelXML.
def dump_children(self, f, indent=''): for child in self.__order: child.dump(f, indent+' ')
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_end block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier binary_operator identifier string string_start string_content string_end
Dump the children of the current section to a file-like object
def calculate_gru_output_shapes(operator): check_input_and_output_numbers(operator, input_count_range=[1, 2], output_count_range=[1, 2]) check_input_and_output_types(operator, good_input_types=[FloatTensorType]) input_shape = operator.inputs[0].type.shape if len(input_shape) not in [2, 4]: raise RuntimeError('Input must be a [N, C]- or [N, C, 1, 1]-tensor') if operator.type == 'gru': params = operator.raw_operator.gru elif operator.type == 'simpleRecurrent': params = operator.raw_operator.simpleRecurrent else: raise RuntimeError('Only GRU and SimpleRNN are supported') output_shape = [input_shape[0] if params.sequenceOutput else 'None', params.outputVectorSize] state_shape = [1, params.outputVectorSize] if len(operator.inputs) > 1: Y_h_in = operator.inputs[1] Y_h_in.type.shape = state_shape operator.outputs[0].type.shape = output_shape if len(operator.outputs) > 1: operator.outputs[1].type.shape = state_shape
module function_definition identifier parameters identifier block expression_statement call identifier argument_list identifier keyword_argument identifier list integer integer keyword_argument identifier list integer integer expression_statement call identifier argument_list identifier keyword_argument identifier list identifier expression_statement assignment identifier attribute attribute subscript attribute identifier identifier integer identifier identifier if_statement comparison_operator call identifier argument_list identifier list integer integer block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier attribute attribute identifier identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier attribute attribute identifier identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier list conditional_expression subscript identifier integer attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier list integer attribute identifier identifier if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement assignment attribute attribute subscript attribute identifier identifier integer identifier identifier identifier if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement assignment attribute attribute subscript attribute identifier identifier integer identifier identifier identifier
See GRU's conversion function for its output shapes.
def _log_multivariate_normal_density_full(X, means, covars, min_covar=1.e-7): n_samples, n_dim = X.shape nmix = len(means) log_prob = np.empty((n_samples, nmix)) for c, (mu, cv) in enumerate(zip(means, covars)): try: cv_chol = linalg.cholesky(cv, lower=True) except linalg.LinAlgError: try: cv_chol = linalg.cholesky(cv + min_covar * np.eye(n_dim), lower=True) except linalg.LinAlgError: raise ValueError("'covars' must be symmetric, " "positive-definite") cv_log_det = 2 * np.sum(np.log(np.diagonal(cv_chol))) cv_sol = linalg.solve_triangular(cv_chol, (X - mu).T, lower=True).T log_prob[:, c] = - .5 * (np.sum(cv_sol ** 2, axis=1) + n_dim * np.log(2 * np.pi) + cv_log_det) return log_prob
module function_definition identifier parameters identifier identifier identifier default_parameter identifier float block expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier identifier for_statement pattern_list identifier tuple_pattern identifier identifier call identifier argument_list call identifier argument_list identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true except_clause attribute identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier binary_operator identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true except_clause 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 identifier binary_operator integer call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list identifier attribute parenthesized_expression binary_operator identifier identifier identifier keyword_argument identifier true identifier expression_statement assignment subscript identifier slice identifier binary_operator unary_operator float parenthesized_expression binary_operator binary_operator call attribute identifier identifier argument_list binary_operator identifier integer keyword_argument identifier integer binary_operator identifier call attribute identifier identifier argument_list binary_operator integer attribute identifier identifier identifier return_statement identifier
Log probability for full covariance matrices.
def _to_json_type(obj, classkey=None): if isinstance(obj, dict): data = {} for (k, v) in obj.items(): data[k] = _to_json_type(v, classkey) return data elif hasattr(obj, "_ast"): return _to_json_type(obj._ast()) elif hasattr(obj, "__iter__"): return [_to_json_type(v, classkey) for v in obj] elif hasattr(obj, "__dict__"): data = dict([ (key, _to_json_type(value, classkey)) for key, value in obj.__dict__.iteritems() if not callable(value) and not key.startswith('_') ]) if classkey is not None and hasattr(obj, "__class__"): data[classkey] = obj.__class__.__name__ return data else: return obj
module function_definition identifier parameters identifier default_parameter identifier none block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier dictionary for_statement tuple_pattern identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier identifier call identifier argument_list identifier identifier return_statement identifier elif_clause call identifier argument_list identifier string string_start string_content string_end block return_statement call identifier argument_list call attribute identifier identifier argument_list elif_clause call identifier argument_list identifier string string_start string_content string_end block return_statement list_comprehension call identifier argument_list identifier identifier for_in_clause identifier identifier elif_clause call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list list_comprehension tuple identifier call identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_clause boolean_operator not_operator call identifier argument_list identifier not_operator call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator comparison_operator identifier none call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment subscript identifier identifier attribute attribute identifier identifier identifier return_statement identifier else_clause block return_statement identifier
Recursively convert the object instance into a valid JSON type.
def compute_bbox_with_margins(margin, x, y): 'Helper function to compute bounding box for the plot' pos = np.asarray((x, y)) minxy, maxxy = pos.min(axis=1), pos.max(axis=1) xy1 = minxy - margin*(maxxy - minxy) xy2 = maxxy + margin*(maxxy - minxy) return tuple(xy1), tuple(xy2)
module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier identifier expression_statement assignment pattern_list identifier identifier expression_list call attribute identifier identifier argument_list keyword_argument identifier integer call attribute identifier identifier argument_list keyword_argument identifier integer expression_statement assignment identifier binary_operator identifier binary_operator identifier parenthesized_expression binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier binary_operator identifier parenthesized_expression binary_operator identifier identifier return_statement expression_list call identifier argument_list identifier call identifier argument_list identifier
Helper function to compute bounding box for the plot
def _plot(self): r_max = min( self.view.x(1) - self.view.x(0), (self.view.y(0) or 0) - self.view.y(1) ) / (2 * 1.05) for serie in self.series: self.dot(serie, r_max)
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator call identifier argument_list binary_operator call attribute attribute identifier identifier identifier argument_list integer call attribute attribute identifier identifier identifier argument_list integer binary_operator parenthesized_expression boolean_operator call attribute attribute identifier identifier identifier argument_list integer integer call attribute attribute identifier identifier identifier argument_list integer parenthesized_expression binary_operator integer float for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
Plot all dots for series
def run_tornado(self, args): server = self import tornado.ioloop import tornado.web import tornado.websocket ioloop = tornado.ioloop.IOLoop.current() class DevWebSocketHandler(tornado.websocket.WebSocketHandler): def open(self): super(DevWebSocketHandler, self).open() server.on_open(self) def on_message(self, message): server.on_message(self, message) def on_close(self): super(DevWebSocketHandler, self).on_close() server.on_close(self) class MainHandler(tornado.web.RequestHandler): def get(self): self.write(server.index_page) server.call_later = ioloop.call_later server.add_callback = ioloop.add_callback app = tornado.web.Application([ (r"/", MainHandler), (r"/dev", DevWebSocketHandler), ]) app.listen(self.port) print("Tornado Dev server started on {}".format(self.port)) ioloop.start()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier identifier import_statement dotted_name identifier identifier import_statement dotted_name identifier identifier import_statement dotted_name identifier identifier expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list class_definition identifier argument_list attribute attribute identifier identifier identifier block function_definition identifier parameters identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier function_definition identifier parameters identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier class_definition identifier argument_list attribute attribute identifier identifier identifier block function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list list tuple string string_start string_content string_end identifier tuple string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list
Tornado dev server implementation
def einsum_sequence(self, other_arrays, einsum_string=None): if not isinstance(other_arrays, list): raise ValueError("other tensors must be list of " "tensors or tensor input") other_arrays = [np.array(a) for a in other_arrays] if not einsum_string: lc = string.ascii_lowercase einsum_string = lc[:self.rank] other_ranks = [len(a.shape) for a in other_arrays] idx = self.rank - sum(other_ranks) for length in other_ranks: einsum_string += ',' + lc[idx:idx + length] idx += length einsum_args = [self] + list(other_arrays) return np.einsum(einsum_string, *einsum_args)
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement not_operator call identifier argument_list 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 identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier subscript identifier slice attribute identifier identifier expression_statement assignment identifier list_comprehension call identifier argument_list attribute identifier identifier for_in_clause identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end subscript identifier slice identifier binary_operator identifier identifier expression_statement augmented_assignment identifier identifier expression_statement assignment identifier binary_operator list identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier list_splat identifier
Calculates the result of an einstein summation expression
def exec_notebook_daemon_command(self, name, cmd, port=0): cmd = self.get_notebook_daemon_command(name, cmd, port) cmd = [str(arg) for arg in cmd] logger.info("Running notebook command: %s", " ".join(cmd)) env = os.environ.copy() env["PYTHONFAULTHANDLER"] = "true" p = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE, env=env) time.sleep(0.2) stdout, stderr = p.communicate() if b"already running" in stderr: raise RuntimeError("Looks like notebook_daemon is already running. Please kill it manually pkill -f notebook_daemon. Was: {}".format(stderr.decode("utf-8"))) if p.returncode != 0: logger.error("STDOUT: %s", stdout) logger.error("STDERR: %s", stderr) raise RuntimeError("Could not execute notebook command. Exit code: {} cmd: {}".format(p.returncode, " ".join(cmd))) return stdout
module function_definition identifier parameters identifier identifier identifier default_parameter identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list float expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list if_statement comparison_operator string string_start string_content string_end identifier block raise_statement call identifier argument_list 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 if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier
Run a daemon script command.
def _make_value(self, value): member = self.__new__(self, value) member.__init__(value) return member
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Instantiates an enum with an arbitrary value.
def wait_condition_spec(self): from harpoon.option_spec import image_objs formatted_string = formatted(string_spec(), formatter=MergedOptionStringFormatter) return create_spec(image_objs.WaitCondition , harpoon = formatted(overridden("{harpoon}"), formatter=MergedOptionStringFormatter) , timeout = defaulted(integer_spec(), 300) , wait_between_attempts = defaulted(float_spec(), 5) , greps = optional_spec(dictof(formatted_string, formatted_string)) , command = optional_spec(listof(formatted_string)) , port_open = optional_spec(listof(integer_spec())) , file_value = optional_spec(dictof(formatted_string, formatted_string)) , curl_result = optional_spec(dictof(formatted_string, formatted_string)) , file_exists = optional_spec(listof(formatted_string)) )
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list keyword_argument identifier identifier return_statement call identifier argument_list attribute identifier identifier keyword_argument identifier call identifier argument_list call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier call identifier argument_list call identifier argument_list integer keyword_argument identifier call identifier argument_list call identifier argument_list integer keyword_argument identifier call identifier argument_list call identifier argument_list identifier identifier keyword_argument identifier call identifier argument_list call identifier argument_list identifier keyword_argument identifier call identifier argument_list call identifier argument_list call identifier argument_list keyword_argument identifier call identifier argument_list call identifier argument_list identifier identifier keyword_argument identifier call identifier argument_list call identifier argument_list identifier identifier keyword_argument identifier call identifier argument_list call identifier argument_list identifier
Spec for a wait_condition block
def instance(cls, *args, **kwgs): if not hasattr(cls, "_instance"): cls._instance = cls(*args, **kwgs) return cls._instance
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call identifier argument_list list_splat identifier dictionary_splat identifier return_statement attribute identifier identifier
Will be the only instance
def _extra_compile_time_classpath(self): def extra_compile_classpath_iter(): for conf in self._confs: for jar in self.extra_compile_time_classpath_elements(): yield (conf, jar) return list(extra_compile_classpath_iter())
module function_definition identifier parameters identifier block function_definition identifier parameters block for_statement identifier attribute identifier identifier block for_statement identifier call attribute identifier identifier argument_list block expression_statement yield tuple identifier identifier return_statement call identifier argument_list call identifier argument_list
Compute any extra compile-time-only classpath elements.
def append(self, node): "Append a new subnode" if not isinstance(node, self.__class__): raise TypeError('Expected Node instance, got %r' % node) self.nodes.append(node)
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end if_statement not_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Append a new subnode
def add_argument_group(self, title, description=None): try: groups = self.__groups except AttributeError: groups = self.__groups = {} if title not in groups: groups[title] = super().add_argument_group( title=title, description=description) return groups[title]
module function_definition identifier parameters identifier identifier default_parameter identifier none block try_statement block expression_statement assignment identifier attribute identifier identifier except_clause identifier block expression_statement assignment identifier assignment attribute identifier identifier dictionary if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier call attribute call identifier argument_list identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier return_statement subscript identifier identifier
Add an argument group, or return a pre-existing one.
def stop(self): Global.LOGGER.info("stopping the flow manager") self._stop_actions() self.isrunning = False Global.LOGGER.debug("flow manager stopped")
module function_definition identifier parameters identifier 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 expression_statement assignment attribute identifier identifier false expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
Stop all the processes
def check_scan_process(self, scan_id): scan_process = self.scan_processes[scan_id] progress = self.get_scan_progress(scan_id) if progress < 100 and not scan_process.is_alive(): self.set_scan_status(scan_id, ScanStatus.STOPPED) self.add_scan_error(scan_id, name="", host="", value="Scan process failure.") logger.info("%s: Scan stopped with errors.", scan_id) elif progress == 100: scan_process.join()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement boolean_operator comparison_operator identifier integer not_operator call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_end keyword_argument identifier string string_start string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier elif_clause comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list
Check the scan's process, and terminate the scan if not alive.
def filesize(self): if self.kind == 'data': return len(self._data.data) return self._data.filesize
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call identifier argument_list attribute attribute identifier identifier identifier return_statement attribute attribute identifier identifier identifier
File size of the object.
def _path_factory(check): @functools.wraps(check) def validator(paths): if isinstance(paths, str): check(paths) elif isinstance(paths, collections.Sequence): for path in paths: check(path) else: raise Exception('expected either basestr or sequenc of basstr') return validator
module function_definition identifier parameters identifier block decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement call identifier argument_list identifier elif_clause call identifier argument_list identifier attribute identifier identifier block for_statement identifier identifier block expression_statement call identifier argument_list identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end return_statement identifier
Create a function that checks paths.
def find_time_base(self, gps, first_ms_stamp): t = self._gpsTimeToTime(gps.Week, gps.TimeMS) self.set_timebase(t - gps.T*0.001) self.timestamp = self.timebase + first_ms_stamp*0.001
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator identifier binary_operator attribute identifier identifier float expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier binary_operator identifier float
work out time basis for the log - new style
def _get_role(rolename): path = os.path.join('roles', rolename + '.json') if not os.path.exists(path): abort("Couldn't read role file {0}".format(path)) with open(path, 'r') as f: try: role = json.loads(f.read()) except ValueError as e: msg = "Little Chef found the following error in your" msg += " {0}.json file:\n {1}".format(rolename, str(e)) abort(msg) role['fullname'] = rolename return role
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 binary_operator identifier string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier
Reads and parses a file containing a role
def do_alarm_history(mc, args): fields = {} fields['alarm_id'] = args.id if args.limit: fields['limit'] = args.limit if args.offset: fields['offset'] = args.offset try: alarm = mc.alarms.history(**fields) except (osc_exc.ClientException, k_exc.HttpError) as he: raise osc_exc.CommandError('%s\n%s' % (he.message, he.details)) else: output_alarm_history(args, alarm)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier except_clause as_pattern tuple attribute identifier identifier attribute identifier identifier as_pattern_target identifier block raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple attribute identifier identifier attribute identifier identifier else_clause block expression_statement call identifier argument_list identifier identifier
Alarm state transition history.
def _create_injector(self, injector): if injector == "block_info": block_info_injector = importlib.import_module( "sawtooth_validator.journal.block_info_injector") return block_info_injector.BlockInfoInjector( self._state_view_factory, self._signer) raise UnknownBatchInjectorError(injector)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier raise_statement call identifier argument_list identifier
Returns a new batch injector
def execution_engine_model_changed(self, model, prop_name, info): if not self._view_initialized: return active_sm_id = rafcon.gui.singleton.state_machine_manager_model.state_machine_manager.active_state_machine_id if active_sm_id is None: self.disable() else: self.check_configuration()
module function_definition identifier parameters identifier identifier identifier identifier block if_statement not_operator attribute identifier identifier block return_statement expression_statement assignment identifier attribute attribute attribute attribute attribute identifier identifier identifier identifier identifier identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list
Active observation of state machine and show and hide widget.
def data(self): if self.is_obsolete(): data = self.get_data() for datum in data: if 'published_parsed' in datum: datum['published_parsed'] = \ self.parse_time(datum['published_parsed']) try: dumped_data = json.dumps(data) except: self.update_cache(data) else: self.update_cache(dumped_data) return data try: return json.loads(self.cache_data) except: return self.cache_data return self.get_data()
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block 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 line_continuation call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier try_statement block return_statement call attribute identifier identifier argument_list attribute identifier identifier except_clause block return_statement attribute identifier identifier return_statement call attribute identifier identifier argument_list
load and cache data in json format
def version_router(self, request, response, api_version=None, versions={}, not_found=None, **kwargs): request_version = self.determine_version(request, api_version) if request_version: request_version = int(request_version) versions.get(request_version or False, versions.get(None, not_found))(request, response, api_version=api_version, **kwargs)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier dictionary default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call call attribute identifier identifier argument_list boolean_operator identifier false call attribute identifier identifier argument_list none identifier argument_list identifier identifier keyword_argument identifier identifier dictionary_splat identifier
Intelligently routes a request to the correct handler based on the version being requested
def register(self, func, singleton=False, threadlocal=False, name=None): func._giveme_singleton = singleton func._giveme_threadlocal = threadlocal if name is None: name = func.__name__ self._registered[name] = func return func
module function_definition identifier parameters identifier identifier default_parameter identifier false default_parameter identifier false default_parameter identifier none block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement identifier
Register a dependency function
def _calibrate(self, radiance, coefs, channel, calibration): if self._is_vis(channel): if not calibration == 'reflectance': raise ValueError('Cannot calibrate VIS channel to ' '{}'.format(calibration)) return self._calibrate_vis(radiance=radiance, k=coefs['k']) else: if not calibration == 'brightness_temperature': raise ValueError('Cannot calibrate IR channel to ' '{}'.format(calibration)) mean_coefs = {'a': np.array(coefs['a']).mean(), 'b': np.array(coefs['b']).mean(), 'n': np.array(coefs['n']).mean(), 'btmin': coefs['btmin'], 'btmax': coefs['btmax']} return self._calibrate_ir(radiance=radiance, coefs=mean_coefs)
module function_definition identifier parameters identifier identifier identifier identifier identifier block if_statement call attribute identifier identifier argument_list identifier block if_statement not_operator comparison_operator identifier string string_start string_content string_end block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier subscript identifier string string_start string_content string_end else_clause block if_statement not_operator comparison_operator identifier string string_start string_content string_end block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier argument_list pair string string_start string_content string_end call attribute call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier argument_list pair string string_start string_content string_end call attribute call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier argument_list pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Convert radiance to reflectance or brightness temperature
def _add_region_params(region, out_file, items, gatk_type): params = [] variant_regions = bedutils.population_variant_regions(items) region = subset_variant_regions(variant_regions, region, out_file, items) if region: if gatk_type == "gatk4": params += ["-L", bamprep.region_to_gatk(region), "--interval-set-rule", "INTERSECTION"] else: params += ["-L", bamprep.region_to_gatk(region), "--interval_set_rule", "INTERSECTION"] params += gatk.standard_cl_params(items) return params
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier if_statement identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement augmented_assignment identifier list 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_content string_end else_clause block expression_statement augmented_assignment identifier list 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_content string_end expression_statement augmented_assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
Add parameters for selecting by region to command line.
def validated_url(url): try: u = urlparse(url) u.port except Exception: raise error.URLError(url) else: if not u.scheme or not u.netloc: raise error.URLError(url) return url
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier expression_statement attribute identifier identifier except_clause identifier block raise_statement call attribute identifier identifier argument_list identifier else_clause block if_statement boolean_operator not_operator attribute identifier identifier not_operator attribute identifier identifier block raise_statement call attribute identifier identifier argument_list identifier return_statement identifier
Return url if valid, raise URLError otherwise
def _IncludeFields(encoded_message, message, include_fields): if include_fields is None: return encoded_message result = json.loads(encoded_message) for field_name in include_fields: try: value = _GetField(message, field_name.split('.')) nullvalue = None if isinstance(value, list): nullvalue = [] except KeyError: raise exceptions.InvalidDataError( 'No field named %s in message of type %s' % ( field_name, type(message))) _SetField(result, field_name.split('.'), nullvalue) return json.dumps(result)
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier none block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier none if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier list except_clause identifier block raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list identifier
Add the requested fields to the encoded message.
def isLevel2(edtf_candidate): if "[" in edtf_candidate or "{" in edtf_candidate: result = edtf_candidate == level2Expression elif " " in edtf_candidate: result = False else: result = edtf_candidate == level2Expression return result
module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier comparison_operator identifier identifier elif_clause comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier false else_clause block expression_statement assignment identifier comparison_operator identifier identifier return_statement identifier
Checks to see if the date is level 2 valid
def pickle_loads(cls, s): strio = StringIO() strio.write(s) strio.seek(0) flow = pmg_pickle_load(strio) return flow
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
Reconstruct the flow from a string.
def approve(self, filepath): try: signature_valid = self.validate_signature(filepath) except ValueError: signature_valid = False if signature_valid: self.leave_safe_mode() post_command_event(self.main_window, self.SafeModeExitMsg) statustext = _("Valid signature found. File is trusted.") post_command_event(self.main_window, self.StatusBarMsg, text=statustext) else: self.enter_safe_mode() post_command_event(self.main_window, self.SafeModeEntryMsg) statustext = \ _("File is not properly signed. Safe mode " "activated. Select File -> Approve to leave safe mode.") post_command_event(self.main_window, self.StatusBarMsg, text=statustext)
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement assignment identifier false if_statement identifier block expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier line_continuation call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier identifier
Sets safe mode if signature missing of invalid
def find_uuid(es_url, index): uid_field = None res = requests.get('%s/%s/_search?size=1' % (es_url, index)) first_item = res.json()['hits']['hits'][0]['_source'] fields = first_item.keys() if 'uuid' in fields: uid_field = 'uuid' else: uuid_value = res.json()['hits']['hits'][0]['_id'] logging.debug("Finding unique id for %s with value %s", index, uuid_value) for field in fields: if first_item[field] == uuid_value: logging.debug("Found unique id for %s: %s", index, field) uid_field = field break if not uid_field: logging.error("Can not find uid field for %s. Can not copy the index.", index) logging.error("Try to copy it directly with elasticdump or similar.") sys.exit(1) return uid_field
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier subscript subscript subscript subscript call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end integer string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier subscript subscript subscript subscript call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end integer string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier for_statement identifier identifier block if_statement comparison_operator subscript identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment identifier identifier break_statement if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer return_statement identifier
Find the unique identifier field for a given index
def check_fam_for_samples(required_samples, source, gold): source_samples = set() with open(source, 'r') as input_file: for line in input_file: sample = tuple(line.rstrip("\r\n").split(" ")[:2]) if sample in required_samples: source_samples.add(sample) gold_samples = set() with open(gold, 'r') as input_file: for line in input_file: sample = tuple(line.rstrip("\r\n").split(" ")[:2]) if sample in required_samples: gold_samples.add(sample) logger.info(" - Found {} samples in source panel".format( len(source_samples), )) logger.info(" - Found {} samples in gold standard".format( len(gold_samples), )) if len(required_samples - (source_samples | gold_samples)) != 0: return False else: return True
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list subscript call attribute call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end identifier argument_list string string_start string_content string_end slice integer if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list subscript call attribute call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end identifier argument_list string string_start string_content string_end slice integer if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier if_statement comparison_operator call identifier argument_list binary_operator identifier parenthesized_expression binary_operator identifier identifier integer block return_statement false else_clause block return_statement true
Check fam files for required_samples.
def init(directory): username = click.prompt("Input your username") password = click.prompt("Input your password", hide_input=True, confirmation_prompt=True) log_directory = click.prompt("Input your log directory") if not path.exists(log_directory): sys.exit("Invalid log directory, please have a check.") config_file_path = path.join(directory, 'v2ex_config.json') config = { "username": username, "password": password, "log_directory": path.abspath(log_directory) } with open(config_file_path, 'w') as f: json.dump(config, f) click.echo("Init the config file at: {0}".format(config_file_path))
module function_definition identifier parameters 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 string string_start string_content string_end keyword_argument identifier true keyword_argument identifier true expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier with_statement with_clause with_item as_pattern call identifier argument_list 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 call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Init the config fle.
def dir_list(directory): try: content = listdir(directory) return content except WindowsError as winErr: print("Directory error: " + str((winErr)))
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier return_statement identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list parenthesized_expression identifier
Returns the list of all files in the directory.
def RV_3(self): return -self.orbpop_long.RV * (self.orbpop_long.M1 / (self.orbpop_long.M1 + self.orbpop_long.M2)) +\ self.orbpop_short.RV_com2
module function_definition identifier parameters identifier block return_statement binary_operator binary_operator unary_operator attribute attribute identifier identifier identifier parenthesized_expression binary_operator attribute attribute identifier identifier identifier parenthesized_expression binary_operator attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier line_continuation attribute attribute identifier identifier identifier
Instantaneous RV of star 3 with respect to system center-of-mass
def update_dns(self, new_ip): headers = None if self.auth_type == 'T': api_call_url = self._base_url.format(hostname=self.hostname, token=self.auth.token, ip=new_ip) else: api_call_url = self._base_url.format(hostname=self.hostname, ip=new_ip) headers = { 'Authorization': "Basic %s" % self.auth.base64key.decode('utf-8'), 'User-Agent': "%s/%s %s" % (__title__, __version__, __email__) } r = requests.get(api_call_url, headers=headers) self.last_ddns_response = str(r.text).strip() return r.status_code, r.text
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end binary_operator string string_start string_content string_end call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end binary_operator string string_start string_content string_end tuple identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment attribute identifier identifier call attribute call identifier argument_list attribute identifier identifier identifier argument_list return_statement expression_list attribute identifier identifier attribute identifier identifier
Call No-IP API based on dict login_info and return the status code.
def run(self): _date = None while QA_util_if_tradetime(self.now): for data in self.ingest_data: date = data.date[0] if self.market_type is MARKET_TYPE.STOCK_CN: if _date != date: try: self.market.trade_engine.join() self.market._settle(self.broker_name) except Exception as e: raise e elif self.market_type in [MARKET_TYPE.FUND_CN, MARKET_TYPE.INDEX_CN, MARKET_TYPE.FUTURE_CN]: self.market._settle(self.broker_name) self.broker.run( QA_Event(event_type=ENGINE_EVENT.UPCOMING_DATA, market_data=data)) self.market.upcoming_data(self.broker_name, data) self.market.trade_engine.join() _date = date
module function_definition identifier parameters identifier block expression_statement assignment identifier none while_statement call identifier argument_list attribute identifier identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier integer if_statement comparison_operator attribute identifier identifier attribute identifier identifier block if_statement comparison_operator identifier identifier block try_statement block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement identifier elif_clause comparison_operator attribute identifier identifier list attribute identifier identifier attribute identifier identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement assignment identifier identifier
generator driven data flow
def main(self): self.secret_finder() self.parse_access_token() self.get_session_token() self.parse_session_token() self.get_route() self.download_profile() self.find_loci() self.download_loci()
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Run the appropriate methods in the correct order
def connect_attenuator(self, connect=True): if connect: try: pa5 = win32com.client.Dispatch("PA5.x") success = pa5.ConnectPA5('GB', 1) if success == 1: print 'Connection to PA5 attenuator established' pass else: print 'Connection to PA5 attenuator failed' errmsg = pa5.GetError() print u"Error: ", errmsg raise Exception(u"Attenuator connection failed") except: print "Error connecting to attenuator" pa5 = None self.attenuator = pa5 else: if self.attenuator: self.attenuator.setAtten(0) self.attenuator = None return self.attenuator
module function_definition identifier parameters identifier default_parameter identifier true block if_statement identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end integer if_statement comparison_operator identifier integer block print_statement string string_start string_content string_end pass_statement else_clause block print_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list print_statement string string_start string_content string_end identifier raise_statement call identifier argument_list string string_start string_content string_end except_clause block print_statement string string_start string_content string_end expression_statement assignment identifier none expression_statement assignment attribute identifier identifier identifier else_clause block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list integer expression_statement assignment attribute identifier identifier none return_statement attribute identifier identifier
Establish a connection to the TDT PA5 attenuator
def _recv(self): prefix = self._read(self.prefix_len) msg = self._read(self._extract_len(prefix)) return prefix + msg
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement binary_operator identifier identifier
Receives and returns a message from Scratch
def _chunks(self, items, limit): for i in range(0, len(items), limit): yield items[i:i + limit]
module function_definition identifier parameters identifier identifier identifier block for_statement identifier call identifier argument_list integer call identifier argument_list identifier identifier block expression_statement yield subscript identifier slice identifier binary_operator identifier identifier
Yield successive chunks from list \a items with a minimum size \a limit
def get(cls): return { SourceRootConfig, Reporting, Reproducer, RunTracker, Changed, BinaryUtil.Factory, Subprocess.Factory }
module function_definition identifier parameters identifier block return_statement set identifier identifier identifier identifier identifier attribute identifier identifier attribute identifier identifier
Subsystems used outside of any task.
def _open_ftp(self): ftp = self.fs._open_ftp() ftp.voidcmd(str("TYPE I")) return ftp
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end return_statement identifier
Open an ftp object for the file.
def unzoom(self, full=False, delay_draw=False): if full: self.zoom_lims = self.zoom_lims[:1] self.zoom_lims = [] elif len(self.zoom_lims) > 0: self.zoom_lims.pop() self.set_viewlimits() if not delay_draw: self.canvas.draw()
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier false block if_statement identifier block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier slice integer expression_statement assignment attribute identifier identifier list elif_clause comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list if_statement not_operator identifier block expression_statement call attribute attribute identifier identifier identifier argument_list
unzoom display 1 level or all the way
def _get_common_cores(resources): all_cores = [] for vs in resources.values(): cores = vs.get("cores") if cores: all_cores.append(int(vs["cores"])) return collections.Counter(all_cores).most_common(1)[0][0]
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end return_statement subscript subscript call attribute call attribute identifier identifier argument_list identifier identifier argument_list integer integer integer
Retrieve the most common configured number of cores in the input file.
def _wait_for_retransmit_thread(transaction): if hasattr(transaction, 'retransmit_thread'): while transaction.retransmit_thread is not None: logger.debug("Waiting for retransmit thread to finish ...") time.sleep(0.01) continue
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block while_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list float continue_statement
Only one retransmit thread at a time, wait for other to finish
def isHouse10MC(self): house10 = self.getHouse(const.HOUSE10) mc = self.getAngle(const.MC) dist = angle.closestdistance(house10.lon, mc.lon) return abs(dist) < 0.0003
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier return_statement comparison_operator call identifier argument_list identifier float
Returns true if House10 is the same as the MC.
def identity_to_string(identity_dict): result = [] if identity_dict.get('proto'): result.append(identity_dict['proto'] + '://') if identity_dict.get('user'): result.append(identity_dict['user'] + '@') result.append(identity_dict['host']) if identity_dict.get('port'): result.append(':' + identity_dict['port']) if identity_dict.get('path'): result.append(identity_dict['path']) log.debug('identity parts: %s', result) return ''.join(result)
module function_definition identifier parameters identifier block expression_statement assignment identifier list if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator subscript identifier string string_start string_content string_end 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 call attribute identifier identifier argument_list binary_operator subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list subscript identifier 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 call attribute identifier identifier argument_list binary_operator string string_start string_content string_end subscript identifier 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 call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement call attribute string string_start string_end identifier argument_list identifier
Dump Identity dictionary into its string representation.
def arcball_constrain_to_axis(point, axis): v = np.array(point, dtype=np.float64, copy=True) a = np.array(axis, dtype=np.float64, copy=True) v -= a * np.dot(a, v) n = vector_norm(v) if n > _EPS: if v[2] < 0.0: np.negative(v, v) v /= n return v if a[2] == 1.0: return np.array([1.0, 0.0, 0.0]) return unit_vector([-a[1], a[0], 0.0])
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier true expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier true expression_statement augmented_assignment identifier binary_operator identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier identifier block if_statement comparison_operator subscript identifier integer float block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement augmented_assignment identifier identifier return_statement identifier if_statement comparison_operator subscript identifier integer float block return_statement call attribute identifier identifier argument_list list float float float return_statement call identifier argument_list list unary_operator subscript identifier integer subscript identifier integer float
Return sphere point perpendicular to axis.
def modify_request(self, http_request=None): if http_request is None: http_request = HttpRequest() if http_request.uri is None: http_request.uri = Uri() if self.scheme: http_request.uri.scheme = self.scheme if self.port: http_request.uri.port = self.port if self.host: http_request.uri.host = self.host if self.path: http_request.uri.path = self.path if self.query: http_request.uri.query = self.query.copy() return http_request
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call identifier argument_list if_statement attribute identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list return_statement identifier
Sets HTTP request components based on the URI.
def _define_array_view(data_type): element_type = data_type.element_type element_view = _resolve_view(element_type) if element_view is None: mixins = (_DirectArrayViewMixin,) attributes = _get_mixin_attributes(mixins) elif isinstance(element_type, _ATOMIC): mixins = (_IndirectAtomicArrayViewMixin,) attributes = _get_mixin_attributes(mixins) attributes.update({ '_element_view': element_view, }) else: mixins = (_IndirectCompositeArrayViewMixin,) attributes = _get_mixin_attributes(mixins) attributes.update({ '_element_view': element_view, }) name = data_type.name if data_type.name else 'ArrayView' return type(name, (), attributes)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier tuple identifier expression_statement assignment identifier call identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier tuple identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier else_clause block expression_statement assignment identifier tuple identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier conditional_expression attribute identifier identifier attribute identifier identifier string string_start string_content string_end return_statement call identifier argument_list identifier tuple identifier
Define a new view object for a `Array` type.
def authentication_validation(username, password, access_token): if bool(username) is not bool(password): raise Exception("Basic authentication requires a username AND" " password.") if (username and access_token) or (password and access_token): raise Exception("Cannot use both Basic Authentication and" " OAuth2.0. Please use only one authentication" " method.")
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end if_statement boolean_operator parenthesized_expression boolean_operator identifier identifier parenthesized_expression boolean_operator 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 string string_start string_content string_end
Only accept one form of authentication.
def _get_start_end(parts, index=7): start = parts[1] end = [x.split("=")[-1] for x in parts[index].split(";") if x.startswith("END=")] if end: end = end[0] return start, end return None, None
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier list_comprehension subscript call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer for_in_clause identifier call attribute subscript identifier identifier identifier argument_list string string_start string_content string_end if_clause call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier subscript identifier integer return_statement expression_list identifier identifier return_statement expression_list none none
Retrieve start and end for a VCF record, skips BNDs without END coords
def save_json(obj, outfile, allow_nan=True, compression=False): if compression: with open(outfile, 'wb') as f: dump(obj, f, allow_nan=allow_nan, compression=compression) else: with open(outfile, 'w') as f: dump(obj, f, allow_nan=allow_nan, compression=compression) log.info('Saved {} (id: {}) to {}'.format(type(obj), obj.id, outfile))
module function_definition identifier parameters identifier identifier default_parameter identifier true default_parameter identifier false block if_statement identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier else_clause block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier attribute identifier identifier identifier
Save an ssbio object as a JSON file using json_tricks
def update_dcnm_out_part(self, tenant_id, fw_dict, is_fw_virt=False): res = fw_const.DCNM_OUT_PART_UPDATE_SUCCESS tenant_name = fw_dict.get('tenant_name') ret = True try: ret = self._update_partition_out_create(tenant_id, tenant_name) if not ret: res = fw_const.DCNM_OUT_PART_UPDATE_FAIL except Exception as exc: LOG.error("Update of Out Partition failed for tenant " "%(tenant)s Exception %(exc)s", {'tenant': tenant_id, 'exc': str(exc)}) res = fw_const.DCNM_OUT_PART_UPDATE_FAIL ret = False self.update_fw_db_result(tenant_id, dcnm_status=res) LOG.info("Out partition updated with service ip addr") return ret
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier true try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier false expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
Update DCNM OUT partition service node IP address and result.
def vulnerability_section_header_element(feature, parent): _ = feature, parent header = vulnerability_section_header['string_format'] return header.capitalize()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier expression_list identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list
Retrieve vulnerability section header string from definitions.
def consume(self, seq): for kmer in iter_kmers(seq, self.k, canonical=self.canonical): self._incr(kmer)
module function_definition identifier parameters identifier identifier block for_statement identifier call identifier argument_list identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
Counts all k-mers in sequence.
def jsonify_error(message_or_exception, status_code=400): if isinstance(message_or_exception, Exception): message = '%s: %s' % ( message_or_exception.__class__.__name__, message_or_exception) else: message = message_or_exception logging.debug('Returning status=%s, error message: %s', status_code, message) response = jsonify(error=message) response.status_code = status_code return response
module function_definition identifier parameters identifier default_parameter identifier integer block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute attribute identifier identifier identifier identifier else_clause block expression_statement assignment identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
Returns a JSON payload that indicates the request had an error.
def _read_pdb(path): r_mode = 'r' openf = open if path.endswith('.gz'): r_mode = 'rb' openf = gzip.open with openf(path, r_mode) as f: txt = f.read() if path.endswith('.gz'): if sys.version_info[0] >= 3: txt = txt.decode('utf-8') else: txt = txt.encode('ascii') return path, txt
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call attribute identifier identifier argument_list string string_start string_content string_end block if_statement comparison_operator subscript attribute identifier identifier integer integer block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement expression_list identifier identifier
Read PDB file from local drive.
def extract_bad_snapshot(e): msg = e.response['Error']['Message'] error = e.response['Error']['Code'] e_snap_id = None if error == 'InvalidSnapshot.NotFound': e_snap_id = msg[msg.find("'") + 1:msg.rfind("'")] log.warning("Snapshot not found %s" % e_snap_id) elif error == 'InvalidSnapshotID.Malformed': e_snap_id = msg[msg.find('"') + 1:msg.rfind('"')] log.warning("Snapshot id malformed %s" % e_snap_id) return e_snap_id
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier none if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier subscript identifier slice binary_operator call attribute identifier identifier argument_list string string_start string_content string_end integer call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier subscript identifier slice binary_operator call attribute identifier identifier argument_list string string_start string_content string_end integer call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier return_statement identifier
Handle various client side errors when describing snapshots
def main(option, problem): if problem == 0 or option in {skip, verify_all}: files = problem_glob() problem = max(file.num for file in files) if files else 0 if problem == 0: if option not in {cheat, preview, verify_all}: msg = "No Project Euler files found in the current directory." click.echo(msg) option = generate problem = 1 elif option is preview: problem += 1 if option is None: verify(problem) problem += 1 option = generate elif option is None: option = verify if Problem(problem).glob else generate option(problem) sys.exit(0)
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier set identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier conditional_expression call identifier generator_expression attribute identifier identifier for_in_clause identifier identifier identifier integer if_statement comparison_operator identifier integer block if_statement comparison_operator identifier set identifier identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier identifier expression_statement assignment identifier integer elif_clause comparison_operator identifier identifier block expression_statement augmented_assignment identifier integer if_statement comparison_operator identifier none block expression_statement call identifier argument_list identifier expression_statement augmented_assignment identifier integer expression_statement assignment identifier identifier elif_clause comparison_operator identifier none block expression_statement assignment identifier conditional_expression identifier attribute call identifier argument_list identifier identifier identifier expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer
Python-based Project Euler command line tool.
def check_virtualserver(self, name): vs = self.bigIP.LocalLB.VirtualServer for v in vs.get_list(): if v.split('/')[-1] == name: return True return False
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator subscript call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer identifier block return_statement true return_statement false
Check to see if a virtual server exists
def run_fixtures(self): self.start_transaction() version = self.fetchone("SELECT version FROM version")["version"] current_version = 9 if version < 8: self.execute("ALTER TABLE activities ADD COLUMN search_name varchar2") activities = self.fetchall("select * from activities") statement = "update activities set search_name = ? where id = ?" for activity in activities: self.execute(statement, (activity['name'].lower(), activity['id'])) self.execute("ALTER TABLE categories ADD COLUMN search_name varchar2") categories = self.fetchall("select * from categories") statement = "update categories set search_name = ? where id = ?" for category in categories: self.execute(statement, (category['name'].lower(), category['id'])) if version < 9: self.execute( ) if version < current_version: self.execute("UPDATE version SET version = %d" % current_version) print("updated database from version %d to %d" % (version, current_version)) self.end_transaction()
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier integer if_statement comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier tuple call attribute subscript identifier string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier tuple call attribute subscript identifier string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement call attribute identifier identifier argument_list
upgrade DB to hamster version
def _store_result(self, task_id, result, status, traceback=None, request=None): self.TaskModel._default_manager.store_result( task_id, result, status, traceback=traceback, children=self.current_task_children(request), ) return result
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list identifier return_statement identifier
Store return value and status of an executed task.
def split_dae_alg(eqs: SYM, dx: SYM) -> Dict[str, SYM]: dae = [] alg = [] for eq in ca.vertsplit(eqs): if ca.depends_on(eq, dx): dae.append(eq) else: alg.append(eq) return { 'dae': ca.vertcat(*dae), 'alg': ca.vertcat(*alg) }
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier type identifier block expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list identifier block if_statement call attribute identifier identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier return_statement dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list list_splat identifier pair string string_start string_content string_end call attribute identifier identifier argument_list list_splat identifier
Split equations into differential algebraic and algebraic only
def flatten_phases_and_groups(phases_or_groups): if isinstance(phases_or_groups, PhaseGroup): phases_or_groups = [phases_or_groups] ret = [] for phase in phases_or_groups: if isinstance(phase, PhaseGroup): ret.append(phase.flatten()) elif isinstance(phase, collections.Iterable): ret.extend(flatten_phases_and_groups(phase)) else: ret.append(phase_descriptor.PhaseDescriptor.wrap_or_copy(phase)) return ret
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier list identifier 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 call attribute identifier identifier argument_list elif_clause call identifier argument_list identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
Recursively flatten nested lists for the list of phases or groups.
def haveSnapshots(self): return os.path.islink(self.latestLink) and os.path.isdir(self.latestLink)
module function_definition identifier parameters identifier block return_statement boolean_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Check if we have at least one snapshot.
def powerDown(self): print '%s call powerDown' % self.port if self.__sendCommand(WPANCTL_CMD + 'setprop Daemon:AutoAssociateAfterReset false')[0] != 'Fail': time.sleep(0.5) if self.__sendCommand(WPANCTL_CMD + 'reset')[0] != 'Fail': self.isPowerDown = True return True else: return False else: return False
module function_definition identifier parameters identifier block print_statement binary_operator string string_start string_content string_end attribute identifier identifier if_statement comparison_operator subscript call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end integer string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list float if_statement comparison_operator subscript call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end integer string string_start string_content string_end block expression_statement assignment attribute identifier identifier true return_statement true else_clause block return_statement false else_clause block return_statement false
power down the OpenThreadWpan
def _cor_compile(rule, var, val, result_class, key, compilation_list): compilation = compilation_list.get(key, None) if compilation: if isinstance(val, ListRule): result = [] for itemv in val.value: result.append(compilation['callback'](itemv)) val = compilation['listclass'](result) else: val = compilation['callback'](val) return result_class(rule.operation, var, val)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier none if_statement identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call subscript identifier string string_start string_content string_end argument_list identifier expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list identifier else_clause block expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list identifier return_statement call identifier argument_list attribute identifier identifier identifier identifier
Actual compilation worker method.