code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def terminal_type(cls): what = sys.platform kind = 'UNDEFINED_TERMINAL_TYPE' if 'linux' in what: kind = 'linux' elif 'darwin' in what: kind = 'darwin' elif 'cygwin' in what: kind = 'cygwin' elif 'windows' in what: kind = 'wi...
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier ...
returns darwin, cygwin, cmd, or linux
def pandoc(args, filein=None, fileout=None): cmd = [u'pandoc'] if filein: cmd.append(filein) if fileout: cmd.append('-o') cmd.append(fileout) cmd.extend(args.split()) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) out, err = proc.communicate() if proc.returncode...
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier list string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argu...
Execute pandoc with the given arguments
def load_mode_builder(obs_mode, node): nval1 = node.get('builder') if nval1 is not None: if isinstance(nval1, str): newmethod = import_object(nval1) obs_mode.build_ob = newmethod.__get__(obs_mode) else: raise TypeError('builder must be None or a string') e...
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block if_statement call identifier argument_list ident...
Load observing mode OB builder
def _init_flds_cur(self): flds = [] flds0 = ['GO', 'NS', 'enrichment', self.pval_fld, 'dcnt', 'tinfo', 'depth', 'ratio_in_study', 'ratio_in_pop', 'name'] flds_p = [f for f in self.flds_all if f[:2] == 'p_' and f != self.pval_fld] flds.extend(flds0) if flds_p: ...
module function_definition identifier parameters identifier block expression_statement assignment identifier list 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 attribute identifier...
Choose fields to print from a multitude of available fields.
def ms_rotate(self, viewer, event, data_x, data_y, msg=True): if not self.canrotate: return True msg = self.settings.get('msg_rotate', msg) x, y = self.get_win_xy(viewer) if event.state == 'move': self._rotate_xy(viewer, x, y) elif event.state == 'down': ...
module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier true block if_statement not_operator attribute identifier identifier block return_statement true expression_statement assignment identifier call attribute attribute identifier identifier ...
Rotate the image by dragging the cursor left or right.
def validate_relation_data(self, sentry_unit, relation, expected): actual = sentry_unit.relation(relation[0], relation[1]) return self._validate_dict_data(expected, actual)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier integer subscript identifier integer return_statement call attribute identifier identifier argument_list i...
Validate actual relation data based on expected relation data.
def _assemble_regulate_activity(stmt): subj_str = _assemble_agent_str(stmt.subj) obj_str = _assemble_agent_str(stmt.obj) if stmt.is_activation: rel_str = ' activates ' else: rel_str = ' inhibits ' stmt_str = subj_str + rel_str + obj_str return _make_sentence(stmt_str)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement attribute identifier identifier...
Assemble RegulateActivity statements into text.
def delete_node_1ton(node_list, begin, node, end): if end is None: assert end is not None end = node.successor elif not isinstance(end, list): end = [end] if any(e_.in_or_out for e_ in end): begin.out_redirect(node.single_input, node.single_output)...
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator identifier none block assert_statement comparison_operator identifier none expression_statement assignment identifier attribute identifier identifier elif_clause not_operator call identifi...
delete the node which has 1-input and n-output
def _reuse_pre_installed_setuptools(env, installer): if not env.setuptools_version: return reuse_old = config.reuse_old_setuptools reuse_best = config.reuse_best_setuptools reuse_future = config.reuse_future_setuptools reuse_comment = None if reuse_old or reuse_best or reuse_future...
module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block return_statement expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_s...
Return whether a pre-installed setuptools distribution should be reused.
def update_docs(self, iface, module): key = "{}.{}".format(module.name, iface.name) if key in module.predocs: iface.docstring = self.docparser.to_doc(module.predocs[key][0], iface.name) iface.docstart, iface.docend = (module.predocs[key][1], module.predocs[key][2])
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier if_statement comparison_operator identi...
Updates the documentation for the specified interface using the module predocs.
def remove_router_from_hosting_device(self, client, hosting_device_id, router_id): res_path = hostingdevice.HostingDevice.resource_path return client.delete((res_path + DEVICE_L3_ROUTERS + "/%s") % ( hosting_device_id, router_id))
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier return_statement call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator ...
Remove a router from hosting_device.
def interrupt(self): if(self.device.read(9) & 0x01): self.handle_request() self.device.clear_IR()
module function_definition identifier parameters identifier block if_statement parenthesized_expression binary_operator call attribute attribute identifier identifier identifier argument_list integer integer block expression_statement call attribute identifier identifier argument_list expression_statement call attribut...
Invoked on a write operation into the IR of the RendererDevice.
def _start_server(self, *args): self.log("Starting server", args) secure = self.certificate is not None if secure: self.log("Running SSL server with cert:", self.certificate) else: self.log("Running insecure server without SSL. Do not use without SSL proxy in prod...
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier comparison_operator attribute identifier identifier ...
Run the node local server
def matches(target, entry): for t, e in itertools.zip_longest(target, entry): if e and t != e: return False return entry[0] and entry[1]
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier block if_statement boolean_operator identifier comparison_operator identifier identifier block return_statement false ret...
Does the target match the whitelist entry?
def _ExtractHuntIdFromPath(entry, event): match = re.match(r".*hunt/([^/]+).*", entry.http_request_path) if match: event.urn = "aff4:/hunts/{}".format(match.group(1))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier if_statement identifier block expression_statement assignment attribute...
Extracts a Hunt ID from an APIAuditEntry's HTTP request path.
def delete_url(self, url): for decompress in [False, True]: key = (url, decompress) if key in self._local_paths: path = self._local_paths[key] remove(path) del self._local_paths[key] path = self.local_path( url, ...
module function_definition identifier parameters identifier identifier block for_statement identifier list false true block expression_statement assignment identifier tuple identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier ...
Delete local files downloaded from given URL
def create(cls, bucket, key, value): with db.session.begin_nested(): obj = cls( bucket_id=as_bucket_id(bucket), key=key, value=value ) db.session.add(obj) return obj
module function_definition identifier parameters identifier identifier identifier identifier block with_statement with_clause with_item call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list keyword_argument identifier call ...
Create a new tag for bucket.
def render_field_previews(self, id_and_obj_list, admin, request, field_name): obj_preview_list = [] for obj_id, obj in id_and_obj_list: try: if obj is None: obj_preview = self.render_field_error( obj_id, obj, None, request ...
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier identifier block try_statement block if_statement comparison_operator identifier none block expression_statement ...
Override this to customise the preview representation of all objects.
def cl_mutect(self, params, tmp_dir): gatk_jar = self._get_jar("muTect", ["mutect"]) jvm_opts = config_utils.adjust_opts(self._jvm_opts, {"algorithm": {"memory_adjust": {"magnitude": 1.1, "direction": ...
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list string string_start string_content string_end expression_statement assignment identifie...
Define parameters to run the mutect paired algorithm.
def _find_stages(self): stages = [] end = last_user_found = None for part in reversed(self.dfp.structure): if end is None: end = part if part['instruction'] == 'USER' and not last_user_found: last_user_found = part['content'] if...
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier assignment identifier none for_statement identifier call identifier argument_list attribute attribute identifier identifier identifier block if_statement compariso...
Find limits of each Dockerfile stage
def flush(self): if not self._emit_partial and len(self._state) != self._state.maxlen: self.notify(tuple(self._state)) self._state.clear()
module function_definition identifier parameters identifier block if_statement boolean_operator not_operator attribute identifier identifier comparison_operator call identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier block expression_statement call attribute id...
Flush the queue - this will emit the current queue
def _cron_id(cron): cid = None if cron['identifier']: cid = cron['identifier'] else: cid = SALT_CRON_NO_IDENTIFIER if cid: return _ensure_string(cid)
module function_definition identifier parameters identifier block expression_statement assignment identifier none if_statement subscript identifier string string_start string_content string_end block expression_statement assignment identifier subscript identifier string string_start string_content string_end else_claus...
SAFETYBELT, Only set if we really have an identifier
def _store_credentials(self, username, password, remember=False): if username and password and remember: CONF.set('main', 'report_error/username', username) try: keyring.set_password('github', username, password) except Exception: if self._show...
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block if_statement boolean_operator boolean_operator identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content stri...
Store credentials for future use.
def _parse_tag(self, name): from_ = self._get_from(b'tag') tagger = self._get_user_info(b'tag', b'tagger', accept_just_who=True) message = self._get_data(b'tag', b'message') return commands.TagCommand(name, from_, tagger, message)
module function_definition identifier parameters identifier 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 st...
Parse a tag command.
def sequences_from_fasta(path): from Bio import SeqIO return {x.description: x.seq for x in SeqIO.parse(path, 'fasta')}
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier dotted_name identifier return_statement dictionary_comprehension pair attribute identifier identifier attribute identifier identifier for_in_clause identifier call attribute identifier identifier argument_list...
Extract multiple sequences from a FASTA file.
def headers_as_dict(cls, resp): if six.PY2: pairs = [header.split(':', 1) for header in resp.msg.headers] return dict([(k, v.strip()) for k, v in pairs]) else: return dict([(k, v.strip()) for k, v in resp.msg._headers])
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list string string_start string_content string_end integer for_in_clause identifier ...
Turns an array of response headers into a dictionary
def can_undo(self): return bool(self._undo) or bool(self._open and self._open[0])
module function_definition identifier parameters identifier block return_statement boolean_operator call identifier argument_list attribute identifier identifier call identifier argument_list boolean_operator attribute identifier identifier subscript attribute identifier identifier integer
Are there actions to undo?
def cached(size): def decorator(func): cached_func = _Cached(func, size) return lambda *a, **kw: cached_func(*a, **kw) return decorator
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier identifier return_statement lambda lambda_parameters list_splat_pattern identifier dictionary_splat_pattern ide...
A caching decorator based on parameter objects
def _align_mem(fastq_file, pair_file, ref_file, out_file, names, rg_info, data): with postalign.tobam_cl(data, out_file, pair_file != "") as (tobam_cl, tx_out_file): cmd = ("unset JAVA_HOME && " "%s | %s" % (_get_bwa_mem_cmd(data, out_file, ref_file, fastq_file, pair_file), tobam_cl)) ...
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier identifier comparison_operator identifier string string_start string_end as_pa...
Perform bwa-mem alignment on supported read lengths.
def __catalina_home(): locations = ['/usr/share/tomcat*', '/opt/tomcat'] for location in locations: folders = glob.glob(location) if folders: for catalina_home in folders: if os.path.isdir(catalina_home + "/bin"): return catalina_home return Fa...
module function_definition identifier parameters block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier arg...
Tomcat paths differ depending on packaging
def short_repr(item, max_length=15): item = repr(item) if len(item) > max_length: item = '{}...{}'.format(item[:max_length - 3], item[-1]) return item
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier...
Short representation of item if it is too long
def filter_string(n: Node, query: str) -> str: return _scalariter2item(n, query, str)
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block return_statement call identifier argument_list identifier identifier identifier
Filter and ensure that the returned value is of string type.
def update_contributions(sender, instance, action, model, pk_set, **kwargs): if action != 'pre_add': return else: for author in model.objects.filter(pk__in=pk_set): update_content_contributions(instance, author)
module function_definition identifier parameters identifier identifier identifier identifier identifier dictionary_splat_pattern identifier block if_statement comparison_operator identifier string string_start string_content string_end block return_statement else_clause block for_statement identifier call attribute att...
Creates a contribution for each author added to an article.
def parse_access_token(self): access_file = os.path.join(self.file_path, 'access_token') if os.path.isfile(access_file): access_list = list() with open(access_file, 'r') as access_token: for line in access_token: value, data = line.split('=') ...
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end if_statement call attribute attribute identifier identifier i...
Extract the secret and token values from the access_token file
def prepare(self, ansi='', ensure_trailing_newline=False): body, styles = self.apply_regex(ansi) if ensure_trailing_newline and _needs_extra_newline(body): body += '\n' self._attrs = { 'dark_bg': self.dark_bg, 'line_wrap': self.line_wrap, 'font_siz...
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end default_parameter identifier false block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier if_statement boolean_operator ...
Load the contents of 'ansi' into this object
def flatten_unique(l: Iterable) -> List: rval = OrderedDict() for e in l: if not isinstance(e, str) and isinstance(e, Iterable): for ev in flatten_unique(e): rval[ev] = None else: rval[e] = None return list(rval.keys())
module function_definition identifier parameters typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block if_statement boolean_operator not_operator call identifier argument_list identifier identif...
Return a list of UNIQUE non-list items in l
def setLocation(self, x, y): self.x = int(x) self.y = int(y) return self
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier return_statement ident...
Set the location of this object to the specified coordinates.
def lastId(self) -> BaseReference: if self.childIds is not None: if len(self.childIds) > 0: return self.childIds[-1] return None else: raise NotImplementedError
module function_definition identifier parameters identifier type identifier block if_statement comparison_operator attribute identifier identifier none block if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block return_statement subscript attribute identifier ident...
Last child's id of current TextualNode
def FileHacks(self): if sys.platform == "win32": import win32api if self.path == "/": self.files = win32api.GetLogicalDriveStrings().split("\x00") self.files = [drive.rstrip("\\") for drive in self.files if drive] elif re.match(r"/*\\\\.\\[^\\]+\\?$", self.path) is not None: ...
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block import_statement dotted_name identifier if_statement comparison_operator attribute identifier identifier string string_start string_conte...
Hacks to make the filesystem look normal.
def extend(self, content, zorder): if zorder not in self._content: self._content[zorder] = [] self._content[zorder].extend(content)
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier list expression_statement call attribute subscript attribute iden...
Extends with a list and a z-order
def build_stop_ids(shape_id): return [cs.SEP.join(['stp', shape_id, str(i)]) for i in range(2)]
module function_definition identifier parameters identifier block return_statement list_comprehension call attribute attribute identifier identifier identifier argument_list list string string_start string_content string_end identifier call identifier argument_list identifier for_in_clause identifier call identifier ar...
Create a pair of stop IDs based on the given shape ID.
def build_specfile_sections(spec): str = "" mandatory_sections = { 'DESCRIPTION' : '\n%%description\n%s\n\n', } str = str + SimpleTagCompiler(mandatory_sections).compile( spec ) optional_sections = { 'DESCRIPTION_' : '%%description -l %s\n%s\n\n', 'CHANGELOG' : ...
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content escape_sequence escape_sequence escape_s...
Builds the sections of a rpm specfile.
def _pdist(p): index, ref, ampl, cutoff, beta = p[:5] if cutoff == 0.0: pdist = models.PowerLaw( ampl * 1e30 * u.Unit("1/eV"), ref * u.TeV, index ) else: pdist = models.ExponentialCutoffPowerLaw( ampl * 1e30 * u.Unit("1/eV"), ...
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier identifier identifier subscript identifier slice integer if_statement comparison_operator identifier float block expression_statement assignment identifier call attribute ident...
Return PL or ECPL instance based on parameters p
def connect_event_handlers(self): self.figure.canvas.mpl_connect('close_event', self.evt_release) self.figure.canvas.mpl_connect('pause_event', self.evt_toggle_pause)
module function_definition identifier parameters identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute attribute identi...
Connects event handlers to the figure.
def handle_profile_save(self, sender, instance, **kwargs): self.handle_save(instance.user.__class__, instance.user)
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier
Custom handler for user profile save
def scipy_sparse_to_spmatrix(A): coo = A.tocoo() SP = spmatrix(coo.data.tolist(), coo.row.tolist(), coo.col.tolist(), size=A.shape) return SP
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute ...
Efficient conversion from scipy sparse matrix to cvxopt sparse matrix
def _get_appoptics(options): conn = appoptics_metrics.connect( options.get('api_token'), sanitizer=appoptics_metrics.sanitize_metric_name, hostname=options.get('api_url')) log.info("Connected to appoptics.") return conn
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier key...
Return an appoptics connection object.
def _missing_imageinfo(self): if 'image' not in self.data: return missing = [] for img in self.data['image']: if 'url' not in img: missing.append(img['file']) return list(set(missing))
module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block return_statement expression_statement assignment identifier list for_statement identifier subscript attribute identifier identifier strin...
returns list of image filenames that are missing info
def strip_prompt_login(path): uri = urlsplit(path) query_params = parse_qs(uri.query) prompt_list = query_params.get('prompt', '')[0].split() if 'login' in prompt_list: prompt_list.remove('login') query_params['prompt'] = ' '.join(prompt_list) if not query_params['prompt']: d...
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute subscri...
Strips 'login' from the 'prompt' query parameter.
def generate_output_path(args, project_path): milisec = datetime.now().microsecond dirname = 'results_{}_{}'.format(time.strftime('%Y.%m.%d_%H.%M.%S', time.localtime()), str(milisec)) return os.path.join(project_path, 'results', dirname)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list...
Generate default output directory
def next(self, type=None): i = self.index + 1 s = self.sentence while i < len(s): if type in (s[i].type, None): return s[i] i += 1
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier binary_operator attribute identifier identifier integer expression_statement assignment identifier attribute identifier identifier while_statement comparison_operator identifier...
Returns the next word in the sentence with the given type.
def _check_import_source(): path_rel = '~/cltk_data/greek/software/greek_software_tlgu/tlgu.h' path = os.path.expanduser(path_rel) if not os.path.isfile(path): try: corpus_importer = CorpusImporter('greek') corpus_importer.import_corpus('greek_software...
module function_definition identifier parameters block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator call attribute attribute...
Check if tlgu imported, if not import it.
async def wait_for_election_success(cls): if cls.leader is None: cls.leader_future = asyncio.Future(loop=cls.loop) await cls.leader_future
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier exp...
Await this function if your cluster must have a leader
def _validate_required(self, attributes): required_fulfilled = set(self._required).issubset(set(attributes)) if not required_fulfilled: raise ValueError( "Not all required attributes fulfilled. Required: {required}".format(required=set(self._required)) )
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list attribute identifier identifier identifier argument_list call identifier argument_list identifier if_statement not_operator identifier block raise_statemen...
Ensure required attributes are present.
def refresh(self): if not self._client: return current_networks = self._client.networks() self.clear() self.update((net['Name'], net['Id']) for net in current_networks)
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier ...
Fetches all current network names from the client, along with their id.
def clicked(self, event): group = event.artist._mt_group n = event.artist._mt_n dt = num2date(event.artist._mt_bin) print("%4i %s events in %s sec beginning at %s" % (n, group, self.bucketsize, dt.strftime("%b %d %H:%M:%S")))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call ide...
Print group name and number of items in bin.
def __parse_affiliations_yml(self, affiliations): enrollments = [] for aff in affiliations: name = self.__encode(aff['organization']) if not name: error = "Empty organization name" msg = self.GRIMOIRELAB_INVALID_FORMAT % {'error': error} ...
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content str...
Parse identity's affiliations from a yaml dict.
def _decorate_axes(ax, freq, kwargs): if not hasattr(ax, '_plot_data'): ax._plot_data = [] ax.freq = freq xaxis = ax.get_xaxis() xaxis.freq = freq if not hasattr(ax, 'legendlabels'): ax.legendlabels = [kwargs.get('label', None)] else: ax.legendlabels.append(kwargs.get('la...
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier list expression_statement assignment attribute id...
Initialize axes for time-series plotting
def _get_name_map(saltenv='base'): u_name_map = {} name_map = get_repo_data(saltenv).get('name_map', {}) if not six.PY2: return name_map for k in name_map: u_name_map[k] = name_map[k] return u_name_map
module function_definition identifier parameters default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list string strin...
Return a reverse map of full pkg names to the names recognized by winrepo.
def bundlestate_to_str(state): states = { pelix.Bundle.INSTALLED: "INSTALLED", pelix.Bundle.ACTIVE: "ACTIVE", pelix.Bundle.RESOLVED: "RESOLVED", pelix.Bundle.STARTING: "STARTING", pelix.Bundle.STOPPING: "STOPPING", pelix.Bundle.UNINSTALLED:...
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair attribute attribute identifier identifier identifier string string_start string_content string_end pair attribute attribute identifier identifier identifier string string_start string_content str...
Converts a bundle state integer to a string
def layout(self, rect=None, width=0, height=0, fontsize=11): if self.isClosed or self.isEncrypted: raise ValueError("operation illegal for closed / encrypted doc") val = _fitz.Document_layout(self, rect, width, height, fontsize) self._reset_page_refs() self.initData() ...
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier integer default_parameter identifier integer default_parameter identifier integer block if_statement boolean_operator attribute identifier identifier attribute identifier identifier block raise_sta...
Re-layout a reflowable document.
def setter_generator(field_name): def set_translation_field(cls, value, language_code=None): setattr(cls.get_translation(language_code, True), field_name, value) set_translation_field.short_description = "set " + field_name return set_translation_field
module function_definition identifier parameters identifier block function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement call identifier argument_list call attribute identifier identifier argument_list identifier true identifier identifier expression...
Generate set_'field name' method for field field_name.
def convert_time(time): split_time = time.split() try: am_pm = split_time[1].replace('.', '') time_str = '{0} {1}'.format(split_time[0], am_pm) except IndexError: return time try: time_obj = datetime.strptime(time_str, '%I:%M %p') except ValueError: time_obj =...
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier call attribute subscript identifier integer identifier argument_list string string_start string_c...
Convert a time string into 24-hour time.
def api_walk(uri, per_page=100, key="login"): page = 1 result = [] while True: response = get_json(uri + "?page=%d&per_page=%d" % (page, per_page)) if len(response) == 0: break else: page += 1 for r in response: if key == USER_LOGIN...
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier integer expression_statement assignment identifier list while_statement true block expression_state...
For a GitHub URI, walk all the pages until there's no more content
def add_checkpoint_file(self, filename): if filename not in self.__checkpoint_files: self.__checkpoint_files.append(filename)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Add filename as a checkpoint file for this DAG job.
def complete(text, state): global completion_results if state == 0: line = readline.get_line_buffer() if line.startswith(':'): completion_results = complete_control_command(line, text) else: if line.startswith('!') and text and line.startswith(text): ...
module function_definition identifier parameters identifier identifier block global_statement identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call attribute identifier identifier argument_list...
On tab press, return the next possible completion
def handle_input(self, proxy, event_type, event, refcon): self.update_timeval() self.events = [] if event_type in (1, 2, 3, 4, 25, 26, 27): self.handle_button(event, event_type) if event_type == 22: self.handle_scrollwheel(event) self.handle_absolute(event...
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier list if_statement comparison_operator identifier tuple integer integer int...
Handle an input event.
def identify_pycbc_live(origin, filepath, fileobj, *args, **kwargs): if identify_hdf5(origin, filepath, fileobj, *args, **kwargs) and ( filepath is not None and PYCBC_FILENAME.match(basename(filepath))): return True return False
module function_definition identifier parameters identifier identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement boolean_operator call identifier argument_list identifier identifier identifier list_splat identifier dictionary_splat identifier parenthesized_expressio...
Identify a PyCBC Live file as an HDF5 with the correct name
def _parse_regr_response(self, response, uri=None, new_authzr_uri=None, terms_of_service=None): links = _parse_header_links(response) if u'terms-of-service' in links: terms_of_service = links[u'terms-of-service'][u'url'] if u'next' in links: n...
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator string string_start stri...
Parse a registration response from the server.
def string_to_sign(self): return (AWS4_HMAC_SHA256 + "\n" + self.request_timestamp + "\n" + self.credential_scope + "\n" + sha256(self.canonical_request.encode("utf-8")).hexdigest())
module function_definition identifier parameters identifier block return_statement parenthesized_expression binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator identifier string string_start string_content escape_sequence string_end attribute identifier identifier string stri...
The AWS SigV4 string being signed.
def _clean_cleaned_data(self): reference_node_id = 0 if '_ref_node_id' in self.cleaned_data: reference_node_id = self.cleaned_data['_ref_node_id'] del self.cleaned_data['_ref_node_id'] position_type = self.cleaned_data['_position'] del self.cleaned_data['_position...
module function_definition identifier parameters identifier block expression_statement assignment identifier integer if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier s...
delete auxilary fields not belonging to node model
def idf2txt(txt): astr = nocomment(txt) objs = astr.split(';') objs = [obj.split(',') for obj in objs] objs = [[line.strip() for line in obj] for obj in objs] objs = [[_tofloat(line) for line in obj] for obj in objs] objs = [tuple(obj) for obj in objs] objs.sort() lst = [] for obj in...
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignmen...
convert the idf text to a simple text
def pre_operations(self, mode=None): version_mode = self._get_version_mode(mode=mode) return version_mode.pre_operations
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier return_statement attribute identifier identifier
Return pre-operations only for the mode asked
def arg_int(name, default=None): try: v = request.args.get(name) return int(v) except (ValueError, TypeError): return default
module function_definition identifier parameters identifier default_parameter identifier none block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call identifier argument_list identifier except_clause tu...
Fetch a query argument, as an integer.
def kill_clients(): clients = request.form.get('clients').split(',') kill_dead = request.args.get('kill_dead', default=False) kill_dead = kill_dead and kill_dead in ['true', '1'] if not kill_dead and not clients: return jsonify({'Error': 'no clients provided'}) for client in list(drivers.key...
module function_definition identifier parameters block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_stateme...
Force kill driver and other objects for a perticular clien
def generate_additional_context(self, matching_datasets): top_tags = Tag.objects.filter( dataset__in=matching_datasets ).annotate( tag_count=Count('word') ).order_by('-tag_count')[:3] return { 'top_tags': top_tags }
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript call attribute call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier identifier argument_list keyword_argument identif...
Return top tags for a source.
def _request_toc_element(self, index): logger.debug('Requesting index %d on port %d', index, self.port) pk = CRTPPacket() if self._useV2: pk.set_header(self.port, TOC_CHANNEL) pk.data = (CMD_TOC_ITEM_V2, index & 0x0ff, (index >> 8) & 0x0ff) self.cf.send_packet...
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list if_statem...
Request information about a specific item in the TOC
def sys_mem_limit(self): if platform.machine() in ['armv7l']: _mem_limit = self.human_to_bytes('2700M') else: _mem_limit = self.human_to_bytes('4G') return _mem_limit
module function_definition identifier parameters identifier block if_statement comparison_operator call attribute identifier identifier argument_list list string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start...
Determine the default memory limit for the current service unit.
def close(self, filehandle): with self.lock: if filehandle in self.files: self.files[filehandle] -= 1 index = 0 size = len(self.past) while size > self.size and index < size: filehandle = self.past[index] ...
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item attribute identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement augmented_assignment subscript attribute identifier identifier id...
Close openend file if no longer used.
def _swaplch(LCH): "Reverse the order of an LCH numpy dstack or tuple for analysis." try: L,C,H = np.dsplit(LCH,3) return np.dstack((H,C,L)) except: L,C,H = LCH return H,C,L
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end try_statement block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier integer return_statement ca...
Reverse the order of an LCH numpy dstack or tuple for analysis.
def _pull_content_revision_parent(self): if self._revision_id is None: query_params = { "prop": "extracts|revisions", "explaintext": "", "rvprop": "ids", } query_params.update(self.__title_query_param()) request = se...
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start st...
combine the pulling of these three properties
def load_data(self, filename, *args, **kwargs): data = super(ParameterizedXLS, self).load_data(filename) parameter_name = self.parameterization['parameter']['name'] parameter_values = self.parameterization['parameter']['values'] parameter_units = str(self.parameterization['parameter']['u...
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list identifier expression_statement assignment...
Load parameterized data from different sheets.
def getContactByUsername(cls, username): pc = api.portal.get_tool("portal_catalog") contacts = pc(portal_type=cls.portal_type, getUsername=username) if len(contacts) == 0: return None if len(contacts) > 1: logger.error("User '{}' is bound to ...
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_a...
Convenience Classmethod which returns a Contact by a Username
def _get_entities(self, user, ids): queryset = get_objects_for_user(user, 'view_entity', Entity.objects.filter(id__in=ids)) actual_ids = queryset.values_list('id', flat=True) missing_ids = list(set(ids) - set(actual_ids)) if missing_ids: raise exceptions.ParseError( ...
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list keyword_argument identifier id...
Return entities queryset based on provided entity ids.
def clone(src, **kwargs): obj = object.__new__(type(src)) obj.__dict__.update(src.__dict__) obj.__dict__.update(kwargs) return obj
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argu...
Clones object with optionally overridden fields
def _is_allowed_command(self, command): cmds = self._meta_data['allowed_commands'] if command not in self._meta_data['allowed_commands']: error_message = "The command value {0} does not exist. " \ "Valid commands are {1}".format(command, cmds) raise In...
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end if_statement comparison_operator identifier subscript attribute identifier identifier string string_start string...
Checking if the given command is allowed on a given endpoint.
def add_new_devices_callback(self, callback): self._new_devices_callbacks.append(callback) _LOGGER.debug('Added new devices callback to %s', callback)
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Register as callback for when new devices are added.
def create_router(self, context, router): new_router = super(AristaL3ServicePlugin, self).create_router( context, router) try: self.driver.create_router(context, new_router) return new_router except Exception: with excutils.save_and_rer...
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier try_statement block expression_statement call attribute attribute identifie...
Create a new router entry in DB, and create it Arista HW.
def _update_config_file(username, password, email, url, config_path): try: config = json.load(open(config_path, "r")) except ValueError: config = dict() if not config.get('auths'): config['auths'] = dict() if not config['auths'].get(url): c...
module function_definition identifier parameters identifier identifier identifier identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end except_cl...
Update the config file with the authorization.
def on_menu_clear_interpretation(self, event): for sp in list(self.Data.keys()): del self.Data[sp]['pars'] self.Data[sp]['pars'] = {} self.Data[sp]['pars']['lab_dc_field'] = self.Data[sp]['lab_dc_field'] self.Data[sp]['pars']['er_specimen_name'] = self.Data[sp]['e...
module function_definition identifier parameters identifier identifier block for_statement identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block delete_statement subscript subscript attribute identifier identifier identifier string string_start string_con...
clear all current interpretations.
def _job_to_text(self, job): next_run = self._format_date(job.get('next_run', None)) tasks = '' for task in job.get('tasks', []): tasks += self._task_to_text(task) tasks += '\n\n' return '\n'.join(['Job name: %s' % job.get('name', None), ...
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier stri...
Return a standard formatting of a Job serialization.
def main(): logging.basicConfig(format=LOGGING_FORMAT) log = logging.getLogger(__name__) parser = argparse.ArgumentParser() add_debug(parser) add_app(parser) add_env(parser) add_properties(parser) args = parser.parse_args() logging.getLogger(__package__.split(".")[0]).setLevel(args.d...
module function_definition identifier parameters block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call a...
Send Slack notification to a configured channel.
def disconnect(self): logger.info("Disconnecting from Zookeeper.") self.client.stop() self.client.close()
module function_definition identifier parameters identifier block expression_statement call attribute 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 attribu...
Stops and closes the kazoo connection.
def get(self): return self.render( 'index.html', databench_version=DATABENCH_VERSION, meta_infos=self.meta_infos(), **self.info )
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list dictionary_splat attri...
Render the List-of-Analyses overview page.
def _Start_refresh_timer(self): if self._refreshPeriod > 60: interval = self._refreshPeriod - 60 else: interval = 60 self._refreshTimer = Timer(self._refreshPeriod, self.Refresh) self._refreshTimer.setDaemon(True) self._refreshTimer.start()
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier binary_operator attribute identifier identifier integer else_clause block expression_statement assignment identifier integer express...
Internal method to support auto-refresh functionality.
def strtype(self): if self.kind is not None: return "{}({})".format(self.dtype, self.kind) else: return self.dtype
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block return_statement call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier else_clause...
Returns a string representing the type and kind of this value element.
def load_shared_data(path: typing.Union[str, None]) -> dict: if path is None: return dict() if not os.path.exists(path): raise FileNotFoundError('No such shared data file "{}"'.format(path)) try: with open(path, 'r') as fp: data = json.load(fp) except Exception: ...
module function_definition identifier parameters typed_parameter identifier type subscript attribute identifier identifier identifier none type identifier block if_statement comparison_operator identifier none block return_statement call identifier argument_list if_statement not_operator call attribute attribute identi...
Load shared data from a JSON file stored on disk
def allowed_values(self): if self._allowed_values is None: self._allowed_values = ValueList() for val in self.scraper._fetch_allowed_values(self): if isinstance(val, DimensionValue): self._allowed_values.append(val) else: ...
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier a...
Return a list of allowed values.
def _shutdown(self): global sconf_global, _ac_config_hs if not self.active: raise SCons.Errors.UserError("Finish may be called only once!") if self.logstream is not None and not dryrun: self.logstream.write("\n") self.logstream.close() self.logstre...
module function_definition identifier parameters identifier block global_statement identifier identifier if_statement not_operator attribute identifier identifier block raise_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement bool...
Private method. Reset to non-piped spawn
def my_archieve(self): if not self._ptr: raise BfdException("BFD not initialized") return _bfd.get_bfd_attribute(self._ptr, BfdAttributes.MY_ARCHIEVE)
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list attribute identifier identifie...
Return the my archieve attribute of the BFD file being processed.