code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
async def save_session(self, session: Session, response: Response) -> None: await ensure_coroutine(self.session_interface.save_session)(self, session, response)
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type none block expression_statement await call call identifier argument_list attribute attribute identifier identifier identifier argument_list identifier identifier identifier
Saves the session to the response.
def _load(self, **kwargs): if 'uri' in self._meta_data: error = "There was an attempt to assign a new uri to this "\ "resource, the _meta_data['uri'] is %s and it should"\ " not be changed." % (self._meta_data['uri']) raise URICreationCollision(error) requests_params = self._handle_requests_params(kwargs) self._check_load_parameters(**kwargs) kwargs['uri_as_parts'] = True refresh_session = self._meta_data['bigip']._meta_data['icr_session'] base_uri = self._meta_data['container']._meta_data['uri'] kwargs.update(requests_params) for key1, key2 in self._meta_data['reduction_forcing_pairs']: kwargs = self._reduce_boolean_pair(kwargs, key1, key2) kwargs = self._check_for_python_keywords(kwargs) response = refresh_session.get(base_uri, **kwargs) return self._produce_instance(response)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end parenthesized_expression subscript attribute identifier identifier string string_start string_content string_end raise_statement call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list dictionary_splat identifier expression_statement assignment subscript identifier string string_start string_content string_end true expression_statement assignment identifier subscript attribute subscript attribute identifier identifier string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute subscript attribute identifier identifier string string_start string_content string_end identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier for_statement pattern_list identifier identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier return_statement call attribute identifier identifier argument_list identifier
wrapped with load, override that in a subclass to customize
def rlw_filter(name, location, size, unsize): arch = _meta_.arch if arch.startswith("i") and arch.endswith("86"): arch = "i486" (fname, flocation, fsize, funsize) = ([] for i in range(4)) for n, l, s, u in zip(name, location, size, unsize): loc = l.split("/") if arch == loc[-1]: fname.append(n) flocation.append(l) fsize.append(s) funsize.append(u) return [fname, flocation, fsize, funsize]
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment tuple_pattern identifier identifier identifier identifier generator_expression list for_in_clause identifier call identifier argument_list integer for_statement pattern_list identifier identifier identifier identifier call identifier argument_list identifier identifier 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 subscript identifier unary_operator integer block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement list identifier identifier identifier identifier
Filter rlw repository data
def find_features(seqs, locus_tag="all", utr_len=200): found_features = [] for seq_i in seqs: for feature in seq_i.features: if feature.type == "CDS" and (locus_tag == "all" or \ ('locus_tag' in feature.qualifiers and \ feature.qualifiers['locus_tag'][0] == locus_tag)): start = max(0, feature.location.nofuzzy_start - utr_len) stop = max(0, feature.location.nofuzzy_end + utr_len) feature_seq = seq_i.seq[start:stop] f_match = FeatureMatch(feature, feature_seq, feature.strand, utr_len) found_features.append(f_match) return found_features
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier integer block expression_statement assignment identifier list for_statement identifier identifier block for_statement identifier attribute identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier string string_start string_content string_end parenthesized_expression boolean_operator comparison_operator identifier string string_start string_content string_end line_continuation parenthesized_expression boolean_operator comparison_operator string string_start string_content string_end attribute identifier identifier line_continuation comparison_operator subscript subscript attribute identifier identifier string string_start string_content string_end integer identifier block expression_statement assignment identifier call identifier argument_list integer binary_operator attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list integer binary_operator attribute attribute identifier identifier identifier identifier expression_statement assignment identifier subscript attribute identifier identifier slice identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Find features in sequences by locus tag
def validate(config): with open(config) as fh: data = utils.yaml_load(fh.read()) jsonschema.validate(data, CONFIG_SCHEMA)
module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier
Validate a configuration file.
def ampliconclear(self): for sample in self.metadata: sample[self.analysistype].ampliconfile = os.path.join( sample[self.analysistype].outputdir, '{sn}_amplicons.fa'.format(sn=sample.name)) try: os.remove(sample[self.analysistype].ampliconfile) except IOError: pass
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement assignment attribute subscript identifier attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list attribute subscript identifier attribute identifier identifier identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list attribute subscript identifier attribute identifier identifier identifier except_clause identifier block pass_statement
Clear previously created amplicon files to prepare for the appending of data to fresh files
def reinitialize(): from ozelot import client from ozelot.orm.target import ORMTargetMarker client = client.get_client() base.Base.drop_all(client) base.Base.create_all(client)
module function_definition identifier parameters block import_from_statement dotted_name identifier dotted_name identifier import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Drop all tables for all models, then re-create them
def safe_mult(a, b): if isinstance(a, str) and isinstance(b, int) and len(a) * b > MAX_STR_LEN: raise RuntimeError("String length exceeded, max string length is {}".format(MAX_STR_LEN)) return a * b
module function_definition identifier parameters identifier identifier block if_statement boolean_operator boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier identifier comparison_operator binary_operator call identifier argument_list identifier identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement binary_operator identifier identifier
safe version of multiply
def calc_halfmax_points(self): d = self._ensure_data() return interpolated_halfmax_points(d.wlen, d.resp)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier
Calculate the wavelengths of the filter half-maximum values.
def update_thresh(self): thresh_val = self.threshLine.value() self.threshold_field.setValue(thresh_val) self.thresholdUpdated.emit(thresh_val, self.getTitle())
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier call attribute identifier identifier argument_list
Emits a Qt signal thresholdUpdated with the current threshold value
def make_response(event): code, message = event.status response = jsonify(**event.response) response.headers['X-Hub-Event'] = event.receiver_id response.headers['X-Hub-Delivery'] = event.id if message: response.headers['X-Hub-Info'] = message add_link_header(response, {'self': url_for( '.event_item', receiver_id=event.receiver_id, event_id=event.id, _external=True )}) return response, code
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list dictionary_splat attribute identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier if_statement identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement call identifier argument_list identifier dictionary pair string string_start string_content string_end call identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier true return_statement expression_list identifier identifier
Make a response from webhook event.
def _symlink_check(name, target, force, user, group, win_owner): changes = {} if not os.path.exists(name) and not __salt__['file.is_link'](name): changes['new'] = name return None, 'Symlink {0} to {1} is set for creation'.format( name, target ), changes if __salt__['file.is_link'](name): if __salt__['file.readlink'](name) != target: changes['change'] = name return None, 'Link {0} target is set to be changed to {1}'.format( name, target ), changes else: result = True msg = 'The symlink {0} is present'.format(name) if not _check_symlink_ownership(name, user, group, win_owner): result = None changes['ownership'] = '{0}:{1}'.format(*_get_symlink_ownership(name)) msg += ( ', but the ownership of the symlink would be changed ' 'from {2}:{3} to {0}:{1}' ).format(user, group, *_get_symlink_ownership(name)) return result, msg, changes else: if force: return None, ('The file or directory {0} is set for removal to ' 'make way for a new symlink targeting {1}' .format(name, target)), changes return False, ('File or directory exists where the symlink {0} ' 'should be. Did you mean to use force?'.format(name)), changes
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier dictionary if_statement boolean_operator not_operator call attribute attribute identifier identifier identifier argument_list identifier not_operator call subscript identifier string string_start string_content string_end argument_list identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement expression_list none call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier if_statement call subscript identifier string string_start string_content string_end argument_list identifier block if_statement comparison_operator call subscript identifier string string_start string_content string_end argument_list identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement expression_list none call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier else_clause block expression_statement assignment identifier true expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement not_operator call identifier argument_list identifier identifier identifier identifier block expression_statement assignment identifier none expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list list_splat call identifier argument_list identifier expression_statement augmented_assignment identifier call attribute parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier identifier list_splat call identifier argument_list identifier return_statement expression_list identifier identifier identifier else_clause block if_statement identifier block return_statement expression_list none parenthesized_expression call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier identifier identifier return_statement expression_list false parenthesized_expression call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier identifier
Check the symlink function
def _element_keywords(cls, backend, elements=None): "Returns a dictionary of element names to allowed keywords" if backend not in Store.loaded_backends(): return {} mapping = {} backend_options = Store.options(backend) elements = elements if elements is not None else backend_options.keys() for element in elements: if '.' in element: continue element = element if isinstance(element, tuple) else (element,) element_keywords = [] options = backend_options['.'.join(element)] for group in Options._option_groups: element_keywords.extend(options[group].allowed_keywords) mapping[element[0]] = element_keywords return mapping
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement string string_start string_content string_end if_statement comparison_operator identifier call attribute identifier identifier argument_list block return_statement dictionary expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier conditional_expression identifier comparison_operator identifier none call attribute identifier identifier argument_list for_statement identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block continue_statement expression_statement assignment identifier conditional_expression identifier call identifier argument_list identifier identifier tuple identifier expression_statement assignment identifier list expression_statement assignment identifier subscript identifier call attribute string string_start string_content string_end identifier argument_list identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute subscript identifier identifier identifier expression_statement assignment subscript identifier subscript identifier integer identifier return_statement identifier
Returns a dictionary of element names to allowed keywords
def unlink(client, name, include, exclude, yes): dataset = client.load_dataset(name=name) records = _filter( client, names=[dataset.name], include=include, exclude=exclude ) if not yes and records: prompt_text = ( 'You are about to remove ' 'following from "{0}" dataset.\n'.format(dataset.name) + '\n'.join([str(record.full_path) for record in records]) + '\nDo you wish to continue?' ) click.confirm(WARNING + prompt_text, abort=True) if records: for item in records: dataset.unlink_file(item.path) dataset.to_yaml() click.secho('OK', fg='green')
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier list attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement boolean_operator not_operator identifier identifier block expression_statement assignment identifier parenthesized_expression binary_operator binary_operator call attribute concatenated_string string string_start string_content string_end string string_start string_content escape_sequence string_end identifier argument_list attribute identifier identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list list_comprehension call identifier argument_list attribute identifier identifier for_in_clause identifier identifier string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list binary_operator identifier identifier keyword_argument identifier true if_statement identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end
Remove matching files from a dataset.
def fetch(self, code, **kwargs): log.debug('fetching QuanDL data (%s)' % code) if 'authtoken' in kwargs: self.quandl_key = kwargs.pop('authtoken') if 'start' in kwargs: kwargs['trim_start'] = kwargs.pop('start') if 'end' in kwargs: kwargs['trim_end'] = kwargs.pop('end') try: data = Quandl.get(code, authtoken=self.quandl_key, **kwargs) data.index = data.index.tz_localize(pytz.utc) except Exception, error: log.error('unable to fetch {}: {}'.format(code, error)) data = pd.DataFrame() return data
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier dictionary_splat identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier except_clause identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list return_statement identifier
Quandl entry point in datafeed object
def write_config(self): if not os.path.exists(os.path.dirname(self.config_file)): os.makedirs(os.path.dirname(self.config_file)) with open(self.config_file, 'w') as f: f.write(json.dumps(self.config)) f.close()
module function_definition identifier parameters identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list
Write config to file
def populate_countries(self): for i in range(1, 12): self.admin_level_comboBox.addItem(self.tr('Level %s') % i, i) self.admin_level_comboBox.setCurrentIndex(7) list_countries = sorted([ self.tr(country) for country in list(self.countries.keys())]) for country in list_countries: self.country_comboBox.addItem(country) self.bbox_countries = {} for country in list_countries: multipolygons = self.countries[country]['bbox'] self.bbox_countries[country] = [] for coords in multipolygons: bbox = QgsRectangle(coords[0], coords[3], coords[2], coords[1]) self.bbox_countries[country].append(bbox) self.update_helper_political_level()
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list integer integer block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list integer expression_statement assignment identifier call identifier argument_list list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier dictionary for_statement identifier identifier block expression_statement assignment identifier subscript subscript attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier identifier list for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list subscript identifier integer subscript identifier integer subscript identifier integer subscript identifier integer expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Populate the combobox about countries and levels.
def echo_detected_environment(env_name, env_vars): env_override_name = 'DEPLOY_ENVIRONMENT' LOGGER.info("") if env_override_name in env_vars: LOGGER.info("Environment \"%s\" was determined from the %s environment variable.", env_name, env_override_name) LOGGER.info("If this is not correct, update " "the value (or unset it to fall back to the name of " "the current git branch or parent directory).") else: LOGGER.info("Environment \"%s\" was determined from the current " "git branch or parent directory.", env_name) LOGGER.info("If this is not the environment name, update the branch/folder name or " "set an override value via the %s environment variable", env_override_name) LOGGER.info("")
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_end if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end identifier identifier expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content escape_sequence escape_sequence string_end string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_end
Print a helper note about how the environment was determined.
def _default_request_kwargs(self): defaults = copy.deepcopy(super(Acls, self)._default_request_kwargs) defaults.setdefault('headers', {}).update({ 'X-Auth-Token': self._client.auth._token }) return defaults
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute call identifier argument_list identifier identifier identifier expression_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list dictionary pair string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier return_statement identifier
The default request keyword arguments to be passed to the requests library.
def showall(self): p = _runshell([brctlexe, 'show'], "Could not show bridges.") wlist = map(str.split, p.stdout.read().splitlines()[1:]) brwlist = filter(lambda x: len(x) != 1, wlist) brlist = map(lambda x: x[0], brwlist) return map(Bridge, brlist)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list list identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier subscript call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list slice integer expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier comparison_operator call identifier argument_list identifier integer identifier expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier subscript identifier integer identifier return_statement call identifier argument_list identifier identifier
Return a list of all available bridges.
def build_kal_scan_band_string(kal_bin, band, args): option_mapping = {"gain": "-g", "device": "-d", "error": "-e"} if not sanity.scan_band_is_valid(band): err_txt = "Unsupported band designation: %" % band raise ValueError(err_txt) base_string = "%s -v -s %s" % (kal_bin, band) base_string += options_string_builder(option_mapping, args) return(base_string)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier raise_statement call identifier argument_list identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement augmented_assignment identifier call identifier argument_list identifier identifier return_statement parenthesized_expression identifier
Return string for CLI invocation of kal, for band scan.
def markCurrentChanged(self): view = self.currentView() if view: view.setCurrent() self.setFocus() view.setFocus() self._hintLabel.hide() else: self._hintLabel.show() self._hintLabel.setText(self.hint()) if not self.count(): self.tabBar().clear() self.adjustSizeConstraint()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list if_statement not_operator call attribute identifier identifier argument_list block expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement call attribute identifier identifier argument_list
Marks that the current widget has changed.
def controlled(self, control_qubit): control_qubit = unpack_qubit(control_qubit) self.modifiers.insert(0, "CONTROLLED") self.qubits.insert(0, control_qubit) return self
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list integer string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list integer identifier return_statement identifier
Add the CONTROLLED modifier to the gate with the given control qubit.
def _get_date_pagination(self, base, oldest_neighbor, newest_neighbor): _, span, date_format = utils.parse_date(self.spec['date']) if newest_neighbor: newer_date = newest_neighbor.date.span(span)[0] newer_view = View({**base, 'order': self._order_by, 'date': newer_date.format(date_format)}) else: newer_view = None if oldest_neighbor: older_date = oldest_neighbor.date.span(span)[0] older_view = View({**base, 'order': self._order_by, 'date': older_date.format(date_format)}) else: older_view = None return older_view, newer_view
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list identifier integer expression_statement assignment identifier call identifier argument_list dictionary dictionary_splat identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier none if_statement identifier block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list identifier integer expression_statement assignment identifier call identifier argument_list dictionary dictionary_splat identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier none return_statement expression_list identifier identifier
Compute the pagination for date-based views
def _update_Frxy(self): self.Frxy.fill(1.0) self.Frxy_no_omega.fill(1.0) with scipy.errstate(divide='raise', under='raise', over='raise', invalid='ignore'): scipy.copyto(self.Frxy_no_omega, -self.ln_piAx_piAy_beta / (1 - self.piAx_piAy_beta), where=scipy.logical_and( CODON_NONSYN, scipy.fabs(1 - self.piAx_piAy_beta) > ALMOST_ZERO)) for r in range(self.nsites): scipy.copyto(self.Frxy_no_omega[r], self.Frxy_no_omega[r] * (1 + self.omega2 * self.deltar[r]), where=CODON_NONSYN) scipy.copyto(self.Frxy, self.Frxy_no_omega * self.omega, where=CODON_NONSYN)
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list float expression_statement call attribute attribute identifier identifier identifier argument_list float with_statement with_clause with_item call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier binary_operator unary_operator attribute identifier identifier parenthesized_expression binary_operator integer attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list identifier comparison_operator call attribute identifier identifier argument_list binary_operator integer attribute identifier identifier identifier for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier identifier binary_operator subscript attribute identifier identifier identifier parenthesized_expression binary_operator integer binary_operator attribute identifier identifier subscript attribute identifier identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier keyword_argument identifier identifier
Update `Frxy` from `piAx_piAy_beta`, `omega`, `omega2`, and `beta`.
def compare_words_lexicographic( word_a, word_b ): if ( not all_tamil(word_a) ) or (not all_tamil(word_b)) : pass La = len(word_a) Lb = len(word_b) all_TA_letters = u"".join(tamil_letters) for itr in range(0,min(La,Lb)): pos1 = all_TA_letters.find( word_a[itr] ) pos2 = all_TA_letters.find( word_b[itr] ) if pos1 != pos2 : return cmp(pos1, pos2) return cmp(La,Lb)
module function_definition identifier parameters identifier identifier block if_statement boolean_operator parenthesized_expression not_operator call identifier argument_list identifier parenthesized_expression not_operator call identifier argument_list identifier block pass_statement expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_end identifier argument_list identifier for_statement identifier call identifier argument_list integer call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier identifier if_statement comparison_operator identifier identifier block return_statement call identifier argument_list identifier identifier return_statement call identifier argument_list identifier identifier
compare words in Tamil lexicographic order
def can_use_enum(func): @wraps(func) def inner(self, value): if isinstance(value, Enum): return self.check_value(value.value) or func(self, value.value) return func(self, value) return inner
module function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block return_statement boolean_operator call attribute identifier identifier argument_list attribute identifier identifier call identifier argument_list identifier attribute identifier identifier return_statement call identifier argument_list identifier identifier return_statement identifier
Decorator to use Enum value on type checks.
def upsert(self, table: str, record: dict, create_cols: bool=False, dtypes: list=None, pks=["id"], namefields=["id"]): try: self.db[table].upsert(record, pks, create_cols, dtypes) except Exception as e: self.err(e, "Can not upsert data") return names = "" for el in namefields: names += " " + record[el] self.ok("Upserted record"+names)
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier false typed_default_parameter identifier type identifier none default_parameter identifier list string string_start string_content string_end default_parameter identifier list string string_start string_content string_end block try_statement block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier identifier identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end return_statement expression_statement assignment identifier string string_start string_end for_statement identifier identifier block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end subscript identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier
Upsert a record in a table
def _get_next_version(self, revisions): versions = [0] for v in revisions: if v.isdigit(): versions.append(int(v)) return six.text_type(sorted(versions)[-1] + 1)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list integer for_statement identifier identifier block if_statement call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier return_statement call attribute identifier identifier argument_list binary_operator subscript call identifier argument_list identifier unary_operator integer integer
Calculates new version number based on existing numeric ones.
def add_candidate(self, artifact): self.candidates.append(artifact) self._log(logging.DEBUG, "CANDIDATES appended:'{}'" .format(artifact))
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 attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier
Add candidate artifact to the list of current candidates.
def check_signing_key(self): user_keys = self.gpg.list_keys() if len(user_keys) > 0: trusted = False for key in user_keys: if key['fingerprint'] == self.key_info['fingerprint']: trusted = True logger.debug(("repo signing key trusted in user keyring, " "fingerprint {0}".format(key['fingerprint']))) else: trusted = False if trusted is False: repo_key_url = "{0}/{1}".format(self.url, self.repo_signing_key) raise RepositoryUntrustedSigningKeyError(repo_key_url, self.key_info['fingerprint'])
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier false for_statement identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier true expression_statement call attribute identifier identifier argument_list parenthesized_expression call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end else_clause block expression_statement assignment identifier false if_statement comparison_operator identifier false block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier raise_statement call identifier argument_list identifier subscript attribute identifier identifier string string_start string_content string_end
Check that repo signing key is trusted by gpg keychain
def pearson_correlation(self): x, y, dt = self.data X, Y = np.array(x), np.array(y) X -= X.mean(0) Y -= Y.mean(0) X /= X.std(0) Y /= Y.std(0) return (np.mean(X*Y) ** 2) * 100
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier expression_list call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier call attribute identifier identifier argument_list integer expression_statement augmented_assignment identifier call attribute identifier identifier argument_list integer expression_statement augmented_assignment identifier call attribute identifier identifier argument_list integer expression_statement augmented_assignment identifier call attribute identifier identifier argument_list integer return_statement binary_operator parenthesized_expression binary_operator call attribute identifier identifier argument_list binary_operator identifier identifier integer integer
Compute Pearson Correlation Coefficient.
def onAuthenticate(self, signature, extra): log.msg("onAuthenticate: {} {}".format(signature, extra)) if self._pending_auth: if signature == self._pending_auth.signature: return types.Accept(authid = self._pending_auth.uid, authrole = self._pending_auth.authrole, authmethod = self._pending_auth.authmethod, authprovider = self._pending_auth.authprovider) else: return types.Deny(message = u"signature is invalid") else: return types.Deny(message = u"no pending authentication")
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier if_statement attribute identifier identifier block if_statement comparison_operator identifier attribute attribute identifier identifier identifier block return_statement call attribute identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier else_clause block return_statement call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end else_clause block return_statement call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end
Callback fired when a client responds to an authentication challenge.
def render(self, *args, **kwargs): output = super(HeavySelect2Mixin, self).render(*args, **kwargs) self.set_to_cache() return output
module function_definition identifier parameters 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 list_splat identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
Render widget and register it in Django's cache.
def _post_init(self): if WIN: self._find_devices_win() elif MAC: self._find_devices_mac() else: self._find_devices() self._update_all_devices() if NIX: self._find_leds()
module function_definition identifier parameters identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list elif_clause identifier block expression_statement call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list
Call the find devices method for the relevant platform.
def _bse_cli_get_versions(args): name = args.basis.lower() metadata = api.get_metadata(args.data_dir) if not name in metadata: raise KeyError( "Basis set {} does not exist. For a complete list of basis sets, use the 'list-basis-sets' command".format( name)) version_data = {k: v['revdesc'] for k, v in metadata[name]['versions'].items()} if args.no_description: liststr = version_data.keys() else: liststr = format_columns(version_data.items()) return '\n'.join(liststr)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement not_operator comparison_operator identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier dictionary_comprehension pair identifier subscript identifier string string_start string_content string_end for_in_clause pattern_list identifier identifier call attribute subscript subscript identifier identifier string string_start string_content string_end identifier argument_list if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list return_statement call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier
Handles the get-versions subcommand
def close(self): if self.connection is not None: self.connection.close() if self.connection_fd is not None: self.connection_fd.close()
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list
Quit the connection with mod-host
def lonlat2xyz(lon, lat): lat = xu.deg2rad(lat) lon = xu.deg2rad(lon) x = xu.cos(lat) * xu.cos(lon) y = xu.cos(lat) * xu.sin(lon) z = xu.sin(lat) return x, y, z
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement expression_list identifier identifier identifier
Convert lon lat to cartesian.
def tonativefunc(enc='utf-8'): if sys.version_info >= (3,0,0): return lambda x: x.decode(enc) if isinstance(x, bytes) else str(x) return lambda x: x.encode(enc) if isinstance(x, unicode) else str(x)
module function_definition identifier parameters default_parameter identifier string string_start string_content string_end block if_statement comparison_operator attribute identifier identifier tuple integer integer integer block return_statement lambda lambda_parameters identifier conditional_expression call attribute identifier identifier argument_list identifier call identifier argument_list identifier identifier call identifier argument_list identifier return_statement lambda lambda_parameters identifier conditional_expression call attribute identifier identifier argument_list identifier call identifier argument_list identifier identifier call identifier argument_list identifier
Returns a function that turns everything into 'native' strings using enc
def comparelist_view(self, request, object_id, extra_context=None): opts = self.model._meta object_id = unquote(object_id) current = get_object_or_404(self.model, pk=object_id) action_list = [ { "revision": version.revision, "url": reverse("%s:%s_%s_compare" % (self.admin_site.name, opts.app_label, opts.model_name), args=(quote(version.object_id), version.id)), } for version in self._reversion_order_version_queryset(Version.objects.get_for_object_reference( self.model, object_id).select_related("revision__user"))] context = {"action_list": action_list, "opts": opts, "object_id": quote(object_id), "original": current, } extra_context = extra_context or {} context.update(extra_context) return render(request, self.compare_list_template or self._get_template_list("compare_list.html"), context)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier keyword_argument identifier identifier expression_statement assignment identifier list_comprehension dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call identifier argument_list binary_operator string string_start string_content string_end tuple attribute attribute identifier identifier identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier tuple call identifier argument_list attribute identifier identifier attribute identifier identifier for_in_clause identifier call attribute identifier identifier argument_list call attribute call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end call identifier argument_list identifier pair string string_start string_content string_end identifier expression_statement assignment identifier boolean_operator identifier dictionary expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier boolean_operator attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier
Allow selecting versions to compare.
def create_geoms(self, gdefs, plot): new_gdefs = [] for gdef in gdefs: gdef = gdef.create_geoms(plot) if gdef: new_gdefs.append(gdef) return new_gdefs
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Add geoms to the guide definitions
def __clear_references(self, request, remove_request=True): if remove_request: with self.__requests: self.__requests.pop(request.id_) if not request.success: with self.__pending_subs: self.__pending_subs.pop(request.id_, None) with self.__pending_controls: self.__pending_controls.pop(request.id_, None)
module function_definition identifier parameters identifier identifier default_parameter identifier true block if_statement identifier block with_statement with_clause with_item attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement not_operator attribute identifier identifier block with_statement with_clause with_item attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier none with_statement with_clause with_item attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier none
Remove any internal references to the given request
def getNbVariants(self, x1, x2 = -1) : if x2 == -1 : xx2 = len(self.defaultSequence) else : xx2 = x2 nbP = 1 for p in self.polymorphisms: if x1 <= p[0] and p[0] <= xx2 : nbP *= len(p[1]) return nbP
module function_definition identifier parameters identifier identifier default_parameter identifier unary_operator integer block if_statement comparison_operator identifier unary_operator integer block expression_statement assignment identifier call identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier integer for_statement identifier attribute identifier identifier block if_statement boolean_operator comparison_operator identifier subscript identifier integer comparison_operator subscript identifier integer identifier block expression_statement augmented_assignment identifier call identifier argument_list subscript identifier integer return_statement identifier
returns the nb of variants of sequences between x1 and x2
def zunionstore(self, destkey, key, *keys, with_weights=False, aggregate=None): keys = (key,) + keys numkeys = len(keys) args = [] if with_weights: assert all(isinstance(val, (list, tuple)) for val in keys), ( "All key arguments must be (key, weight) tuples") weights = ['WEIGHTS'] for key, weight in keys: args.append(key) weights.append(weight) args.extend(weights) else: args.extend(keys) if aggregate is self.ZSET_AGGREGATE_SUM: args.extend(('AGGREGATE', 'SUM')) elif aggregate is self.ZSET_AGGREGATE_MAX: args.extend(('AGGREGATE', 'MAX')) elif aggregate is self.ZSET_AGGREGATE_MIN: args.extend(('AGGREGATE', 'MIN')) fut = self.execute(b'ZUNIONSTORE', destkey, numkeys, *args) return fut
module function_definition identifier parameters identifier identifier identifier list_splat_pattern identifier default_parameter identifier false default_parameter identifier none block expression_statement assignment identifier binary_operator tuple identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier list if_statement identifier block assert_statement call identifier generator_expression call identifier argument_list identifier tuple identifier identifier for_in_clause identifier identifier parenthesized_expression string string_start string_content string_end expression_statement assignment identifier list string string_start string_content string_end for_statement pattern_list identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end elif_clause comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end elif_clause comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier list_splat identifier return_statement identifier
Add multiple sorted sets and store result in a new key.
def apply(self, q, bindings, drilldowns): info = [] for drilldown in self.parse(drilldowns): for attribute in self.cube.model.match(drilldown): info.append(attribute.ref) table, column = attribute.bind(self.cube) bindings.append(Binding(table, attribute.ref)) q = q.column(column) q = q.group_by(column) return info, q, bindings
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list identifier block for_statement identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement expression_list identifier identifier identifier
Apply a set of grouping criteria and project them.
def activate_boost_by_name(self, zone_name, target_temperature, num_hours=1): zone = self.get_zone(zone_name) if zone is None: raise RuntimeError("Unknown zone") return self.activate_boost_by_id(zone["zoneId"], target_temperature, num_hours)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier identifier
Activate boost by the name of the zone
def exists(provider, config_location=DEFAULT_CONFIG_DIR): config_dir = os.path.join(config_location, NOIPY_CONFIG) auth_file = os.path.join(config_dir, provider) return os.path.exists(auth_file)
module function_definition identifier parameters identifier default_parameter identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier
Check whether provider info is already stored
def pbar_strings(files, desc='', **kwargs): return tqdm( sorted(files, key=lambda s: s.lower()), desc=('<' + str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) + '> ' + desc), dynamic_ncols=True, **kwargs)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end dictionary_splat_pattern identifier block return_statement call identifier argument_list call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier call attribute identifier identifier argument_list keyword_argument identifier parenthesized_expression binary_operator binary_operator binary_operator string string_start string_content string_end call identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier keyword_argument identifier true dictionary_splat identifier
Wrapper for `tqdm` progress bar which also sorts list of strings
def _sanitize_params(prefix, suffix, dir): output_type = _infer_return_type(prefix, suffix, dir) if suffix is None: suffix = output_type() if prefix is None: if output_type is str: prefix = "tmp" else: prefix = os.fsencode("tmp") if dir is None: if output_type is str: dir = gettempdir() else: dir = fs_encode(gettempdir()) return prefix, suffix, dir, output_type
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator identifier none block if_statement comparison_operator identifier identifier block expression_statement assignment identifier string string_start string_content string_end else_clause 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 comparison_operator identifier identifier block expression_statement assignment identifier call identifier argument_list else_clause block expression_statement assignment identifier call identifier argument_list call identifier argument_list return_statement expression_list identifier identifier identifier identifier
Common parameter processing for most APIs in this module.
def dynamic_info(self): "Return a map that for a given year will return the correct Info" if self.key_name: dyn_key = self.get_key().subkey('Dynamic DST') del dyn_key['FirstEntry'] del dyn_key['LastEntry'] years = map(int, dyn_key.keys()) values = map(Info, dyn_key.values()) return RangeMap(zip(years, values), RangeMap.descending, operator.ge) else: return AnyDict(self)
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement attribute identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end delete_statement subscript identifier string string_start string_content string_end delete_statement subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier call attribute identifier identifier argument_list return_statement call identifier argument_list call identifier argument_list identifier identifier attribute identifier identifier attribute identifier identifier else_clause block return_statement call identifier argument_list identifier
Return a map that for a given year will return the correct Info
def getreadergroups(self): innerreadergroups.getreadergroups(self) hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) if hresult != 0: raise EstablishContextException(hresult) hresult, readers = SCardListReaderGroups(hcontext) if hresult != 0: raise ListReadersException(hresult) hresult = SCardReleaseContext(hcontext) if hresult != 0: raise ReleaseContextException(hresult) return readers
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement comparison_operator identifier integer block raise_statement call identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement comparison_operator identifier integer block raise_statement call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier integer block raise_statement call identifier argument_list identifier return_statement identifier
Returns the list of smartcard reader groups.
def checkout_default_branch(self): set_state(WORKFLOW_STATES.CHECKING_OUT_DEFAULT_BRANCH) cmd = "git", "checkout", self.config["default_branch"] self.run_cmd(cmd) set_state(WORKFLOW_STATES.CHECKED_OUT_DEFAULT_BRANCH)
module function_definition identifier parameters identifier block expression_statement call identifier argument_list attribute identifier identifier expression_statement assignment identifier expression_list string string_start string_content string_end string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list attribute identifier identifier
git checkout default branch
def reset(self): self.minimum = None self.maximum = None self.start_time = None self.idx_current = None self.idx_markers = [] self.idx_annot = [] if self.scene is not None: self.scene.clear() self.scene = None
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier list if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none
Reset the widget, and clear the scene.
def draw_no_data(self): no_data = self.node( self.graph.nodes['text_overlay'], 'text', x=self.graph.view.width / 2, y=self.graph.view.height / 2, class_='no_data' ) no_data.text = self.graph.no_data_text
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript attribute attribute identifier identifier identifier string string_start string_content string_end string string_start string_content string_end keyword_argument identifier binary_operator attribute attribute attribute identifier identifier identifier identifier integer keyword_argument identifier binary_operator attribute attribute attribute identifier identifier identifier identifier integer keyword_argument identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier
Write the no data text to the svg
def new_stack(self, keep_stacks: int, new_traffic: int, senza_yaml: dict, stack_version: str, disable_rollback: bool, parameters: List[str], region: Optional[str], dry_run: bool, tags: List[str]) -> (Dict[str, str], str): header = make_header(self.access_token) data = {'senza_yaml': yaml.dump(senza_yaml), 'stack_version': stack_version, 'disable_rollback': disable_rollback, 'dry_run': dry_run, 'keep_stacks': keep_stacks, 'new_traffic': new_traffic, 'parameters': parameters, 'tags': tags} if region: data['region'] = region request = self.stacks_url.post(json=data, headers=header, verify=False) request.raise_for_status() return request.json(), self.get_output(request)
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type generic_type identifier type_parameter type identifier typed_parameter identifier type generic_type identifier type_parameter type identifier typed_parameter identifier type identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type tuple subscript identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier false expression_statement call attribute identifier identifier argument_list return_statement expression_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier
Requests a new stack.
def trim(self): overlay_data_offset = self.get_overlay_data_start_offset() if overlay_data_offset is not None: return self.__data__[ : overlay_data_offset ] return self.__data__[:]
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block return_statement subscript attribute identifier identifier slice identifier return_statement subscript attribute identifier identifier slice
Return the just data defined by the PE headers, removing any overlayed data.
def discover_slaves(self, service_name): "Returns a list of alive slaves for service ``service_name``" for sentinel in self.sentinels: try: slaves = sentinel.sentinel_slaves(service_name) except (ConnectionError, ResponseError, TimeoutError): continue slaves = self.filter_slaves(slaves) if slaves: return slaves return []
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end for_statement identifier attribute identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause tuple identifier identifier identifier block continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block return_statement identifier return_statement list
Returns a list of alive slaves for service ``service_name``
def gen(skipdirhtml=False): docs_changelog = 'docs/changelog.rst' check_git_unchanged(docs_changelog) pandoc('--from=markdown', '--to=rst', '--output=' + docs_changelog, 'CHANGELOG.md') if not skipdirhtml: sphinx_build['-b', 'dirhtml', '-W', '-E', 'docs', 'docs/_build/dirhtml'] & FG sphinx_build['-b', 'html', '-W', '-E', 'docs', 'docs/_build/html'] & FG
module function_definition identifier parameters default_parameter identifier false block expression_statement assignment identifier string string_start string_content string_end expression_statement call identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content string_end string string_start string_content string_end binary_operator string string_start string_content string_end identifier string string_start string_content string_end if_statement not_operator identifier block expression_statement binary_operator subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier expression_statement binary_operator subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier
Generate html and dirhtml output.
def _check_equals(self): card_string = self['card_string'] if len(card_string) < 9: self._has_equals = False elif card_string[8] == '=': self._has_equals = True else: self._has_equals = False
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment attribute identifier identifier false elif_clause comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement assignment attribute identifier identifier true else_clause block expression_statement assignment attribute identifier identifier false
check for = in position 8, set attribute _has_equals
def _inherited_panel(panel, base_panels_from_pillar, ret): base_panels = [] for base_panel_from_pillar in base_panels_from_pillar: base_panel = __salt__['pillar.get'](base_panel_from_pillar) if base_panel: base_panels.append(base_panel) elif base_panel_from_pillar != _DEFAULT_PANEL_PILLAR: ret.setdefault('warnings', []) warning_message = 'Cannot find panel pillar "{0}".'.format( base_panel_from_pillar) if warning_message not in ret['warnings']: ret['warnings'].append(warning_message) base_panels.append(panel) result_panel = {} for panel in base_panels: result_panel.update(panel) return result_panel
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end list expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement comparison_operator identifier subscript identifier string string_start string_content string_end block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Return a panel with properties from parents.
def get(self, path, params, **options): return self.request('get', path, params=params, **options)
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier keyword_argument identifier identifier dictionary_splat identifier
Parses GET request options and dispatches a request
def approve(self, request, *args, **kwargs): self.object = self.get_object() success_url = self.get_success_url() self.object.approved = True self.object.save() messages.success(self.request, self.success_message) return HttpResponseRedirect(success_url)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier true expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier return_statement call identifier argument_list identifier
Approves the considered post and retirects the user to the success URL.
def _create_buffer_control(self, editor_buffer): @Condition def preview_search(): return self.editor.incsearch input_processors = [ ConditionalProcessor( ShowTrailingWhiteSpaceProcessor(), Condition(lambda: self.editor.display_unprintable_characters)), TabsProcessor( tabstop=(lambda: self.editor.tabstop), char1=(lambda: '|' if self.editor.display_unprintable_characters else ' '), char2=(lambda: _try_char('\u2508', '.', get_app().output.encoding()) if self.editor.display_unprintable_characters else ' '), ), ReportingProcessor(editor_buffer), HighlightSelectionProcessor(), ConditionalProcessor( HighlightSearchProcessor(), Condition(lambda: self.editor.highlight_search)), ConditionalProcessor( HighlightIncrementalSearchProcessor(), Condition(lambda: self.editor.highlight_search) & preview_search), HighlightMatchingBracketProcessor(), DisplayMultipleCursors(), ] return BufferControl( lexer=DocumentLexer(editor_buffer), include_default_input_processors=False, input_processors=input_processors, buffer=editor_buffer.buffer, preview_search=preview_search, search_buffer_control=self.search_control, focus_on_click=True)
module function_definition identifier parameters identifier identifier block decorated_definition decorator identifier function_definition identifier parameters block return_statement attribute attribute identifier identifier identifier expression_statement assignment identifier list call identifier argument_list call identifier argument_list call identifier argument_list lambda attribute attribute identifier identifier identifier call identifier argument_list keyword_argument identifier parenthesized_expression lambda attribute attribute identifier identifier identifier keyword_argument identifier parenthesized_expression lambda conditional_expression string string_start string_content string_end attribute attribute identifier identifier identifier string string_start string_content string_end keyword_argument identifier parenthesized_expression lambda conditional_expression call identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end call attribute attribute call identifier argument_list identifier identifier argument_list attribute attribute identifier identifier identifier string string_start string_content string_end call identifier argument_list identifier call identifier argument_list call identifier argument_list call identifier argument_list call identifier argument_list lambda attribute attribute identifier identifier identifier call identifier argument_list call identifier argument_list binary_operator call identifier argument_list lambda attribute attribute identifier identifier identifier identifier call identifier argument_list call identifier argument_list return_statement call identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier false keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier true
Create a new BufferControl for a given location.
def chunk_on(pipeline, new_chunk_signal, output_type=tuple): assert iterable(pipeline), 'chunks needs pipeline to be iterable' assert callable(new_chunk_signal), 'chunks needs new_chunk_signal to be callable' assert callable(output_type), 'chunks needs output_type to be callable' out = deque() for i in pipeline: if new_chunk_signal(i) and len(out): yield output_type(out) out.clear() out.append(i) if len(out): yield output_type(out)
module function_definition identifier parameters identifier identifier default_parameter identifier identifier block assert_statement call identifier argument_list identifier string string_start string_content string_end assert_statement call identifier argument_list identifier string string_start string_content string_end assert_statement call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block if_statement boolean_operator call identifier argument_list identifier call identifier argument_list identifier block expression_statement yield call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier if_statement call identifier argument_list identifier block expression_statement yield call identifier argument_list identifier
split the stream into seperate chunks based on a new chunk signal
def attached_to_model(self): try: if not bool(self.model): return False except AttributeError: return False else: try: return not bool(self.instance) except AttributeError: return True
module function_definition identifier parameters identifier block try_statement block if_statement not_operator call identifier argument_list attribute identifier identifier block return_statement false except_clause identifier block return_statement false else_clause block try_statement block return_statement not_operator call identifier argument_list attribute identifier identifier except_clause identifier block return_statement true
Tells if the current index is the one attached to the model field, not instance field
def default(): algorithm = algorithms.PPO num_agents = 30 eval_episodes = 30 use_gpu = False normalize_ranges = True network = networks.feed_forward_gaussian weight_summaries = dict( all=r'.*', policy=r'.*/policy/.*', value=r'.*/value/.*') policy_layers = 200, 100 value_layers = 200, 100 init_output_factor = 0.1 init_std = 0.35 update_every = 30 update_epochs = 25 optimizer = tf.train.AdamOptimizer learning_rate = 1e-4 discount = 0.995 kl_target = 1e-2 kl_cutoff_factor = 2 kl_cutoff_coef = 1000 kl_init_penalty = 1 return locals()
module function_definition identifier parameters block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier integer expression_statement assignment identifier integer expression_statement assignment identifier false expression_statement assignment identifier true expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier expression_list integer integer expression_statement assignment identifier expression_list integer integer expression_statement assignment identifier float expression_statement assignment identifier float expression_statement assignment identifier integer expression_statement assignment identifier integer expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier float expression_statement assignment identifier float expression_statement assignment identifier float expression_statement assignment identifier integer expression_statement assignment identifier integer expression_statement assignment identifier integer return_statement call identifier argument_list
Default configuration for PPO.
def _process_filter_block(query_metadata_table, block): base_predicate = block.predicate ternary_conditionals = [] problematic_locations = [] def find_ternary_conditionals(expression): if isinstance(expression, TernaryConditional): ternary_conditionals.append(expression) return expression def extract_locations_visitor(expression): if isinstance(expression, (ContextField, ContextFieldExistence)): location_at_vertex = expression.location.at_vertex() if location_at_vertex not in problematic_locations: problematic_locations.append(location_at_vertex) return expression return_value = base_predicate.visit_and_update(find_ternary_conditionals) if return_value is not base_predicate: raise AssertionError(u'Read-only visitor function "find_ternary_conditionals" ' u'caused state to change: ' u'{} {}'.format(base_predicate, return_value)) for ternary in ternary_conditionals: return_value = ternary.visit_and_update(extract_locations_visitor) if return_value is not ternary: raise AssertionError(u'Read-only visitor function "extract_locations_visitor" ' u'caused state to change: ' u'{} {}'.format(ternary, return_value)) tautologies = [ _create_tautological_expression_for_location(query_metadata_table, location) for location in problematic_locations ] if not tautologies: return block final_predicate = base_predicate for tautology in tautologies: final_predicate = BinaryComposition(u'&&', final_predicate, tautology) return Filter(final_predicate)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier list expression_statement assignment identifier list function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier function_definition identifier parameters identifier block if_statement call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier identifier for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier identifier expression_statement assignment identifier list_comprehension call identifier argument_list identifier identifier for_in_clause identifier identifier if_statement not_operator identifier block return_statement identifier expression_statement assignment identifier identifier for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end identifier identifier return_statement call identifier argument_list identifier
Rewrite the provided Filter block if necessary.
def camel_to_snake(camel_str): s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', camel_str) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier return_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier identifier argument_list
Convert `camel_str` from camelCase to snake_case
def _track_class(cls, fields): assert not getattr(cls, '_is_tracked', False) for field in fields: _track_class_field(cls, field) _add_signals_to_cls(cls) cls._is_tracked = True cls._tracked_fields = [ field for field in fields if '__' not in field ]
module function_definition identifier parameters identifier identifier block assert_statement not_operator call identifier argument_list identifier string string_start string_content string_end false for_statement identifier identifier block expression_statement call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator string string_start string_content string_end identifier
Track fields on the specified model
def events(self, argv): opts = cmdline(argv, FLAGS_EVENTS) self.foreach(opts.args, lambda job: output(job.events(**opts.kwargs)))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier lambda lambda_parameters identifier call identifier argument_list call attribute identifier identifier argument_list dictionary_splat attribute identifier identifier
Retrieve events for the specified search jobs.
def _get_auth_header(self): realm = 'realm="{realm}"'.format(realm=self.realm) params = ['{k}="{v}"'.format(k=k, v=quote(str(v), safe='')) for k, v in self.oauth_params.items()] return 'OAuth ' + ','.join([realm] + params)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement assignment identifier list_comprehension call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier call identifier argument_list call identifier argument_list identifier keyword_argument identifier string string_start string_end for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list return_statement binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list binary_operator list identifier identifier
Constructs and returns an authentication header.
def _list_model(self, model_cls: Type[X]) -> List[X]: return self.session.query(model_cls).all()
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type generic_type identifier type_parameter type identifier block return_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list
List the models in this class.
def abort_job(self, job_id): doc = self.create_abort_job_doc() url = self.endpoint + "/job/%s" % job_id resp = requests.post( url, headers=self.headers(), data=doc ) self.check_status(resp)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator attribute identifier identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Abort a given bulk job
def showContextMenu(self, pos): contextMenu = QtWidgets.QMenu() addInspectorActionsToMenu(contextMenu, self.execInspectorDialogAction, self.inspectorActionGroup) contextMenu.exec_(self.mapToGlobal(pos))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier
Shows the context menu at position pos.
def GenerateNetworkedConfigFile(load_hook, normal_class_load_hook, normal_class_dump_hook, **kwargs) -> NetworkedConfigObject: def NetworkedConfigObjectGenerator(url, safe_load: bool=True): cfg = NetworkedConfigObject(url=url, load_hook=load_hook, safe_load=safe_load, normal_class_load_hook=normal_class_load_hook, normal_class_dump_hook=normal_class_dump_hook) return cfg return NetworkedConfigObjectGenerator
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier type identifier block function_definition identifier parameters identifier typed_default_parameter identifier type identifier true block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier return_statement identifier
Generates a NetworkedConfigObject using the specified hooks.
def _check_unpack_options(extensions, function, extra_args): existing_extensions = {} for name, info in _UNPACK_FORMATS.items(): for ext in info[0]: existing_extensions[ext] = name for extension in extensions: if extension in existing_extensions: msg = '%s is already registered for "%s"' raise RegistryError(msg % (extension, existing_extensions[extension])) if not isinstance(function, collections.Callable): raise TypeError('The registered function must be a callable')
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block for_statement identifier subscript identifier integer block expression_statement assignment subscript identifier identifier identifier for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier string string_start string_content string_end raise_statement call identifier argument_list binary_operator identifier tuple identifier subscript identifier identifier if_statement not_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end
Checks what gets registered as an unpacker.
def _list_patient_ids(self): results = [] for patient in self: results.append(patient.id) return(results)
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement parenthesized_expression identifier
Utility function to return a list of patient ids in the Cohort
def to_tgt(self): enc_part = EncryptedData({'etype': 1, 'cipher': b''}) tgt_rep = {} tgt_rep['pvno'] = krb5_pvno tgt_rep['msg-type'] = MESSAGE_TYPE.KRB_AS_REP.value tgt_rep['crealm'] = self.server.realm.to_string() tgt_rep['cname'] = self.client.to_asn1()[0] tgt_rep['ticket'] = Ticket.load(self.ticket.to_asn1()).native tgt_rep['enc-part'] = enc_part.native t = EncryptionKey(self.key.to_asn1()).native return tgt_rep, t
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list dictionary pair string string_start string_content string_end integer pair string string_start string_content string_end string string_start string_end expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end subscript call attribute attribute identifier identifier identifier argument_list integer expression_statement assignment subscript identifier string string_start string_content string_end attribute call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier attribute call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier return_statement expression_list identifier identifier
Returns the native format of an AS_REP message and the sessionkey in EncryptionKey native format
def force_disconnect_url(self, session_id, connection_id): url = ( self.api_url + '/v2/project/' + self.api_key + '/session/' + session_id + '/connection/' + connection_id ) return url
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier parenthesized_expression binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator attribute identifier identifier string string_start string_content string_end attribute identifier identifier string string_start string_content string_end identifier string string_start string_content string_end identifier return_statement identifier
this method returns the force disconnect url endpoint
def _is_writable(self): topology = self._get_topology() try: svr = topology.select_server(writable_server_selector) return svr.description.is_writable except ConnectionFailure: return False
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 identifier identifier argument_list identifier return_statement attribute attribute identifier identifier identifier except_clause identifier block return_statement false
Attempt to connect to a writable server, or return False.
def prettyprint(self): return json.dumps(self.asJSON(), sort_keys=True, indent=4, separators=(',', ': '))
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier true keyword_argument identifier integer keyword_argument identifier tuple string string_start string_content string_end string string_start string_content string_end
Return hypercat formatted prettily
def flush(self): for key in self.grouping_info.keys(): if self._should_flush(key): self._write_current_buffer_for_group_key(key)
module function_definition identifier parameters identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier
Ensure all remaining buffers are written.
def arcball_nearest_axis(point, axes): point = np.array(point, dtype=np.float64, copy=False) nearest = None mx = -1.0 for axis in axes: t = np.dot(arcball_constrain_to_axis(point, axis), point) if t > mx: nearest = axis mx = t return nearest
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier false expression_statement assignment identifier none expression_statement assignment identifier unary_operator float for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier identifier return_statement identifier
Return axis, which arc is nearest to point.
def read_handshake(self): msg = self.read_message() pid_dir, _conf, _context = msg["pidDir"], msg["conf"], msg["context"] open(join(pid_dir, str(self.pid)), "w").close() self.send_message({"pid": self.pid}) return _conf, _context
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier identifier expression_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute call identifier argument_list call identifier argument_list identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end identifier argument_list expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end attribute identifier identifier return_statement expression_list identifier identifier
Read and process an initial handshake message from Storm.
def cmd_distclean(self, *args): print("Warning: Your ndk, sdk and all other cached packages will be" " removed. Continue? (y/n)") if sys.stdin.readline().lower()[0] == 'y': self.info('Clean the global build directory') if not exists(self.global_buildozer_dir): return rmtree(self.global_buildozer_dir)
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator subscript call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list integer string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator call identifier argument_list attribute identifier identifier block return_statement expression_statement call identifier argument_list attribute identifier identifier
Clean the whole Buildozer environment.
def all_apps(self): cmd = ["heroku", "apps", "--json"] if self.team: cmd.extend(["--team", self.team]) return json.loads(self._result(cmd))
module function_definition identifier parameters 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 if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end attribute identifier identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier
Capture a backup of the app.
def remove_domain_user_role(request, user, role, domain=None): manager = keystoneclient(request, admin=True).roles return manager.revoke(role, user=user, domain=domain)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier attribute call identifier argument_list identifier keyword_argument identifier true identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier
Removes a given single role for a user from a domain.
def session_demo_danger_callback(da_children, session_state=None, **kwargs): 'Update output based just on state' if not session_state: return "Session state not yet available" return "Session state contains: " + str(session_state.get('bootstrap_demo_state', "NOTHING")) + " and the page render count is " + str(session_state.get("ind_use", "NOT SET"))
module function_definition identifier parameters identifier default_parameter identifier none dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end if_statement not_operator identifier block return_statement string string_start string_content string_end return_statement binary_operator binary_operator binary_operator string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end
Update output based just on state
def _bake_css(link): if "href" in link.attrs and (re.search("\.css$", link["href"])) or ("rel" in link.attrs and link["rel"] is "stylesheet") or ("type" in link.attrs and link["type"] is "text/css"): if re.match("https?://", link["href"]): css_data = _load_url(link["href"]).read() else: css_data = _load_file(link["href"]).read() link.clear() if USING_PYTHON2: link.string = css_data else: link.string = str(css_data) link.name = "style" del link["rel"] del link["href"]
module function_definition identifier parameters identifier block if_statement boolean_operator boolean_operator boolean_operator comparison_operator string string_start string_content string_end attribute identifier identifier parenthesized_expression call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end parenthesized_expression boolean_operator comparison_operator string string_start string_content string_end attribute identifier identifier comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end parenthesized_expression boolean_operator comparison_operator string string_start string_content string_end attribute identifier identifier comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block if_statement call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement assignment identifier call attribute call identifier argument_list subscript identifier string string_start string_content string_end identifier argument_list else_clause block expression_statement assignment identifier call attribute call identifier argument_list subscript identifier string string_start string_content string_end identifier argument_list expression_statement call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment attribute identifier identifier identifier else_clause block expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier string string_start string_content string_end delete_statement subscript identifier string string_start string_content string_end delete_statement subscript identifier string string_start string_content string_end
Takes a link element and turns it into an inline style link if applicable
def read_with_columns(func): def wrapper(*args, **kwargs): columns = kwargs.pop("columns", None) tab = func(*args, **kwargs) if columns is None: return tab return tab[columns] return _safe_wraps(wrapper, func)
module function_definition identifier parameters identifier block function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call identifier argument_list list_splat identifier dictionary_splat identifier if_statement comparison_operator identifier none block return_statement identifier return_statement subscript identifier identifier return_statement call identifier argument_list identifier identifier
Decorate a Table read method to use the ``columns`` keyword
def getSets(self): sets = lock_and_call( lambda: self._impl.getSets(), self._lock ) return EntityMap(sets, Set)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list lambda call attribute attribute identifier identifier identifier argument_list attribute identifier identifier return_statement call identifier argument_list identifier identifier
Get all the sets declared.
def populate(self, other): self.clear() self.update(other) self.reset_all_changes()
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Like update, but clears the contents first.
def show_dscp_marking_rule(self, rule, policy, body=None): return self.get(self.qos_dscp_marking_rule_path % (policy, rule), body=body)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier tuple identifier identifier keyword_argument identifier identifier
Shows information of a certain DSCP marking rule.
def download_file_helper(url, input_path): r = requests.get(url, stream=True) if r.status_code != 200: cli_log.error("Failed to download file: %s" % r.json()["message"]) local_full_path = get_download_dest(input_path, r.url) original_filename = os.path.split(local_full_path)[-1] with open(local_full_path, "wb") as f: click.echo("Downloading {}".format(original_filename), err=True) for chunk in r.iter_content(chunk_size=1024): if chunk: f.write(chunk) f.flush() pprint("Successfully downloaded %s to %s" % (original_filename, local_full_path), True)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end subscript call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list identifier unary_operator integer with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier true for_statement identifier call attribute identifier identifier argument_list keyword_argument identifier integer block if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier true
Manages the chunked downloading of a file given an url
def push_state(self, new_file=''): 'Saves the current error state to parse subpackages' self.subpackages.append({'detected_type': self.detected_type, 'message_tree': self.message_tree, 'resources': self.pushable_resources, 'metadata': self.metadata}) self.message_tree = {} self.pushable_resources = {} self.metadata = {'requires_chrome': False, 'listed': self.metadata.get('listed'), 'validator_version': validator.__version__} self.package_stack.append(new_file)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end block expression_statement string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier dictionary expression_statement assignment attribute identifier identifier dictionary expression_statement assignment attribute identifier identifier dictionary pair string string_start string_content string_end false pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Saves the current error state to parse subpackages
def FilterCollection(aff4_collection, offset, count=0, filter_value=None): if offset < 0: raise ValueError("Offset needs to be greater than or equal to zero") if count < 0: raise ValueError("Count needs to be greater than or equal to zero") count = count or sys.maxsize if filter_value: index = 0 items = [] for item in aff4_collection.GenerateItems(): serialized_item = item.SerializeToString() if re.search(re.escape(filter_value), serialized_item, re.I): if index >= offset: items.append(item) index += 1 if len(items) >= count: break else: items = list(itertools.islice(aff4_collection.GenerateItems(offset), count)) return items
module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier none block if_statement comparison_operator identifier integer block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier boolean_operator identifier attribute identifier identifier if_statement identifier block expression_statement assignment identifier integer expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier attribute identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier integer if_statement comparison_operator call identifier argument_list identifier identifier block break_statement else_clause block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier return_statement identifier
Filters an aff4 collection, getting count elements, starting at offset.
def name(self): if self._path: name = self._path if name[0] != '/': name = '/' + name return name return '/'
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier return_statement identifier return_statement string string_start string_content string_end
Group name following h5py convention.
async def send_data(self, data, addr): channel = self.peer_to_channel.get(addr) if channel is None: channel = self.channel_number self.channel_number += 1 self.channel_to_peer[channel] = addr self.peer_to_channel[addr] = channel await self.channel_bind(channel, addr) header = struct.pack('!HH', channel, len(data)) self._send(header + data)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier integer expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement await call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator identifier identifier
Send data to a remote host via the TURN server.
def register(self): self._do_selection_update = True if self.__my_selected_sm_id is not None: self.relieve_model(self._selected_sm_model) self.__my_selected_sm_id = self.model.selected_state_machine_id if self.__my_selected_sm_id is not None: self._selected_sm_model = self.model.state_machines[self.__my_selected_sm_id] self.observe_model(self._selected_sm_model) self.update() else: self._selected_sm_model = None self.state_row_iter_dict_by_state_path.clear() self.tree_store.clear() self._do_selection_update = False
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier true if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier subscript attribute attribute identifier identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list else_clause block expression_statement assignment attribute identifier identifier none expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier false
Change the state machine that is observed for new selected states to the selected state machine.
def uint64(self, val): try: self.msg += [pack("!Q", val)] except struct.error: raise ValueError("Expected uint64") return self
module function_definition identifier parameters identifier identifier block try_statement block expression_statement augmented_assignment attribute identifier identifier list call identifier argument_list string string_start string_content string_end identifier except_clause attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement identifier
append a frame containing a uint64