code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def add_file(self, path, yaml): if is_job_config(yaml): name = self.get_job_name(yaml) file_data = FileData(path=path, yaml=yaml) self.files[path] = file_data self.jobs[name] = file_data else: self.files[path] = FileData(path=path, yaml=yaml)
module function_definition identifier parameters identifier identifier identifier block if_statement call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier else_clause block expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Adds given file to the file index
def reset_sequence(model): sql = connection.ops.sequence_reset_sql(no_style(), [model]) for cmd in sql: connection.cursor().execute(cmd)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list list identifier for_statement identifier identifier block expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list identifier
Reset the ID sequence for a model.
def _rapply(d, func, *args, **kwargs): if isinstance(d, (tuple, list)): return [_rapply(each, func, *args, **kwargs) for each in d] if isinstance(d, dict): return { key: _rapply(value, func, *args, **kwargs) for key, value in iteritems(d) } else: return func(d, *args, **kwargs)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement call identifier argument_list identifier tuple identifier identifier block return_statement list_comprehension call identifier argument_list identifier identifier list_splat identifier dictionary_splat identifier for_in_clause identifier identifier if_statement call identifier argument_list identifier identifier block return_statement dictionary_comprehension pair identifier call identifier argument_list identifier identifier list_splat identifier dictionary_splat identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier else_clause block return_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier
Apply a function to all values in a dictionary or list of dictionaries, recursively.
def resolveEPICS(self): kw_name_list = [] kw_ctrlconf_list = [] for line in self.file_lines: if line.startswith('!!epics'): el = line.replace('!!epics', '').replace(':', ';;', 1).split(';;') kw_name_list.append(el[0].strip()) kw_ctrlconf_list.append(json.loads(el[1].strip())) self.ctrlconf_dict = dict(zip(kw_name_list, kw_ctrlconf_list))
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier attribute identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute call attribute call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier argument_list string string_start string_content string_end string string_start string_content string_end integer identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute subscript identifier integer identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute subscript identifier integer identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list call identifier argument_list identifier identifier
extract epics control configs into
def to_cpu(b:ItemsList): "Recursively map lists of tensors in `b ` to the cpu." if is_listy(b): return [to_cpu(o) for o in b] return b.cpu() if isinstance(b,Tensor) else b
module function_definition identifier parameters typed_parameter identifier type identifier block expression_statement string string_start string_content string_end if_statement call identifier argument_list identifier block return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier return_statement conditional_expression call attribute identifier identifier argument_list call identifier argument_list identifier identifier identifier
Recursively map lists of tensors in `b ` to the cpu.
def main(): tar_file = TMPDIR + '/' + BINARY_URL.split('/')[-1] chksum = TMPDIR + '/' + MD5_URL.split('/')[-1] if precheck() and os_packages(distro.linux_distribution()): stdout_message('begin download') download() stdout_message('begin valid_checksum') valid_checksum(tar_file, chksum) return compile_binary(tar_file) logger.warning('%s: Pre-run dependency check fail - Exit' % inspect.stack()[0][3]) return False
module function_definition identifier parameters block expression_statement assignment identifier binary_operator binary_operator identifier string string_start string_content string_end subscript call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer expression_statement assignment identifier binary_operator binary_operator identifier string string_start string_content string_end subscript call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer if_statement boolean_operator call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list identifier identifier return_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end subscript subscript call attribute identifier identifier argument_list integer integer return_statement false
Check Dependencies, download files, integrity check
def bands(self): bands = [] for c in self.stars.columns: if re.search('_mag',c): bands.append(c) return bands
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier attribute attribute identifier identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Bandpasses for which StarPopulation has magnitude data
def refresh_hrefs(self, request): for item in treenav.MenuItem.objects.all(): item.save() self.message_user(request, _('Menu item HREFs refreshed successfully.')) info = self.model._meta.app_label, self.model._meta.model_name changelist_url = reverse('admin:%s_%s_changelist' % info, current_app=self.admin_site.name) return redirect(changelist_url)
module function_definition identifier parameters identifier identifier block for_statement identifier call attribute attribute attribute identifier identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier expression_list attribute attribute attribute identifier identifier identifier identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator string string_start string_content string_end identifier keyword_argument identifier attribute attribute identifier identifier identifier return_statement call identifier argument_list identifier
Refresh all the cached menu item HREFs in the database.
def query_by_post(postid): return TabPost2Tag.select().where( TabPost2Tag.post_id == postid ).order_by(TabPost2Tag.order)
module function_definition identifier parameters identifier block return_statement call attribute call attribute call attribute identifier identifier argument_list identifier argument_list comparison_operator attribute identifier identifier identifier identifier argument_list attribute identifier identifier
Query records by post.
def make_bundle(bundle, fixed_version=None): tmp_output_file_name = '%s.%s.%s' % (os.path.join(bundle.bundle_file_root, bundle.bundle_filename), 'temp', bundle.bundle_type) iter_input = iter_bundle_files(bundle) output_pipeline = processor_pipeline(bundle.processors, iter_input) m = md5() with open(tmp_output_file_name, 'wb') as output_file: for chunk in output_pipeline: m.update(chunk) output_file.write(chunk) hash_version = fixed_version or m.hexdigest() output_file_name = bundle.get_path(hash_version) os.rename(tmp_output_file_name, output_file_name) return hash_version
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier 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 call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier boolean_operator identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier
Does all of the processing required to create a bundle and write it to disk, returning its hash version
def AreHostsReachable(hostnames, ssh_key): for hostname in hostnames: assert(len(hostname)) ssh_ok = [exit_code == 0 for (exit_code, _) in RunCommandOnHosts('echo test > /dev/null', hostnames, ssh_key)] return ssh_ok
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block assert_statement parenthesized_expression call identifier argument_list identifier expression_statement assignment identifier list_comprehension comparison_operator identifier integer for_in_clause tuple_pattern identifier identifier call identifier argument_list string string_start string_content string_end identifier identifier return_statement identifier
Returns list of bools indicating if host reachable via ssh.
def organisation_logo_path(feature, parent): _ = feature, parent organisation_logo_file = setting( inasafe_organisation_logo_path['setting_key']) if os.path.exists(organisation_logo_file): return organisation_logo_file else: LOGGER.info( 'The custom organisation logo is not found in {logo_path}. ' 'Default organisation logo will be used.').format( logo_path=organisation_logo_file) return inasafe_default_settings['organisation_logo_path']
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier expression_list identifier identifier expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list identifier block return_statement identifier else_clause block expression_statement call attribute call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list keyword_argument identifier identifier return_statement subscript identifier string string_start string_content string_end
Retrieve the full path of used specified organisation logo.
def compute(self, text, lang = "eng"): params = { "lang": lang, "text": text, "topClustersCount": self._nrOfEventsToReturn } res = self._er.jsonRequest("/json/getEventForText/enqueueRequest", params) requestId = res["requestId"] for i in range(10): time.sleep(1) res = self._er.jsonRequest("/json/getEventForText/testRequest", { "requestId": requestId }) if isinstance(res, list) and len(res) > 0: return res return None
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block 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 attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end for_statement identifier call identifier argument_list integer block expression_statement call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end identifier if_statement boolean_operator call identifier argument_list identifier identifier comparison_operator call identifier argument_list identifier integer block return_statement identifier return_statement none
compute the list of most similar events for the given text
def close(self): if callable(getattr(self._file, 'close', None)): self._iterator.close() self._iterator = None self._unconsumed = None self.closed = True
module function_definition identifier parameters identifier block if_statement call identifier argument_list call identifier argument_list attribute identifier identifier string string_start string_content string_end none block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier true
Disable al operations and close the underlying file-like object, if any
def keys(self): keys = self._keys if keys is None: keys = tuple(self[i].name for i in self.key_indices) return keys
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier generator_expression attribute subscript identifier identifier identifier for_in_clause identifier attribute identifier identifier return_statement identifier
Return the tuple of field names of key fields.
def _complete_execution(self, g): assert g.ready() self.greenlets.remove(g) placed = UserCritical(msg='placeholder bogus exception', hint='report a bug') if g.successful(): try: segment = g.get() if not segment.explicit: segment.mark_done() except BaseException as e: placed = e else: placed = None else: placed = g.exception self.wait_change.put(placed)
module function_definition identifier parameters identifier identifier block assert_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier 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 if_statement call attribute identifier identifier argument_list block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier none else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Forward any raised exceptions across a channel.
def skip(): if not settings.platformCompatible(): return False (output, error) = subprocess.Popen(["osascript", "-e", SKIP], stdout=subprocess.PIPE).communicate()
module function_definition identifier parameters block if_statement not_operator call attribute identifier identifier argument_list block return_statement false expression_statement assignment tuple_pattern identifier identifier call attribute call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end identifier keyword_argument identifier attribute identifier identifier identifier argument_list
Tell iTunes to skip a song
def _is_bright(rgb): r, g, b = rgb gray = 0.299 * r + 0.587 * g + 0.114 * b return gray >= .5
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier identifier expression_statement assignment identifier binary_operator binary_operator binary_operator float identifier binary_operator float identifier binary_operator float identifier return_statement comparison_operator identifier float
Return whether a RGB color is bright or not.
def apply_customizations(cls, spec, options): for key in sorted(spec.keys()): if isinstance(spec[key], (list, tuple)): customization = {v.key:v for v in spec[key]} else: customization = {k:(Options(**v) if isinstance(v, dict) else v) for k,v in spec[key].items()} customization = {k:v.keywords_target(key.split('.')[0]) for k,v in customization.items()} options[str(key)] = customization return options
module function_definition identifier parameters identifier identifier identifier block for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block if_statement call identifier argument_list subscript identifier identifier tuple identifier identifier block expression_statement assignment identifier dictionary_comprehension pair attribute identifier identifier identifier for_in_clause identifier subscript identifier identifier else_clause block expression_statement assignment identifier dictionary_comprehension pair identifier parenthesized_expression conditional_expression call identifier argument_list dictionary_splat identifier call identifier argument_list identifier identifier identifier for_in_clause pattern_list identifier identifier call attribute subscript identifier identifier identifier argument_list expression_statement assignment identifier dictionary_comprehension pair identifier call attribute identifier identifier argument_list subscript call attribute identifier identifier argument_list string string_start string_content string_end integer for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier call identifier argument_list identifier identifier return_statement identifier
Apply the given option specs to the supplied options tree.
def _remove_wrappers(self): ansible_mitogen.loaders.action_loader.get = action_loader__get ansible_mitogen.loaders.connection_loader.get = connection_loader__get ansible.executor.process.worker.WorkerProcess.run = worker__run
module function_definition identifier parameters identifier block expression_statement assignment attribute attribute attribute identifier identifier identifier identifier identifier expression_statement assignment attribute attribute attribute identifier identifier identifier identifier identifier expression_statement assignment attribute attribute attribute attribute attribute identifier identifier identifier identifier identifier identifier identifier
Uninstall the PluginLoader monkey patches.
def view(self, request, group, **kwargs): if request.method == 'POST': message = request.POST.get('message') if message is not None and message.strip(): comment = GroupComments(group=group, author=request.user, message=message.strip()) comment.save() msg = _(u'Comment added.') if request.POST.get('sendmail', ''): self._send_mail(comment, group) if 'postresolve' in request.POST: self._resolve_group(request, group) msg = _(u'Comment added and event marked as resolved.') messages.success(request, msg) return HttpResponseRedirect(request.path) query = GroupComments.objects.filter(group=group).order_by('-created') return self.render('sentry_comments/index.html', { 'comments': query, 'group': group, })
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block 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 string string_start string_content string_end if_statement boolean_operator comparison_operator identifier none call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end block expression_statement call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier return_statement call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list 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 identifier
Display and store comments.
def unit(self): return Vector( (self.x / self.magnitude()), (self.y / self.magnitude()), (self.z / self.magnitude()) )
module function_definition identifier parameters identifier block return_statement call identifier argument_list parenthesized_expression binary_operator attribute identifier identifier call attribute identifier identifier argument_list parenthesized_expression binary_operator attribute identifier identifier call attribute identifier identifier argument_list parenthesized_expression binary_operator attribute identifier identifier call attribute identifier identifier argument_list
Return a Vector instance of the unit vector
def anyword_substring_search(target_words, query_words): matches_required = len(query_words) matches_found = 0 for query_word in query_words: reply = anyword_substring_search_inner(query_word, target_words) if reply is not False: matches_found += 1 else: return False if(matches_found == matches_required): return True else: return False
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier integer for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement comparison_operator identifier false block expression_statement augmented_assignment identifier integer else_clause block return_statement false if_statement parenthesized_expression comparison_operator identifier identifier block return_statement true else_clause block return_statement false
return True if all query_words match
def start(self, *args, **kwargs): self._stop = False super(Plant, self).start(*args, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment attribute identifier identifier false expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list list_splat identifier dictionary_splat identifier
start the instrument thread
def populate_source(cls, source): if "name" not in source: source["name"] = get_url_name(source["url"]) if "verify_ssl" not in source: source["verify_ssl"] = "https://" in source["url"] if not isinstance(source["verify_ssl"], bool): source["verify_ssl"] = source["verify_ssl"].lower() == "true" return source
module function_definition identifier parameters 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 call identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement not_operator call identifier argument_list subscript identifier string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end comparison_operator call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end return_statement identifier
Derive missing values of source from the existing fields.
def download_url(url, filename, headers): ensure_dirs(filename) response = requests.get(url, headers=headers, stream=True) if response.status_code == 200: with open(filename, 'wb') as f: for chunk in response.iter_content(16 * 1024): f.write(chunk)
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier true if_statement comparison_operator attribute identifier identifier integer 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 for_statement identifier call attribute identifier identifier argument_list binary_operator integer integer block expression_statement call attribute identifier identifier argument_list identifier
Download a file from `url` to `filename`.
def project_path(*names): return os.path.join(os.path.dirname(__file__), *names)
module function_definition identifier parameters list_splat_pattern identifier block return_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier list_splat identifier
Path to a file in the project.
def unregister(self, recipe): recipe = self.get_recipe_instance_from_class(recipe) if recipe.slug in self._registry: del self._registry[recipe.slug]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block delete_statement subscript attribute identifier identifier attribute identifier identifier
Unregisters a given recipe class.
def _get_candidates(self, v): candidates = [] for lshash in self.lshashes: for bucket_key in lshash.hash_vector(v, querying=True): bucket_content = self.storage.get_bucket( lshash.hash_name, bucket_key, ) candidates.extend(bucket_content) return candidates
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block for_statement identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Collect candidates from all buckets from all hashes
def reset(cls): cls._codecs = {} c = cls._codec for (name, encode, decode) in cls._common_codec_data: cls._codecs[name] = c(encode, decode)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier dictionary expression_statement assignment identifier attribute identifier identifier for_statement tuple_pattern identifier identifier identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list identifier identifier
Reset the registry to the standard codecs.
def el_is_empty(el): if len(el) == 1 and not isinstance(el[0], (list, tuple)): return True subels_are_empty = [] for subel in el: if isinstance(subel, (list, tuple)): subels_are_empty.append(el_is_empty(subel)) else: subels_are_empty.append(not bool(subel)) return all(subels_are_empty)
module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator call identifier argument_list identifier integer not_operator call identifier argument_list subscript identifier integer tuple identifier identifier block return_statement true expression_statement assignment identifier list for_statement identifier identifier block if_statement call identifier argument_list identifier tuple 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 not_operator call identifier argument_list identifier return_statement call identifier argument_list identifier
Return ``True`` if tuple ``el`` represents an empty XML element.
def reference_year(self, index): ref_date = self.reference_date(index) try: return parse(ref_date).year except ValueError: matched = re.search(r"\d{4}", ref_date) if matched: return int(matched.group()) else: return ""
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier try_statement block return_statement attribute call identifier argument_list identifier identifier except_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list else_clause block return_statement string string_start string_end
Return the reference publication year.
def update_positions(self, positions): sphs_verts = self.sphs_verts_radii.copy() sphs_verts += positions.reshape(self.n_spheres, 1, 3) self.tr.update_vertices(sphs_verts) self.poslist = positions
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement augmented_assignment identifier call attribute identifier identifier argument_list attribute identifier identifier integer integer expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier
Update the sphere positions.
def common_package_action_options(f): @click.option( "-s", "--skip-errors", default=False, is_flag=True, help="Skip/ignore errors when copying packages.", ) @click.option( "-W", "--no-wait-for-sync", default=False, is_flag=True, help="Don't wait for package synchronisation to complete before " "exiting.", ) @click.option( "-I", "--wait-interval", default=5.0, type=float, show_default=True, help="The time in seconds to wait between checking synchronisation.", ) @click.option( "--sync-attempts", default=3, type=int, help="Number of times to attempt package synchronisation. If the " "package fails the first time, the client will attempt to " "automatically resynchronise it.", ) @click.pass_context @functools.wraps(f) def wrapper(ctx, *args, **kwargs): return ctx.invoke(f, *args, **kwargs) return wrapper
module function_definition identifier parameters identifier block decorated_definition decorator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier false keyword_argument identifier true keyword_argument identifier string string_start string_content string_end decorator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier false keyword_argument identifier true keyword_argument identifier concatenated_string string string_start string_content string_end string string_start string_content string_end decorator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier float keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier string string_start string_content string_end decorator call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier integer keyword_argument identifier identifier keyword_argument identifier concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end decorator attribute identifier identifier decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement identifier
Add common options for package actions.
def _translate_str(self, oprnd1, oprnd2, oprnd3): assert oprnd1.size and oprnd3.size op1_var = self._translate_src_oprnd(oprnd1) op3_var, op3_var_constrs = self._translate_dst_oprnd(oprnd3) if oprnd3.size > oprnd1.size: result = smtfunction.zero_extend(op1_var, op3_var.size) elif oprnd3.size < oprnd1.size: result = smtfunction.extract(op1_var, 0, op3_var.size) else: result = op1_var return [op3_var == result] + op3_var_constrs
module function_definition identifier parameters identifier identifier identifier identifier block assert_statement boolean_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier integer attribute identifier identifier else_clause block expression_statement assignment identifier identifier return_statement binary_operator list comparison_operator identifier identifier identifier
Return a formula representation of a STR instruction.
def serving_from_csv_input(train_config, args, keep_target): examples = tf.placeholder( dtype=tf.string, shape=(None,), name='csv_input_string') features = parse_example_tensor(examples=examples, train_config=train_config, keep_target=keep_target) if keep_target: target = features.pop(train_config['target_column']) else: target = None features, target = preprocess_input( features=features, target=target, train_config=train_config, preprocess_output_dir=args.preprocess_output_dir, model_type=args.model_type) return input_fn_utils.InputFnOps(features, target, {'csv_line': examples} )
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier tuple none keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end else_clause block expression_statement assignment identifier none expression_statement assignment pattern_list identifier identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier dictionary pair string string_start string_content string_end identifier
Read the input features from a placeholder csv string tensor.
def _find_usage_network_interfaces(self): enis = paginate_dict( self.conn.describe_network_interfaces, alc_marker_path=['NextToken'], alc_data_path=['NetworkInterfaces'], alc_marker_param='NextToken' ) self.limits['Network interfaces per Region']._add_current_usage( len(enis['NetworkInterfaces']), aws_type='AWS::EC2::NetworkInterface' )
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier keyword_argument identifier list string string_start string_content string_end keyword_argument identifier list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end
find usage of network interfaces
def authenticate_credentials(self, userid, password): credentials = { get_user_model().USERNAME_FIELD: userid, 'password': password } user = authenticate(**credentials) if user is None: raise exceptions.AuthenticationFailed(_('Invalid username/password.')) if not user.is_active: raise exceptions.AuthenticationFailed(_('User inactive or deleted.')) return (user, None)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary pair attribute call identifier argument_list identifier identifier pair string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list dictionary_splat identifier if_statement comparison_operator identifier none block raise_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end if_statement not_operator attribute identifier identifier block raise_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end return_statement tuple identifier none
Authenticate the userid and password against username and password.
def _smooth_hpx_map(hpx_map, sigma): if hpx_map.hpx.ordering == "NESTED": ring_map = hpx_map.swap_scheme() else: ring_map = hpx_map ring_data = ring_map.data.copy() nebins = len(hpx_map.data) smoothed_data = np.zeros((hpx_map.data.shape)) for i in range(nebins): smoothed_data[i] = healpy.sphtfunc.smoothing( ring_data[i], sigma=np.radians(sigma), verbose=False) smoothed_data.clip(0., 1e99) smoothed_ring_map = HpxMap(smoothed_data, ring_map.hpx) if hpx_map.hpx.ordering == "NESTED": return smoothed_ring_map.swap_scheme() return smoothed_ring_map
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list parenthesized_expression attribute attribute identifier identifier identifier for_statement identifier call identifier argument_list identifier block expression_statement assignment subscript identifier identifier call attribute attribute identifier identifier identifier argument_list subscript identifier identifier keyword_argument identifier call attribute identifier identifier argument_list identifier keyword_argument identifier false expression_statement call attribute identifier identifier argument_list float float expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier if_statement comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list return_statement identifier
Smooth a healpix map using a Gaussian
def quote_code(self, key): code = self.grid.code_array(key) quoted_code = quote(code) if quoted_code is not None: self.set_code(key, quoted_code)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier identifier
Returns string quoted code
def authenticate_admin(self, transport, account_name, password): Authenticator.authenticate_admin(self, transport, account_name, password) auth_token = AuthToken() auth_token.account_name = account_name params = {sconstant.E_NAME: account_name, sconstant.E_PASSWORD: password} self.log.debug('Authenticating admin %s' % account_name) try: res = transport.invoke(zconstant.NS_ZIMBRA_ADMIN_URL, sconstant.AuthRequest, params, auth_token) except SoapException as exc: raise AuthException(unicode(exc), exc) auth_token.token = res.authToken auth_token.session_id = res.sessionId self.log.info('Authenticated admin %s, session id %s' % (account_name, auth_token.session_id)) return auth_token
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier dictionary pair attribute identifier identifier identifier pair attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier identifier identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list call identifier argument_list identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier return_statement identifier
Authenticates administrator using username and password.
def _blackbox_partial_noise(blackbox, system): node_tpms = [] for node in system.nodes: node_tpm = node.tpm_on for input_node in node.inputs: if blackbox.hidden_from(input_node, node.index): node_tpm = marginalize_out([input_node], node_tpm) node_tpms.append(node_tpm) tpm = rebuild_system_tpm(node_tpms) return system._replace(tpm=tpm)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier for_statement identifier attribute identifier identifier block if_statement call attribute identifier identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list list identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
Noise connections from hidden elements to other boxes.
def local(reload, port): import logging from bottle import run from app import controller, app from c7n.resources import load_resources load_resources() print("Loaded resources definitions") logging.basicConfig(level=logging.DEBUG) logging.getLogger('botocore').setLevel(logging.WARNING) if controller.db.provision(): print("Table Created") run(app, reloader=reload, port=port)
module function_definition identifier parameters identifier identifier block import_statement dotted_name identifier import_from_statement dotted_name identifier dotted_name identifier import_from_statement dotted_name identifier dotted_name identifier dotted_name identifier import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement call identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list attribute identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier
run local app server, assumes into the account
def find(path, saltenv='base'): ret = [] if saltenv not in __opts__['pillar_roots']: return ret for root in __opts__['pillar_roots'][saltenv]: full = os.path.join(root, path) if os.path.isfile(full): with salt.utils.files.fopen(full, 'rb') as fp_: if salt.utils.files.is_text(fp_): ret.append({full: 'txt'}) else: ret.append({full: 'bin'}) return ret
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier list if_statement comparison_operator identifier subscript identifier string string_start string_content string_end block return_statement identifier for_statement identifier subscript subscript identifier string string_start string_content string_end identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block with_statement with_clause with_item as_pattern call attribute attribute attribute identifier identifier identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block if_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list dictionary pair identifier string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list dictionary pair identifier string string_start string_content string_end return_statement identifier
Return a dict of the files located with the given path and environment
def notify(self, data): LOG.debug('notify received: %s', data) self._notify_count += 1 if self._cancelled: LOG.debug('notify skipping due to `cancelled`') return self if self._once_done and self._once: LOG.debug('notify skipping due to `once`') return self with self._lock: try: self._waitables.get_nowait().put_nowait(data) LOG.debug('found a consumer, notifying') except queue.Empty: try: self._notifications.put_nowait(data) LOG.debug('no consumers, queueing data') except queue.Full: LOG.warning('notification queue full - discarding new data') for callback in self._callbacks: LOG.debug('callback: %s', callback) callback(data) self._once_done = True return self
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement augmented_assignment attribute identifier identifier integer if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier if_statement boolean_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier with_statement with_clause with_item attribute identifier identifier block try_statement block expression_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end except_clause attribute identifier identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call identifier argument_list identifier expression_statement assignment attribute identifier identifier true return_statement identifier
Notify this observer that data has arrived
def _load_weird_container(container_name): old_container_loading.load_all_containers_from_disk() container = old_container_loading.get_persisted_container( container_name) rotated_container = database_migration.rotate_container_for_alpha( container) database.save_new_container(rotated_container, container_name) return container
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier
Load a container from persisted containers, whatever that is
def do_add_signature(input_file, output_file, signature_file): signature = open(signature_file, 'rb').read() if len(signature) == 256: hash_algo = 'sha1' elif len(signature) == 512: hash_algo = 'sha384' else: raise ValueError() with open(output_file, 'w+b') as dst: with open(input_file, 'rb') as src: add_signature_block(src, dst, hash_algo, signature)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier string string_start string_content string_end identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier string string_start string_content string_end else_clause block raise_statement 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 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 identifier identifier
Add a signature to the MAR file.
def readCommaList(fileList): names=fileList.split(',') fileList=[] for item in names: fileList.append(item) return fileList
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 list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Return a list of the files with the commas removed.
def make(self, url, browsers=None, destination=None, timeout=DEFAULT_TIMEOUT, retries=DEFAULT_RETRIES, **kwargs): response = self.generate(url, browsers, **kwargs) return self.download(response['job_id'], destination, timeout, retries)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier identifier default_parameter identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier return_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier identifier identifier
Generates screenshots for given settings and saves it to specified destination.
def membuf_tempfile(memfile): memfile.seek(0, 0) tmpfd, tmpname = mkstemp(suffix='.rar') tmpf = os.fdopen(tmpfd, "wb") try: while True: buf = memfile.read(BSIZE) if not buf: break tmpf.write(buf) tmpf.close() except: tmpf.close() os.unlink(tmpname) raise return tmpname
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list integer integer expression_statement assignment pattern_list identifier identifier call identifier argument_list keyword_argument identifier 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 try_statement block while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block break_statement expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list except_clause block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier raise_statement return_statement identifier
Write in-memory file object to real file.
def _ProcessImage(self, tag, wall_time, step, image): event = ImageEvent(wall_time=wall_time, step=step, encoded_image_string=image.encoded_image_string, width=image.width, height=image.height) self.images.AddItem(tag, event)
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
Processes an image by adding it to accumulated state.
def toggle_sensor(request, sensorname): if service.read_only: service.logger.warning("Could not perform operation: read only mode enabled") raise Http404 source = request.GET.get('source', 'main') sensor = service.system.namespace[sensorname] sensor.status = not sensor.status service.system.flush() return HttpResponseRedirect(reverse(source))
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end raise_statement identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier subscript attribute attribute identifier identifier identifier identifier expression_statement assignment attribute identifier identifier not_operator attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list return_statement call identifier argument_list call identifier argument_list identifier
This is used only if websocket fails
def doc(elt): "Show `show_doc` info in preview window along with link to full docs." global use_relative_links use_relative_links = False elt = getattr(elt, '__func__', elt) md = show_doc(elt, markdown=False) if is_fastai_class(elt): md += f'\n\n<a href="{get_fn_link(elt)}" target="_blank" rel="noreferrer noopener">Show in docs</a>' output = HTMLExporter().markdown2html(md) use_relative_links = True if IS_IN_COLAB: get_ipython().run_cell_magic(u'html', u'', output) else: try: page.page({'text/html': output}) except: display(Markdown(md))
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end global_statement identifier expression_statement assignment identifier false expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier false if_statement call identifier argument_list identifier block expression_statement augmented_assignment identifier string string_start string_content escape_sequence escape_sequence interpolation call identifier argument_list identifier string_content string_end expression_statement assignment identifier call attribute call identifier argument_list identifier argument_list identifier expression_statement assignment identifier true if_statement identifier block expression_statement call attribute call identifier argument_list identifier argument_list string string_start string_content string_end string string_start string_end identifier else_clause block try_statement block expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier except_clause block expression_statement call identifier argument_list call identifier argument_list identifier
Show `show_doc` info in preview window along with link to full docs.
def parse_macro_params(token): try: bits = token.split_contents() tag_name, macro_name, values = bits[0], bits[1], bits[2:] except IndexError: raise template.TemplateSyntaxError( "{0} tag requires at least one argument (macro name)".format( token.contents.split()[0])) args = [] kwargs = {} kwarg_regex = ( r'^([A-Za-z_][\w_]*)=(".*"|{0}.*{0}|[A-Za-z_][\w_]*)$'.format( "'")) arg_regex = r'^([A-Za-z_][\w_]*|".*"|{0}.*{0}|(\d+))$'.format( "'") for value in values: kwarg_match = regex_match( kwarg_regex, value) if kwarg_match: kwargs[kwarg_match.groups()[0]] = template.Variable( kwarg_match.groups()[1]) else: arg_match = regex_match( arg_regex, value) if arg_match: args.append(template.Variable(arg_match.groups()[0])) else: raise template.TemplateSyntaxError( "Malformed arguments to the {0} tag.".format( tag_name)) return tag_name, macro_name, args, kwargs
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier identifier expression_list subscript identifier integer subscript identifier integer subscript identifier slice integer except_clause identifier block raise_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript call attribute attribute identifier identifier identifier argument_list integer expression_statement assignment identifier list expression_statement assignment identifier dictionary expression_statement assignment identifier parenthesized_expression call attribute string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement identifier block expression_statement assignment subscript identifier subscript call attribute identifier identifier argument_list integer call attribute identifier identifier argument_list subscript call attribute identifier identifier argument_list integer else_clause block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list subscript call attribute identifier identifier argument_list integer else_clause block raise_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement expression_list identifier identifier identifier identifier
Common parsing logic for both use_macro and macro_block
def fitness(self, width, height): assert(width > 0 and height >0) if width > max(self.width, self.height) or\ height > max(self.height, self.width): return None if self._waste_management: if self._waste.fitness(width, height) is not None: return 0 rect, fitness = self._select_position(width, height) return fitness
module function_definition identifier parameters identifier identifier identifier block assert_statement parenthesized_expression boolean_operator comparison_operator identifier integer comparison_operator identifier integer if_statement boolean_operator comparison_operator identifier call identifier argument_list attribute identifier identifier attribute identifier identifier line_continuation comparison_operator identifier call identifier argument_list attribute identifier identifier attribute identifier identifier block return_statement none if_statement attribute identifier identifier block if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list identifier identifier none block return_statement integer expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier
Search for the best fitness
def _scrub_generated_timestamps(self, target_workdir): for root, _, filenames in safe_walk(target_workdir): for filename in filenames: source = os.path.join(root, filename) with open(source, 'r') as f: lines = f.readlines() if len(lines) < 1: return with open(source, 'w') as f: if not self._COMMENT_WITH_TIMESTAMP_RE.match(lines[0]): f.write(lines[0]) for line in lines[1:]: f.write(line)
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier identifier call identifier argument_list identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier 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 assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block return_statement 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 if_statement not_operator call attribute attribute identifier identifier identifier argument_list subscript identifier integer block expression_statement call attribute identifier identifier argument_list subscript identifier integer for_statement identifier subscript identifier slice integer block expression_statement call attribute identifier identifier argument_list identifier
Remove the first line of comment from each file if it contains a timestamp.
def _str(value, depth): output = [] if depth >0 and _get(value, CLASS) in data_types: for k, v in value.items(): output.append(str(k) + "=" + _str(v, depth - 1)) return "{" + ",\n".join(output) + "}" elif depth >0 and is_list(value): for v in value: output.append(_str(v, depth-1)) return "[" + ",\n".join(output) + "]" else: return str(type(value))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list if_statement boolean_operator comparison_operator identifier integer comparison_operator call identifier argument_list identifier identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator call identifier argument_list identifier string string_start string_content string_end call identifier argument_list identifier binary_operator identifier integer return_statement binary_operator binary_operator string string_start string_content string_end call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier string string_start string_content string_end elif_clause boolean_operator comparison_operator identifier integer call identifier argument_list identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier binary_operator identifier integer return_statement binary_operator binary_operator string string_start string_content string_end call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier string string_start string_content string_end else_clause block return_statement call identifier argument_list call identifier argument_list identifier
FOR DEBUGGING POSSIBLY RECURSIVE STRUCTURES
def __set_transaction_detail(self, *args, **kwargs): customer_transaction_id = kwargs.get('customer_transaction_id', None) if customer_transaction_id: transaction_detail = self.client.factory.create('TransactionDetail') transaction_detail.CustomerTransactionId = customer_transaction_id self.logger.debug(transaction_detail) self.TransactionDetail = transaction_detail
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none if_statement identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier
Checks kwargs for 'customer_transaction_id' and sets it if present.
def list_build_set_records(id=None, name=None, page_size=200, page_index=0, sort="", q=""): content = list_build_set_records_raw(id, name, page_size, page_index, sort, q) if content: return utils.format_json_list(content)
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none default_parameter identifier integer default_parameter identifier integer default_parameter identifier string string_start string_end default_parameter identifier string string_start string_end block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier identifier if_statement identifier block return_statement call attribute identifier identifier argument_list identifier
List all build set records for a BuildConfigurationSet
def _compute_error(self): self._err = np.sum(np.multiply(self._R_k, self._C_k.T), axis=0) - self._d
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier binary_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier keyword_argument identifier integer attribute identifier identifier
Evaluate the absolute error of the Nystroem approximation for each column
def st_atime(self): atime = self._st_atime_ns / 1e9 return atime if self.use_float else int(atime)
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator attribute identifier identifier float return_statement conditional_expression identifier attribute identifier identifier call identifier argument_list identifier
Return the access time in seconds.
def arm(self, value): if value: return api.request_system_arm(self.blink, self.network_id) return api.request_system_disarm(self.blink, self.network_id)
module function_definition identifier parameters identifier identifier block if_statement identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier
Arm or disarm system.
def teecsv(table, source=None, encoding=None, errors='strict', write_header=True, **csvargs): source = write_source_from_arg(source) csvargs.setdefault('dialect', 'excel') return teecsv_impl(table, source=source, encoding=encoding, errors=errors, write_header=write_header, **csvargs)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier true dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier dictionary_splat identifier
Returns a table that writes rows to a CSV file as they are iterated over.
def cygpath(filename): if sys.platform == 'cygwin': proc = Popen(['cygpath', '-am', filename], stdout=PIPE) return proc.communicate()[0].strip() else: return filename
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list list string string_start string_content string_end string string_start string_content string_end identifier keyword_argument identifier identifier return_statement call attribute subscript call attribute identifier identifier argument_list integer identifier argument_list else_clause block return_statement identifier
Convert a cygwin path into a windows style path
def load_or_create_config(self, filename, config=None): os.makedirs(os.path.dirname(os.path.expanduser(filename)), exist_ok=True) if os.path.exists(filename): return self.load(filename) if(config == None): config = self.random_config() self.save(filename, config) return config
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier true if_statement call attribute attribute identifier identifier identifier argument_list identifier block return_statement call attribute identifier identifier argument_list identifier if_statement parenthesized_expression comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier
Loads a config from disk. Defaults to a random config if none is specified
def limit(self, limit): query = self._copy() query._limit = limit return query
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier return_statement identifier
Apply a LIMIT to the query and return the newly resulting Query.
def geometric_mean(data): if not data: raise StatisticsError('geometric_mean requires at least one data point') data = [x if x > 0 else math.e if x == 0 else 1.0 for x in data] return math.pow(math.fabs(functools.reduce(operator.mul, data)), 1.0 / len(data))
module function_definition identifier parameters identifier block if_statement not_operator identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier list_comprehension conditional_expression identifier comparison_operator identifier integer conditional_expression attribute identifier identifier comparison_operator identifier integer float for_in_clause identifier identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier binary_operator float call identifier argument_list identifier
Return the geometric mean of data
def networks(self, role="all", full="all"): if full not in ["all", True, False]: raise ValueError( "full must be boolean or all, it cannot be {}".format(full) ) if full == "all": if role == "all": return Network.query.all() else: return Network.query.filter_by(role=role).all() else: if role == "all": return Network.query.filter_by(full=full).all() else: return Network.query.filter( and_(Network.role == role, Network.full == full) ).all()
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block if_statement comparison_operator identifier list string string_start string_content string_end true false block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block if_statement comparison_operator identifier string string_start string_content string_end block return_statement call attribute attribute identifier identifier identifier argument_list else_clause block return_statement call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier identifier argument_list else_clause block if_statement comparison_operator identifier string string_start string_content string_end block return_statement call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier identifier argument_list else_clause block return_statement call attribute call attribute attribute identifier identifier identifier argument_list call identifier argument_list comparison_operator attribute identifier identifier identifier comparison_operator attribute identifier identifier identifier identifier argument_list
All the networks in the experiment.
def list_datasources(self, source_id): target_url = self.client.get_url('DATASOURCE', 'GET', 'multi', {'source_id': source_id}) return base.Query(self.client.get_manager(Datasource), target_url)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end dictionary pair string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier
Filterable list of Datasources for a Source.
def debugger(): sdb = _current[0] if sdb is None or not sdb.active: sdb = _current[0] = Sdb() return sdb
module function_definition identifier parameters block expression_statement assignment identifier subscript identifier integer if_statement boolean_operator comparison_operator identifier none not_operator attribute identifier identifier block expression_statement assignment identifier assignment subscript identifier integer call identifier argument_list return_statement identifier
Return the current debugger instance, or create if none.
def cublasSsymm(handle, side, uplo, m, n, alpha, A, lda, B, ldb, beta, C, ldc): status = _libcublas.cublasSsymm_v2(handle, _CUBLAS_SIDE_MODE[side], _CUBLAS_FILL_MODE[uplo], m, n, ctypes.byref(ctypes.c_float(alpha)), int(A), lda, int(B), ldb, ctypes.byref(ctypes.c_float(beta)), int(C), ldc) cublasCheckStatus(status)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier subscript identifier identifier subscript identifier identifier identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier call identifier argument_list identifier identifier call identifier argument_list identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier
Matrix-matrix product for symmetric matrix.
def create_bzip2 (archive, compression, cmd, verbosity, interactive, filenames): if len(filenames) > 1: raise util.PatoolError('multi-file compression not supported in Python bz2') try: with bz2.BZ2File(archive, 'wb') as bz2file: filename = filenames[0] with open(filename, 'rb') as srcfile: data = srcfile.read(READ_SIZE_BYTES) while data: bz2file.write(data) data = srcfile.read(READ_SIZE_BYTES) except Exception as err: msg = "error creating %s: %s" % (archive, err) raise util.PatoolError(msg) return None
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end try_statement block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier subscript identifier integer 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 assignment identifier call attribute identifier identifier argument_list identifier while_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier raise_statement call attribute identifier identifier argument_list identifier return_statement none
Create a BZIP2 archive with the bz2 Python module.
def indent(text: str, num: int = 2) -> str: lines = text.splitlines() return "\n".join(indent_iterable(lines, num=num))
module function_definition identifier parameters typed_parameter identifier type identifier typed_default_parameter identifier type identifier integer type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call attribute string string_start string_content escape_sequence string_end identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier
Indent a piece of text.
def _get_drive_api(credentials): http = httplib2.Http() http = credentials.authorize(http) service = discovery.build('drive', 'v2', http=http) service.credentials = credentials return service
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
For a given set of credentials, return a drive API object.
def makeUnicodeToGlyphNameMapping(self): compiler = self.context.compiler cmap = None if compiler is not None: table = compiler.ttFont.get("cmap") if table is not None: cmap = table.getBestCmap() if cmap is None: from ufo2ft.util import makeUnicodeToGlyphNameMapping if compiler is not None: glyphSet = compiler.glyphSet else: glyphSet = self.context.font cmap = makeUnicodeToGlyphNameMapping(glyphSet) return cmap
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier none if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block import_from_statement dotted_name identifier identifier dotted_name identifier if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
Return the Unicode to glyph name mapping for the current font.
def re_general(Vel, Area, PerimWetted, Nu): ut.check_range([Vel, ">=0", "Velocity"], [Nu, ">0", "Nu"]) return 4 * radius_hydraulic_general(Area, PerimWetted).magnitude * Vel / Nu
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list list identifier string string_start string_content string_end string string_start string_content string_end list identifier string string_start string_content string_end string string_start string_content string_end return_statement binary_operator binary_operator binary_operator integer attribute call identifier argument_list identifier identifier identifier identifier identifier
Return the Reynolds Number for a general cross section.
def _load(self, dataset_spec): for idx, ds in enumerate(dataset_spec): self.append(ds, idx)
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
Actual loading of datasets
def getWaitingFeedbacks(self): feedbacks = [] offset = 0 amount = self.__ask__('doGetWaitingFeedbacksCount') while amount > 0: rc = self.__ask__('doGetWaitingFeedbacks', offset=offset, packageSize=200) feedbacks.extend(rc['feWaitList']) amount -= 200 offset += 1 return feedbacks
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end while_statement comparison_operator identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement augmented_assignment identifier integer expression_statement augmented_assignment identifier integer return_statement identifier
Return all waiting feedbacks from buyers.
def add_timeframed_query_manager(sender, **kwargs): if not issubclass(sender, TimeFramedModel): return if _field_exists(sender, 'timeframed'): raise ImproperlyConfigured( "Model '%s' has a field named 'timeframed' " "which conflicts with the TimeFramedModel manager." % sender.__name__ ) sender.add_to_class('timeframed', QueryManager( (models.Q(start__lte=now) | models.Q(start__isnull=True)) & (models.Q(end__gte=now) | models.Q(end__isnull=True)) ))
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block if_statement not_operator call identifier argument_list identifier identifier block return_statement if_statement call identifier argument_list identifier string string_start string_content string_end 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 attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list binary_operator parenthesized_expression binary_operator call attribute identifier identifier argument_list keyword_argument identifier identifier call attribute identifier identifier argument_list keyword_argument identifier true parenthesized_expression binary_operator call attribute identifier identifier argument_list keyword_argument identifier identifier call attribute identifier identifier argument_list keyword_argument identifier true
Add a QueryManager for a specific timeframe.
def len(self): def stream_len(stream): cur = stream.tell() try: stream.seek(0, 2) return stream.tell() - cur finally: stream.seek(cur) return sum(stream_len(s) for s in self.streams)
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement call attribute identifier identifier argument_list integer integer return_statement binary_operator call attribute identifier identifier argument_list identifier finally_clause block expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier generator_expression call identifier argument_list identifier for_in_clause identifier attribute identifier identifier
Length of the data stream
def create_bokeh_server(io_loop, files, argvs, host, port): from bokeh.server.server import Server from bokeh.command.util import build_single_handler_applications apps = build_single_handler_applications(files, argvs) kwargs = { 'io_loop':io_loop, 'generate_session_ids':True, 'redirect_root':True, 'use_x_headers':False, 'secret_key':None, 'num_procs':1, 'host': host, 'sign_sessions':False, 'develop':False, 'port':port, 'use_index':True } server = Server(apps,**kwargs) return server
module function_definition identifier parameters identifier identifier identifier identifier identifier block import_from_statement dotted_name identifier identifier identifier dotted_name identifier import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end true pair string string_start string_content string_end true pair string string_start string_content string_end false pair string string_start string_content string_end none pair string string_start string_content string_end integer pair string string_start string_content string_end identifier pair string string_start string_content string_end false pair string string_start string_content string_end false pair string string_start string_content string_end identifier pair string string_start string_content string_end true expression_statement assignment identifier call identifier argument_list identifier dictionary_splat identifier return_statement identifier
Start bokeh server with applications paths
def master_call(self, **kwargs): load = kwargs load['cmd'] = self.client channel = salt.transport.client.ReqChannel.factory(self.opts, crypt='clear', usage='master_call') try: ret = channel.send(load) finally: channel.close() if isinstance(ret, collections.Mapping): if 'error' in ret: salt.utils.error.raise_error(**ret['error']) return ret
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier finally_clause block expression_statement call attribute identifier identifier argument_list if_statement call identifier argument_list identifier attribute identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list dictionary_splat subscript identifier string string_start string_content string_end return_statement identifier
Execute a function through the master network interface.
def set(self, key, value): task = Task.current_task() try: context = task._context except AttributeError: task._context = context = {} context[key] = value
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier attribute identifier identifier except_clause identifier block expression_statement assignment attribute identifier identifier assignment identifier dictionary expression_statement assignment subscript identifier identifier identifier
Set a value in the task context
def show_data_file(fname): txt = '<H2>' + fname + '</H2>' print (fname) txt += web.read_csv_to_html_table(fname, 'Y') txt += '</div>\n' return txt
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end expression_statement call identifier argument_list identifier expression_statement augmented_assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end return_statement identifier
shows a data file in CSV format - all files live in CORE folder
def beginning_of_line(event): " Move to the start of the current line. " buff = event.current_buffer buff.cursor_position += buff.document.get_start_of_line_position(after_whitespace=False)
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier false
Move to the start of the current line.
def on_close(self): log.info('WebSocket connection closed: code=%s, reason=%r', self.close_code, self.close_reason) if self.connection is not None: self.application.client_lost(self.connection)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Clean up when the connection is closed.
def list_files(dirname, extension=None): f = [] for (dirpath, dirnames, filenames) in os.walk(dirname): f.extend(filenames) break if extension is not None: filtered = [] for filename in f: fn, ext = os.path.splitext(filename) if ext.lower() == '.' + extension.lower(): filtered.append(filename) f = filtered return f
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier list for_statement tuple_pattern identifier identifier identifier call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier break_statement if_statement comparison_operator identifier none block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier identifier return_statement identifier
List all files in directory `dirname`, option to filter on file extension
def _write_incron_lines(user, lines): if user == 'system': ret = {} ret['retcode'] = _write_file(_INCRON_SYSTEM_TAB, 'salt', ''.join(lines)) return ret else: path = salt.utils.files.mkstemp() with salt.utils.files.fopen(path, 'wb') as fp_: fp_.writelines(salt.utils.data.encode(lines)) if __grains__['os_family'] == 'Solaris' and user != "root": __salt__['cmd.run']('chown {0} {1}'.format(user, path), python_shell=False) ret = __salt__['cmd.run_all'](_get_incron_cmdstr(path), runas=user, python_shell=False) os.remove(path) return ret
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 dictionary expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end call attribute string string_start string_end identifier argument_list identifier return_statement identifier else_clause block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list with_statement with_clause with_item as_pattern call attribute attribute attribute identifier identifier identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute attribute identifier identifier identifier identifier argument_list identifier if_statement boolean_operator comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block expression_statement call subscript identifier string string_start string_content string_end argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier keyword_argument identifier false expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier false expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Takes a list of lines to be committed to a user's incrontab and writes it
def load( self, stats ): rows = self.rows for func, raw in stats.iteritems(): try: rows[func] = row = PStatRow( func,raw ) except ValueError, err: log.info( 'Null row: %s', func ) for row in rows.itervalues(): row.weave( rows ) return self.find_root( rows )
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block try_statement block expression_statement assignment subscript identifier identifier assignment identifier call identifier argument_list identifier identifier except_clause identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier
Build a squaremap-compatible model from a pstats class
def _FieldSkipper(): WIRETYPE_TO_SKIPPER = [ _SkipVarint, _SkipFixed64, _SkipLengthDelimited, _SkipGroup, _EndGroup, _SkipFixed32, _RaiseInvalidWireType, _RaiseInvalidWireType, ] wiretype_mask = wire_format.TAG_TYPE_MASK def SkipField(buffer, pos, end, tag_bytes): wire_type = ord(tag_bytes[0:1]) & wiretype_mask return WIRETYPE_TO_SKIPPER[wire_type](buffer, pos, end) return SkipField
module function_definition identifier parameters block expression_statement assignment identifier list identifier identifier identifier identifier identifier identifier identifier identifier expression_statement assignment identifier attribute identifier identifier function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier binary_operator call identifier argument_list subscript identifier slice integer integer identifier return_statement call subscript identifier identifier argument_list identifier identifier identifier return_statement identifier
Constructs the SkipField function.
def filter_archives(ctx, prefix, pattern, engine): _generate_api(ctx) for i, match in enumerate(ctx.obj.api.filter( pattern, engine, prefix=prefix)): click.echo(match, nl=False) print('')
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier keyword_argument identifier identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier false expression_statement call identifier argument_list string string_start string_end
List all archives matching filter criteria
def extract_smiles(s): smiles = [] for t in s.split(): if len(t) > 2 and SMILES_RE.match(t) and not t.endswith('.') and bracket_level(t) == 0: smiles.append(t) return smiles
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list block if_statement boolean_operator boolean_operator boolean_operator comparison_operator call identifier argument_list identifier integer call attribute identifier identifier argument_list identifier not_operator call attribute identifier identifier argument_list string string_start string_content string_end comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Return a list of SMILES identifiers extracted from the string.
def _check_pid(self, allow_reset=False): if not self.pid == current_process().pid: if allow_reset: self.reset() else: raise RuntimeError("Forbidden operation in multiple processes")
module function_definition identifier parameters identifier default_parameter identifier false block if_statement not_operator comparison_operator attribute identifier identifier attribute call identifier argument_list identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list else_clause block raise_statement call identifier argument_list string string_start string_content string_end
Check process id to ensure integrity, reset if in new process.
def deleteSelected(self): 'Delete all selected rows.' ndeleted = self.deleteBy(self.isSelected) nselected = len(self._selectedRows) self._selectedRows.clear() if ndeleted != nselected: error('expected %s' % nselected)
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
Delete all selected rows.
def _get_top_file_envs(): try: return __context__['saltutil._top_file_envs'] except KeyError: try: st_ = salt.state.HighState(__opts__, initial_pillar=__pillar__) top = st_.get_top() if top: envs = list(st_.top_matches(top).keys()) or 'base' else: envs = 'base' except SaltRenderError as exc: raise CommandExecutionError( 'Unable to render top file(s): {0}'.format(exc) ) __context__['saltutil._top_file_envs'] = envs return envs
module function_definition identifier parameters block try_statement block return_statement subscript identifier string string_start string_content string_end except_clause identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment identifier boolean_operator call identifier argument_list call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier
Get all environments from the top file
def _access_rule(method, ip=None, port=None, proto='tcp', direction='in', port_origin='d', ip_origin='d', comment=''): if _status_csf(): if ip is None: return {'error': 'You must supply an ip address or CIDR.'} if port is None: args = _build_args(method, ip, comment) return __csf_cmd(args) else: if method not in ['allow', 'deny']: return {'error': 'Only allow and deny rules are allowed when specifying a port.'} return _access_rule_with_port(method=method, ip=ip, port=port, proto=proto, direction=direction, port_origin=port_origin, ip_origin=ip_origin, comment=comment)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_end block if_statement call identifier argument_list block if_statement comparison_operator identifier none block return_statement dictionary pair string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list identifier identifier identifier return_statement call identifier argument_list identifier else_clause block if_statement comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block return_statement dictionary pair string string_start string_content string_end string string_start string_content string_end return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Handles the cmd execution for allow and deny commands.
def scan(): cflib.crtp.init_drivers(enable_debug_driver=False) print('Scanning interfaces for Crazyflies...') available = cflib.crtp.scan_interfaces() interfaces = [uri for uri, _ in available] if not interfaces: return None return choose(interfaces, 'Crazyflies found:', 'Select interface: ')
module function_definition identifier parameters block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier false expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier list_comprehension identifier for_in_clause pattern_list identifier identifier identifier if_statement not_operator identifier block return_statement none return_statement call identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end
Scan for Crazyflie and return its URI.
async def status(cls): rqst = Request(cls.session, 'GET', '/manager/status') rqst.set_json({ 'status': 'running', }) async with rqst.fetch() as resp: return await resp.json()
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block return_statement await call attribute identifier identifier argument_list
Returns the current status of the configured API server.
def cleanup(self): for item in self.server_map: self.member_del(item, reconfig=False) self.server_map.clear()
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier false expression_statement call attribute attribute identifier identifier identifier argument_list
remove all members without reconfig
def shaped_metadata(self): if not self.is_shaped: return None return tuple(json_description_metadata(s.pages[0].is_shaped) for s in self.series if s.kind.lower() == 'shaped')
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement none return_statement call identifier generator_expression call identifier argument_list attribute subscript attribute identifier identifier integer identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
Return tifffile metadata from JSON descriptions as dicts.