code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def check_extraneous(config, schema): if not isinstance(config, dict): raise ValueError("Config {} is not a dictionary".format(config)) for k in config: if k not in schema: raise ValueError("Unexpected config key `{}` not in {}".format( k, list(schema.keys()))) v, kreq = schema[k] if v is None: continue elif isinstance(v, type): if not isinstance(config[k], v): if v is str and isinstance(config[k], string_types): continue raise ValueError( "Config key `{}` has wrong type {}, expected {}".format( k, type(config[k]).__name__, v.__name__)) else: check_extraneous(config[k], v)
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier subscript identifier identifier if_statement comparison_operator identifier none block continue_statement elif_clause call identifier argument_list identifier identifier block if_statement not_operator call identifier argument_list subscript identifier identifier identifier block if_statement boolean_operator comparison_operator identifier identifier call identifier argument_list subscript identifier identifier identifier block continue_statement raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute call identifier argument_list subscript identifier identifier identifier attribute identifier identifier else_clause block expression_statement call identifier argument_list subscript identifier identifier identifier
Make sure all items of config are in schema
def bbox2wktpolygon(bbox): minx = float(bbox[0]) miny = float(bbox[1]) maxx = float(bbox[2]) maxy = float(bbox[3]) return 'POLYGON((%.2f %.2f, %.2f %.2f, %.2f %.2f, %.2f %.2f, %.2f %.2f))' \ % (minx, miny, minx, maxy, maxx, maxy, maxx, miny, minx, miny)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list subscript identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier integer return_statement binary_operator string string_start string_content string_end line_continuation tuple identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier
Return OGC WKT Polygon of a simple bbox list of strings
def _validate_class(self, cl): if cl not in self.schema_def.attributes_by_class: search_string = self._build_search_string(cl) err = self.err( "{0} - invalid class", self._field_name_from_uri(cl), search_string=search_string) return ValidationWarning(ValidationResult.ERROR, err['err'], err['line'], err['num'])
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute attribute identifier identifier identifier block 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 call attribute identifier identifier argument_list identifier keyword_argument identifier identifier return_statement call identifier argument_list attribute identifier identifier subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end
return error if class `cl` is not found in the ontology
def to_unit(self, values, unit, from_unit): return self._to_unit_base('degC-days', values, unit, from_unit)
module function_definition identifier parameters identifier identifier identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier
Return values converted to the unit given the input from_unit.
def port_ranges(): try: return _linux_ranges() except (OSError, IOError): try: ranges = _bsd_ranges() if ranges: return ranges except (OSError, IOError): pass return [DEFAULT_EPHEMERAL_PORT_RANGE]
module function_definition identifier parameters block try_statement block return_statement call identifier argument_list except_clause tuple identifier identifier block try_statement block expression_statement assignment identifier call identifier argument_list if_statement identifier block return_statement identifier except_clause tuple identifier identifier block pass_statement return_statement list identifier
Returns a list of ephemeral port ranges for current machine.
def run(self): global world self.__is_running = True while(self.__is_running): self.__handle_events() self.__clock.tick(self.preferred_fps) elapsed_milliseconds = self.__clock.get_time() if 2 in self.event_flags: self.elapsed_milliseconds = 0 if self.print_frames: self.fpsTimer += elapsed_milliseconds if self.fpsTimer > self.print_fps_frequency: print "FPS: ", self.__clock.get_fps() self.fpsTimer = 0.0 if not 0 in self.event_flags: world.update(elapsed_milliseconds) if not 1 in self.event_flags: world.draw(elapsed_milliseconds) pygame.display.flip()
module function_definition identifier parameters identifier block global_statement identifier expression_statement assignment attribute identifier identifier true while_statement parenthesized_expression attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator integer attribute identifier identifier block expression_statement assignment attribute identifier identifier integer if_statement attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block print_statement string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier float if_statement not_operator comparison_operator integer attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement not_operator comparison_operator integer attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Start the game loop
def _default_dict(self): options = {} for attr, _, _, default, multi, _ in self._optiondict.values(): if multi and default is None: options[attr] = [] else: options[attr] = default return options
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier identifier identifier identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement boolean_operator identifier comparison_operator identifier none block expression_statement assignment subscript identifier identifier list else_clause block expression_statement assignment subscript identifier identifier identifier return_statement identifier
Return a dictionary with the default for each option.
def replace(code, pattern, goal): finder = similarfinder.RawSimilarFinder(code) matches = list(finder.get_matches(pattern)) ast = patchedast.get_patched_ast(code) lines = codeanalyze.SourceLinesAdapter(code) template = similarfinder.CodeTemplate(goal) computer = _ChangeComputer(code, ast, lines, template, matches) result = computer.get_changed() if result is None: return code return result
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block return_statement identifier return_statement identifier
used by other refactorings
def _add_links(self, links, key="href", proxy_key="proxyURL", endpoints=None): if endpoints is None: endpoints = ["likes", "replies", "shares", "self", "followers", "following", "lists", "favorites", "members"] if links.get("links"): for endpoint in links['links']: if isinstance(links['links'][endpoint], dict): self._add_link(endpoint, links['links'][endpoint]["href"]) else: self._add_link(endpoint, links["links"][endpoint]) for endpoint in endpoints: if links.get(endpoint, None) is None: continue if "pump_io" in links[endpoint]: self._add_link(endpoint, links[endpoint]["pump_io"][proxy_key]) elif "url" in links[endpoint]: self._add_link(endpoint, links[endpoint]["url"]) else: self._add_link(endpoint, links[endpoint][key]) return self.links
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_statement call attribute identifier identifier argument_list string string_start string_content string_end block for_statement identifier subscript identifier string string_start string_content string_end block if_statement call identifier argument_list subscript subscript identifier string string_start string_content string_end identifier identifier block expression_statement call attribute identifier identifier argument_list identifier subscript subscript subscript identifier string string_start string_content string_end identifier string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list identifier subscript subscript identifier string string_start string_content string_end identifier for_statement identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list identifier none none block continue_statement if_statement comparison_operator string string_start string_content string_end subscript identifier identifier block expression_statement call attribute identifier identifier argument_list identifier subscript subscript subscript identifier identifier string string_start string_content string_end identifier elif_clause comparison_operator string string_start string_content string_end subscript identifier identifier block expression_statement call attribute identifier identifier argument_list identifier subscript subscript identifier identifier string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list identifier subscript subscript identifier identifier identifier return_statement attribute identifier identifier
Parses and adds block of links
def css_classes(self, extra_classes=None): if hasattr(extra_classes, 'split'): extra_classes = extra_classes.split() extra_classes = set(extra_classes or []) field_css_classes = getattr(self.form, 'field_css_classes', None) if hasattr(field_css_classes, 'split'): extra_classes.update(field_css_classes.split()) elif isinstance(field_css_classes, (list, tuple)): extra_classes.update(field_css_classes) elif isinstance(field_css_classes, dict): extra_field_classes = [] for key in ('*', self.name): css_classes = field_css_classes.get(key) if hasattr(css_classes, 'split'): extra_field_classes = css_classes.split() elif isinstance(css_classes, (list, tuple)): if '__default__' in css_classes: css_classes.remove('__default__') extra_field_classes.extend(css_classes) else: extra_field_classes = css_classes extra_classes.update(extra_field_classes) return super(NgBoundField, self).css_classes(extra_classes)
module function_definition identifier parameters identifier default_parameter identifier none block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list boolean_operator identifier list expression_statement assignment identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end none if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list elif_clause call identifier argument_list identifier tuple identifier identifier block expression_statement call attribute identifier identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier list for_statement identifier tuple string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list elif_clause call identifier argument_list identifier tuple identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier
Returns a string of space-separated CSS classes for the wrapping element of this input field.
def update_class_by_type(old, new): autoreload.update_class(old, new) if isinstance2(old, new, AtomMeta): update_atom_members(old, new)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier if_statement call identifier argument_list identifier identifier identifier block expression_statement call identifier argument_list identifier identifier
Update declarative classes or fallback on default
def sentence_spans(self): if not self.is_tagged(SENTENCES): self.tokenize_sentences() return self.spans(SENTENCES)
module function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier
The list of spans representing ``sentences`` layer elements.
def apply_child_computation(self, child_msg: Message) -> 'BaseComputation': child_computation = self.generate_child_computation(child_msg) self.add_child_computation(child_computation) return child_computation
module function_definition identifier parameters identifier typed_parameter identifier type identifier type string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Apply the vm message ``child_msg`` as a child computation.
def _install_nukeassist(use_threaded_wrapper): import nuke if "--nukeassist" not in nuke.rawArgs: raise ImportError def threaded_wrapper(func, *args, **kwargs): return nuke.executeInMainThreadWithResult( func, args, kwargs) _common_setup("NukeAssist", threaded_wrapper, use_threaded_wrapper)
module function_definition identifier parameters identifier block import_statement dotted_name identifier if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block raise_statement identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement call identifier argument_list string string_start string_content string_end identifier identifier
Helper function to The Foundry NukeAssist support
def save_genome_fitness(self, delimiter=' ', filename='fitness_history.csv', with_cross_validation=False): with open(filename, 'w') as f: w = csv.writer(f, delimiter=delimiter) best_fitness = [c.fitness for c in self.most_fit_genomes] avg_fitness = self.get_fitness_mean() if with_cross_validation: cv_best_fitness = [c.cross_fitness for c in self.most_fit_genomes] cv_avg_fitness = self.get_average_cross_validation_fitness() for best, avg, cv_best, cv_avg in zip(best_fitness, avg_fitness, cv_best_fitness, cv_avg_fitness): w.writerow([best, avg, cv_best, cv_avg]) else: for best, avg in zip(best_fitness, avg_fitness): w.writerow([best, avg])
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 default_parameter identifier false 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 assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier identifier identifier call identifier argument_list identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list list identifier identifier identifier identifier else_clause block for_statement pattern_list identifier identifier call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list list identifier identifier
Saves the population's best and average fitness.
def hydra_breakpoints(in_bam, pair_stats): in_bed = convert_bam_to_bed(in_bam) if os.path.getsize(in_bed) > 0: pair_bed = pair_discordants(in_bed, pair_stats) dedup_bed = dedup_discordants(pair_bed) return run_hydra(dedup_bed, pair_stats) else: return None
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list identifier integer block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier return_statement call identifier argument_list identifier identifier else_clause block return_statement none
Detect structural variation breakpoints with hydra.
def CreateDialectActions(dialect): CompAction = SCons.Action.Action('$%sCOM ' % dialect, '$%sCOMSTR' % dialect) CompPPAction = SCons.Action.Action('$%sPPCOM ' % dialect, '$%sPPCOMSTR' % dialect) ShCompAction = SCons.Action.Action('$SH%sCOM ' % dialect, '$SH%sCOMSTR' % dialect) ShCompPPAction = SCons.Action.Action('$SH%sPPCOM ' % dialect, '$SH%sPPCOMSTR' % dialect) return CompAction, CompPPAction, ShCompAction, ShCompPPAction
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier binary_operator string string_start string_content string_end identifier return_statement expression_list identifier identifier identifier identifier
Create dialect specific actions.
def create_kernel_manager_and_kernel_client(self, connection_file, stderr_handle, is_cython=False, is_pylab=False, is_sympy=False): kernel_spec = self.create_kernel_spec(is_cython=is_cython, is_pylab=is_pylab, is_sympy=is_sympy) try: kernel_manager = QtKernelManager(connection_file=connection_file, config=None, autorestart=True) except Exception: error_msg = _("The error is:<br><br>" "<tt>{}</tt>").format(traceback.format_exc()) return (error_msg, None) kernel_manager._kernel_spec = kernel_spec kwargs = {} if os.name == 'nt': kwargs['close_fds'] = False try: kernel_manager.start_kernel(stderr=stderr_handle, **kwargs) except Exception: error_msg = _("The error is:<br><br>" "<tt>{}</tt>").format(traceback.format_exc()) return (error_msg, None) kernel_client = kernel_manager.client() kernel_client.hb_channel.time_to_dead = 18.0 return kernel_manager, kernel_client
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false default_parameter identifier false default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier try_statement block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier none keyword_argument identifier true except_clause identifier block expression_statement assignment identifier call attribute call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list return_statement tuple identifier none expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier dictionary if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end false try_statement block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier dictionary_splat identifier except_clause identifier block expression_statement assignment identifier call attribute call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list return_statement tuple identifier none expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier float return_statement expression_list identifier identifier
Create kernel manager and client.
def trunc_list(s: List) -> List: if len(s) > max_list_size: i = max_list_size // 2 j = i - 1 s = s[:i] + [ELLIPSIS] + s[-j:] return s
module function_definition identifier parameters typed_parameter identifier type identifier type identifier block if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier binary_operator identifier integer expression_statement assignment identifier binary_operator identifier integer expression_statement assignment identifier binary_operator binary_operator subscript identifier slice identifier list identifier subscript identifier slice unary_operator identifier return_statement identifier
Truncate lists to maximum length.
def logWrite(self, string): logFile = open(self.logFile, 'at') logFile.write(string + '\n') logFile.close()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator identifier string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list
Only write text to the log file, do not print
def migrate(self, host, port, key, dest_db, timeout, *, copy=False, replace=False): if not isinstance(host, str): raise TypeError("host argument must be str") if not isinstance(timeout, int): raise TypeError("timeout argument must be int") if not isinstance(dest_db, int): raise TypeError("dest_db argument must be int") if not host: raise ValueError("Got empty host") if dest_db < 0: raise ValueError("dest_db must be greater equal 0") if timeout < 0: raise ValueError("timeout must be greater equal 0") flags = [] if copy: flags.append(b'COPY') if replace: flags.append(b'REPLACE') fut = self.execute(b'MIGRATE', host, port, key, dest_db, timeout, *flags) return wait_ok(fut)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier keyword_separator default_parameter identifier false default_parameter identifier false block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement not_operator identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier integer block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier list if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier identifier identifier list_splat identifier return_statement call identifier argument_list identifier
Atomically transfer a key from a Redis instance to another one.
def nvrtcGetErrorString(self, code): code_int = c_int(code) res = self._lib.nvrtcGetErrorString(code_int) return res.decode('utf-8')
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end
Returns a text identifier for the given NVRTC status code.
def _elapsed(self): self.last_time = time.time() return self.last_time - self.start
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list return_statement binary_operator attribute identifier identifier attribute identifier identifier
Returns elapsed time at update.
def _create_trustdb(cls): trustdb = os.path.join(cls.homedir, 'trustdb.gpg') if not os.path.isfile(trustdb): log.info("GnuPG complained that your trustdb file was missing. %s" % "This is likely due to changing to a new homedir.") log.info("Creating trustdb.gpg file in your GnuPG homedir.") cls.fix_trustdb(trustdb)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier
Create the trustdb file in our homedir, if it doesn't exist.
def parallel_prep_region(samples, run_parallel): file_key = "work_bam" split_fn = _split_by_regions("bamprep", "-prep.bam", file_key) extras = [] torun = [] for data in [x[0] for x in samples]: if data.get("work_bam"): data["align_bam"] = data["work_bam"] if (not dd.get_realign(data) and not dd.get_variantcaller(data)): extras.append([data]) elif not data.get(file_key): extras.append([data]) else: data["config"]["algorithm"]["orig_markduplicates"] = dd.get_mark_duplicates(data) data = dd.set_mark_duplicates(data, False) torun.append([data]) return extras + parallel_split_combine(torun, split_fn, run_parallel, "piped_bamprep", _add_combine_info, file_key, ["config"])
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier list_comprehension subscript identifier integer for_in_clause identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement parenthesized_expression boolean_operator not_operator call attribute identifier identifier argument_list identifier not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list list identifier elif_clause not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list list identifier else_clause block expression_statement assignment subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier false expression_statement call attribute identifier identifier argument_list list identifier return_statement binary_operator identifier call identifier argument_list identifier identifier identifier string string_start string_content string_end identifier identifier list string string_start string_content string_end
Perform full pre-variant calling BAM prep work on regions.
def _event_duration(vevent): if hasattr(vevent, 'dtend'): return vevent.dtend.value - vevent.dtstart.value elif hasattr(vevent, 'duration') and vevent.duration.value: return vevent.duration.value return timedelta(0)
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement binary_operator attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier elif_clause boolean_operator call identifier argument_list identifier string string_start string_content string_end attribute attribute identifier identifier identifier block return_statement attribute attribute identifier identifier identifier return_statement call identifier argument_list integer
unify dtend and duration to the duration of the given vevent
def __focus(self, item): cols = self.__get_display_columns() for col in cols: self.__event_info =(col,item) self.event_generate('<<TreeviewInplaceEdit>>') if col in self._inplace_widgets: w = self._inplace_widgets[col] w.bind('<Key-Tab>', lambda e: w.tk_focusNext().focus_set()) w.bind('<Shift-Key-Tab>', lambda e: w.tk_focusPrev().focus_set())
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement assignment attribute identifier identifier tuple identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end lambda lambda_parameters identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end lambda lambda_parameters identifier call attribute call attribute identifier identifier argument_list identifier argument_list
Called when focus item has changed
def _has_expired(self): expired = False if hasattr(self, 'Expiration'): now = datetime.datetime.utcnow() expiration = datetime.datetime.strptime(self.Expiration, '%Y-%m-%dT%H:%M:%SZ') expired = (now >= expiration) else: raise ValueError("ERROR: Request for expired property, but no Expiration in HIT!") return expired
module function_definition identifier parameters identifier block expression_statement assignment identifier false if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier parenthesized_expression comparison_operator identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end return_statement identifier
Has this HIT expired yet?
def create_swag_from_ctx(ctx): swag_opts = {} if ctx.type == 'file': swag_opts = { 'swag.type': 'file', 'swag.data_dir': ctx.data_dir, 'swag.data_file': ctx.data_file } elif ctx.type == 's3': swag_opts = { 'swag.type': 's3', 'swag.bucket_name': ctx.bucket_name, 'swag.data_file': ctx.data_file, 'swag.region': ctx.region } elif ctx.type == 'dynamodb': swag_opts = { 'swag.type': 'dynamodb', 'swag.region': ctx.region } return SWAGManager(**parse_swag_config_options(swag_opts))
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end attribute identifier identifier return_statement call identifier argument_list dictionary_splat call identifier argument_list identifier
Creates SWAG client from the current context.
def lock(self, request, *args, **kwargs): self.object = self.get_object() success_url = self.get_success_url() self.object.status = Topic.TOPIC_LOCKED self.object.save() messages.success(self.request, self.success_message) return HttpResponseRedirect(success_url)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier return_statement call identifier argument_list identifier
Locks the considered topic and retirects the user to the success URL.
def convert_to_utf8(string): if (isinstance(string, unicode)): return string.encode('utf-8') try: u = unicode(string, 'utf-8') except TypeError: return str(string) utf8 = u.encode('utf-8') return utf8
module function_definition identifier parameters identifier block if_statement parenthesized_expression call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end except_clause identifier block return_statement call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
Convert string to UTF8
def ungap_sequences(records, gap_chars=GAP_TABLE): logging.info('Applying _ungap_sequences generator: removing all gap characters') for record in records: yield ungap_all(record, gap_chars)
module function_definition identifier parameters identifier default_parameter identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement yield call identifier argument_list identifier identifier
Remove gaps from sequences, given an alignment.
def _infer_all_types(self): self._initialize_graph_status_for_traversing() for raw_name, initial_type in self.initial_types: for scope in self.scopes: if raw_name not in scope.variable_name_mapping: continue for onnx_name in scope.variable_name_mapping[raw_name]: variable = scope.variables[onnx_name] if variable.is_root: variable.type = initial_type for operator in self.topological_operator_iterator(): if operator.type in self.custom_shape_calculators: self.custom_shape_calculators[operator.type](operator) elif operator.type in self.custom_conversion_functions: pass else: operator.infer_types()
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list for_statement pattern_list identifier identifier attribute identifier identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block continue_statement for_statement identifier subscript attribute identifier identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call subscript attribute identifier identifier attribute identifier identifier argument_list identifier elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block pass_statement else_clause block expression_statement call attribute identifier identifier argument_list
Infer all variables' shapes in the computational graph.
def process_topojson(self, name, layer, input_path): output_path = os.path.join(TEMP_DIRECTORY, '%s.topojson' % name) topojson_binary = 'node_modules/bin/topojson' if not os.path.exists(topojson_binary): topojson_binary = 'topojson' topo_cmd = [ topojson_binary, '-o', output_path ] if 'id-property' in layer: topo_cmd.extend([ '--id-property', layer['id-property'] ]) if layer.get('all-properties', False): topo_cmd.append('-p') elif 'properties' in layer: topo_cmd.extend([ '-p', ','.join(layer['properties']) ]) topo_cmd.extend([ '--', input_path ]) sys.stdout.write('* Running TopoJSON\n') if self.args.verbose: sys.stdout.write(' %s\n' % ' '.join(topo_cmd)) r = envoy.run(' '.join(topo_cmd)) if r.status_code != 0: sys.stderr.write(r.std_err) return output_path
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier list identifier string string_start string_content string_end identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement call attribute identifier identifier argument_list string string_start string_content string_end false block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end elif_clause comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end if_statement attribute attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier return_statement identifier
Process layer using topojson.
def annotation_wrapper(annotation, doc=None): def decorator(attr): __cache__.setdefault(attr, []).append(annotation) try: if not hasattr(attr, '_coaster_annotations'): setattr(attr, '_coaster_annotations', []) attr._coaster_annotations.append(annotation) except AttributeError: pass return attr decorator.__name__ = decorator.name = annotation decorator.__doc__ = doc return decorator
module function_definition identifier parameters identifier default_parameter identifier none block function_definition identifier parameters identifier block expression_statement call attribute call attribute identifier identifier argument_list identifier list identifier argument_list identifier try_statement block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement call identifier argument_list identifier string string_start string_content string_end list expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block pass_statement return_statement identifier expression_statement assignment attribute identifier identifier assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
Defines an annotation, which can be applied to attributes in a database model.
def ObjectInitializedEventHandler(analysis, event): wf.doActionFor(analysis, "initialize") request = analysis.getRequest() wf.doActionFor(request, "rollback_to_receive") analysis.reindexObject(idxs="getServiceUID") return
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end return_statement
Actions to be done when an analysis is added in an Analysis Request
def list_vips(self, retrieve_all=True, **_params): return self.list('vips', self.vips_path, retrieve_all, **_params)
module function_definition identifier parameters identifier default_parameter identifier true dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier dictionary_splat identifier
Fetches a list of all load balancer vips for a project.
def recentMatches(self, **criteria): if not self.matches: return [] try: maxMatches = criteria["maxMatches"] del criteria["maxMatches"] except AttributeError: maxMatches = c.RECENT_MATCHES alLMatches = self.matchSubset(**criteria) matchTimes = [(m.endTime, m) for m in matches] selMatches = sorted(matchTimes)[:maxMatches] retMatches = [m for endTime,m in selMatches] return retMatches
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block if_statement not_operator attribute identifier identifier block return_statement list try_statement block expression_statement assignment identifier subscript identifier string string_start string_content string_end delete_statement subscript identifier string string_start string_content string_end except_clause identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier expression_statement assignment identifier list_comprehension tuple attribute identifier identifier identifier for_in_clause identifier identifier expression_statement assignment identifier subscript call identifier argument_list identifier slice identifier expression_statement assignment identifier list_comprehension identifier for_in_clause pattern_list identifier identifier identifier return_statement identifier
identify all recent matches for player given optional, additional criteria
def export_datasource_schema(back_references): data = dict_import_export.export_schema_to_dict( back_references=back_references) yaml.safe_dump(data, stdout, default_flow_style=False)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier false
Export datasource YAML schema to stdout
def to_device(b:Tensors, device:torch.device): "Recursively put `b` on `device`." device = ifnone(device, defaults.device) if is_listy(b): return [to_device(o, device) for o in b] if is_dict(b): return {k: to_device(v, device) for k, v in b.items()} return b.to(device, non_blocking=True)
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type attribute identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier if_statement call identifier argument_list identifier block return_statement list_comprehension call identifier argument_list identifier identifier for_in_clause identifier identifier if_statement call identifier argument_list identifier block return_statement dictionary_comprehension pair identifier call identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true
Recursively put `b` on `device`.
def visit_while(self, node): whiles = "while %s:\n%s" % (node.test.accept(self), self._stmt_list(node.body)) if node.orelse: whiles = "%s\nelse:\n%s" % (whiles, self._stmt_list(node.orelse)) return whiles
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content escape_sequence string_end tuple call attribute attribute identifier identifier identifier argument_list identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence string_end tuple identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
return an astroid.While node as string
def df(self, src): return self._getStdOutCmd([self._hadoop_cmd, 'fs', '-df', self._full_hdfs_path(src)], True)
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list list attribute identifier identifier string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list identifier true
Perform ``df`` on a path
def extendMarkdown(self, md, md_globals): md.registerExtension(self) md.preprocessors.add('fenced_code_block', SpecialFencePreprocessor(md), ">normalize_whitespace")
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end
Add FencedBlockPreprocessor to the Markdown instance.
def cublasSdgmm(handle, mode, m, n, A, lda, x, incx, C, ldc): status = _libcublas.cublasSdgmm(handle, _CUBLAS_SIDE[mode], m, n, int(A), lda, int(x), incx, int(C), ldc) cublasCheckStatus(status)
module function_definition identifier parameters 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 identifier identifier call identifier argument_list identifier identifier call identifier argument_list identifier identifier call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier
Matrix-diagonal matrix product for real general matrix.
def peaks(x, y, lookahead=20, delta=0.00003): _max, _min = peakdetect(y, x, lookahead, delta) x_peaks = [p[0] for p in _max] y_peaks = [p[1] for p in _max] x_valleys = [p[0] for p in _min] y_valleys = [p[1] for p in _min] _peaks = [x_peaks, y_peaks] _valleys = [x_valleys, y_valleys] return {"peaks": _peaks, "valleys": _valleys}
module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier float block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier identifier identifier expression_statement assignment identifier list_comprehension subscript identifier integer for_in_clause identifier identifier expression_statement assignment identifier list_comprehension subscript identifier integer for_in_clause identifier identifier expression_statement assignment identifier list_comprehension subscript identifier integer for_in_clause identifier identifier expression_statement assignment identifier list_comprehension subscript identifier integer for_in_clause identifier identifier expression_statement assignment identifier list identifier identifier expression_statement assignment identifier list identifier identifier return_statement dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier
A wrapper around peakdetect to pack the return values in a nicer format
def to_type(value, ptype): if ptype == 'str': return str(value) elif ptype == 'int': return int(value) elif ptype == 'float': return float(value) elif ptype == 'bool': if value.lower() == 'true': return True elif value.lower() == 'false': return False raise ValueError('Bad bool value: %s' % value) elif ptype == 'json': return json.loads(value) return ValueError('Unknown type')
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block return_statement call identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content string_end block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block return_statement true elif_clause comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block return_statement false raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list string string_start string_content string_end
Convert value to ptype
def dispatch_request(self, req): log.debug("Dispatching request: {}".format(str(req))) res = None try: req.validate() except MissingFieldError as e: res = APIMissingFieldErrorResponse(str(e)) if not res: try: res = req.dispatch() except Exception as e: msg = "Exception raised while dispatching request: {}".format(repr(e)) log.exception(msg) res = APIGenericErrorResponse(msg) log.debug("Response: {}".format(str(res))) return res
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier expression_statement assignment identifier none try_statement block expression_statement call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier if_statement not_operator identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier return_statement identifier
Dispatch a request object.
def keys_values(self): keys_values = [] for value in self.keys.values(): if isinstance(value, list): keys_values += value elif isinstance(value, basestring) and not value.startswith('-'): keys_values.append(value) elif isinstance(value, int) and value >= 0: keys_values.append(str(value)) return keys_values
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block expression_statement augmented_assignment identifier identifier elif_clause boolean_operator call identifier argument_list identifier identifier not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier elif_clause boolean_operator call identifier argument_list identifier identifier comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier return_statement identifier
Key values might be a list or not, always return a list.
def parse(string, language=None): if language: string = replace_word_tokens(string, language) tokens = tokenize(string) postfix = to_postfix(tokens) return evaluate_postfix(postfix)
module function_definition identifier parameters identifier default_parameter identifier none block if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier return_statement call identifier argument_list identifier
Return a solution to the equation in the input string.
def parse_correlation(self, f): s_names = None data = list() for l in f['f'].splitlines(): s = l.strip().split("\t") if s_names is None: s_names = [ x for x in s if x != '' ] else: data.append(s[1:]) if f['fn'] == 'corrMatrixPearson.txt': self.rna_seqc_pearson = (s_names, data) elif f['fn'] == 'corrMatrixSpearman.txt': self.rna_seqc_spearman = (s_names, data)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none expression_statement assignment identifier call identifier argument_list for_statement identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content escape_sequence string_end if_statement comparison_operator identifier none block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier string string_start string_end else_clause block expression_statement call attribute identifier identifier argument_list subscript identifier slice integer if_statement comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment attribute identifier identifier tuple identifier identifier elif_clause comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment attribute identifier identifier tuple identifier identifier
Parse RNA-SeQC correlation matrices
def xml(self, fn=None, src='word/document.xml', XMLClass=XML, **params): "return the src with the given transformation applied, if any." if src in self.xml_cache: return self.xml_cache[src] if src not in self.zipfile.namelist(): return x = XMLClass( fn=fn or (self.fn and self.fn.replace('.docx', '.xml')) or None, root=self.zipfile.read(src)) self.xml_cache[src] = x return x
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier identifier dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end if_statement comparison_operator identifier attribute identifier identifier block return_statement subscript attribute identifier identifier identifier if_statement comparison_operator identifier call attribute attribute identifier identifier identifier argument_list block return_statement expression_statement assignment identifier call identifier argument_list keyword_argument identifier boolean_operator boolean_operator identifier parenthesized_expression boolean_operator attribute identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end none keyword_argument identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement identifier
return the src with the given transformation applied, if any.
async def setFormName(self, oldn, newn): logger.info(f'Migrating [{oldn}] to [{newn}]') async with self.getTempSlab(): i = 0 async for buid, valu in self.getFormTodo(oldn): await self.editNodeNdef((oldn, valu), (newn, valu)) i = i + 1 if i and i % _progress == 0: logger.info(f'Migrated {i} buids.')
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content interpolation identifier string_content interpolation identifier string_content string_end with_statement with_clause with_item call attribute identifier identifier argument_list block expression_statement assignment identifier integer for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block expression_statement await call attribute identifier identifier argument_list tuple identifier identifier tuple identifier identifier expression_statement assignment identifier binary_operator identifier integer if_statement boolean_operator identifier comparison_operator binary_operator identifier identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content interpolation identifier string_content string_end
Rename a form within all the layers.
def error(self, err=None): if self.state == 'half-open': self.test_fail_count = min(self.test_fail_count + 1, 16) self.errors.append(self.clock()) if len(self.errors) > self.maxfail: time = self.clock() - self.errors.pop(0) if time < self.time_unit: if time == 0: time = 0.0001 self.log.debug('error rate: %f errors per second' % ( float(self.maxfail) / time)) self.open(err)
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call identifier argument_list binary_operator attribute identifier identifier integer integer expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list integer if_statement comparison_operator identifier attribute identifier identifier block if_statement comparison_operator identifier integer block expression_statement assignment identifier float expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression binary_operator call identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Update the circuit breaker with an error event.
def _make_interpolation_node(self, tag_type, tag_key, leading_whitespace): if tag_type == '!': return _CommentNode() if tag_type == '=': delimiters = tag_key.split() self._change_delimiters(delimiters) return _ChangeNode(delimiters) if tag_type == '': return _EscapeNode(tag_key) if tag_type == '&': return _LiteralNode(tag_key) if tag_type == '>': return _PartialNode(tag_key, leading_whitespace) raise Exception("Invalid symbol for interpolation tag: %s" % repr(tag_type))
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block return_statement call identifier argument_list if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier if_statement comparison_operator identifier string string_start string_end block return_statement call identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block return_statement call identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block return_statement call identifier argument_list identifier identifier raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier
Create and return a non-section node for the parse tree.
def read_fastq(filename): if not filename: return itertools.cycle((None,)) if filename == "-": filename_fh = sys.stdin elif filename.endswith('gz'): if is_python3: filename_fh = gzip.open(filename, mode='rt') else: filename_fh = BufferedReader(gzip.open(filename, mode='rt')) else: filename_fh = open(filename) return stream_fastq(filename_fh)
module function_definition identifier parameters identifier block if_statement not_operator identifier block return_statement call attribute identifier identifier argument_list tuple none if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call identifier argument_list identifier return_statement call identifier argument_list identifier
return a stream of FASTQ entries, handling gzipped and empty files
def GetCountStopTimes(self): cursor = self._schedule._connection.cursor() cursor.execute( 'SELECT count(*) FROM stop_times WHERE trip_id=?', (self.trip_id,)) return cursor.fetchone()[0]
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end tuple attribute identifier identifier return_statement subscript call attribute identifier identifier argument_list integer
Return the number of stops made by this trip.
def trim(self): for key, value in list(iteritems(self.counters)): if value.empty(): del self.counters[key]
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call identifier argument_list call identifier argument_list attribute identifier identifier block if_statement call attribute identifier identifier argument_list block delete_statement subscript attribute identifier identifier identifier
Clear not used counters
def _chk_fields(field_data, field_formatter): if len(field_data) == len(field_formatter): return len_dat = len(field_data) len_fmt = len(field_formatter) msg = [ "FIELD DATA({d}) != FORMATTER({f})".format(d=len_dat, f=len_fmt), "DAT({N}): {D}".format(N=len_dat, D=field_data), "FMT({N}): {F}".format(N=len_fmt, F=field_formatter)] raise Exception("\n".join(msg))
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier block return_statement expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier raise_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier
Check that expected fields are present.
def on_any_event(self, event): for delegate in self.delegates: if hasattr(delegate, "on_any_event"): delegate.on_any_event(event)
module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier
On any event method
def safe_setattr(obj, name, value): try: setattr(obj, name, value) return True except AttributeError: return False
module function_definition identifier parameters identifier identifier identifier block try_statement block expression_statement call identifier argument_list identifier identifier identifier return_statement true except_clause identifier block return_statement false
Attempt to setattr but catch AttributeErrors.
def _treat_devices_removed(self): for device in self._removed_ports.copy(): eventlet.spawn_n(self._process_removed_port, device)
module function_definition identifier parameters identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier
Process the removed devices.
def isAvailable(self, requester, access): debuglog("%s isAvailable(%s, %s): self.owners=%r" % (self, requester, access, self.owners)) num_excl, num_counting = self._claimed_excl, self._claimed_counting for idx, waiter in enumerate(self.waiting): if waiter[0] is requester: w_index = idx break else: w_index = len(self.waiting) ahead = self.waiting[:w_index] if access.mode == 'counting': return num_excl == 0 and num_counting + len(ahead) < self.maxCount \ and all([w[1].mode == 'counting' for w in ahead]) return num_excl == 0 and num_counting == 0 and not ahead
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier expression_list attribute identifier identifier attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block if_statement comparison_operator subscript identifier integer identifier block expression_statement assignment identifier identifier break_statement else_clause block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier subscript attribute identifier identifier slice identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement boolean_operator boolean_operator comparison_operator identifier integer comparison_operator binary_operator identifier call identifier argument_list identifier attribute identifier identifier line_continuation call identifier argument_list list_comprehension comparison_operator attribute subscript identifier integer identifier string string_start string_content string_end for_in_clause identifier identifier return_statement boolean_operator boolean_operator comparison_operator identifier integer comparison_operator identifier integer not_operator identifier
Return a boolean whether the lock is available for claiming
def to_json(self): obj = { "vertices": [ { "id": vertex.id, "annotation": vertex.annotation, } for vertex in self.vertices ], "edges": [ { "id": edge.id, "annotation": edge.annotation, "head": edge.head, "tail": edge.tail, } for edge in self._edges ], } return six.text_type(json.dumps(obj, ensure_ascii=False))
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end list_comprehension dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier for_in_clause identifier attribute identifier identifier pair string string_start string_content string_end list_comprehension dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier for_in_clause identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier false
Convert to a JSON string.
def _from_dict(cls, _dict): args = {} if 'entities' in _dict: args['entities'] = [ RelationEntity._from_dict(x) for x in (_dict.get('entities')) ] if 'location' in _dict: args['location'] = _dict.get('location') if 'text' in _dict: args['text'] = _dict.get('text') return cls(**args)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary 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 list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier parenthesized_expression call attribute identifier identifier argument_list 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 call attribute identifier identifier argument_list 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 call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list dictionary_splat identifier
Initialize a RelationArgument object from a json dictionary.
def _apply_cached_indexes(self, cached_indexes, persist=False): for elt in ['valid_input_index', 'valid_output_index', 'index_array', 'distance_array']: val = cached_indexes[elt] if isinstance(val, tuple): val = cached_indexes[elt][0] elif isinstance(val, np.ndarray): val = da.from_array(val, chunks=CHUNK_SIZE) elif persist and isinstance(val, da.Array): cached_indexes[elt] = val = val.persist() setattr(self.resampler, elt, val)
module function_definition identifier parameters identifier identifier default_parameter identifier false block for_statement identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier subscript identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier subscript subscript identifier identifier integer elif_clause call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier elif_clause boolean_operator identifier call identifier argument_list identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list attribute identifier identifier identifier identifier
Reassign various resampler index attributes.
def add_toolbars_to_menu(self, menu_title, actions): view_menu = self.menus[6] if actions == self.toolbars and view_menu: toolbars = [] for toolbar in self.toolbars: action = toolbar.toggleViewAction() toolbars.append(action) add_actions(view_menu, toolbars)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier integer if_statement boolean_operator comparison_operator identifier attribute identifier identifier identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list identifier identifier
Add toolbars to a menu.
def addVariantSet(self, variantSet): id_ = variantSet.getId() self._variantSetIdMap[id_] = variantSet self._variantSetNameMap[variantSet.getLocalId()] = variantSet self._variantSetIds.append(id_)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Adds the specified variantSet to this dataset.
def ping_directories(self, request, queryset, messages=True): for directory in settings.PING_DIRECTORIES: pinger = DirectoryPinger(directory, queryset) pinger.join() if messages: success = 0 for result in pinger.results: if not result.get('flerror', True): success += 1 else: self.message_user(request, '%s : %s' % (directory, result['message'])) if success: self.message_user( request, _('%(directory)s directory succesfully ' 'pinged %(success)d entries.') % {'directory': directory, 'success': success})
module function_definition identifier parameters identifier identifier identifier default_parameter identifier true block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment identifier integer for_statement identifier attribute identifier identifier block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end true block expression_statement augmented_assignment identifier integer else_clause block expression_statement call attribute identifier identifier argument_list identifier binary_operator string string_start string_content string_end tuple identifier subscript identifier string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier binary_operator call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier
Ping web directories for selected entries.
def top_view(self): self.msg.template(78) print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format( "| Package", " " * 17, "New Version", " " * 8, "Arch", " " * 4, "Build", " " * 2, "Repos", " " * 10, "Size")) self.msg.template(78)
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list integer expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list string string_start string_content string_end binary_operator string string_start string_content string_end integer string string_start string_content string_end binary_operator string string_start string_content string_end integer string string_start string_content string_end binary_operator string string_start string_content string_end integer string string_start string_content string_end binary_operator string string_start string_content string_end integer string string_start string_content string_end binary_operator string string_start string_content string_end integer string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list integer
Print packages status bar
def _setup_ipc(self): log.debug('Setting up the internal IPC proxy') self.ctx = zmq.Context() self.sub = self.ctx.socket(zmq.SUB) self.sub.bind(PUB_PX_IPC_URL) self.sub.setsockopt(zmq.SUBSCRIBE, b'') log.debug('Setting HWM for the proxy frontend: %d', self.hwm) try: self.sub.setsockopt(zmq.HWM, self.hwm) except AttributeError: self.sub.setsockopt(zmq.SNDHWM, self.hwm) self.pub = self.ctx.socket(zmq.PUB) self.pub.bind(PUB_IPC_URL) log.debug('Setting HWM for the proxy backend: %d', self.hwm) try: self.pub.setsockopt(zmq.HWM, self.hwm) except AttributeError: self.pub.setsockopt(zmq.SNDHWM, self.hwm)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier except_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier 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 attribute identifier identifier try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier except_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier
Setup the IPC PUB and SUB sockets for the proxy.
def zoom_out_pixel(self, curr_pixel): low_frag = curr_pixel[0] high_frag = curr_pixel[1] level = curr_pixel[2] str_level = str(level) if level < self.n_level - 1: low_super = self.spec_level[str_level]["fragments_dict"][low_frag][ "super_index" ] high_super = self.spec_level[str_level]["fragments_dict"][ high_frag ]["sub_index"] new_pix_low = min([low_super, high_super]) new_pix_high = max([low_super, high_super]) new_level = level + 1 new_pixel = [new_pix_low, new_pix_high, new_level] else: new_pixel = curr_pixel return new_pixel
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier binary_operator attribute identifier identifier integer block expression_statement assignment identifier subscript subscript subscript subscript attribute identifier identifier identifier string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier subscript subscript subscript subscript attribute identifier identifier identifier string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list list identifier identifier expression_statement assignment identifier call identifier argument_list list identifier identifier expression_statement assignment identifier binary_operator identifier integer expression_statement assignment identifier list identifier identifier identifier else_clause block expression_statement assignment identifier identifier return_statement identifier
return the curr_frag at a lower resolution
def yara_match(file_path, rules): print('New Extracted File: {:s}'.format(file_path)) print('Mathes:') pprint(rules.match(file_path))
module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list call attribute identifier identifier argument_list identifier
Callback for a newly extracted file
def _on_changed(self): page = self._get_page() if not page.flag_autosave: page.flag_changed = True self._update_gui_text_tabs()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list
Slot for changed events
def _add_parent_cnt(self, hdr, goobj, c2ps): if goobj.id in c2ps: parents = c2ps[goobj.id] if 'prt_pcnt' in self.present or parents and len(goobj.parents) != len(parents): assert len(goobj.parents) == len(set(goobj.parents)) hdr.append("p{N}".format(N=len(set(goobj.parents))))
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier subscript identifier attribute identifier identifier if_statement boolean_operator comparison_operator string string_start string_content string_end attribute identifier identifier boolean_operator identifier comparison_operator call identifier argument_list attribute identifier identifier call identifier argument_list identifier block assert_statement comparison_operator call identifier argument_list attribute identifier identifier call identifier argument_list call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier call identifier argument_list call identifier argument_list attribute identifier identifier
Add the parent count to the GO term box for if not all parents are plotted.
def use_comparative_hierarchy_view(self): self._hierarchy_view = COMPARATIVE for session in self._get_provider_sessions(): try: session.use_comparative_hierarchy_view() except AttributeError: pass
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier identifier for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement
Pass through to provider HierarchyLookupSession.use_comparative_hierarchy_view
def next_bit_address(self): if self._current_bit_address == "": if self._is_16bit: return "{0}.{1}".format( self.next_address(), "00") return "{0}.{1}".format( self.next_address(), "0") if self._is_16bit: bool_half = int(self._current_bit_address.split(".")[1]) if bool_half < 4: register_half = self._current_bit_address.split(".")[0] return "{0}.{1}".format( register_half, pad_zeroes(str(bool_half + 1), 2)) self.move_to_next_address(self._size_of_current_register_address) return "{0}.{1}".format( self.next_address(), "00") bool_half = int(self._current_bit_address.split(".")[1]) if bool_half < 3: register_half = self._current_bit_address.split(".")[0] return "{0}.{1}".format( register_half, bool_half + 1) self.move_to_next_address(self._size_of_current_register_address) return "{0}.{1}".format( self.next_address(), "0")
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_end block if_statement attribute identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer if_statement comparison_operator identifier integer block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer return_statement call attribute string string_start string_content string_end identifier argument_list identifier call identifier argument_list call identifier argument_list binary_operator identifier integer integer expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer if_statement comparison_operator identifier integer block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer return_statement call attribute string string_start string_content string_end identifier argument_list identifier binary_operator identifier integer expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end
Gets the next boolean address
def clamp(self, clampVal): if self.x > clampVal: self.x = clampVal if self.y > clampVal: self.y = clampVal if self.z > clampVal: self.z = clampVal if self.w > clampVal: self.w = clampVal
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier identifier
Clamps all the components in the vector to the specified clampVal.
def qual(obj): return u'{}.{}'.format(obj.__class__.__module__, obj.__class__.__name__)
module function_definition identifier parameters identifier block return_statement call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier
Return fully qualified name of a class.
def writeString(self, u): s = self.context.getBytesForString(u) self.writeBytes(s)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
Write a unicode to the data stream.
def write_pidfile(pidfile): pid = os.getpid() if pidfile: with open(pidfile, "w", encoding="utf-8") as fobj: fobj.write(six.u(str(pid))) return pid
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call identifier argument_list identifier return_statement identifier
write current pid to pidfile.
def _get_temp(self, content): temp = None for line in content.splitlines(): if not temp: match = TEMP_NEEDLE.match(line) if match: temp = match.group(1).strip() continue else: match = TEMP_END_NEEDLE.match(line) if match: return temp raise IndexError(self.path)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none for_statement identifier call attribute identifier identifier argument_list block if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list integer identifier argument_list continue_statement else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block return_statement identifier raise_statement call identifier argument_list attribute identifier identifier
Get the string that points to a specific base16 scheme.
def update_records(self, domain, records): if not isinstance(records, list): raise TypeError("Expected records of type list") uri = "/domains/%s/records" % utils.get_id(domain) resp, resp_body = self._async_call(uri, method="PUT", body={"records": records}, error_class=exc.DomainRecordUpdateFailed, has_response=False) return resp_body
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier dictionary pair string string_start string_content string_end identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier false return_statement identifier
Modifies an existing records for a domain.
def to_element(self, root_name=None): if not root_name: root_name = self.nodename elem = ElementTreeBuilder.Element(root_name) for attrname in self.serializable_attributes(): try: value = self.__dict__[attrname] except KeyError: continue if attrname in self.xml_attribute_attributes: elem.attrib[attrname] = six.text_type(value) else: sub_elem = self.element_for_value(attrname, value) elem.append(sub_elem) return elem
module function_definition identifier parameters identifier default_parameter identifier none block if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement assignment identifier subscript attribute identifier identifier identifier except_clause identifier block continue_statement if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Serialize this `Resource` instance to an XML element.
def check_uniqe(self, obj_class, error_msg=_('Must be unique'), **kwargs): if obj_class.objects.filter(**kwargs).exclude(pk=self.instance.pk): raise forms.ValidationError(error_msg)
module function_definition identifier parameters identifier identifier default_parameter identifier call identifier argument_list string string_start string_content string_end dictionary_splat_pattern identifier block if_statement call attribute call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier block raise_statement call attribute identifier identifier argument_list identifier
check if this object is unique
def remove(self, spec_or_id, multi=True, *args, **kwargs): if multi: return self.delete_many(spec_or_id) return self.delete_one(spec_or_id)
module function_definition identifier parameters identifier identifier default_parameter identifier true list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement identifier block return_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier
Backwards compatibility with remove
def add_button(self, name, button_class=wtf_fields.SubmitField, **options): self._buttons[name] = button_class(**options)
module function_definition identifier parameters identifier identifier default_parameter identifier attribute identifier identifier dictionary_splat_pattern identifier block expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list dictionary_splat identifier
Adds a button to the form.
def _parse_sacct(sacct_jobs: List[dict], jobs_count: int=None): failed_jobs = sacct_api.filter_jobs(sacct_jobs, failed=True) completed_jobs = [job for job in sacct_jobs if job['is_completed']] last_job_end = completed_jobs[-1]['end'] if len(completed_jobs) > 0 else None data = { 'jobs': jobs_count, 'completed_jobs': len(completed_jobs), 'progress': (len(completed_jobs) / jobs_count) if jobs_count else None, 'failed_jobs': [{ 'slurm_id': job['id'], 'started_at': job['start'], 'elapsed': job['elapsed'], 'status': job['state'].lower(), 'name': job['step'], 'context': job['context'], } for job in failed_jobs] } return data, last_job_end
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier typed_default_parameter identifier type identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause subscript identifier string string_start string_content string_end expression_statement assignment identifier conditional_expression subscript subscript identifier unary_operator integer string string_start string_content string_end comparison_operator call identifier argument_list identifier integer none expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call identifier argument_list identifier pair string string_start string_content string_end conditional_expression parenthesized_expression binary_operator call identifier argument_list identifier identifier identifier none pair string string_start string_content string_end list_comprehension dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end call attribute subscript identifier string string_start string_content string_end identifier argument_list pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end for_in_clause identifier identifier return_statement expression_list identifier identifier
Parse out info from Sacct log.
def net_recv(ws, conn): in_data = conn.recv(RECEIVE_BYTES) if not in_data: print('Received 0 bytes (connection closed)') ws.receive_data(None) else: print('Received {} bytes'.format(len(in_data))) ws.receive_data(in_data)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list none else_clause block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
Read pending data from network into websocket.
def userinfo_json(request, user_id): data = {'first_name': '', 'last_name': '', 'email': '', 'slug': '', 'bio': '', 'phone': '', 'is_active': False} try: member = StaffMember.objects.get(pk=user_id) for key in data.keys(): if hasattr(member, key): data[key] = getattr(member, key, '') except StaffMember.DoesNotExist: pass return HttpResponse(json.dumps(data), mimetype='application/json')
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end string string_start string_end pair string string_start string_content string_end false try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier for_statement identifier call attribute identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier identifier string string_start string_end except_clause attribute identifier identifier block pass_statement return_statement call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end
Return the user's information in a json object
def unique_string(length=UUID_LENGTH): string = str(uuid4()) * int(math.ceil(length / float(UUID_LENGTH))) return string[:length] if length else string
module function_definition identifier parameters default_parameter identifier identifier block expression_statement assignment identifier binary_operator call identifier argument_list call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list binary_operator identifier call identifier argument_list identifier return_statement conditional_expression subscript identifier slice identifier identifier identifier
Generate a unique string
def local_session(factory): factory_region = getattr(factory, 'region', 'global') s = getattr(CONN_CACHE, factory_region, {}).get('session') t = getattr(CONN_CACHE, factory_region, {}).get('time') n = time.time() if s is not None and t + (60 * 45) > n: return s s = factory() setattr(CONN_CACHE, factory_region, {'session': s, 'time': n}) return s
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute call identifier argument_list identifier identifier dictionary identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute call identifier argument_list identifier identifier dictionary identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator identifier none comparison_operator binary_operator identifier parenthesized_expression binary_operator integer integer identifier block return_statement identifier expression_statement assignment identifier call identifier argument_list expression_statement call identifier argument_list identifier identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier return_statement identifier
Cache a session thread local for up to 45m
def _get_site_amplification_term(self, C, vs30): f_s = np.zeros_like(vs30) idx = np.logical_and(vs30 < 800.0, vs30 >= 360.0) f_s[idx] = C["eB"] idx = np.logical_and(vs30 < 360.0, vs30 >= 180.0) f_s[idx] = C["eC"] idx = vs30 < 180.0 f_s[idx] = C["eD"] return f_s
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list comparison_operator identifier float comparison_operator identifier float expression_statement assignment subscript identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list comparison_operator identifier float comparison_operator identifier float expression_statement assignment subscript identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier comparison_operator identifier float expression_statement assignment subscript identifier identifier subscript identifier string string_start string_content string_end return_statement identifier
Returns the site amplification given Eurocode 8 site classification
def add_permission(self, role, name): if self.has_permission(role, name): return True targetGroup = AuthGroup.objects(role=role, creator=self.client).first() if not targetGroup: return False permission = AuthPermission.objects(name=name).update( add_to_set__groups=[targetGroup], creator=self.client, upsert=True ) return True
module function_definition identifier parameters identifier identifier identifier block if_statement call attribute identifier identifier argument_list identifier identifier block return_statement true expression_statement assignment identifier call attribute call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier identifier argument_list if_statement not_operator identifier block return_statement false expression_statement assignment identifier call attribute call attribute identifier identifier argument_list keyword_argument identifier identifier identifier argument_list keyword_argument identifier list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier true return_statement true
authorize a group for something
def print_user(self, user): status = "active" token = user.token if token in ['finished', 'revoked']: status = token if token is None: token = '' subid = "%s\t%s[%s]" %(user.id, token, status) print(subid) return subid
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier binary_operator string string_start string_content escape_sequence string_end tuple attribute identifier identifier identifier identifier expression_statement call identifier argument_list identifier return_statement identifier
print a relational database user
def _get_item_class(self, url): if '/layers/' in url: return Layer elif '/tables/' in url: return Table elif '/sets/' in url: return Set else: raise NotImplementedError("No support for catalog results of type %s" % url)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block return_statement identifier elif_clause comparison_operator string string_start string_content string_end identifier block return_statement identifier elif_clause comparison_operator string string_start string_content string_end identifier block return_statement identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
Return the model class matching a URL
def _WriteAttributes(self): if "w" not in self.mode: return if self.urn is None: raise ValueError("Storing of anonymous AFF4 objects not supported.") to_set = {} for attribute_name, value_array in iteritems(self.new_attributes): to_set_list = to_set.setdefault(attribute_name, []) for value in value_array: to_set_list.append((value.SerializeToDataStore(), value.age)) if self._dirty: if self._new_version: to_set[self.Schema.TYPE] = [ (utils.SmartUnicode(self.__class__.__name__), rdfvalue.RDFDatetime.Now()) ] add_child_index = self.Schema.ADD_CHILD_INDEX if self.object_exists: add_child_index = False FACTORY.SetAttributes( self.urn, to_set, self._to_delete, add_child_index=add_child_index, mutation_pool=self.mutation_pool)
module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block return_statement if_statement comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list tuple call attribute identifier identifier argument_list attribute identifier identifier if_statement attribute identifier identifier block if_statement attribute identifier identifier block expression_statement assignment subscript identifier attribute attribute identifier identifier identifier list tuple call attribute identifier identifier argument_list attribute attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier false expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier
Write the dirty attributes to the data store.
def _remove_lead_trail_false(bool_list): for i in (0, -1): while bool_list and not bool_list[i]: bool_list.pop(i) return bool_list
module function_definition identifier parameters identifier block for_statement identifier tuple integer unary_operator integer block while_statement boolean_operator identifier not_operator subscript identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Remove leading and trailing false's from a list
def create_shield_layer(shield, hashcode): return pgnreader.parse_pagan_file(('%s%spgn%s' % (PACKAGE_DIR, os.sep, os.sep)) + shield + '.pgn', hashcode, sym=False, invert=False)
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list binary_operator binary_operator parenthesized_expression binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier attribute identifier identifier identifier string string_start string_content string_end identifier keyword_argument identifier false keyword_argument identifier false
Creates the layer for shields.
def isSequence(arg): if hasattr(arg, "strip"): return False if hasattr(arg, "__getslice__"): return True if hasattr(arg, "__iter__"): return True return False
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement false if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement true if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement true return_statement false
Check if input is iterable.
def isVisible(self, instance, mode='view', default="visible", field=None): vis_dic = getattr(aq_base(self), 'visible', _marker) state = default if vis_dic is _marker: return state if type(vis_dic) is DictType: state = vis_dic.get(mode, state) elif not vis_dic: state = 'invisible' elif vis_dic < 0: state = 'hidden' if not field: return state adapters = sorted(getAdapters([instance], IATWidgetVisibility), key=lambda adapter: getattr(adapter[1], "sort", 1000), reverse=True) for adapter_name, adapter in adapters: if field.getName() not in getattr(adapter, "field_names", []): continue adapter_state = adapter(instance, mode, field, state) adapter_name = adapter.__class__.__name__ logger.info("IATWidgetVisibility rule {} for {}.{} ({}): {} -> {}" .format(adapter_name, instance.id, field.getName(), mode, state, adapter_state)) if adapter_state == state: continue return adapter_state return state
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier none block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier string string_start string_content string_end identifier expression_statement assignment identifier identifier if_statement comparison_operator identifier identifier block return_statement identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier elif_clause not_operator identifier block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end if_statement not_operator identifier block return_statement identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list list identifier identifier keyword_argument identifier lambda lambda_parameters identifier call identifier argument_list subscript identifier integer string string_start string_content string_end integer keyword_argument identifier true for_statement pattern_list identifier identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end list block continue_statement expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier call attribute identifier identifier argument_list identifier identifier identifier if_statement comparison_operator identifier identifier block continue_statement return_statement identifier return_statement identifier
decide if a field is visible in a given mode -> 'state'.