code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def check(cls, config, strict=False): result = {"errors": [], "warnings": []} validation_errors = validate_object(config, "poetry-schema") result["errors"] += validation_errors if strict: license = config.get("license") if license: try: license_by_id(license) except ValueError: result["errors"].append("{} is not a valid license".format(license)) if "dependencies" in config: python_versions = config["dependencies"]["python"] if python_versions == "*": result["warnings"].append( "A wildcard Python dependency is ambiguous. " "Consider specifying a more explicit one." ) if "scripts" in config: scripts = config["scripts"] for name, script in scripts.items(): if not isinstance(script, dict): continue extras = script["extras"] for extra in extras: if extra not in config["extras"]: result["errors"].append( 'Script "{}" requires extra "{}" which is not defined.'.format( name, extra ) ) return result
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier dictionary pair string string_start string_content string_end list pair string string_start string_content string_end list expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement augmented_assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block try_statement block expression_statement call identifier argument_list identifier except_clause identifier block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator 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 concatenated_string string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement not_operator call identifier argument_list identifier identifier block continue_statement expression_statement assignment identifier subscript identifier string string_start string_content string_end for_statement identifier identifier block 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 call attribute string string_start string_content string_end identifier argument_list identifier identifier return_statement identifier
Checks the validity of a configuration
def to_build_module(build_file_path: str, conf: Config) -> str: build_file = Path(build_file_path) root = Path(conf.project_root) return build_file.resolve().relative_to(root).parent.as_posix().strip('.')
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier return_statement call attribute call attribute attribute call attribute call attribute identifier identifier argument_list identifier argument_list identifier identifier identifier argument_list identifier argument_list string string_start string_content string_end
Return a normalized build module name for `build_file_path`.
def digit(m: Union[int, pd.Series], n: int) -> Union[int, pd.Series]: return (m // (10 ** n)) % 10
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type attribute identifier identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier type attribute identifier identifier block return_statement binary_operator parenthesized_expression binary_operator identifier parenthesized_expression binary_operator integer identifier integer
Returns the nth digit of each number in m.
def __load_asset_class(self, ac_id: int): db = self.__get_session() entity = db.query(dal.AssetClass).filter(dal.AssetClass.id == ac_id).first() return entity
module function_definition identifier parameters identifier typed_parameter identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute call attribute call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list comparison_operator attribute attribute identifier identifier identifier identifier identifier argument_list return_statement identifier
Loads Asset Class entity
def obj_to_string(obj): if not obj: return None elif isinstance(obj, bytes): return obj.decode('utf-8') elif isinstance(obj, basestring): return obj elif is_lazy_string(obj): return obj.value elif hasattr(obj, '__html__'): return obj.__html__() else: return str(obj)
module function_definition identifier parameters identifier block if_statement not_operator identifier block return_statement none elif_clause call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end elif_clause call identifier argument_list identifier identifier block return_statement identifier elif_clause call identifier argument_list identifier block return_statement attribute identifier identifier elif_clause call identifier argument_list identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list else_clause block return_statement call identifier argument_list identifier
Render an object into a unicode string if possible
def reload_me(*args, ignore_patterns=[]): command = [sys.executable, sys.argv[0]] command.extend(args) reload(*command, ignore_patterns=ignore_patterns)
module function_definition identifier parameters list_splat_pattern identifier default_parameter identifier list block expression_statement assignment identifier list attribute identifier identifier subscript attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list list_splat identifier keyword_argument identifier identifier
Reload currently running command with given args
def poll_crontab(self): polled_time = self._get_current_time() if polled_time.second >= 30: self.log.debug('Skip cronjobs in {}'.format(polled_time)) return for job in self._crontab: if not job.is_runnable(polled_time): continue job.do_action(self, polled_time)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement for_statement identifier attribute identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block continue_statement expression_statement call attribute identifier identifier argument_list identifier identifier
Check crontab and run target jobs
def make_url(self, container=None, resource=None, query_items=None): pth = [self._base_url] if container: pth.append(container.strip('/')) if resource: pth.append(resource) else: pth.append('') url = '/'.join(pth) if isinstance(query_items, (list, tuple, set)): url += RestHttp._list_query_str(query_items) query_items = None p = requests.PreparedRequest() p.prepare_url(url, query_items) return p.url
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier list attribute identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement call identifier argument_list identifier tuple identifier identifier identifier block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier none expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier return_statement attribute identifier identifier
Create a URL from the specified parts.
def getFixedStars(self): IDs = const.LIST_FIXED_STARS return ephem.getFixedStarList(IDs, self.date)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier attribute identifier identifier
Returns a list with all fixed stars.
def watch(filenames, callback, use_sudo=False): filenames = [filenames] if isinstance(filenames, basestring) else filenames old_md5 = {fn: md5sum(fn, use_sudo) for fn in filenames} yield for filename in filenames: if md5sum(filename, use_sudo) != old_md5[filename]: callback() return
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier conditional_expression list identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier dictionary_comprehension pair identifier call identifier argument_list identifier identifier for_in_clause identifier identifier expression_statement yield for_statement identifier identifier block if_statement comparison_operator call identifier argument_list identifier identifier subscript identifier identifier block expression_statement call identifier argument_list return_statement
Call callback if any of filenames change during the context
def remove_bookmark(self, name=None, time=None, chan=None): bookmarks = self.rater.find('bookmarks') for m in bookmarks: bookmark_name = m.find('bookmark_name').text bookmark_start = float(m.find('bookmark_start').text) bookmark_end = float(m.find('bookmark_end').text) bookmark_chan = m.find('bookmark_chan').text if bookmark_chan is None: bookmark_chan = '' if name is None: name_cond = True else: name_cond = bookmark_name == name if time is None: time_cond = True else: time_cond = (time[0] <= bookmark_end and time[1] >= bookmark_start) if chan is None: chan_cond = True else: chan_cond = bookmark_chan == chan if name_cond and time_cond and chan_cond: bookmarks.remove(m) self.save()
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_end if_statement comparison_operator identifier none block expression_statement assignment identifier true else_clause block expression_statement assignment identifier comparison_operator identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier true else_clause block expression_statement assignment identifier parenthesized_expression boolean_operator comparison_operator subscript identifier integer identifier comparison_operator subscript identifier integer identifier if_statement comparison_operator identifier none block expression_statement assignment identifier true else_clause block expression_statement assignment identifier comparison_operator identifier identifier if_statement boolean_operator boolean_operator identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
if you call it without arguments, it removes ALL the bookmarks.
def create_user(ctx): try: new_user = _create_user(ctx) new_user.save() log("Done") except KeyError: log('User already exists', lvl=warn)
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end except_clause identifier block expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier
Creates a new local user
def copy_assets(app, exception): if 'getLogger' in dir(logging): log = logging.getLogger(__name__).info else: log = app.info builders = get_compatible_builders(app) if exception: return if app.builder.name not in builders: if not app.config['sphinx_tabs_nowarn']: app.warn( 'Not copying tabs assets! Not compatible with %s builder' % app.builder.name) return log('Copying tabs assets') installdir = os.path.join(app.builder.outdir, '_static', 'sphinx_tabs') for path in FILES: source = resource_filename('sphinx_tabs', path) dest = os.path.join(installdir, path) destdir = os.path.dirname(dest) if not os.path.exists(destdir): os.makedirs(destdir) copyfile(source, dest)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end call identifier argument_list identifier block expression_statement assignment identifier attribute call attribute identifier identifier argument_list identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block return_statement if_statement comparison_operator attribute attribute identifier identifier identifier identifier block if_statement not_operator subscript attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier return_statement expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end identifier 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 if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list identifier identifier
Copy asset files to the output
def _categorize_file_diffs(self, file_diffs): candidate_feature_diffs = [] valid_init_diffs = [] inadmissible_files = [] for diff in file_diffs: valid, failures = check_from_class( ProjectStructureCheck, diff, self.project) if valid: if pathlib.Path(diff.b_path).parts[-1] != '__init__.py': candidate_feature_diffs.append(diff) logger.debug( 'Categorized {file} as CANDIDATE FEATURE MODULE' .format(file=diff.b_path)) else: valid_init_diffs.append(diff) logger.debug( 'Categorized {file} as VALID INIT MODULE' .format(file=diff.b_path)) else: inadmissible_files.append(diff) logger.debug( 'Categorized {file} as INADMISSIBLE; ' 'failures were {failures}' .format(file=diff.b_path, failures=failures)) logger.info( 'Admitted {} candidate feature{} ' 'and {} __init__ module{} ' 'and rejected {} file{}' .format(len(candidate_feature_diffs), make_plural_suffix(candidate_feature_diffs), len(valid_init_diffs), make_plural_suffix(valid_init_diffs), len(inadmissible_files), make_plural_suffix(inadmissible_files))) return candidate_feature_diffs, valid_init_diffs, inadmissible_files
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier attribute identifier identifier if_statement identifier block if_statement comparison_operator subscript attribute call attribute identifier identifier argument_list attribute identifier identifier identifier unary_operator integer string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier 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 call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier return_statement expression_list identifier identifier identifier
Partition file changes into admissible and inadmissible changes
def save_device_info(self): if self._workdir is not None: devices = [] for addr in self._devices: device = self._devices.get(addr) if not device.address.is_x10: aldb = {} for mem in device.aldb: rec = device.aldb[mem] if rec: aldbRec = {'memory': mem, 'control_flags': rec.control_flags.byte, 'group': rec.group, 'address': rec.address.id, 'data1': rec.data1, 'data2': rec.data2, 'data3': rec.data3} aldb[mem] = aldbRec deviceInfo = {'address': device.address.id, 'cat': device.cat, 'subcat': device.subcat, 'product_key': device.product_key, 'aldb_status': device.aldb.status.value, 'aldb': aldb} devices.append(deviceInfo) asyncio.ensure_future(self._write_saved_device_info(devices), loop=self._loop)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator attribute attribute identifier identifier identifier block expression_statement assignment identifier dictionary for_statement identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute attribute identifier 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 subscript identifier identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute attribute identifier 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 pair string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier
Save all device information to the device info file.
def create(self, request, *args, **kwargs): if not request.user.is_authenticated: raise exceptions.NotFound return super().create(request, *args, **kwargs)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement not_operator attribute attribute identifier identifier identifier block raise_statement attribute identifier identifier return_statement call attribute call identifier argument_list identifier argument_list identifier list_splat identifier dictionary_splat identifier
Only authenticated usesr can create new collections.
def build_data_availability(datasets_json): data_availability = None if 'availability' in datasets_json and datasets_json.get('availability'): data_availability = datasets_json.get('availability')[0].get('text') return data_availability
module function_definition identifier parameters identifier block expression_statement assignment identifier none if_statement boolean_operator comparison_operator string string_start string_content string_end identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end integer identifier argument_list string string_start string_content string_end return_statement identifier
Given datasets in JSON format, get the data availability from it if present
def extract_facts(rule): def _extract_facts(ce): if isinstance(ce, Fact): yield ce elif isinstance(ce, TEST): pass else: for e in ce: yield from _extract_facts(e) return set(_extract_facts(rule))
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement yield identifier elif_clause call identifier argument_list identifier identifier block pass_statement else_clause block for_statement identifier identifier block expression_statement yield call identifier argument_list identifier return_statement call identifier argument_list call identifier argument_list identifier
Given a rule, return a set containing all rule LHS facts.
def delete(ctx,tweet): if not ctx.obj['DRYRUN']: try: ctx.obj['TWEETLIST'].delete(tweet) except ValueError as e: click.echo("Now tweet was found with that id.") ctx.exit(1) else: click.echo("Not ran due to dry-run.")
module function_definition identifier parameters identifier identifier block if_statement not_operator subscript attribute identifier identifier string string_start string_content string_end block try_statement block expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Deletes a tweet from the queue with a given ID
def decode_list(self, integers): integers = list(np.squeeze(integers)) return self.encoders["inputs"].decode_list(integers)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier return_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list identifier
List of ints to list of str.
def calculate_A50(ctgsizes, cutoff=0, percent=50): ctgsizes = np.array(ctgsizes, dtype="int") ctgsizes = np.sort(ctgsizes)[::-1] ctgsizes = ctgsizes[ctgsizes >= cutoff] a50 = np.cumsum(ctgsizes) total = np.sum(ctgsizes) idx = bisect(a50, total * percent / 100.) l50 = ctgsizes[idx] n50 = idx + 1 return a50, l50, n50
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier subscript call attribute identifier identifier argument_list identifier slice unary_operator integer expression_statement assignment identifier subscript identifier comparison_operator identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier binary_operator binary_operator identifier identifier float expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier binary_operator identifier integer return_statement expression_list identifier identifier identifier
Given an array of contig sizes, produce A50, N50, and L50 values
def extern_project_multi(self, context_handle, val, field_str_ptr, field_str_len): c = self._ffi.from_handle(context_handle) obj = c.from_value(val[0]) field_name = self.to_py_str(field_str_ptr, field_str_len) return c.vals_buf(tuple(c.to_value(p) for p in getattr(obj, field_name)))
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list call identifier generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier identifier
Given a Key for `obj`, and a field name, project the field as a list of Keys.
def dependencies(self, images): for dep in self.commands.dependent_images: if not isinstance(dep, six.string_types): yield dep.name for image, _ in self.dependency_images(): yield image
module function_definition identifier parameters identifier identifier block for_statement identifier attribute attribute identifier identifier identifier block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block expression_statement yield attribute identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement yield identifier
Yield just the dependency images
def _is_parent(self, roleid1, roleid2): role2 = copy.deepcopy(self.flatten[roleid2]) role1 = copy.deepcopy(self.flatten[roleid1]) if role1 == role2: return False for b1 in role1['backends_groups']: if b1 not in role2['backends_groups']: return False for group in role1['backends_groups'][b1]: if group not in role2['backends_groups'][b1]: return False for b2 in role2['backends_groups']: if b2 not in role1['backends_groups']: return True for group in role2['backends_groups'][b2]: if group not in role1['backends_groups'][b2]: return True raise DumplicateRoleContent(roleid1, roleid2)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript attribute identifier identifier identifier if_statement comparison_operator identifier identifier block return_statement false for_statement identifier subscript identifier string string_start string_content string_end block if_statement comparison_operator identifier subscript identifier string string_start string_content string_end block return_statement false for_statement identifier subscript subscript identifier string string_start string_content string_end identifier block if_statement comparison_operator identifier subscript subscript identifier string string_start string_content string_end identifier block return_statement false for_statement identifier subscript identifier string string_start string_content string_end block if_statement comparison_operator identifier subscript identifier string string_start string_content string_end block return_statement true for_statement identifier subscript subscript identifier string string_start string_content string_end identifier block if_statement comparison_operator identifier subscript subscript identifier string string_start string_content string_end identifier block return_statement true raise_statement call identifier argument_list identifier identifier
Test if roleid1 is contained inside roleid2
def _ensure_scope(level, global_dict=None, local_dict=None, resolvers=(), target=None, **kwargs): return Scope(level + 1, global_dict=global_dict, local_dict=local_dict, resolvers=resolvers, target=target)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier tuple default_parameter identifier none dictionary_splat_pattern identifier block return_statement call identifier argument_list binary_operator identifier integer keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Ensure that we are grabbing the correct scope.
def retrieve_loadbalancer_status(self, loadbalancer, **_params): return self.get(self.lbaas_loadbalancer_path_status % (loadbalancer), params=_params)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier parenthesized_expression identifier keyword_argument identifier identifier
Retrieves status for a certain load balancer.
def getheader(self, which, use_hash=None, polish=True): header = getheader( which, use_hash=use_hash, target=self.target, no_tco=self.no_tco, strict=self.strict, ) if polish: header = self.polish(header) return header
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier true block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
Get a formatted header.
def _calculate_weights(self, this_samples, N): this_weights = self.weights.append(N)[:,0] if self.target_values is None: for i in range(N): tmp = self.target(this_samples[i]) - self.proposal.evaluate(this_samples[i]) this_weights[i] = _exp(tmp) else: this_target_values = self.target_values.append(N) for i in range(N): this_target_values[i] = self.target(this_samples[i]) tmp = this_target_values[i] - self.proposal.evaluate(this_samples[i]) this_weights[i] = _exp(tmp)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list identifier slice integer if_statement comparison_operator attribute identifier identifier none block for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list subscript identifier identifier call attribute attribute identifier identifier identifier argument_list subscript identifier identifier expression_statement assignment subscript identifier identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier call identifier argument_list identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list subscript identifier identifier expression_statement assignment identifier binary_operator subscript identifier identifier call attribute attribute identifier identifier identifier argument_list subscript identifier identifier expression_statement assignment subscript identifier identifier call identifier argument_list identifier
Calculate and save the weights of a run.
def OnInit(self): self.frame = SimpleSCardAppFrame( self.appname, self.apppanel, self.appstyle, self.appicon, self.pos, self.size) self.frame.Show(True) self.SetTopWindow(self.frame) return True
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list true expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement true
Create and display application frame.
def setHeader(self, fileHeader): self.technician = fileHeader["technician"] self.recording_additional = fileHeader["recording_additional"] self.patient_name = fileHeader["patientname"] self.patient_additional = fileHeader["patient_additional"] self.patient_code = fileHeader["patientcode"] self.equipment = fileHeader["equipment"] self.admincode = fileHeader["admincode"] self.gender = fileHeader["gender"] self.recording_start_time = fileHeader["startdate"] self.birthdate = fileHeader["birthdate"] self.update_header()
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list
Sets the file header
def _add(a, b, relicAdd): assertSameType(a,b) result = type(a)() relicAdd(byref(result), byref(a), byref(b)) return result
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list identifier identifier expression_statement assignment identifier call call identifier argument_list identifier argument_list expression_statement call identifier argument_list call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier return_statement identifier
Adds two elements @a,@b of the same type into @result using @relicAddFunc.
def _skip_lines(self, n): for i in range(n): self.line = next(self.output) return self.line
module function_definition identifier parameters identifier identifier block for_statement identifier call identifier argument_list identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier return_statement attribute identifier identifier
Skip a number of lines from the output.
def response(self): values = [] sum_values = 0. ma_coefs = self.ma_coefs ar_coefs = self.ar_coefs ma_order = self.ma_order for idx in range(len(self.ma.delays)): value = 0. if idx < ma_order: value += ma_coefs[idx] for jdx, ar_coef in enumerate(ar_coefs): zdx = idx-jdx-1 if zdx >= 0: value += ar_coef*values[zdx] values.append(value) sum_values += value return numpy.array(values)
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier float expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier for_statement identifier call identifier argument_list call identifier argument_list attribute attribute identifier identifier identifier block expression_statement assignment identifier float if_statement comparison_operator identifier identifier block expression_statement augmented_assignment identifier subscript identifier identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier binary_operator binary_operator identifier identifier integer if_statement comparison_operator identifier integer block expression_statement augmented_assignment identifier binary_operator identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier identifier return_statement call attribute identifier identifier argument_list identifier
Return the response to a standard dt impulse.
def termfinder(self, pattern): if Config.options.regex: flags = re.M | re.S | \ (0 if Config.options.case_sensitive else re.I) self.project.set_search_regex( pattern, flags=flags) else: self.project.set_search_string( pattern, ignore_case=not Config.options.case_sensitive) matches = [] while True: try: if matches: last = matches[-1] new = self.project.find_next(last + 1)[0] if new != last and new > last: matches.append(new) else: break else: matches.append(self.project.find_next()[0]) except StopIteration: break return matches
module function_definition identifier parameters identifier identifier block if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier binary_operator binary_operator attribute identifier identifier attribute identifier identifier line_continuation parenthesized_expression conditional_expression integer attribute attribute identifier identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier not_operator attribute attribute identifier identifier identifier expression_statement assignment identifier list while_statement true block try_statement block if_statement identifier block expression_statement assignment identifier subscript identifier unary_operator integer expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list binary_operator identifier integer integer if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block break_statement else_clause block expression_statement call attribute identifier identifier argument_list subscript call attribute attribute identifier identifier identifier argument_list integer except_clause identifier block break_statement return_statement identifier
Search srt in project for cells matching term.
def nonlocal_check(self, original, loc, tokens): return self.check_py("3", "nonlocal statement", original, loc, tokens)
module function_definition identifier parameters identifier identifier identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier identifier identifier
Check for Python 3 nonlocal statement.
def start_fileoutput (self): path = os.path.dirname(self.filename) try: if path and not os.path.isdir(path): os.makedirs(path) self.fd = self.create_fd() self.close_fd = True except IOError: msg = sys.exc_info()[1] log.warn(LOG_CHECK, "Could not open file %r for writing: %s\n" "Disabling log output of %s", self.filename, msg, self) self.fd = dummy.Dummy() self.is_active = False self.filename = None
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier try_statement block if_statement boolean_operator identifier not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier true except_clause identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list identifier concatenated_string string string_start string_content escape_sequence string_end string string_start string_content string_end attribute identifier identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier none
Start output to configured file.
def visit_classdef(self, node, parent, newstyle=None): node, doc = self._get_doc(node) newnode = nodes.ClassDef(node.name, doc, node.lineno, node.col_offset, parent) metaclass = None if PY3: for keyword in node.keywords: if keyword.arg == "metaclass": metaclass = self.visit(keyword, newnode).value break if node.decorator_list: decorators = self.visit_decorators(node, newnode) else: decorators = None newnode.postinit( [self.visit(child, newnode) for child in node.bases], [self.visit(child, newnode) for child in node.body], decorators, newstyle, metaclass, [ self.visit(kwd, newnode) for kwd in node.keywords if kwd.arg != "metaclass" ] if PY3 else [], ) return newnode
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier attribute identifier identifier attribute identifier identifier identifier expression_statement assignment identifier none if_statement identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier attribute call attribute identifier identifier argument_list identifier identifier identifier break_statement if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier else_clause block expression_statement assignment identifier none expression_statement call attribute identifier identifier argument_list list_comprehension call attribute identifier identifier argument_list identifier identifier for_in_clause identifier attribute identifier identifier list_comprehension call attribute identifier identifier argument_list identifier identifier for_in_clause identifier attribute identifier identifier identifier identifier identifier conditional_expression list_comprehension call attribute identifier identifier argument_list identifier identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator attribute identifier identifier string string_start string_content string_end identifier list return_statement identifier
visit a ClassDef node to become astroid
def restore(self, url): self._run( [ "heroku", "pg:backups:restore", "{}".format(url), "DATABASE_URL", "--app", self.name, "--confirm", self.name, ] )
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end attribute identifier identifier string string_start string_content string_end attribute identifier identifier
Restore the remote database from the URL of a backup.
def _domain_event_balloon_change_cb(conn, domain, actual, opaque): _salt_send_domain_event(opaque, conn, domain, opaque['event'], { 'actual': actual })
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call identifier argument_list identifier identifier identifier subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end identifier
Domain balloon change events handler
def safe_lshift(a, b): if b > MAX_SHIFT: raise RuntimeError("Invalid left shift, max left shift is {}".format(MAX_SHIFT)) return a << b
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement binary_operator identifier identifier
safe version of lshift
def combine(self, a, b): for l in (a, b): for x in l: yield x
module function_definition identifier parameters identifier identifier identifier block for_statement identifier tuple identifier identifier block for_statement identifier identifier block expression_statement yield identifier
A generator that combines two iterables.
def handleArgs(self, event): if self.djsettings: os.environ['DJANGO_SETTINGS_MODULE'] = self.djsettings if self.djconfig: os.environ['DJANGO_CONFIGURATION'] = self.djconfig try: from configurations import importer importer.install() except ImportError: pass from django.conf import settings try: from south.management.commands import patch_for_test_db_setup patch_for_test_db_setup() except ImportError: pass
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier try_statement block import_from_statement dotted_name identifier dotted_name identifier expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement import_from_statement dotted_name identifier identifier dotted_name identifier try_statement block import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement call identifier argument_list except_clause identifier block pass_statement
Nose2 hook for the handling the command line args
def _clone(self): clone = self.__class__(self._entity_cls, criteria=self._criteria, offset=self._offset, limit=self._limit, order_by=self._order_by) return clone
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier return_statement identifier
Return a copy of the current QuerySet.
def measures(self): from ambry.valuetype.core import ROLE return [c for c in self.columns if c.role == ROLE.MEASURE]
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier identifier dotted_name identifier return_statement list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator attribute identifier identifier attribute identifier identifier
Iterate over all measures
def mainview(request, **criterias): 'View that handles all page requests.' view_data = initview(request) wrap = lambda func: ft.partial(func, _view_data=view_data, **criterias) return condition( etag_func=wrap(cache_etag), last_modified_func=wrap(cache_last_modified) )\ (_mainview)(request, view_data, **criterias)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier lambda lambda_parameters identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier dictionary_splat identifier return_statement call call call identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list identifier line_continuation argument_list identifier argument_list identifier identifier dictionary_splat identifier
View that handles all page requests.
def retrieve(self): data = self.resource(self.id).get() self.data = data return data
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier return_statement identifier
Retrieves all data for this document and saves it.
def load(self, dtype_out_time, dtype_out_vert=False, region=False, plot_units=False, mask_unphysical=False): msg = ("Loading data from disk for object={0}, dtype_out_time={1}, " "dtype_out_vert={2}, and region=" "{3}".format(self, dtype_out_time, dtype_out_vert, region)) logging.info(msg + ' ({})'.format(ctime())) try: data = self.data_out[dtype_out_time] except (AttributeError, KeyError): try: data = self._load_from_disk(dtype_out_time, dtype_out_vert, region=region) except IOError: data = self._load_from_tar(dtype_out_time, dtype_out_vert) self._update_data_out(data, dtype_out_time) if mask_unphysical: data = self.var.mask_unphysical(data) if plot_units: data = self.var.to_plot_units(data, dtype_vert=dtype_out_vert) return data
module function_definition identifier parameters identifier identifier default_parameter identifier false default_parameter identifier false default_parameter identifier false default_parameter identifier false block expression_statement assignment identifier parenthesized_expression 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 identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list try_statement block expression_statement assignment identifier subscript attribute identifier identifier identifier except_clause tuple identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier except_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier return_statement identifier
Load the data from the object if possible or from disk.
def choose_font(self, font=None): fmt_widget = self.parent() if font is None: if self.current_font: font, ok = QFontDialog.getFont( self.current_font, fmt_widget, 'Select %s font' % self.fmto_name, QFontDialog.DontUseNativeDialog) else: font, ok = QFontDialog.getFont(fmt_widget) if not ok: return self.current_font = font properties = self.load_properties() properties.update(self.qfont_to_artist_props(font)) fmt_widget.set_obj(properties) self.refresh()
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block if_statement attribute identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier identifier binary_operator string string_start string_content string_end attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block return_statement expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Choose a font for the label through a dialog
def fill_with_defaults(process_input, input_schema): for field_schema, fields, path in iterate_schema(process_input, input_schema): if 'default' in field_schema and field_schema['name'] not in fields: dict_dot(process_input, path, field_schema['default'])
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier identifier call identifier argument_list identifier identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement call identifier argument_list identifier identifier subscript identifier string string_start string_content string_end
Fill empty optional fields in input with default values.
def _onMessage(self, ws, message): try: data = json.loads(message)['NotificationContainer'] log.debug('Alert: %s %s %s', *data) if self._callback: self._callback(data) except Exception as err: log.error('AlertListener Msg Error: %s', err)
module function_definition identifier parameters identifier identifier identifier block try_statement block expression_statement assignment identifier subscript call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end list_splat identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Called when websocket message is recieved.
def serial(self): asnint = libcrypto.X509_get_serialNumber(self.cert) bio = Membio() libcrypto.i2a_ASN1_INTEGER(bio.bio, asnint) return int(str(bio), 16)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier return_statement call identifier argument_list call identifier argument_list identifier integer
Serial number of certificate as integer
def service_table(format='simple', authenticated=False): if authenticated: all_services = ExchangeUniverse.get_authenticated_services() else: all_services = ALL_SERVICES if format == 'html': linkify = lambda x: "<a href='{0}' target='_blank'>{0}</a>".format(x) else: linkify = lambda x: x ret = [] for service in sorted(all_services, key=lambda x: x.service_id): ret.append([ service.service_id, service.__name__, linkify(service.api_homepage.format( domain=service.domain, protocol=service.protocol )), ", ".join(service.supported_cryptos or []) ]) return tabulate(ret, headers=['ID', 'Name', 'URL', 'Supported Currencies'], tablefmt=format)
module function_definition identifier parameters default_parameter identifier string string_start string_content string_end default_parameter identifier false block if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier lambda lambda_parameters identifier call attribute string string_start string_content string_end identifier argument_list identifier else_clause block expression_statement assignment identifier lambda lambda_parameters identifier identifier expression_statement assignment identifier list for_statement identifier call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list list attribute identifier identifier attribute identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list boolean_operator attribute identifier identifier list return_statement call identifier argument_list identifier keyword_argument identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier
Returns a string depicting all services currently installed.
def _extra_regression_kwargs(self): omega_switch_test = 0.019 extra_args = [] extra_args.append({ 'omega0': 5e-3, 'PN_approximant': 'SpinTaylorT4', 'PN_dt': 0.1, 'PN_spin_order': 7, 'PN_phase_order': 7, 'omega_switch': omega_switch_test, }) extra_args.append({ 'omega0': 6e-3, 'PN_approximant': 'SpinTaylorT1', 'PN_dt': 0.5, 'PN_spin_order': 5, 'PN_phase_order': 7, 'omega_switch': omega_switch_test, }) extra_args.append({ 'omega0': 7e-3, 'PN_approximant': 'SpinTaylorT2', 'PN_dt': 1, 'PN_spin_order': 7, 'PN_phase_order': 5, 'omega_switch': omega_switch_test, }) extra_args.append({'omega0': 3e-2}) extra_args.append({'omega0': 5e-2}) return extra_args
module function_definition identifier parameters identifier block expression_statement assignment identifier float expression_statement assignment identifier list expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end float pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end float pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end float pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end float pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end float pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end float expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end float return_statement identifier
List of additional kwargs to use in regression tests.
def _extract_info_from_useragent(user_agent): parsed_string = user_agent_parser.Parse(user_agent) return { 'os': parsed_string.get('os', {}).get('family'), 'browser': parsed_string.get('user_agent', {}).get('family'), 'browser_version': parsed_string.get('user_agent', {}).get('major'), 'device': parsed_string.get('device', {}).get('family'), }
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement dictionary pair string string_start string_content string_end call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end
Extract extra informations from user.
def from_json(buffer): buffer = to_bytes(buffer) return Index._from_ptr(rustcall( _lib.lsm_index_from_json, buffer, len(buffer)))
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier identifier call identifier argument_list identifier
Creates an index from a JSON string.
def _get_uid(name): if getpwnam is None or name is None: return None try: result = getpwnam(name) except KeyError: result = None if result is not None: return result[2] return None
module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator identifier none comparison_operator identifier none block return_statement none try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block expression_statement assignment identifier none if_statement comparison_operator identifier none block return_statement subscript identifier integer return_statement none
Returns an uid, given a user name.
def format(self, action): item = { 'id': self.get_uri(action), 'url': self.get_url(action), 'verb': action.verb, 'published': rfc3339_date(action.timestamp), 'actor': self.format_actor(action), 'title': text_type(action), } if action.description: item['content'] = action.description if action.target: item['target'] = self.format_target(action) if action.action_object: item['object'] = self.format_action_object(action) return item
module function_definition identifier parameters identifier identifier block 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 call attribute identifier identifier argument_list identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call identifier argument_list attribute identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier pair string string_start string_content string_end call identifier argument_list identifier if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier return_statement identifier
Returns a formatted dictionary for the given action.
def extract_entity(found): obj = dict() for prop in found.entity.property: obj[prop.name] = prop.value.string_value return obj
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier attribute attribute identifier identifier identifier block expression_statement assignment subscript identifier attribute identifier identifier attribute attribute identifier identifier identifier return_statement identifier
Copy found entity to a dict.
def cancel_queue(self): q = list(self.queue) self.queue = [] log.debug("Canceling requests: {}".format(q)) for req in q: req.response = APIServerNotRunningErrorResponse() for req in q: req.signal()
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier list expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier for_statement identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list
Cancel all requests in the queue so we can exit.
def quit(self, *args, **kwargs): self.stop() self._stop = True self.msleep(2* int(1e3 / self.settings['update frequency'])) super(Plant, self).quit(*args, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list binary_operator integer call identifier argument_list binary_operator float subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list list_splat identifier dictionary_splat identifier
quit the instrument thread
def render(self, path): return ReactComponent( self.layout, self.src_file, self.component_id, props=self.props, static_path=path)
module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier
Render the component to a javascript file.
def create_hierarchy(self, *args, **kwargs): return Hierarchy( self._provider_manager, self._get_provider_session('hierarchy_admin_session').create_hierarchy(*args, **kwargs), self._runtime, self._proxy)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call identifier argument_list attribute identifier identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list list_splat identifier dictionary_splat identifier attribute identifier identifier attribute identifier identifier
Pass through to provider HierarchyAdminSession.create_hierarchy
def _cast_to_type(self, value): if isinstance(value, str) or value is None: return value return str(value)
module function_definition identifier parameters identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier comparison_operator identifier none block return_statement identifier return_statement call identifier argument_list identifier
Convert the value to its string representation
def sanitize_cloud(cloud: str) -> str: if len(cloud) < 4: return cloud if not cloud[3].isdigit() and cloud[3] != '/': if cloud[3] == 'O': cloud = cloud[:3] + '0' + cloud[4:] else: cloud = cloud[:3] + cloud[4:] + cloud[3] return cloud
module function_definition identifier parameters typed_parameter identifier type identifier type identifier block if_statement comparison_operator call identifier argument_list identifier integer block return_statement identifier if_statement boolean_operator not_operator call attribute subscript identifier integer identifier argument_list comparison_operator subscript identifier integer string string_start string_content string_end block if_statement comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement assignment identifier binary_operator binary_operator subscript identifier slice integer string string_start string_content string_end subscript identifier slice integer else_clause block expression_statement assignment identifier binary_operator binary_operator subscript identifier slice integer subscript identifier slice integer subscript identifier integer return_statement identifier
Fix rare cloud layer issues
def to_json(self): result = super(Locale, self).to_json() result.update({ 'code': self.code, 'name': self.name, 'fallbackCode': self.fallback_code, 'optional': self.optional, 'contentDeliveryApi': self.content_delivery_api, 'contentManagementApi': self.content_management_api }) return result
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list expression_statement call attribute 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 pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier return_statement identifier
Returns the JSON representation of the locale.
def color(colors, export_type, output_file=None): all_colors = flatten_colors(colors) template_name = get_export_type(export_type) template_file = os.path.join(MODULE_DIR, "templates", template_name) output_file = output_file or os.path.join(CACHE_DIR, template_name) if os.path.isfile(template_file): template(all_colors, template_file, output_file) logging.info("Exported %s.", export_type) else: logging.warning("Template '%s' doesn't exist.", export_type)
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end identifier expression_statement assignment identifier boolean_operator identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Export a single template file.
def migrateDown(self): subStore = self.store.parent.getItemByID(self.store.idInParent) ssph = self.store.parent.findUnique( _SubSchedulerParentHook, _SubSchedulerParentHook.subStore == subStore, default=None) if ssph is not None: te = self.store.parent.findUnique(TimedEvent, TimedEvent.runnable == ssph, default=None) if te is not None: te.deleteFromStore() ssph.deleteFromStore()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier comparison_operator attribute identifier identifier identifier keyword_argument identifier none if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier comparison_operator attribute identifier identifier identifier keyword_argument identifier none if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Remove the components in the site store for this SubScheduler.
def _calculate_areas(self, label): heights = np.maximum(0, label[:, 3] - label[:, 1]) widths = np.maximum(0, label[:, 2] - label[:, 0]) return heights * widths
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer binary_operator subscript identifier slice integer subscript identifier slice integer expression_statement assignment identifier call attribute identifier identifier argument_list integer binary_operator subscript identifier slice integer subscript identifier slice integer return_statement binary_operator identifier identifier
Calculate areas for multiple labels
def mongodb_auth_uri(self, hosts): parts = ['mongodb://'] if self.login: parts.append(self.login) if self.password: parts.append(':' + self.password) parts.append('@') parts.append(hosts + '/') if self.login: parts.append('?authSource=' + self.auth_source) if self.x509_extra_user: parts.append('&authMechanism=MONGODB-X509') return ''.join(parts)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list string string_start string_content string_end if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute string string_start string_end identifier argument_list identifier
Get a connection string with all info necessary to authenticate.
def clear(self): layout = self.layout() for index in reversed(range(layout.count())): item = layout.takeAt(index) try: item.widget().deleteLater() except AttributeError: item = None
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier try_statement block expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list except_clause identifier block expression_statement assignment identifier none
Removes all child widgets.
def marshmallow_loader(schema_class): def json_loader(): request_json = request.get_json() context = {} pid_data = request.view_args.get('pid_value') if pid_data: pid, _ = pid_data.data context['pid'] = pid result = schema_class(context=context).load(request_json) if result.errors: raise MarshmallowErrors(result.errors) return result.data return json_loader
module function_definition identifier parameters identifier block function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute call identifier argument_list keyword_argument identifier identifier identifier argument_list identifier if_statement attribute identifier identifier block raise_statement call identifier argument_list attribute identifier identifier return_statement attribute identifier identifier return_statement identifier
Marshmallow loader for JSON requests.
def pool_delete(storage_pool, logger): path = etree.fromstring(storage_pool.XMLDesc(0)).find('.//path').text volumes_delete(storage_pool, logger) try: storage_pool.destroy() except libvirt.libvirtError: logger.exception("Unable to delete storage pool.") try: if os.path.exists(path): shutil.rmtree(path) except EnvironmentError: logger.exception("Unable to delete storage pool folder.")
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute call attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list integer identifier argument_list string string_start string_content string_end identifier expression_statement call identifier argument_list identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end try_statement block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Storage Pool deletion, removes all the created disk images within the pool and the pool itself.
def func_globals_inject(func, **overrides): if hasattr(func, 'im_func'): func = func.__func__ func_globals = func.__globals__ injected_func_globals = [] overridden_func_globals = {} for override in overrides: if override in func_globals: overridden_func_globals[override] = func_globals[override] else: injected_func_globals.append(override) func_globals.update(overrides) yield func_globals.update(overridden_func_globals) for injected in injected_func_globals: del func_globals[injected]
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier list expression_statement assignment identifier dictionary for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier subscript identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement yield expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block delete_statement subscript identifier identifier
Override specific variables within a function's global context.
def run_dict_method(self, request): state_method_name, args, kwargs = ( request[Msgs.info], request[Msgs.args], request[Msgs.kwargs], ) with self.mutate_safely(): self.reply(getattr(self.state, state_method_name)(*args, **kwargs))
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier tuple subscript identifier attribute identifier identifier subscript identifier attribute identifier identifier subscript identifier attribute identifier identifier with_statement with_clause with_item call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call call identifier argument_list attribute identifier identifier identifier argument_list list_splat identifier dictionary_splat identifier
Execute a method on the state ``dict`` and reply with the result.
def _get_calls(data, cnv_only=False): cnvs_supported = set(["cnvkit", "battenberg"]) out = {} for sv in data.get("sv", []): if not cnv_only or sv["variantcaller"] in cnvs_supported: out[sv["variantcaller"]] = sv return out
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier call identifier argument_list list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier dictionary for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end list block if_statement boolean_operator not_operator identifier comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement assignment subscript identifier subscript identifier string string_start string_content string_end identifier return_statement identifier
Retrieve calls, organized by name, to use for heterogeneity analysis.
def gone_online(stream): while True: packet = yield from stream.get() session_id = packet.get('session_key') if session_id: user_owner = get_user_from_session(session_id) if user_owner: logger.debug('User ' + user_owner.username + ' gone online') online_opponents = list(filter(lambda x: x[1] == user_owner.username, ws_connections)) online_opponents_sockets = [ws_connections[i] for i in online_opponents] yield from fanout_message(online_opponents_sockets, {'type': 'gone-online', 'usernames': [user_owner.username]}) else: pass else: pass
module function_definition identifier parameters identifier block while_statement true block expression_statement assignment identifier yield call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call identifier argument_list lambda lambda_parameters identifier comparison_operator subscript identifier integer attribute identifier identifier identifier expression_statement assignment identifier list_comprehension subscript identifier identifier for_in_clause identifier identifier expression_statement yield call identifier argument_list 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 list attribute identifier identifier else_clause block pass_statement else_clause block pass_statement
Distributes the users online status to everyone he has dialog with
def update_band_description(self): self.clear_further_steps() selected_band = self.selected_band() statistics = self.parent.layer.dataProvider().bandStatistics( selected_band, QgsRasterBandStats.All, self.parent.layer.extent(), 0) band_description = tr( 'This band contains data from {min_value} to {max_value}').format( min_value=statistics.minimumValue, max_value=statistics.maximumValue ) self.lblDescribeBandSelector.setText(band_description)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list identifier argument_list identifier attribute identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list integer expression_statement assignment identifier call attribute call identifier argument_list string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Helper to update band description.
def write_generator_cost_data(self, file): file.write("\n%%%% generator cost data\n") file.write("%%\t1\tstartup\tshutdown\tn\tx1\ty1\t...\txn\tyn\n") file.write("%%\t2\tstartup\tshutdown\tn\tc(n-1)\t...\tc0\n") file.write("%sgencost = [\n" % self._prefix) for generator in self.case.generators: n = len(generator.p_cost) template = '\t%d\t%g\t%g\t%d' for _ in range(n): template = '%s\t%%g' % template template = '%s;\n' % template if generator.pcost_model == PW_LINEAR: t = 2 c = [v for pc in generator.p_cost for v in pc] elif generator.pcost_model == POLYNOMIAL: t = 1 c = list(generator.p_cost) else: raise vals = [t, generator.c_startup, generator.c_shutdown, n] + c file.write(template % tuple(vals)) file.write("];\n")
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence string_end expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end attribute identifier identifier for_statement identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence string_end for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier binary_operator string string_start string_content escape_sequence string_end identifier expression_statement assignment identifier binary_operator string string_start string_content escape_sequence string_end identifier if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier integer expression_statement assignment identifier list_comprehension identifier for_in_clause identifier attribute identifier identifier for_in_clause identifier identifier elif_clause comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier integer expression_statement assignment identifier call identifier argument_list attribute identifier identifier else_clause block raise_statement expression_statement assignment identifier binary_operator list identifier attribute identifier identifier attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end
Writes generator cost data to file.
def _compute_v1_factor(self, imt): if imt.name == "SA": t = imt.period if t <= 0.50: v1 = 1500.0 elif t > 0.50 and t <= 1.0: v1 = np.exp(8.0 - 0.795 * np.log(t / 0.21)) elif t > 1.0 and t < 2.0: v1 = np.exp(6.76 - 0.297 * np.log(t)) else: v1 = 700.0 elif imt.name == "PGA": v1 = 1500.0 else: v1 = 862.0 return v1
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier float block expression_statement assignment identifier float elif_clause boolean_operator comparison_operator identifier float comparison_operator identifier float block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator float binary_operator float call attribute identifier identifier argument_list binary_operator identifier float elif_clause boolean_operator comparison_operator identifier float comparison_operator identifier float block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator float binary_operator float call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier float elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier float else_clause block expression_statement assignment identifier float return_statement identifier
Compute and return v1 factor, equation 6, page 77.
def post_outcome_request(self): if not self.has_required_attributes(): raise InvalidLTIConfigError( 'OutcomeRequest does not have all required attributes') consumer = oauth2.Consumer(key=self.consumer_key, secret=self.consumer_secret) client = oauth2.Client(consumer) monkey_patch_headers = True monkey_patch_function = None if monkey_patch_headers: import httplib2 http = httplib2.Http normalize = http._normalize_headers def my_normalize(self, headers): print("My Normalize", headers) ret = normalize(self, headers) if 'authorization' in ret: ret['Authorization'] = ret.pop('authorization') print("My Normalize", ret) return ret http._normalize_headers = my_normalize monkey_patch_function = normalize response, content = client.request( self.lis_outcome_service_url, 'POST', body=self.generate_request_xml(), headers={'Content-Type': 'application/xml'}) if monkey_patch_headers and monkey_patch_function: import httplib2 http = httplib2.Http http._normalize_headers = monkey_patch_function self.outcome_response = OutcomeResponse.from_post_response(response, content) return self.outcome_response
module function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier true expression_statement assignment identifier none if_statement identifier block import_statement dotted_name identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier identifier 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 expression_statement call identifier argument_list string string_start string_content string_end identifier return_statement identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier dictionary pair string string_start string_content string_end string string_start string_content string_end if_statement boolean_operator identifier identifier block import_statement dotted_name identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier identifier return_statement attribute identifier identifier
POST an OAuth signed request to the Tool Consumer.
def xpathNewParserContext(self, str): ret = libxml2mod.xmlXPathNewParserContext(str, self._o) if ret is None:raise xpathError('xmlXPathNewParserContext() failed') __tmp = xpathParserContext(_obj=ret) return __tmp
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier return_statement identifier
Create a new xmlXPathParserContext
def request_time(self, req): r = time.time() self._time_result.set_value(r) return ("ok", r)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement tuple string string_start string_content string_end identifier
Return the current time in ms since the Unix Epoch.
def __notify(self, sender, content): if self.handle_message is not None: try: self.handle_message(sender, content) except Exception as ex: logging.exception("Error calling message listener: %s", ex)
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator attribute identifier identifier none block try_statement block expression_statement call attribute identifier identifier argument_list identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Calls back listener when a message is received
def simple_parse_file(filename: str) -> Feed: pairs = ( (rss.parse_rss_file, _adapt_rss_channel), (atom.parse_atom_file, _adapt_atom_feed), (json_feed.parse_json_feed_file, _adapt_json_feed) ) return _simple_parse(pairs, filename)
module function_definition identifier parameters typed_parameter identifier type identifier type identifier block expression_statement assignment identifier tuple tuple attribute identifier identifier identifier tuple attribute identifier identifier identifier tuple attribute identifier identifier identifier return_statement call identifier argument_list identifier identifier
Parse an Atom, RSS or JSON feed from a local file.
def position(self, node): rv = 'line %d' % node.lineno if self.name is not None: rv += ' in ' + repr(self.name) return rv
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end call identifier argument_list attribute identifier identifier return_statement identifier
Return a human readable position for the node.
def stop(self) -> None: self._shutdown = True self._protocol.close() self.cancel_pending_tasks()
module function_definition identifier parameters identifier type none block expression_statement assignment attribute identifier identifier true expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Stop monitoring the base unit.
def prepare(self): SCons.Node.Node.prepare(self) if self.get_state() != SCons.Node.up_to_date: if self.exists(): if self.is_derived() and not self.precious: self._rmv_existing() else: try: self._createDir() except SCons.Errors.StopError as drive: raise SCons.Errors.StopError("No drive `{}' for target `{}'.".format(drive, self))
module function_definition identifier parameters identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier if_statement comparison_operator call attribute identifier identifier argument_list attribute attribute identifier identifier identifier block if_statement call attribute identifier identifier argument_list block if_statement boolean_operator call attribute identifier identifier argument_list not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list else_clause block try_statement block expression_statement call attribute identifier identifier argument_list except_clause as_pattern attribute attribute identifier identifier identifier as_pattern_target identifier block raise_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier
Prepare for this file to be created.
def modify_subroutine(subroutine): subroutine['use'] = {'shtools': {'map': {subroutine['name']: subroutine['name']}, 'only': 1}} for varname, varattribs in subroutine['vars'].items(): if varname == subroutine['name']: subroutine['vars']['py' + varname] = subroutine['vars'].pop(varname) varname = 'py' + varname if has_assumed_shape(varattribs): make_explicit(subroutine, varname, varattribs) subroutine['name'] = 'py' + subroutine['name']
module function_definition identifier parameters identifier block expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary pair subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end integer for_statement pattern_list identifier identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list block if_statement comparison_operator identifier subscript identifier string string_start string_content string_end block expression_statement assignment subscript subscript identifier string string_start string_content string_end binary_operator string string_start string_content string_end identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier binary_operator string string_start string_content string_end identifier if_statement call identifier argument_list identifier block expression_statement call identifier argument_list identifier identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end binary_operator string string_start string_content string_end subscript identifier string string_start string_content string_end
loops through variables of a subroutine and modifies them
def baltree(ntips, treeheight=1.0): if ntips % 2: raise ToytreeError("balanced trees must have even number of tips.") rtree = toytree.tree() rtree.treenode.add_child(name="0") rtree.treenode.add_child(name="1") for i in range(2, ntips): node = return_small_clade(rtree.treenode) node.add_child(name=node.name) node.add_child(name=str(i)) node.name = None idx = 0 for node in rtree.treenode.traverse("postorder"): if node.is_leaf(): node.name = str(idx) idx += 1 tre = toytree.tree(rtree.write(tree_format=9)) tre = tre.mod.make_ultrametric() self = tre.mod.node_scale_root_height(treeheight) self._coords.update() return self
module function_definition identifier parameters identifier default_parameter identifier float block if_statement binary_operator identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end for_statement identifier call identifier argument_list integer identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier none expression_statement assignment identifier integer for_statement identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block if_statement call attribute identifier identifier argument_list block expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement augmented_assignment identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list return_statement identifier
Returns a balanced tree topology.
def _rnd_date(start, end): return date.fromordinal(random.randint(start.toordinal(), end.toordinal()))
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list
Internal random date generator.
def gravatar(self, size=20): default = "mm" gravatar_url = "//www.gravatar.com/avatar/" + hashlib.md5(self.email.lower()).hexdigest() + "?" gravatar_url += urllib.urlencode({'d': default, 's': str(size)}) return gravatar_url
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end call attribute call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier argument_list string string_start string_content string_end expression_statement augmented_assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call identifier argument_list identifier return_statement identifier
Construct a gravatar image address for the user
def divides(self): acc = [0] for s in self.chunks: acc.append(acc[-1] + len(s)) return acc
module function_definition identifier parameters identifier block expression_statement assignment identifier list integer for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator subscript identifier unary_operator integer call identifier argument_list identifier return_statement identifier
List of indices of divisions between the constituent chunks.
def _createGeometry(self, session, spatialReferenceID): session.flush() for link in self.getFluvialLinks(): nodes = link.nodes nodeCoordinates = [] for node in nodes: coordinates = '{0} {1} {2}'.format(node.x, node.y, node.elevation) nodeCoordinates.append(coordinates) wktPoint = 'POINT Z ({0})'.format(coordinates) statement = self._getUpdateGeometrySqlString(geometryID=node.id, tableName=node.tableName, spatialReferenceID=spatialReferenceID, wktString=wktPoint) session.execute(statement) wktLineString = 'LINESTRING Z ({0})'.format(', '.join(nodeCoordinates)) statement = self._getUpdateGeometrySqlString(geometryID=link.id, tableName=link.tableName, spatialReferenceID=spatialReferenceID, wktString=wktLineString) session.execute(statement)
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Create PostGIS geometric objects
def resolve(self, pubID, sysID): ret = libxml2mod.xmlACatalogResolve(self._o, pubID, sysID) return ret
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier identifier return_statement identifier
Do a complete resolution lookup of an External Identifier
def _from_jd_equinox(jd): jd = trunc(jd) + 0.5 equinoxe = premier_da_la_annee(jd) an = gregorian.from_jd(equinoxe)[0] - YEAR_EPOCH mois = trunc((jd - equinoxe) / 30.) + 1 jour = int((jd - equinoxe) % 30) + 1 return (an, mois, jour)
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator call identifier argument_list identifier float expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator subscript call attribute identifier identifier argument_list identifier integer identifier expression_statement assignment identifier binary_operator call identifier argument_list binary_operator parenthesized_expression binary_operator identifier identifier float integer expression_statement assignment identifier binary_operator call identifier argument_list binary_operator parenthesized_expression binary_operator identifier identifier integer integer return_statement tuple identifier identifier identifier
Calculate the FR day using the equinox as day 1
def _validate_iso8601_string(self, value): ISO8601_REGEX = r'(\d{4})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})([+-](\d{2})\:(\d{2})|Z)' if re.match(ISO8601_REGEX, value): return value else: raise ValueError('{} must be in ISO8601 format.'.format(value))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end if_statement call attribute identifier identifier argument_list identifier identifier block return_statement identifier else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Return the value or raise a ValueError if it is not a string in ISO8601 format.
def new_term(self, term, value, **kwargs): tc = self.doc.get_term_class(term.lower()) t = tc(term, value, doc=self.doc, parent=None, section=self).new_children(**kwargs) self.doc.add_term(t) return t
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call attribute call identifier argument_list identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier none keyword_argument identifier identifier identifier argument_list dictionary_splat identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
Create a new root-level term in this section
def matchSubset(**kwargs): ret = [] for m in self.matches: allMatched = True for k,v in iteritems(kwargs): mVal = getattr(m, k) try: if v == mVal or v in mVal: continue except Exception: pass allMatched = False break if allMatched: ret.append(m) return ret
module function_definition identifier parameters dictionary_splat_pattern identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier true for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier identifier try_statement block if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier identifier block continue_statement except_clause identifier block pass_statement expression_statement assignment identifier false break_statement if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
extract matches from player's entire match history given matching criteria kwargs
def visit_DictComp(self, node: ast.DictComp) -> Any: result = self._execute_comprehension(node=node) for generator in node.generators: self.visit(generator.iter) self.recomputed_values[node] = result return result
module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement identifier
Compile the dictionary comprehension as a function and call it.
def restore_configuration_files(self): try: for f in self._configuration_to_save: config_file = os.path.join(self._config_dir, f) backup_file = os.path.join(self._data_dir, f + '.backup') if not os.path.isfile(config_file): if os.path.isfile(backup_file): shutil.copy(backup_file, config_file) elif f == 'pg_ident.conf': open(config_file, 'w').close() except IOError: logger.exception('unable to restore configuration files from backup')
module function_definition identifier parameters identifier block try_statement block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier binary_operator identifier string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement call attribute call identifier argument_list identifier string string_start string_content string_end identifier argument_list except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
restore a previously saved postgresql.conf