code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def validate(self, data): if 'start' in data and 'end' in data and data['start'] >= data['end']: raise serializers.ValidationError(_('End must occur after start.')) return data
module function_definition identifier parameters identifier identifier block if_statement boolean_operator boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier comparison_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end block raise_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end return_statement identifier
Check that the start is before the end.
def _tl15(self, data, wavenumber): return ((C2 * wavenumber) / xu.log((1.0 / data) * C1 * wavenumber ** 3 + 1.0))
module function_definition identifier parameters identifier identifier identifier block return_statement parenthesized_expression binary_operator parenthesized_expression binary_operator identifier identifier call attribute identifier identifier argument_list binary_operator binary_operator binary_operator parenthesized_expression binary_operator float identifier identifier binary_operator identifier integer float
Compute the L15 temperature.
def find_all(query: Query=None) -> List['ApiKey']: return [ApiKey.from_db(key) for key in db.get_keys(query)]
module function_definition identifier parameters typed_default_parameter identifier type identifier none type generic_type identifier type_parameter type string string_start string_content string_end block return_statement list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list identifier
List all API keys.
def load_modules_from_path(path): if path[-1:] != '/': path += '/' if not os.path.exists(path): raise OSError("Directory does not exist: %s" % path) sys.path.append(path) for f in os.listdir(path): if len(f) > 3 and f[-3:] == '.py': modname = f[:-3] __import__(modname, globals(), locals(), ['*'])
module function_definition identifier parameters identifier block if_statement comparison_operator subscript identifier slice unary_operator integer string string_start string_content string_end block expression_statement augmented_assignment identifier string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list identifier block if_statement boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator subscript identifier slice unary_operator integer string string_start string_content string_end block expression_statement assignment identifier subscript identifier slice unary_operator integer expression_statement call identifier argument_list identifier call identifier argument_list call identifier argument_list list string string_start string_content string_end
Import all modules from the given directory
def on_hover(self, callback, remove=False): self._hover_callbacks.register_callback(callback, remove=remove)
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier
The hover callback takes an unpacked set of keyword arguments.
def delete_file(self, path, prefixed_path, source_storage): if self.faster: return True else: return super(Command, self).delete_file(path, prefixed_path, source_storage)
module function_definition identifier parameters identifier identifier identifier identifier block if_statement attribute identifier identifier block return_statement true else_clause block return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier identifier
We don't need all the file_exists stuff because we have to override all files anyways.
def refresh_token(self): if (not self.auth_details or not 'refresh_token' in self.auth_details or not self.auth_details['refresh_token']): raise Exception( "auth_details['refresh_token'] does not contain a refresh token.") refresh_token = self.auth_details['refresh_token'] params = [ ('grant_type', 'refresh_token'), ('refresh_token', refresh_token) ] response = self._post('', urlencode(params), CreateSend.oauth_token_uri, "application/x-www-form-urlencoded") new_access_token, new_expires_in, new_refresh_token = None, None, None r = json_to_py(response) new_access_token, new_expires_in, new_refresh_token = r.access_token, r.expires_in, r.refresh_token self.auth({ 'access_token': new_access_token, 'refresh_token': new_refresh_token}) return [new_access_token, new_expires_in, new_refresh_token]
module function_definition identifier parameters identifier block if_statement parenthesized_expression boolean_operator boolean_operator not_operator attribute identifier identifier not_operator comparison_operator string string_start string_content string_end attribute identifier identifier not_operator subscript attribute identifier identifier string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier list tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_end call identifier argument_list identifier attribute identifier identifier string string_start string_content string_end expression_statement assignment pattern_list identifier identifier identifier expression_list none none none expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment pattern_list identifier identifier identifier expression_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier return_statement list identifier identifier identifier
Refresh an OAuth token given a refresh token.
def schedule(ident, cron=None, minute='*', hour='*', day_of_week='*', day_of_month='*', month_of_year='*'): source = get_source(ident) if cron: minute, hour, day_of_month, month_of_year, day_of_week = cron.split() crontab = PeriodicTask.Crontab( minute=str(minute), hour=str(hour), day_of_week=str(day_of_week), day_of_month=str(day_of_month), month_of_year=str(month_of_year) ) if source.periodic_task: source.periodic_task.modify(crontab=crontab) else: source.modify(periodic_task=PeriodicTask.objects.create( task='harvest', name='Harvest {0}'.format(source.name), description='Periodic Harvesting', enabled=True, args=[str(source.id)], crontab=crontab, )) signals.harvest_source_scheduled.send(source) return source
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement assignment pattern_list identifier identifier identifier identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list identifier if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list keyword_argument identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier true keyword_argument identifier list call identifier argument_list attribute identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
Schedule an harvesting on a source given a crontab
def shrink_wrap(self): self.frame.size = (self.text_size[0] + self.padding[0] * 2, self.text_size[1] + self.padding[1] * 2)
module function_definition identifier parameters identifier block expression_statement assignment attribute attribute identifier identifier identifier tuple binary_operator subscript attribute identifier identifier integer binary_operator subscript attribute identifier identifier integer integer binary_operator subscript attribute identifier identifier integer binary_operator subscript attribute identifier identifier integer integer
Tightly bound the current text respecting current padding.
def escape_filename_sh_ansic(name): out =[] for ch in name: if ord(ch) < 32: out.append("\\x%02x"% ord(ch)) elif ch == '\\': out.append('\\\\') else: out.append(ch) return "$'" + "".join(out) + "'"
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end call identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content escape_sequence string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end else_clause block expression_statement call attribute identifier identifier argument_list identifier return_statement binary_operator binary_operator string string_start string_content string_end call attribute string string_start string_end identifier argument_list identifier string string_start string_content string_end
Return an ansi-c shell-escaped version of a filename.
def _structure_dict(self, obj, cl): if is_bare(cl) or cl.__args__ == (Any, Any): return dict(obj) else: key_type, val_type = cl.__args__ if key_type is Any: val_conv = self._structure_func.dispatch(val_type) return {k: val_conv(v, val_type) for k, v in obj.items()} elif val_type is Any: key_conv = self._structure_func.dispatch(key_type) return {key_conv(k, key_type): v for k, v in obj.items()} else: key_conv = self._structure_func.dispatch(key_type) val_conv = self._structure_func.dispatch(val_type) return { key_conv(k, key_type): val_conv(v, val_type) for k, v in obj.items() }
module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator call identifier argument_list identifier comparison_operator attribute identifier identifier tuple identifier identifier block return_statement call identifier argument_list identifier else_clause block expression_statement assignment pattern_list identifier identifier attribute identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier 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 elif_clause comparison_operator identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement dictionary_comprehension pair call identifier argument_list identifier identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement dictionary_comprehension pair call identifier argument_list identifier identifier call identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list
Convert a mapping into a potentially generic dict.
def external2internal(xe, bounds): xi = np.empty_like(xe) for i, (v, bound) in enumerate(zip(xe, bounds)): a = bound[0] b = bound[1] if a == None and b == None: xi[i] = v elif b == None: xi[i] = np.sqrt((v - a + 1.) ** 2. - 1) elif a == None: xi[i] = np.sqrt((b - v + 1.) ** 2. - 1) else: xi[i] = np.arcsin((2. * (v - a) / (b - a)) - 1.) return xi
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement pattern_list identifier tuple_pattern identifier identifier call identifier argument_list call identifier argument_list identifier identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier subscript identifier integer if_statement boolean_operator comparison_operator identifier none comparison_operator identifier none block expression_statement assignment subscript identifier identifier identifier elif_clause comparison_operator identifier none block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list binary_operator binary_operator parenthesized_expression binary_operator binary_operator identifier identifier float float integer elif_clause comparison_operator identifier none block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list binary_operator binary_operator parenthesized_expression binary_operator binary_operator identifier identifier float float integer else_clause block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator binary_operator float parenthesized_expression binary_operator identifier identifier parenthesized_expression binary_operator identifier identifier float return_statement identifier
Convert a series of external variables to internal variables
def print(self, indent=0): LOG.info("%s:: %s", indent * " ", self.__class__) for ext in self.next_extensions: ext.print(indent=indent + 2)
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end binary_operator identifier string string_start string_content string_end attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier binary_operator identifier integer
Print a structural view of the registered extensions.
def _get_tmp_gcs_bucket(cls, writer_spec): if cls.TMP_BUCKET_NAME_PARAM in writer_spec: return writer_spec[cls.TMP_BUCKET_NAME_PARAM] return cls._get_gcs_bucket(writer_spec)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block return_statement subscript identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier
Returns bucket used for writing tmp files.
def sample(generator, min=-1, max=1, width=SAMPLE_WIDTH): fmt = { 1: '<B', 2: '<h', 4: '<i' }[width] return (struct.pack(fmt, int(sample)) for sample in \ normalize(hard_clip(generator, min, max),\ min, max, -2**(width * 8 - 1), 2**(width * 8 - 1) - 1))
module function_definition identifier parameters identifier default_parameter identifier unary_operator integer default_parameter identifier integer default_parameter identifier identifier block expression_statement assignment identifier subscript dictionary pair integer string string_start string_content string_end pair integer string string_start string_content string_end pair integer string string_start string_content string_end identifier return_statement generator_expression call attribute identifier identifier argument_list identifier call identifier argument_list identifier for_in_clause identifier line_continuation call identifier argument_list call identifier argument_list identifier identifier identifier line_continuation identifier identifier unary_operator binary_operator integer parenthesized_expression binary_operator binary_operator identifier integer integer binary_operator binary_operator integer parenthesized_expression binary_operator binary_operator identifier integer integer integer
Convert audio waveform generator into packed sample generator.
def _K_compute_eq(self): t_eq = self._t[self._index==0] if self._t2 is None: if t_eq.size==0: self._K_eq = np.zeros((0, 0)) return self._dist2 = np.square(t_eq[:, None] - t_eq[None, :]) else: t2_eq = self._t2[self._index2==0] if t_eq.size==0 or t2_eq.size==0: self._K_eq = np.zeros((t_eq.size, t2_eq.size)) return self._dist2 = np.square(t_eq[:, None] - t2_eq[None, :]) self._K_eq = np.exp(-self._dist2/(2*self.lengthscale*self.lengthscale)) if self.is_normalized: self._K_eq/=(np.sqrt(2*np.pi)*self.lengthscale)
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier comparison_operator attribute identifier identifier integer if_statement comparison_operator attribute identifier identifier none block if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list tuple integer integer return_statement expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list binary_operator subscript identifier slice none subscript identifier none slice else_clause block expression_statement assignment identifier subscript attribute identifier identifier comparison_operator attribute identifier identifier integer if_statement boolean_operator comparison_operator attribute identifier identifier integer comparison_operator attribute identifier identifier integer block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list tuple attribute identifier identifier attribute identifier identifier return_statement expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list binary_operator subscript identifier slice none subscript identifier none slice expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list binary_operator unary_operator attribute identifier identifier parenthesized_expression binary_operator binary_operator integer attribute identifier identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier parenthesized_expression binary_operator call attribute identifier identifier argument_list binary_operator integer attribute identifier identifier attribute identifier identifier
Compute covariance for latent covariance.
def load_manifest(check_name): manifest_path = os.path.join(get_root(), check_name, 'manifest.json') if file_exists(manifest_path): return json.loads(read_file(manifest_path)) return {}
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end if_statement call identifier argument_list identifier block return_statement call attribute identifier identifier argument_list call identifier argument_list identifier return_statement dictionary
Load the manifest file into a dictionary
def _get_managed_files(self): if self.grains_core.os_data().get('os_family') == 'Debian': return self.__get_managed_files_dpkg() elif self.grains_core.os_data().get('os_family') in ['Suse', 'redhat']: return self.__get_managed_files_rpm() return list(), list(), list()
module function_definition identifier parameters identifier block if_statement comparison_operator call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list string string_start string_content string_end string string_start string_content string_end block return_statement call attribute identifier identifier argument_list elif_clause comparison_operator call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end block return_statement call attribute identifier identifier argument_list return_statement expression_list call identifier argument_list call identifier argument_list call identifier argument_list
Build a in-memory data of all managed files.
def build_scala(app): if any(v in _BUILD_VER for v in ['1.2.', '1.3.', '1.4.']): _run_cmd("cd %s/.. && make scalapkg" % app.builder.srcdir) _run_cmd("cd %s/.. && make scalainstall" % app.builder.srcdir) else: _run_cmd("cd %s/../scala-package && mvn -B install -DskipTests" % app.builder.srcdir)
module function_definition identifier parameters identifier block if_statement call identifier generator_expression comparison_operator identifier identifier for_in_clause identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement call identifier argument_list binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier else_clause block expression_statement call identifier argument_list binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier
build scala for scala docs, java docs, and clojure docs to use
def store_attribute(self, key, value): if key == 'summary' or key == 'filename' or key == 'previous': return attr = key.replace('-', '_') if key.endswith('-time'): value = int(value) setattr(self, attr, value)
module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier identifier identifier
Store blame info we are interested in.
def fetch(self, url): try: r = requests.get(url, timeout=self.timeout) except requests.exceptions.Timeout: if not self.safe: raise else: return None if r and not self.safe: r.raise_for_status() return r.text
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier except_clause attribute attribute identifier identifier identifier block if_statement not_operator attribute identifier identifier block raise_statement else_clause block return_statement none if_statement boolean_operator identifier not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list return_statement attribute identifier identifier
Get the feed content using 'requests'
def action(elem, doc): if type(elem) == Str and doc.mhash is not None: elem.text = doc.mrenderer.render(elem.text, doc.mhash) return elem
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator call identifier argument_list identifier identifier comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier return_statement identifier
Apply combined mustache template to all strings in document.
def readlines(self, encoding=None): try: encoding = encoding or ENCODING with codecs.open(self.path, encoding=None) as fi: return fi.readlines() except: return []
module function_definition identifier parameters identifier default_parameter identifier none block try_statement block expression_statement assignment identifier boolean_operator identifier identifier with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier none as_pattern_target identifier block return_statement call attribute identifier identifier argument_list except_clause block return_statement list
Reads from the file and returns result as a list of lines.
def in_path(self, new_path, old_path=None): self.path = new_path try: yield finally: self.path = old_path
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment attribute identifier identifier identifier try_statement block expression_statement yield finally_clause block expression_statement assignment attribute identifier identifier identifier
Temporarily enters a path.
def _op(self, operation, other, *allowed): f = self._field if self._combining: return reduce(self._combining, (q._op(operation, other, *allowed) for q in f)) if __debug__ and _complex_safety_check(f, {operation} | set(allowed)): raise NotImplementedError("{self!r} does not allow {op} comparison.".format(self=self, op=operation)) if other is not None: other = f.transformer.foreign(other, (f, self._document)) return Filter({self._name: {operation: other}})
module function_definition identifier parameters identifier identifier identifier list_splat_pattern identifier block expression_statement assignment identifier attribute identifier identifier if_statement attribute identifier identifier block return_statement call identifier argument_list attribute identifier identifier generator_expression call attribute identifier identifier argument_list identifier identifier list_splat identifier for_in_clause identifier identifier if_statement boolean_operator identifier call identifier argument_list identifier binary_operator set identifier call identifier argument_list identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier tuple identifier attribute identifier identifier return_statement call identifier argument_list dictionary pair attribute identifier identifier dictionary pair identifier identifier
A basic operation operating on a single value.
def enable_receiving(self, loop=None): self.receive_task = asyncio.ensure_future(self._receive_loop(), loop=loop) def do_if_done(fut): try: fut.result() except asyncio.CancelledError: pass except Exception as ex: self.receive_task_exception = ex self.receive_task = None self.receive_task.add_done_callback(do_if_done)
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier function_definition identifier parameters identifier block try_statement block expression_statement call attribute identifier identifier argument_list except_clause attribute identifier identifier block pass_statement except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier none expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Schedules the receive loop to run on the given loop.
def match(tgt, delimiter=DEFAULT_TARGET_DELIM, opts=None): if not opts: opts = __opts__ log.debug('grains pcre target: %s', tgt) if delimiter not in tgt: log.error('Got insufficient arguments for grains pcre match ' 'statement from master') return False return salt.utils.data.subdict_match( opts['grains'], tgt, delimiter=delimiter, regex_match=True)
module function_definition identifier parameters identifier default_parameter identifier identifier default_parameter identifier none block if_statement not_operator identifier block expression_statement assignment identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end return_statement false return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list subscript identifier string string_start string_content string_end identifier keyword_argument identifier identifier keyword_argument identifier true
Matches a grain based on regex
def store_directory(ctx, param, value): Path(value).mkdir(parents=True, exist_ok=True) set_git_home(value) return value
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute call identifier argument_list identifier identifier argument_list keyword_argument identifier true keyword_argument identifier true expression_statement call identifier argument_list identifier return_statement identifier
Store directory as a new Git home.
def _rank_tags(tagged_paired_aligns): tag_count_dict = defaultdict(int) for paired_align in tagged_paired_aligns: tag_count_dict[paired_align.umt] += 1 tags_by_count = utils.sort_dict(tag_count_dict) ranked_tags = [tag_count[0] for tag_count in tags_by_count] return ranked_tags
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement augmented_assignment subscript identifier attribute identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension subscript identifier integer for_in_clause identifier identifier return_statement identifier
Return the list of tags ranked from most to least popular.
def next_frame_ae_range(rhp): rhp.set_float("dropout", 0.3, 0.5) rhp.set_int("num_compress_steps", 1, 3) rhp.set_int("num_hidden_layers", 2, 6) rhp.set_float("learning_rate_constant", 1., 2.) rhp.set_float("initializer_gain", 0.8, 1.5) rhp.set_int("filter_double_steps", 2, 3)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end float float expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end float float expression_statement call attribute identifier identifier argument_list string string_start string_content string_end float float expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer integer
Autoencoder world model tuning grid.
def gather_files(self): self.all_files = utils.files_in_path(self.paths["role"]) return len(self.all_files)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end return_statement call identifier argument_list attribute identifier identifier
Return the number of files.
def pandas(self): if self._pandas is None: self._pandas = pd.DataFrame().from_records(self.list_of_dicts) return self._pandas
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute call attribute identifier identifier argument_list identifier argument_list attribute identifier identifier return_statement attribute identifier identifier
Return a Pandas dataframe.
def build_header(self, plugin, attribute, stat): line = '' if attribute is not None: line += '{}.{}{}'.format(plugin, attribute, self.separator) else: if isinstance(stat, dict): for k in stat.keys(): line += '{}.{}{}'.format(plugin, str(k), self.separator) elif isinstance(stat, list): for i in stat: if isinstance(i, dict) and 'key' in i: for k in i.keys(): line += '{}.{}.{}{}'.format(plugin, str(i[i['key']]), str(k), self.separator) else: line += '{}{}'.format(plugin, self.separator) return line
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier string string_start string_end if_statement comparison_operator identifier none block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier attribute identifier identifier else_clause block if_statement call identifier argument_list identifier identifier block for_statement identifier call attribute identifier identifier argument_list block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier call identifier argument_list identifier attribute identifier identifier elif_clause call identifier argument_list identifier identifier block for_statement identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier comparison_operator string string_start string_content string_end identifier block for_statement identifier call attribute identifier identifier argument_list block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier call identifier argument_list subscript identifier subscript identifier string string_start string_content string_end call identifier argument_list identifier attribute identifier identifier else_clause block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier return_statement identifier
Build and return the header line
def on_window_horizontal_displacement_value_changed(self, spin): self.settings.general.set_int('window-horizontal-displacement', int(spin.get_value()))
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list
Changes the value of window-horizontal-displacement
def connectSubsystem(connection, protocol, subsystem): deferred = connectSession(connection, protocol) @deferred.addCallback def requestSubsystem(session): return session.requestSubsystem(subsystem) return deferred
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier decorated_definition decorator attribute identifier identifier function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list identifier return_statement identifier
Connect a Protocol to a ssh subsystem channel
def fail_all(self, err): for c_id in self._futures: self._fail_reply(c_id, err)
module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
Fail all the expected replies with a given error.
def _analyze(self): pids = [] for ip in self.filter['ips']: if ip in self.ips_to_pids: for pid in self.ips_to_pids[ip]: pids.append(pid) for line in self.parsed_lines: if 'processid' in line and line['processid'] in pids: self.noisy_logs.append(line) else: self.quiet_logs.append(line)
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier subscript attribute identifier identifier string string_start string_content string_end block if_statement comparison_operator identifier attribute identifier identifier block for_statement identifier subscript attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Decide which lines should be filtered out
def init_loopback(self, data): self.name = data["name"] self.description = data['description'] self.win_index = data['win_index'] self.mac = data["mac"] self.guid = data["guid"] self.ip = "127.0.0.1"
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier string string_start string_content string_end
Just initialize the object for our Pseudo Loopback
def add(self, req: Request): key = req.key if key not in self: self[key] = ReqState(req) return self[key]
module function_definition identifier parameters identifier typed_parameter identifier type identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier return_statement subscript identifier identifier
Add the specified request to this request store.
def _read_wrapper(data): if isinstance(data, int): data = chr(data) return py23_compat.text_type(data)
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier
Ensure unicode always returned on read.
def complete(self): return self.valid and (self.access_token or self.refresh_token or self.type == 2)
module function_definition identifier parameters identifier block return_statement boolean_operator attribute identifier identifier parenthesized_expression boolean_operator boolean_operator attribute identifier identifier attribute identifier identifier comparison_operator attribute identifier identifier integer
Complete credentials are valid and are either two-legged or include a token.
def get(key, adapter = MemoryAdapter): try: return pickle.loads(adapter().get(key)) except CacheExpiredException: return None
module function_definition identifier parameters identifier default_parameter identifier identifier block try_statement block return_statement call attribute identifier identifier argument_list call attribute call identifier argument_list identifier argument_list identifier except_clause identifier block return_statement none
get the cache value
def reload_all_manifests(self): self._logger.debug("Reloading all manifests.") self._manifests = [] self.load_manifests() self._logger.debug("All manifests reloaded.")
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier list expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
Reloads all loaded manifests, and loads any new manifests
def _archive_cls(file, ext=''): cls = None filename = None if is_string(file): filename = file else: try: filename = file.name except AttributeError: raise UnrecognizedArchiveFormat( "File object not a recognized archive format.") lookup_filename = filename + ext base, tail_ext = os.path.splitext(lookup_filename.lower()) cls = extension_map.get(tail_ext) if not cls: base, ext = os.path.splitext(base) cls = extension_map.get(ext) if not cls: raise UnrecognizedArchiveFormat( "Path not a recognized archive format: %s" % filename) return cls
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end block expression_statement assignment identifier none expression_statement assignment identifier none if_statement call identifier argument_list identifier block expression_statement assignment identifier identifier else_clause block try_statement block expression_statement assignment identifier attribute identifier identifier except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier return_statement identifier
Return the proper Archive implementation class, based on the file type.
def setaxes(self, *axes): if axes is None: self._axes = None else: self._axes = [unit_vector(axis) for axis in axes]
module function_definition identifier parameters identifier list_splat_pattern identifier block if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier none else_clause block expression_statement assignment attribute identifier identifier list_comprehension call identifier argument_list identifier for_in_clause identifier identifier
Set axes to constrain rotations.
def to_dict(self): return {k: v.to_dict() if isinstance(v, AttrDict) else v for k, v in self.__dict__.items() if not k.startswith('_')}
module function_definition identifier parameters identifier block return_statement dictionary_comprehension pair identifier conditional_expression call attribute identifier identifier argument_list call identifier argument_list identifier identifier identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_clause not_operator call attribute identifier identifier argument_list string string_start string_content string_end
Convert to a nested dict.
def _is_path_match(req_path: str, cookie_path: str) -> bool: if not req_path.startswith("/"): req_path = "/" if req_path == cookie_path: return True if not req_path.startswith(cookie_path): return False if cookie_path.endswith("/"): return True non_matching = req_path[len(cookie_path):] return non_matching.startswith("/")
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator identifier identifier block return_statement true if_statement not_operator call attribute identifier identifier argument_list identifier block return_statement false if_statement call attribute identifier identifier argument_list string string_start string_content string_end block return_statement true expression_statement assignment identifier subscript identifier slice call identifier argument_list identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end
Implements path matching adhering to RFC 6265.
def getPixelAttrRandom(self, x, y): 'weighted-random choice of attr at this pixel.' c = list(attr for attr, rows in self.pixels[y][x].items() for r in rows if attr and attr not in self.hiddenAttrs) return random.choice(c) if c else 0
module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier generator_expression identifier for_in_clause pattern_list identifier identifier call attribute subscript subscript attribute identifier identifier identifier identifier identifier argument_list for_in_clause identifier identifier if_clause boolean_operator identifier comparison_operator identifier attribute identifier identifier return_statement conditional_expression call attribute identifier identifier argument_list identifier identifier integer
weighted-random choice of attr at this pixel.
def sample_greedy(self): if self.leafnode: return self.sample_bounds() else: lp = self.lower.max_leaf_progress gp = self.greater.max_leaf_progress maxp = max(lp, gp) if self.sampling_mode['multiscale']: tp = self.progress if tp > maxp: return self.sample_bounds() if gp == maxp: sampling_mode = self.sampling_mode sampling_mode['mode'] = 'greedy' return self.greater.sample(sampling_mode=sampling_mode) else: sampling_mode = self.sampling_mode sampling_mode['mode'] = 'greedy' return self.lower.sample(sampling_mode=sampling_mode)
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier if_statement subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier identifier block return_statement call attribute identifier identifier argument_list if_statement comparison_operator identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier
Sample a point in the leaf with the max progress.
def cdx_reverse(cdx_iter, limit): if limit == 1: last = None for cdx in cdx_iter: last = cdx if not last: return yield last reverse_cdxs = deque(maxlen=limit) for cdx in cdx_iter: reverse_cdxs.appendleft(cdx) for cdx in reverse_cdxs: yield cdx
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier integer block expression_statement assignment identifier none for_statement identifier identifier block expression_statement assignment identifier identifier if_statement not_operator identifier block return_statement expression_statement yield identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement yield identifier
return cdx records in reverse order.
def _validate_type_key(key, value, types, validated): for key_schema, value_schema in types.items(): if not isinstance(key, key_schema): continue try: validated[key] = value_schema(value) except NotValid: continue else: return [] return ['%r: %r not matched' % (key, value)]
module function_definition identifier parameters identifier identifier identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement not_operator call identifier argument_list identifier identifier block continue_statement try_statement block expression_statement assignment subscript identifier identifier call identifier argument_list identifier except_clause identifier block continue_statement else_clause block return_statement list return_statement list binary_operator string string_start string_content string_end tuple identifier identifier
Validate a key's value by type.
def _hook(self, hook_name, doc_uri=None, **kwargs): doc = self.workspace.get_document(doc_uri) if doc_uri else None hook_handlers = self.config.plugin_manager.subset_hook_caller(hook_name, self.config.disabled_plugins) return hook_handlers(config=self.config, workspace=self.workspace, document=doc, **kwargs)
module function_definition identifier parameters identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment identifier conditional_expression call attribute attribute identifier identifier identifier argument_list identifier identifier none expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier attribute attribute identifier identifier identifier return_statement call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier dictionary_splat identifier
Calls hook_name and returns a list of results from all registered handlers
def delete_extra_files(self, relpaths, cloud_objs): for cloud_obj in cloud_objs: if cloud_obj not in relpaths: if not self.test_run: self.delete_cloud_obj(cloud_obj) self.delete_count += 1 if not self.quiet or self.verbosity > 1: print("Deleted: {0}".format(cloud_obj))
module function_definition identifier parameters identifier identifier identifier block for_statement identifier identifier block if_statement comparison_operator identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment attribute identifier identifier integer if_statement boolean_operator not_operator attribute identifier identifier comparison_operator attribute identifier identifier integer block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Deletes any objects from the container that do not exist locally.
def _exec(**kwargs): if 'ignore_retcode' not in kwargs: kwargs['ignore_retcode'] = True if 'output_loglevel' not in kwargs: kwargs['output_loglevel'] = 'quiet' return salt.modules.cmdmod.run_all(**kwargs)
module function_definition identifier parameters dictionary_splat_pattern identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end true if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list dictionary_splat identifier
Simple internal wrapper for cmdmod.run
def retry_until_not_none_or_limit_reached(method, limit, sleep_s=1, catch_exceptions=()): return retry_until_valid_or_limit_reached( method, limit, lambda x: x is not None, sleep_s, catch_exceptions)
module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier tuple block return_statement call identifier argument_list identifier identifier lambda lambda_parameters identifier comparison_operator identifier none identifier identifier
Executes a method until the retry limit is hit or not None is returned.
def _read_regpol_file(reg_pol_path): returndata = None if os.path.exists(reg_pol_path): with salt.utils.files.fopen(reg_pol_path, 'rb') as pol_file: returndata = pol_file.read() return returndata
module function_definition identifier parameters identifier block expression_statement assignment identifier none if_statement call attribute attribute identifier identifier identifier argument_list identifier block with_statement with_clause with_item as_pattern call attribute attribute attribute identifier identifier identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement identifier
helper function to read a reg policy file and return decoded data
def stacksize(self): return max(scanl( op.add, 0, map(op.attrgetter('stack_effect'), self.instrs), ))
module function_definition identifier parameters identifier block return_statement call identifier argument_list call identifier argument_list attribute identifier identifier integer call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier
The maximum amount of stack space used by this code object.
def _update_pvalcorr(ntmt, corrected_pvals): if corrected_pvals is None: return for rec, val in zip(ntmt.results, corrected_pvals): rec.set_corrected_pval(ntmt.nt_method, val)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block return_statement for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier
Add data members to store multiple test corrections.
def _has_changed_related(instance): tracked_related_fields = getattr( instance, '_tracked_related_fields', {} ).keys() for field, value in instance._original_fields.items(): if field != 'pk' and \ not isinstance(instance._meta.get_field(field), ManyToManyField): if field in tracked_related_fields: if isinstance(instance._meta.get_field(field), ForeignKey): if getattr(instance, '{0}_id'.format(field)) != value: return True else: if getattr(instance, field) != value: return True return False
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier string string_start string_content string_end dictionary identifier argument_list for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement boolean_operator comparison_operator identifier string string_start string_content string_end line_continuation not_operator call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier block if_statement comparison_operator identifier identifier block if_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier block if_statement comparison_operator call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier block return_statement true else_clause block if_statement comparison_operator call identifier argument_list identifier identifier identifier block return_statement true return_statement false
Check if some related tracked fields have changed
def _check_model(obj, models=None): return isinstance(obj, type) and issubclass(obj, pw.Model) and hasattr(obj, '_meta')
module function_definition identifier parameters identifier default_parameter identifier none block return_statement boolean_operator boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier attribute identifier identifier call identifier argument_list identifier string string_start string_content string_end
Checks object if it's a peewee model and unique.
def random_val(index, tune_params): key = list(tune_params.keys())[index] return random.choice(tune_params[key])
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript call identifier argument_list call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list subscript identifier identifier
return a random value for a parameter
def _get_version(addon_dir, manifest, odoo_version_override=None, git_post_version=True): version = manifest.get('version') if not version: warn("No version in manifest in %s" % addon_dir) version = '0.0.0' if not odoo_version_override: if len(version.split('.')) < 5: raise DistutilsSetupError("Version in manifest must have at least " "5 components and start with " "the Odoo series number in %s" % addon_dir) odoo_version = '.'.join(version.split('.')[:2]) else: odoo_version = odoo_version_override if odoo_version not in ODOO_VERSION_INFO: raise DistutilsSetupError("Unsupported odoo version '%s' in %s" % (odoo_version, addon_dir)) odoo_version_info = ODOO_VERSION_INFO[odoo_version] if git_post_version: version = get_git_postversion(addon_dir) return version, odoo_version, odoo_version_info
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier true block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block expression_statement call identifier argument_list 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 identifier block if_statement comparison_operator call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end integer block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list subscript call attribute identifier identifier argument_list string string_start string_content string_end slice integer else_clause block expression_statement assignment identifier identifier if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier subscript identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement expression_list identifier identifier identifier
Get addon version information from an addon directory
def do_HEAD(self): self.queue.put(self.headers.get("User-Agent")) self.send_response(six.moves.BaseHTTPServer.HTTPStatus.OK) self.send_header("Location", self.path) self.end_headers()
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute attribute attribute attribute identifier identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list
Serve a HEAD request.
def _read_json_file(self, json_file): self.log.debug("Reading '%s' JSON file..." % json_file) with open(json_file, 'r') as f: return json.load(f, object_pairs_hook=OrderedDict)
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
Helper function to read JSON file as OrderedDict
def parse(self, val): s = str(val).lower() if s == "true": return True elif s == "false": return False else: raise ValueError("cannot interpret '{}' as boolean".format(val))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list if_statement comparison_operator identifier string string_start string_content string_end block return_statement true elif_clause comparison_operator identifier string string_start string_content string_end block return_statement false else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Parses a ``bool`` from the string, matching 'true' or 'false' ignoring case.
def _clean_key_expiration_option(self): allowed_entry = re.findall('^(\d+)(|w|m|y)$', self._expiration_time) if not allowed_entry: raise UsageError("Key expiration option: %s is not valid" % self._expiration_time)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier if_statement not_operator identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier
validates the expiration option supplied
def remove_None(params: dict): return { key: value for key, value in params.items() if value is not None }
module function_definition identifier parameters typed_parameter identifier type identifier block return_statement dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list if_clause comparison_operator identifier none
Remove all keys in `params` that have the value of `None`.
def start(self) -> pd.Timestamp: start = self.data.timestamp.min() self.data = self.data.assign(start=start) return start
module function_definition identifier parameters identifier type attribute identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier return_statement identifier
Returns the minimum timestamp value of the DataFrame.
def parse_date(date_str): if not date_str: return None try: date = ciso8601.parse_datetime(date_str) if not date: date = arrow.get(date_str).datetime except TypeError: date = arrow.get(date_str[0]).datetime return date
module function_definition identifier parameters identifier block if_statement not_operator identifier block return_statement none try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment identifier attribute call attribute identifier identifier argument_list identifier identifier except_clause identifier block expression_statement assignment identifier attribute call attribute identifier identifier argument_list subscript identifier integer identifier return_statement identifier
Parse elastic datetime string.
def dialect_class(self, adapter): if self.dialects.get(adapter): return self.dialects[adapter] try: class_prefix = getattr( __import__('db.' + adapter, globals(), locals(), ['__class_prefix__']), '__class_prefix__') driver = self._import_class('db.' + adapter + '.dialect.' + class_prefix + 'Dialect') except ImportError: raise DBError("Must install adapter `%s` or doesn't support" % (adapter)) self.dialects[adapter] = driver return driver
module function_definition identifier parameters identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block return_statement subscript attribute identifier identifier identifier try_statement block expression_statement assignment identifier call identifier argument_list call identifier argument_list binary_operator string string_start string_content string_end identifier call identifier argument_list call identifier argument_list list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression identifier expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement identifier
Get dialect sql class by adapter
def DeleteNotifications(self, session_ids, start=None, end=None): if not session_ids: return for session_id in session_ids: if not isinstance(session_id, rdfvalue.SessionID): raise RuntimeError( "Can only delete notifications for rdfvalue.SessionIDs.") if start is None: start = 0 else: start = int(start) if end is None: end = self.frozen_timestamp or rdfvalue.RDFDatetime.Now() for queue, ids in iteritems( collection.Group(session_ids, lambda session_id: session_id.Queue())): queue_shards = self.GetAllNotificationShards(queue) self.data_store.DeleteNotifications(queue_shards, ids, start, end)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block if_statement not_operator identifier block return_statement for_statement identifier identifier block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment identifier integer else_clause block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier boolean_operator attribute identifier identifier call attribute attribute identifier identifier identifier argument_list for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list identifier lambda lambda_parameters identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier identifier
This deletes the notification when all messages have been processed.
def more(self): _, more, is_markdown = self._entry_content return TrueCallableProxy( self._get_markup, more, is_markdown) if more else CallableProxy(None)
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier attribute identifier identifier return_statement conditional_expression call identifier argument_list attribute identifier identifier identifier identifier identifier call identifier argument_list none
Get the below-the-fold entry body text
def copyfile(src, dest, no_progress_bar=False, name=None): from dvc.progress import progress copied = 0 name = name if name else os.path.basename(dest) total = os.stat(src).st_size if os.path.isdir(dest): dest = os.path.join(dest, os.path.basename(src)) with open(src, "rb") as fsrc, open(dest, "wb+") as fdest: while True: buf = fsrc.read(LOCAL_CHUNK_SIZE) if not buf: break fdest.write(buf) copied += len(buf) if not no_progress_bar: progress.update_target(name, copied, total) if not no_progress_bar: progress.finish_target(name)
module function_definition identifier parameters identifier identifier default_parameter identifier false default_parameter identifier none block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier integer expression_statement assignment identifier conditional_expression identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block break_statement expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier call identifier argument_list identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list identifier
Copy file with progress bar
def expr_contains(e, o): if o == e: return True if e.has_args(): for a in e.args(): if expr_contains(a, o): return True return False
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier identifier block return_statement true if_statement call attribute identifier identifier argument_list block for_statement identifier call attribute identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block return_statement true return_statement false
Returns true if o is in e
def start_processing_handler(self, event): results_path = os.path.join(self.configuration['results_folder'], "filesystem.json") self.logger.debug("Event %s: start comparing %s with %s.", event, self.checkpoints[0], self.checkpoints[1]) results = compare_disks(self.checkpoints[0], self.checkpoints[1], self.configuration) with open(results_path, 'w') as results_file: json.dump(results, results_file) self.processing_done.set()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier subscript attribute identifier identifier integer subscript attribute identifier identifier integer expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier integer subscript attribute identifier identifier integer attribute identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Asynchronous handler starting the disk analysis process.
def _generate_components(self, X): rs = check_random_state(self.random_state) if (self._use_mlp_input): self._compute_biases(rs) self._compute_weights(X, rs) if (self._use_rbf_input): self._compute_centers(X, sp.issparse(X), rs) self._compute_radii()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement parenthesized_expression attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier if_statement parenthesized_expression attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list
Generate components of hidden layer given X
def show(self): thr_is_alive = self._spin_thread and self._spin_thread.is_alive() if thr_is_alive and self._hide_spin.is_set(): self._hide_spin.clear() sys.stdout.write("\r") self._clear_line()
module function_definition identifier parameters identifier block expression_statement assignment identifier boolean_operator attribute identifier identifier call attribute attribute identifier identifier identifier argument_list if_statement boolean_operator identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list
Show the hidden spinner.
def _report(data, reference): seqcluster = op.join(get_bcbio_bin(), "seqcluster") work_dir = dd.get_work_dir(data) out_dir = safe_makedir(os.path.join(work_dir, "seqcluster", "report")) out_file = op.join(out_dir, "seqcluster.db") json = op.join(work_dir, "seqcluster", "cluster", "seqcluster.json") cmd = ("{seqcluster} report -o {out_dir} -r {reference} -j {json}") if not file_exists(out_file): do.run(cmd.format(**locals()), "Run report on clusters") return out_file
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier parenthesized_expression string string_start string_content string_end if_statement not_operator call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list dictionary_splat call identifier argument_list string string_start string_content string_end return_statement identifier
Run report of seqcluster to get browser options for results
def yaml_parse(yamlstr): try: return json.loads(yamlstr) except ValueError: yaml.SafeLoader.add_multi_constructor("!", intrinsics_multi_constructor) return yaml.safe_load(yamlstr)
module function_definition identifier parameters identifier block try_statement block return_statement call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list identifier
Parse a yaml string
def add_option(self, parser): group = parser.add_argument_group(self.name) for stat in self.stats: stat.add_option(group) group.add_argument( "--{0}".format(self.option), action="store_true", help="All above")
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end
Add option group and all children options.
def do(self): "run it, get a new url" scheme, netloc, path, params, query, fragment = Split(self.url).do() if isinstance(self.query, dict): query = query + "&" + urllib.urlencode(self.query) if query else urllib.urlencode(self.query) path = urljoin(path, self.path).replace('\\', '/') if self.path else path return Splice(scheme=scheme, netloc=netloc, path=path, params=params, query=query, fragment=fragment).geturl
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment pattern_list identifier identifier identifier identifier identifier identifier call attribute call identifier argument_list attribute identifier identifier identifier argument_list if_statement call identifier argument_list attribute identifier identifier identifier block expression_statement assignment identifier conditional_expression binary_operator binary_operator identifier string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier conditional_expression call attribute call identifier argument_list identifier attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end attribute identifier identifier identifier return_statement attribute call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier identifier
run it, get a new url
def round_sig(x, sig): return round(x, sig - int(floor(log10(abs(x)))) - 1)
module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list identifier binary_operator binary_operator identifier call identifier argument_list call identifier argument_list call identifier argument_list call identifier argument_list identifier integer
Round the number to the specified number of significant figures
def delete_files(sender, **kwargs): instance = kwargs['instance'] if not hasattr(instance.distribution, 'path'): return if not os.path.exists(instance.distribution.path): return is_referenced = ( instance.__class__.objects .filter(distribution=instance.distribution) .exclude(pk=instance._get_pk_val()) .exists()) if is_referenced: return try: instance.distribution.storage.delete(instance.distribution.path) except Exception: logger.exception( 'Error when trying to delete file %s of package %s:' % ( instance.pk, instance.distribution.path))
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement not_operator call identifier argument_list attribute identifier identifier string string_start string_content string_end block return_statement if_statement not_operator call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier block return_statement expression_statement assignment identifier parenthesized_expression call attribute call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list identifier argument_list if_statement identifier block return_statement try_statement block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute attribute identifier identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute attribute identifier identifier identifier
Signal callback for deleting old files when database item is deleted
def signalMinimum2(img, bins=None): f = FitHistogramPeaks(img, bins=bins) i = signalPeakIndex(f.fitParams) spos = f.fitParams[i][1] bpos = f.fitParams[i - 1][1] ind = np.logical_and(f.xvals > bpos, f.xvals < spos) try: i = np.argmin(f.yvals[ind]) return f.xvals[ind][i] except ValueError as e: if bins is None: return signalMinimum2(img, bins=400) else: raise e
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier subscript subscript attribute identifier identifier identifier integer expression_statement assignment identifier subscript subscript attribute identifier identifier binary_operator identifier integer integer expression_statement assignment identifier call attribute identifier identifier argument_list comparison_operator attribute identifier identifier identifier comparison_operator attribute identifier identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list subscript attribute identifier identifier identifier return_statement subscript subscript attribute identifier identifier identifier identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator identifier none block return_statement call identifier argument_list identifier keyword_argument identifier integer else_clause block raise_statement identifier
minimum position between signal and background peak
def execute_nb(fname, metadata=None, save=True, show_doc_only=False): "Execute notebook `fname` with `metadata` for preprocessing." with open(fname) as f: nb = nbformat.read(f, as_version=4) ep_class = ExecuteShowDocPreprocessor if show_doc_only else ExecutePreprocessor ep = ep_class(timeout=600, kernel_name='python3') metadata = metadata or {} ep.preprocess(nb, metadata) if save: with open(fname, 'wt') as f: nbformat.write(nb, f) NotebookNotary().sign(nb)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier true default_parameter identifier false block expression_statement string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier integer expression_statement assignment identifier conditional_expression identifier identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier integer keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier boolean_operator identifier dictionary expression_statement call attribute identifier identifier argument_list identifier identifier if_statement identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute call identifier argument_list identifier argument_list identifier
Execute notebook `fname` with `metadata` for preprocessing.
def terms(self): terms = PropertyTerms( self.name, self.__class__, self._args, self._kwargs, self.meta ) return terms
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier return_statement identifier
Initialization terms and options for Property
def _emplace_pmrna(mrnas, parent, strict=False): mrnas.sort(key=lambda m: (m.cdslen, m.get_attribute('ID'))) pmrna = mrnas.pop() if strict: parent.children = [pmrna] else: parent.children = [c for c in parent.children if c not in mrnas]
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement call attribute identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier tuple attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment attribute identifier identifier list identifier else_clause block expression_statement assignment attribute identifier identifier list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator identifier identifier
Retrieve the primary mRNA and discard all others.
def normpath(path: Optional[str]) -> Optional[str]: if path is not None: return os.path.normpath(path)
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type generic_type identifier type_parameter type identifier block if_statement comparison_operator identifier none block return_statement call attribute attribute identifier identifier identifier argument_list identifier
Normalizes the path, returns None if the argument is None
def addHost(self, name=None): if name is None: while True: name = 'h' + str(self.__hnum) self.__hnum += 1 if name not in self.__nxgraph: break self.__addNode(name, Host) return name
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block while_statement true block expression_statement assignment identifier binary_operator string string_start string_content string_end call identifier argument_list attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier integer if_statement comparison_operator identifier attribute identifier identifier block break_statement expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier
Add a new host node to the topology.
def main(argv=None): args = parse_arguments(sys.argv if argv is None else argv) tf.logging.set_verbosity(tf.logging.INFO) learn_runner.run( experiment_fn=get_experiment_fn(args), output_dir=args.job_dir)
module function_definition identifier parameters default_parameter identifier none block expression_statement assignment identifier call identifier argument_list conditional_expression attribute identifier identifier comparison_operator identifier none identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier attribute identifier identifier
Run a Tensorflow model on the Iris dataset.
def _do_write(self): with self.lock: self._commit_counter += 1 if self._commit_counter >= self._commit_every: self._db.commit() self._commit_counter = 0
module function_definition identifier parameters identifier block with_statement with_clause with_item attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier integer if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier integer
Check commit counter and do a commit if need be
def add_regex_start_end(pattern_function): @wraps(pattern_function) def func_wrapper(*args, **kwargs): return r'^{}$'.format(pattern_function(*args, **kwargs)) return func_wrapper
module function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call attribute string string_start string_content string_end identifier argument_list call identifier argument_list list_splat identifier dictionary_splat identifier return_statement identifier
Decorator for adding regex pattern start and end characters.
def _init_pluginmanager(self): self.pluginmanager = PluginManager(logger=self.logger) self.logger.debug("Registering execution wide plugins:") self.pluginmanager.load_default_run_plugins() self.pluginmanager.load_custom_run_plugins(self.args.plugin_path) self.logger.debug("Execution wide plugins loaded and registered.")
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
Initialize PluginManager and load run wide plugins.
def calling(data): chip_bam = data.get("work_bam") input_bam = data.get("work_bam_input", None) caller_fn = get_callers()[data["peak_fn"]] name = dd.get_sample_name(data) out_dir = utils.safe_makedir(os.path.join(dd.get_work_dir(data), data["peak_fn"], name)) out_files = caller_fn(name, chip_bam, input_bam, dd.get_genome_build(data), out_dir, dd.get_chip_method(data), data["resources"], data) greylistdir = greylisting(data) data.update({"peaks_files": out_files}) if greylistdir: data["greylist"] = greylistdir return [[data]]
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier subscript call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier call attribute identifier identifier argument_list identifier identifier call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement list list identifier
Main function to parallelize peak calling.
def eval_agg_call(self, exp): "helper for eval_callx; evaluator for CallX that consume multiple rows" if not isinstance(self.c_row,list): raise TypeError('aggregate function expected a list of rows') if len(exp.args.children)!=1: raise ValueError('aggregate function expected a single value',exp.args) arg,=exp.args.children vals=[Evaluator(c_r,self.nix,self.tables).eval(arg) for c_r in self.c_row] if not vals: return None if exp.f=='min': return min(vals) elif exp.f=='max': return max(vals) elif exp.f=='count': return len(vals) else: raise NotImplementedError('unk_func',exp.f)
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end if_statement not_operator call identifier argument_list attribute identifier identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list attribute attribute identifier identifier identifier integer block raise_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment pattern_list identifier attribute attribute identifier identifier identifier expression_statement assignment identifier list_comprehension call attribute call identifier argument_list identifier attribute identifier identifier attribute identifier identifier identifier argument_list identifier for_in_clause identifier attribute identifier identifier if_statement not_operator identifier block return_statement none if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call identifier argument_list identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call identifier argument_list identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call identifier argument_list identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier
helper for eval_callx; evaluator for CallX that consume multiple rows
def getApplicationsTransitionStateNameFromEnum(self, state): fn = self.function_table.getApplicationsTransitionStateNameFromEnum result = fn(state) return result
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
Returns a string for an application transition state
def record_download_archive(track): global arguments if not arguments['--download-archive']: return archive_filename = arguments.get('--download-archive') try: with open(archive_filename, 'a', encoding='utf-8') as file: file.write('{0}'.format(track['id'])+'\n') except IOError as ioe: logger.error('Error trying to write to download archive...') logger.debug(ioe)
module function_definition identifier parameters identifier block global_statement identifier if_statement not_operator subscript identifier string string_start string_content string_end block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end try_statement block with_statement with_clause with_item as_pattern call 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 binary_operator call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end string string_start string_content escape_sequence string_end except_clause as_pattern identifier as_pattern_target 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
Write the track_id in the download archive
def masked(self): return IPNetwork('%s/%d' % (self.network, self._prefixlen), version=self._version)
module function_definition identifier parameters identifier block return_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Return the network object with the host bits masked out.
def debugObject(object, cat, format, *args): doLog(DEBUG, object, cat, format, args)
module function_definition identifier parameters identifier identifier identifier list_splat_pattern identifier block expression_statement call identifier argument_list identifier identifier identifier identifier identifier
Log a debug message in the given category.
def execute(self): self.provider.authenticate() identifier = self.config.resolve('lexicon:identifier') record_type = self.config.resolve('lexicon:type') name = self.config.resolve('lexicon:name') content = self.config.resolve('lexicon:content') if self.action == 'create': return self.provider.create_record(record_type, name, content) if self.action == 'list': return self.provider.list_records(record_type, name, content) if self.action == 'update': return self.provider.update_record(identifier, record_type, name, content) if self.action == 'delete': return self.provider.delete_record(identifier, record_type, name, content) raise ValueError('Invalid action statement: {0}'.format(self.action))
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier identifier raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier
Execute provided configuration in class constructor to the DNS records