code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def StringEncoder(field_number, is_repeated, is_packed): tag = TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED) local_EncodeVarint = _EncodeVarint local_len = len assert not is_packed if is_repeated: def EncodeRepeatedField(write, value): for element in value: encoded = element....
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier identifier expression_statement assignment identifier identifier assert_s...
Returns an encoder for a string field.
def datetimes(self): if self._timestamps_data is None: self._calculate_timestamps() return tuple(DateTime.from_moy(moy, self.is_leap_year) for moy in self._timestamps_data)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list return_statement call identifier generator_expression call attribute identifier identifier argument_list i...
A sorted list of datetimes in this analysis period.
def OnSortAscending(self, event): try: with undo.group(_("Sort ascending")): self.grid.actions.sort_ascending(self.grid.actions.cursor) statustext = _(u"Sorting complete.") except Exception, err: statustext = _(u"Sorting failed: {}").format(err) ...
module function_definition identifier parameters identifier identifier block try_statement block with_statement with_clause with_item call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end block expression_statement call attribute attribute attribu...
Sort ascending event handler
def download(): ftp = ftplib.FTP(SITE) ftp.set_debuglevel(DEBUG) ftp.login(USER, PASSWD) ftp.cwd(DIR) filelist = ftp.nlst() filecounter = MANAGER.counter(total=len(filelist), desc='Downloading', unit='files') for filename in filelist: with Writer(fil...
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list ident...
Download all files from an FTP share
def command_preflight_check(self): checks_pass, failures = self.environment.perform_preflight_check() if checks_pass: print('All checks pass.') else: sys.stderr.write('Problems encountered:\n') for msg in failures: sys.stderr.write(' - %s\n' % ...
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_statement identifier block expression_statement call identifier argument_list string string_start string_content...
Detects whether we have everything needed to mount sshfs filesystems.
def abort (aggregate): while True: try: aggregate.abort() aggregate.finish() aggregate.end_log_output(interrupt=True) break except KeyboardInterrupt: log.warn(LOG_CHECK, _("user abort; force shutdown")) aggregate.end_log_output(...
module function_definition identifier parameters identifier block while_statement true block try_statement block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argum...
Helper function to ensure a clean shutdown.
def _fill_request(self, request, rdata): if not isinstance(rdata, dict): raise InvalidRequestError request['jsonrpc'] = self._get_jsonrpc(rdata) request['id'] = self._get_id(rdata) request['method'] = self._get_method(rdata) request['params'] = self._get_params(rdata)
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute identif...
Fills request with data from the jsonrpc call.
def timedeltaToString(delta): if delta.days == 0: sign = 1 else: sign = delta.days / abs(delta.days) delta = abs(delta) days = delta.days hours = int(delta.seconds / 3600) minutes = int((delta.seconds % 3600) / 60) seconds = int(delta.seconds % 60) output = '' if sign...
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier integer else_clause block expression_statement assignment identifier binary_operator attribute identifier identifier call identifier...
Convert timedelta to an ical DURATION.
def _parse( self, item_iter, state ): parsed_array = [] for i, item in enumerate(item_iter): state.push_location(self._item_processor.element_path, i) parsed_array.append(self._item_processor.parse_at_element(item, state)) state...
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list attribute attrib...
Parse the array data using the provided iterator of XML elements.
def obsres_from_oblock_id(self, obsid, configuration=None): este = self.ob_table[obsid] obsres = obsres_from_dict(este) _logger.debug("obsres_from_oblock_id id='%s', mode='%s' START", obsid, obsres.mode) try: this_drp = self.drps.query_by_name(obsres.instrument) excep...
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call att...
Override instrument configuration if configuration is not None
def predictive_probability_multistate(M_c, X_L_list, X_D_list, Y, Q): logprobs = [float(predictive_probability(M_c, X_L, X_D, Y, Q)) for X_L, X_D in zip(X_L_list, X_D_list)] return logmeanexp(logprobs)
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier list_comprehension call identifier argument_list call identifier argument_list identifier identifier identifier identifier identifier for_in_clause pattern_list identi...
Returns the predictive probability, averaged over each sample.
def _set_session_cookie(self): LOGGER.debug('Setting session cookie for %s', self.session.id) self.set_secure_cookie(name=self._session_cookie_name, value=self.session.id, expires=self._cookie_expiration)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list keyword_arg...
Set the session data cookie.
def prepare_mongod_server(server): log_info("Preparing server '%s' for use as configured..." % server.id) cluster = server.get_cluster() if server.supports_local_users(): users.setup_server_local_users(server) if not server.is_cluster_member() or server.is_standalone_config_server()...
module function_definition identifier parameters identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement ca...
Contains post start server operations
def apply(self): self.read_group_info() if self.tabs.count() == 0: self.button_color.setEnabled(False) self.button_del.setEnabled(False) self.button_apply.setEnabled(False) else: self.button_color.setEnabled(True) self.button_del.setEna...
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list integer block expression_statement call attribute attribute identifier identi...
Apply changes to the plots.
def local_timezone(self): if self._local_tz.zone in pytz.all_timezones: return self._local_tz.zone return self.timezone
module function_definition identifier parameters identifier block if_statement comparison_operator attribute attribute identifier identifier identifier attribute identifier identifier block return_statement attribute attribute identifier identifier identifier return_statement attribute identifier identifier
Returns the name of the local timezone.
def module_functions(modulestr): funcs = dict(inspect.getmembers(import_module(modulestr), inspect.isfunction)) return OrderedDict(sorted(funcs.items(), key=lambda f: f[0]))
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list call identifier argument_list identifier attribute identifier identifier return_statement call identifier argument_list call ident...
Return ordered dictionary of all functions declared in module
def create_node_tables(self): self.cursor.execute('PRAGMA foreign_keys=1') self.cursor.execute( ) self.cursor.execute( ) self.cursor.execute( ) self.cursor.execute( 'CREATE UNIQUE INDEX IF NOT EXISTS node ON nodes (value)' ) self.cursor.execute( ...
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement c...
Create node and link tables if they don't exist.
def _is_allowed_abbr(self, tokens): if len(tokens) <= 2: abbr_text = ''.join(tokens) if self.abbr_min <= len(abbr_text) <= self.abbr_max and bracket_level(abbr_text) == 0: if abbr_text[0].isalnum() and any(c.isalpha() for c in abbr_text): if re.match('...
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call attribute string string_start string_end identifier argument_list identifier if_statement boolean_operator ...
Return True if text is an allowed abbreviation.
def dict_to_enum_fn(d: Dict[str, Any], enum_class: Type[Enum]) -> Enum: return enum_class[d['name']]
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier block return_statement subscript identifier subscript identifier ...
Converts an ``dict`` to a ``Enum``.
def _get_fix_my_django_submission_url(self, tb_info, sanitized_tb): err_post_create_path = '/create/' url = '{0}{1}'.format(base_url, err_post_create_path) return '{url}?{query}'.format( url=url, query=urlencode({ 'exception_type': clean_exception_type(tb_...
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier ide...
Links to the error submission url with pre filled fields
def _copy_params(self): cls = type(self) src_name_attrs = [(x, getattr(cls, x)) for x in dir(cls)] src_params = list(filter(lambda nameAttr: isinstance(nameAttr[1], Param), src_name_attrs)) for name, param in src_params: setattr(self, name, param._copy_new_parent(self))
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier list_comprehension tuple identifier call identifier argument_list identifier identifier for_in_clause identifier call identifie...
Copy all params defined on the class to current object.
def _factory(cls, constraints, op): pieces = [] for i, constraint in enumerate(constraints): pieces.append(constraint) if i != len(constraints) - 1: pieces.append(op) return cls(pieces)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier if_st...
Factory for joining constraints with a single conjunction
def _size_map(size): try: if not isinstance(size, int): if re.search(r'[Kk]', size): size = 1024 * float(re.sub(r'[Kk]', '', size)) elif re.search(r'[Mm]', size): size = 1024**2 * float(re.sub(r'[Mm]', '', size)) size = int(size) re...
module function_definition identifier parameters identifier block try_statement block if_statement not_operator call identifier argument_list identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier block expression_statement as...
Map Bcache's size strings to real bytes
def change_last_time_step(self, **replace_time_step_kwargs): assert self._time_steps self._time_steps[-1] = self._time_steps[-1].replace( **replace_time_step_kwargs)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block assert_statement attribute identifier identifier expression_statement assignment subscript attribute identifier identifier unary_operator integer call attribute subscript attribute identifier identifier unary_operator ...
Replace the last time-steps with the given kwargs.
def skip(self): for pos, element in self.element_iter: tag, class_attr = _tag_and_class_attr(element) if tag == "div" and "thread" in class_attr and pos == "end": break
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier attribute identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement boolean_operator boolean_operator comparison_o...
Eats through the input iterator without recording the content.
def destroy(self): node = self.node if not config.is_node_destroyable(node.name): logger.error('node %s has non-destroyable prefix' % node.name) return False logger.info('destroying node %s' % node) return node.destroy()
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement not_operator call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argume...
Insure only destroyable nodes are destroyed
def list_types(self): uri = "/notification_types" resp, resp_body = self.api.method_get(uri) return [CloudMonitorNotificationType(self, info) for info in resp_body["values"]]
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier return_statemen...
Returns a list of all available notification types.
def _get_float(data, position, dummy0, dummy1, dummy2): end = position + 8 return _UNPACK_FLOAT(data[position:end])[0], end
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier binary_operator identifier integer return_statement expression_list subscript call identifier argument_list subscript identifier slice identifier identifier integer id...
Decode a BSON double to python float.
def _start_container(self, container, tool_d, s_containers, f_containers): section = tool_d[container]['section'] del tool_d[container]['section'] manifest = Template(self.manifest) try: c = self.d_client.containers.get(container) c.start() s_container...
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier subscript subscript identifier identifier string string_start string_content string_end delete_statement subscript subscript identifier identifier string string_start ...
Start container that was passed in and return status
def _active_mounts_openbsd(ret): for line in __salt__['cmd.run_stdout']('mount -v').split('\n'): comps = re.sub(r"\s+", " ", line).split() parens = re.findall(r'\((.*?)\)', line, re.DOTALL) if len(parens) > 1: nod = __salt__['cmd.run_stdout']('ls -l {0}'.format(comps[0])) ...
module function_definition identifier parameters identifier block for_statement identifier call attribute call subscript identifier string string_start string_content string_end argument_list string string_start string_content string_end identifier argument_list string string_start string_content escape_sequence string...
List active mounts on OpenBSD systems
def must_stop(self): return bool(self.terminate_gracefuly and self.end_signal_caught or self.num_loops >= self.max_loops or self.end_forced or self.wanted_end_date and datetime.utcnow() >= self.wanted_end_date)
module function_definition identifier parameters identifier block return_statement call identifier argument_list boolean_operator boolean_operator boolean_operator boolean_operator attribute identifier identifier attribute identifier identifier comparison_operator attribute identifier identifier attribute identifier id...
Return True if the worker must stop when the current loop is over.
def compare_digest(a, b): py_version = sys.version_info[0] if py_version >= 3: return _compare_digest_py3(a, b) return _compare_digest_py2(a, b)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier integer if_statement comparison_operator identifier integer block return_statement call identifier argument_list identifier identifier return_statement call i...
Compare 2 hash digest.
def generate(env): global PDFLaTeXAction if PDFLaTeXAction is None: PDFLaTeXAction = SCons.Action.Action('$PDFLATEXCOM', '$PDFLATEXCOMSTR') global PDFLaTeXAuxAction if PDFLaTeXAuxAction is None: PDFLaTeXAuxAction = SCons.Action.Action(PDFLaTeXAuxFunction, st...
module function_definition identifier parameters identifier block global_statement identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string str...
Add Builders and construction variables for pdflatex to an Environment.
def bar3d(h2: Histogram2D, ax: Axes3D, **kwargs): density = kwargs.pop("density", False) data = get_data(h2, cumulative=False, flatten=True, density=density) if "cmap" in kwargs: cmap = _get_cmap(kwargs) _, cmap_data = _get_cmap_data(data, kwargs) colors = cmap(cmap_data) else: ...
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end fal...
Plot of 2D histograms as 3D boxes.
def root_urns_for_deletion(self): roots = set() for urn in self._urns_for_deletion: new_root = True str_urn = utils.SmartUnicode(urn) fake_roots = [] for root in roots: str_root = utils.SmartUnicode(root) if str_urn.startswith(str_root): new_root = False ...
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier attribute identifier identifier block expression_statement assignment identifier true expression_statement assignment identifier call attribute identifier i...
Roots of the graph of urns marked for deletion.
def _load_ssh(self, tag): for child in tag: if child.tag == "server": self._vardict["server"] = child.attrib elif child.tag == "codes": self._load_codes(child, True) elif child.tag == "mappings": self._load_mapping(child, True) ...
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment subscript attribute identifier identifier string str...
Loads the SSH configuration into the vardict.
def request(self, method, url, **kwargs): if not url.startswith('https'): url = '{}{}'.format(self.args.tc_api_path, url) return super(TcExSession, self).request(method, url, **kwargs)
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute string st...
Override request method disabling verify on token renewal if disabled on session.
def compose(func_list): def f(G, bim): for func in func_list: G, bim = func(G, bim) return G, bim return f
module function_definition identifier parameters identifier block function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier return_statement expres...
composion of preprocessing functions
def user_can_add_attachments(self): if not self.global_attachments_allowed(): return False context = self.context pm = api.get_tool("portal_membership") return pm.checkPermission(AddAttachment, context)
module function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list block return_statement false expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier iden...
Checks if the current logged in user is allowed to add attachments
def backlink(node): seen = set() to_see = [node] while to_see: node = to_see.pop() seen.add(node) for succ in node.next: succ.prev.add(node) if succ not in seen: to_see.append(succ)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier list identifier while_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_...
Given a CFG with outgoing links, create incoming links.
def attr(aid): def _attr(ctx): return ctx.current_link[ATTRIBUTES].get(aid) return _attr
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block return_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier return_statement identifier
Action function generator to retrieve an attribute from the current link
def log_all(self, file): global rflink_log if file == None: rflink_log = None else: log.debug('logging to: %s', file) rflink_log = open(file, 'a')
module function_definition identifier parameters identifier identifier block global_statement identifier if_statement comparison_operator identifier none block expression_statement assignment identifier none else_clause block expression_statement call attribute identifier identifier argument_list string string_start st...
Log all data received from RFLink to file.
def access_list(**kwargs): ctx = Context(**kwargs) ctx.execute_action('access:list', **{ 'unicorn': ctx.repo.create_secure_service('unicorn'), })
module function_definition identifier parameters dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list dictionary_splat identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end dictionary...
Shows services for which there are ACL specified.
def fix_e271(self, result): line_index = result['line'] - 1 target = self.source[line_index] offset = result['column'] - 1 fixed = fix_whitespace(target, offset=offset, replacement=' ') if fixed == target: ...
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator subscript identifier string string_start string_content string_end integer expression_statement assignment identifier subscript attribute identifier identifier identifier expression_st...
Fix extraneous whitespace around keywords.
def bytes_needed(self): if self.native: ret = self.native.expected_length - self.buf_len() else: ret = self.expected_length - self.buf_len() if ret <= 0: return 1 return ret
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier binary_operator attribute attribute identifier identifier identifier call attribute identifier identifier argument_list else_clause block expression_statement a...
return number of bytes needed for next parsing stage
def _installed_snpeff_genome(base_name, config): snpeff_config_file = os.path.join(config_utils.get_program("snpeff", config, "dir"), "snpEff.config") if os.path.exists(snpeff_config_file): data_dir = _find_snpeff_datadir(snpeff_config_file) dbs = [d for d i...
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier string string_start ...
Find the most recent installed genome for snpEff with the given name.
def keys(self): keys = ttk.Label.keys(self) keys.extend(["link", "normal_color", "hover_color", "clicked_color"]) return keys
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end strin...
Return a list of all resource names of this widget.
def Validate(self): ValidateMultiple(self.probe, "Method has invalid probes") Validate(self.target, "Method has invalid target") Validate(self.hint, "Method has invalid hint")
module function_definition identifier parameters identifier block expression_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier string string_start string_content string_...
Check the Method is well constructed.
def resumable(self): jids = self.client.workers[self.client.worker_name]['jobs'] jobs = self.client.jobs.get(*jids) queue_names = set([queue.name for queue in self.queues]) return [job for job in jobs if job.queue_name in queue_names]
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript subscript attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identif...
Find all the jobs that we'd previously been working on
def dl_cub(cub_url, cub_archive_name): with open(cub_archive_name, 'wb') as f: remote_file = urllib2.urlopen(cub_url) meta = remote_file.info() cl_header = meta.getheaders("Content-Length") remote_file_size = int(cl_header[0]) if len(cl_header) > 0 else None local_file_size =...
module function_definition identifier parameters identifier 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 assignment identifier call attribute identifier iden...
Download cub archive from cub_url and store it in cub_archive_name
def generate_vector_color_map(self): vector_stops = [] if type(self.data) == str: self.data = geojson_to_dict_list(self.data) for row in self.data: color = color_map(row[self.color_property], self.color_stops, self.color_default) vector_stops.append([row[self....
module function_definition identifier parameters identifier block expression_statement assignment identifier list if_statement comparison_operator call identifier argument_list attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list ...
Generate color stops array for use with match expression in mapbox template
def can_use_cached_output(self, contentitem): return contentitem.plugin.search_output and not contentitem.plugin.search_fields \ and super(SearchRenderingPipe, self).can_use_cached_output(contentitem)
module function_definition identifier parameters identifier identifier block return_statement boolean_operator boolean_operator attribute attribute identifier identifier identifier not_operator attribute attribute identifier identifier identifier line_continuation call attribute call identifier argument_list identifier...
Read the cached output - only when search needs it.
def using_ios_stash(): print('detected install path:') print(os.path.dirname(__file__)) module_names = set(sys.modules.keys()) return 'stash' in module_names or 'stash.system' in module_names
module function_definition identifier parameters block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment id...
returns true if sys path hints the install is running on ios
def change_channel_group(self, group): assert self._probe is not None self._channels = _probe_channels(self._probe, group) self._positions = _probe_positions(self._probe, group)
module function_definition identifier parameters identifier identifier block assert_statement comparison_operator attribute identifier identifier none expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier identifier expression_statement assignment ...
Change the current channel group.
def retryable_writes_supported(self): return ( self._ls_timeout_minutes is not None and self._server_type in (SERVER_TYPE.Mongos, SERVER_TYPE.RSPrimary))
module function_definition identifier parameters identifier block return_statement parenthesized_expression boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier tuple attribute identifier identifier attribute identifier identifier
Checks if this server supports retryable writes.
def _get_context_id(self): from furious.context import get_current_context context_id = self._options.get('context_id') if context_id: return context_id try: context = get_current_context() except errors.NotInContextError: context = None ...
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement i...
If this async is in a context set the context id.
def _prepare_app(self, app): for key in ['url', 'html', 'script', 'implies']: try: value = app[key] except KeyError: app[key] = [] else: if not isinstance(value, list): app[key] = [value] for key in [...
module function_definition identifier parameters identifier identifier block for_statement identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block try_statement block exp...
Normalize app data, preparing it for the detection phase.
def register_directory(self, dirpath, **kwargs): kwargs['file_extensions'] = kwargs.get("file_extensions", self.rdf_formats) files = list_files(file_directory=dirpath, **kwargs) for fileinfo in files: self.register_rml(fileinfo[-1], **kw...
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end attribute i...
Registers all of the files in the the directory path
def start_block(self,stylestack=None): if self.dirty: self.escpos._raw('\n') self.dirty = False self.stack.append('block') if stylestack: self.style(stylestack)
module function_definition identifier parameters identifier default_parameter identifier none block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end expression_sta...
starts a block entity with an optional style definition
def infer_endpoint(rule_payload): bucket = (rule_payload if isinstance(rule_payload, dict) else json.loads(rule_payload)).get("bucket") return "counts" if bucket else "search"
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute parenthesized_expression conditional_expression identifier call identifier argument_list identifier identifier call attribute identifier identifier argument_list identifier identifier argument_lis...
Infer which endpoint should be used for a given rule payload.
def parse(self, node): self._attrs = {} vals = [] yielded = False for x in self._read_parts(node): if isinstance(x, Field): yielded = True x.attrs = self._attrs yield x else: vals.append(ustr(x).strip...
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier dictionary expression_statement assignment identifier list expression_statement assignment identifier false for_statement identifier call attribute identifier identifier argument_...
Return generator yielding Field objects for a given node
def permissions(self, **kwargs): self._validate_loaded() return TailoredAudiencePermission.all(self.account, self.id, **kwargs)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier dictionary_spl...
Returns a collection of permissions for the curent tailored audience.
def _validate_nodes_with_data(self, names): names = names if isinstance(names, list) else [names] if not names: raise RuntimeError("Argument `nodes` is not valid") for ndict in names: if (not isinstance(ndict, dict)) or ( isinstance(ndict, dict) and (set(n...
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier conditional_expression identifier call identifier argument_list identifier identifier list identifier if_statement not_operator identifier block raise_statement call identifier argument_list string st...
Validate NodeWithData pseudo-type.
def _collect_names(handlers, scopes, user, client): results = set() data = {'user': user, 'client': client} def visitor(_scope_name, func): claim_names = func(data) if claim_names is not None: results.update(claim_names) _visit_handlers(handlers, visitor, 'scope', scopes) ...
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_...
Get the names of the claims supported by the handlers for the requested scope.
def changelog_cli(ctx): if ctx.invoked_subcommand: return from peltak.core import shell from . import logic shell.cprint(logic.changelog())
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement import_from_statement dotted_name identifier identifier dotted_name identifier import_from_statement relative_import import_prefix dotted_name identifier expression_statement call attrib...
Generate changelog from commit messages.
def hilite(s, ok=True, bold=False): if not term_supports_colors(): return s attr = [] if ok is None: pass elif ok: attr.append('32') else: attr.append('31') if bold: attr.append('1') return '\x1b[%sm%s\x1b[0m' % (';'.join(attr), s)
module function_definition identifier parameters identifier default_parameter identifier true default_parameter identifier false block if_statement not_operator call identifier argument_list block return_statement identifier expression_statement assignment identifier list if_statement comparison_operator identifier non...
Return an highlighted version of 'string'.
def _make_color_fn(color): def _color(text = ""): return (_color_sep + color + _color_sep2 + text + _color_sep + "default" + _color_sep2) return _color
module function_definition identifier parameters identifier block function_definition identifier parameters default_parameter identifier string string_start string_end block return_statement parenthesized_expression binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator identifi...
Create a function that set the foreground color.
def list(self, wg_uuid, parent=None, flat=False, node_types=None): url = "%(base)s/%(wg_uuid)s/nodes" % { 'base': self.local_base_url, 'wg_uuid': wg_uuid } param = [] if parent: if isinstance(parent, (list,)): if len(parent) >= 1: ...
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier false default_parameter identifier none block expression_statement assignment identifier binary_operator string string_start string_content string_end dictionary pair string string_start...
Get a list of workgroup nodes.
def _error(self, message, start, end=None): raise errors.EfilterParseError( source=self.source, start=start, end=end, message=message)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block raise_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier iden...
Raise a nice error, with the token highlighted.
def _load_get_attr(self, name): 'Return an internal attribute after ensuring the headers is loaded if necessary.' if self._mode in _allowed_read and self._N is None: self._read_header() return getattr(self, name)
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end if_statement boolean_operator comparison_operator attribute identifier identifier identifier comparison_operator attribute identifier identifier none block expression_statement...
Return an internal attribute after ensuring the headers is loaded if necessary.
def _find_chain_name(self, mac): ipt_cmd = ['iptables', '-t', 'filter', '-S'] cmdo = dsl.execute(ipt_cmd, root_helper=self._root_helper, log_output=False) for o in cmdo.split('\n'): if mac in o.lower(): chain = o.split()[1] L...
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_...
Find a rule associated with a given mac.
def write(name, keyword, domain, citation, author, description, species, version, contact, licenses, values, functions, output, value_prefix): write_namespace( name, keyword, domain, author, citation, values, namespace_description=description, namespace_species=species, nam...
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier block expression_statement call identifier argument_list identifier identifier identifier identifier identifier ident...
Build a namespace from items.
def smsTextMode(self, textMode): if textMode != self._smsTextMode: if self.alive: self.write('AT+CMGF={0}'.format(1 if textMode else 0)) self._smsTextMode = textMode self._compileSmsRegexes()
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start str...
Set to True for the modem to use text mode for SMS, or False for it to use PDU mode
def low(self, fun, low): l_fun = getattr(self, fun) f_call = salt.utils.args.format_call(l_fun, low) return l_fun(*f_call.get('args', ()), **f_call.get('kwargs', {}))
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list i...
Pass the cloud function and low data structure to run
def probe_git(): try: repo = git.Repo() except git.InvalidGitRepositoryError: LOGGER.warning( "We highly recommend keeping your model in a git repository." " It allows you to track changes and to easily collaborate with" " others via online platforms such as h...
module function_definition identifier parameters block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string ...
Return a git repository instance if it exists.
def id(self): id = self.element.attrib[GML_NS + 'id'] code = id.split('-')[-1] return code
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier binary_operator identifier string string_start string_content string_end expression_statement assignment identifier subscript call attribute identif...
The EPSG code for this CRS.
def delete_role_perm(role_id, perm_id,**kwargs): _get_perm(perm_id) _get_role(role_id) try: roleperm_i = db.DBSession.query(RolePerm).filter(RolePerm.role_id==role_id, RolePerm.perm_id==perm_id).one() db.DBSession.delete(roleperm_i) except NoResultFound: raise ResourceNotFoundErr...
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier try_statement block expression_statement assignment identifier call attribute call ...
Remove a permission from a role
def add_toc_entry(self, title, level, slide_number): self.__toc.append({'title': title, 'number': slide_number, 'level': level})
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end iden...
Adds a new entry to current presentation Table of Contents.
def state_length(state, size): if len(state) != size: raise ValueError('Invalid state: there must be one entry per ' 'node in the network; this state has {} entries, but ' 'there are {} nodes.'.format(len(state), size)) return True
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start strin...
Check that the state is the given size.
def Ctt_(self): self._check_estimated() return self._rc.cov_YY(bessel=self.bessel)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier
Covariance matrix of the time shifted data
def error(*args): if sys.stdin.isatty(): print('ERROR:', *args, file=sys.stderr) else: notify_error(*args)
module function_definition identifier parameters list_splat_pattern identifier block if_statement call attribute attribute identifier identifier identifier argument_list block expression_statement call identifier argument_list string string_start string_content string_end list_splat identifier keyword_argument identifi...
Display error message via stderr or GUI.
def benchmark_mitdb_record(rec, detector, verbose): sig, fields = rdsamp(rec, pb_dir='mitdb', channels=[0]) ann_ref = rdann(rec, pb_dir='mitdb', extension='atr') qrs_inds = detector(sig=sig[:,0], fs=fields['fs'], verbose=verbose) comparitor = compare_annotations(ref_sample=ann_ref.sample[1:], ...
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier list integer expressio...
Benchmark a single mitdb record
def list_roles(): for role in lib.get_roles(): margin_left = lib.get_margin(len(role['fullname'])) print("{0}{1}{2}".format( role['fullname'], margin_left, role.get('description', '(no description)')))
module function_definition identifier parameters block for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list subscript identifier string string_start string_content str...
Show a list of all available roles
def get(self, *args, **kwargs): payload = self.buf.get(*args, **kwargs) logger.debug("Removing RPC payload from ControlBuffer queue: %s", payload) return payload
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list list_splat identifier dictionary_splat identifier expression_statement ca...
Call from main thread.
def push_bus(self, tokens): logger.debug("Pushing bus data: %s" % tokens) bus = Bus() bus.name = tokens["bus_no"] bus.v_magnitude = tokens["v_magnitude"] bus.v_angle = tokens["v_angle"] bus.v_magnitude = tokens["v_magnitude"] bus.v_angle = tokens["v_angle"] ...
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list expression_statement assi...
Adds a Bus object to the case.
def create_payload(self): payload = super(OverrideValue, self).create_payload() if hasattr(self, 'smart_class_parameter'): del payload['smart_class_parameter_id'] if hasattr(self, 'smart_variable'): del payload['smart_variable_id'] return payload
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list if_statement call identifier argument_list identifier string string_start string_content string_end block delete_statem...
Remove ``smart_class_parameter_id`` or ``smart_variable_id``
def addFile(self, path, msg=""): item = Item.from_path(repo=self.repo, path=path) self.addItem(item)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_end block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier i...
Adds a file to the version
def getbranchcomponents(idf, branch, utest=False): fobjtype = 'Component_%s_Object_Type' fobjname = 'Component_%s_Name' complist = [] for i in range(1, 100000): try: objtype = branch[fobjtype % (i,)] if objtype.strip() == '': break objname = br...
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignmen...
get the components of the branch
def ensure_bytes(str_or_bytes, encoding='utf-8', errors='strict'): if isinstance(str_or_bytes, six.text_type): return str_or_bytes.encode(encoding, errors) return str_or_bytes
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block if_statement call identifier argument_list identifier attribute identifier identifier block return_state...
Ensures an input is bytes, encoding if it is a string.
def register_view(self, view, timestamp): if len(self.exporters) > 0: try: for e in self.exporters: e.on_register_view(view) except AttributeError: pass self._exported_views = None existing_view = self._registered_views....
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block try_statement block for_statement identifier attribute identifier identifier block expression_statement call attribute iden...
registers the view's measure name to View Datas given a view
def isubsample(full_sample, k, full_sample_len=None): if not full_sample_len: full_sample_len = len(full_sample) if not 0 <= k <= full_sample_len: raise ValueError('Required that 0 <= k <= full_sample_length') picked = 0 for i, element in enumerate(full_sample): prob = (k-picked) / (full...
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator comparison_operator integer identifier identifier block ...
Down-sample an enumerable list of things
def flatten_list(l): return list(chain.from_iterable(repeat(x,1) if isinstance(x,str) else x for x in l))
module function_definition identifier parameters identifier block return_statement call identifier argument_list call attribute identifier identifier generator_expression conditional_expression call identifier argument_list identifier integer call identifier argument_list identifier identifier identifier for_in_clause ...
Nested lists to single-level list, does not split strings
def remove_accounts_from_group(accounts_query, group): query = accounts_query.filter(date_deleted__isnull=True) for account in query: remove_account_from_group(account, group)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier true for_statement identifier identifier block expression_statement call identifier argument_list identifier identifier
Remove accounts from group.
def cli(env, columns, sortby, volume_id): file_storage_manager = SoftLayer.FileStorageManager(env.client) legal_centers = file_storage_manager.get_replication_locations( volume_id ) if not legal_centers: click.echo("No data centers compatible for replication.") else: table = ...
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list i...
List suitable replication datacenters for the given volume.
def _apply_data(self, f, ts, reverse=False): if isinstance(ts, (int, float)): d = ts * np.ones(self.shape[0]) elif ts is None: d = None elif np.array_equal(ts.index, self.index): d = ts.values else: d = ts._retime(self.index) if not...
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block if_statement call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier binary_operator identifier call attribute identifier identifier ar...
Convenience function for all of the math stuff.
def _sorted_actions(self): for a in filter(lambda _: not _.last and \ not self.is_action(_, 'parsers'), self._actions): yield a for a in filter(lambda _: _.last and \ not self.is_action(_, 'parsers'), self._actions): yield a ...
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list lambda lambda_parameters identifier boolean_operator not_operator attribute identifier identifier line_continuation not_operator call attribute identifier identifier argument_list identifier string s...
Generate the sorted list of actions based on the "last" attribute.
def plot_and_save(self, data, w=800, h=420, filename='chart', overwrite=True): self.save(data, filename, overwrite) return IFrame(filename + '.html', w, h)
module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier integer default_parameter identifier string string_start string_content string_end default_parameter identifier true block expression_statement call attribute identifier identifier ar...
Save the rendered html to a file and returns an IFrame to display the plot in the notebook.
def parse(self, func, *args, **kwargs): result = [] for element in self.xpath('child::node()'): if isinstance(element, Parser): children = element.parse(func, *args, **kwargs) element_result = func(element, children, *args, **kwargs) if element...
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block i...
Parse element with given function
def insertCallSet(self, callSet): try: models.Callset.create( id=callSet.getId(), name=callSet.getLocalId(), variantsetid=callSet.getParentContainer().getId(), biosampleid=callSet.getBiosampleId(), attributes=json.dumps(...
module function_definition identifier parameters identifier identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier call attribute identifi...
Inserts a the specified callSet into this repository.
def removeUrl(self, url): root = self.etree t_urls = root.find('urls') if not t_urls: return False for t_url in t_urls.findall('url'): if t_url.text == url.strip(): t_urls.remove(t_url) if url in self.urls: self....
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator id...
Remove passed url from a binder