code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def describe_partitioner(self, ): self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_describe_partitioner() return d
module function_definition identifier parameters identifier block expression_statement augmented_assignment attribute identifier identifier integer expression_statement assignment identifier assignment subscript attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement identifier
returns the partitioner used by this cluster
def check_config_integrity(self): tasks_by_hash = {_hash_task(t): t for t in self.config_tasks} if len(tasks_by_hash) != len(self.config_tasks): raise Exception("Fatal error: there was a hash duplicate in the scheduled tasks config.") for h, task in tasks_by_hash.items(): if task.get("monthday") and not task.get("dailytime"): raise Exception("Fatal error: you can't schedule a task with 'monthday' and without 'dailytime' (%s)" % h) if task.get("weekday") and not task.get("dailytime"): raise Exception("Fatal error: you can't schedule a task with 'weekday' and without 'dailytime' (%s)" % h) if not task.get("monthday") and not task.get("weekday") and not task.get("dailytime") and not task.get("interval"): raise Exception("Fatal error: scheduler must be specified one of monthday,weekday,dailytime,interval. (%s)" % h)
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary_comprehension pair call identifier argument_list identifier identifier for_in_clause identifier attribute identifier identifier if_statement comparison_operator call identifier argument_list identifier call identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end not_operator call attribute identifier identifier argument_list string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end not_operator call attribute identifier identifier argument_list string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement boolean_operator boolean_operator boolean_operator not_operator call attribute identifier identifier argument_list string string_start string_content string_end not_operator call attribute identifier identifier argument_list string string_start string_content string_end not_operator call attribute identifier identifier argument_list string string_start string_content string_end not_operator call attribute identifier identifier argument_list string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
Make sure the scheduler config is valid
def parse_compound(self): compound_tag = Compound() for token in self.collect_tokens_until('CLOSE_COMPOUND'): item_key = token.value if token.type not in ('NUMBER', 'STRING', 'QUOTED_STRING'): raise self.error(f'Expected compound key but got {item_key!r}') if token.type == 'QUOTED_STRING': item_key = self.unquote_string(item_key) if self.next().current_token.type != 'COLON': raise self.error(f'Expected colon but got ' f'{self.current_token.value!r}') self.next() compound_tag[item_key] = self.parse() return compound_tag
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block raise_statement call attribute identifier identifier argument_list string string_start string_content interpolation identifier type_conversion string_end if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute attribute call attribute identifier identifier argument_list identifier identifier string string_start string_content string_end block raise_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start interpolation attribute attribute identifier identifier identifier type_conversion string_end expression_statement call attribute identifier identifier argument_list expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list return_statement identifier
Parse a compound from the token stream.
def domain_whois(self, domain): uri = self._uris["whois_domain"].format(domain) resp_json = self.get_parse(uri) return resp_json
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
Gets whois information for a domain
def capture_exception(fn): def wrapped(*args): try: return fn(*args) except Exception as e: return e return wrapped
module function_definition identifier parameters identifier block function_definition identifier parameters list_splat_pattern identifier block try_statement block return_statement call identifier argument_list list_splat identifier except_clause as_pattern identifier as_pattern_target identifier block return_statement identifier return_statement identifier
decorator that catches and returns an exception from wrapped function
def from_string(cls, line, ignore_bad_cookies=False, ignore_bad_attributes=True): "Construct a Cookie object from a line of Set-Cookie header data." cookie_dict = parse_one_response( line, ignore_bad_cookies=ignore_bad_cookies, ignore_bad_attributes=ignore_bad_attributes) if not cookie_dict: return None return cls.from_dict( cookie_dict, ignore_bad_attributes=ignore_bad_attributes)
module function_definition identifier parameters identifier identifier default_parameter identifier false default_parameter identifier true block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement not_operator identifier block return_statement none return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
Construct a Cookie object from a line of Set-Cookie header data.
def __zipped_files_data(self): files = {} with zipfile.ZipFile(self.__zip_file) as thezip: for zipinfo in thezip.infolist(): if zipinfo.filename.endswith('metadata/icons.json'): with thezip.open(zipinfo) as compressed_file: files['icons.json'] = compressed_file.read() elif zipinfo.filename.endswith('.ttf'): name = os.path.basename(zipinfo.filename) tokens = name.split('-') style = tokens[1] if style in self.FA_STYLES: with thezip.open(zipinfo) as compressed_file: files[style] = compressed_file.read() assert all(style in files for style in self.FA_STYLES), \ 'Not all FA styles found! Update code is broken.' assert 'icons.json' in files, 'icons.json not found! Update code is broken.' return files
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list attribute identifier identifier as_pattern_target identifier block for_statement identifier call attribute identifier identifier argument_list block if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier as_pattern_target identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list elif_clause call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript identifier integer if_statement comparison_operator identifier attribute identifier identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier as_pattern_target identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list assert_statement call identifier generator_expression comparison_operator identifier identifier for_in_clause identifier attribute identifier identifier string string_start string_content string_end assert_statement comparison_operator string string_start string_content string_end identifier string string_start string_content string_end return_statement identifier
Get a dict of all files of interest from the FA release zipfile.
def reduce_l1(attrs, inputs, proto_obj): new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'}) new_attrs = translation_utils._add_extra_attributes(new_attrs, {'ord' : 1}) return 'norm', new_attrs, inputs
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary pair string string_start string_content string_end integer return_statement expression_list string string_start string_content string_end identifier identifier
Reduce input tensor by l1 normalization.
def clean_cookie(self): if not self.is_cookie_necessary: return self headers = self.request.get('headers', {}) cookies = SimpleCookie(headers['Cookie']) for k, v in cookies.items(): new_cookie = '; '.join( [i.OutputString() for i in cookies.values() if i != v]) new_request = deepcopy(self.request) new_request['headers']['Cookie'] = new_cookie self._add_task('Cookie', k, new_request) return self
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end dictionary expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list_comprehension call attribute identifier identifier argument_list for_in_clause identifier call attribute identifier identifier argument_list if_clause comparison_operator identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier return_statement identifier
Only clean the cookie from headers and return self.
def _find_keys(self, identity='image'): prefix = add_prefix('', identity) raw_keys = self._find_keys_raw(prefix) or [] for raw_key in raw_keys: yield del_prefix(raw_key)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list string string_start string_end identifier expression_statement assignment identifier boolean_operator call attribute identifier identifier argument_list identifier list for_statement identifier identifier block expression_statement yield call identifier argument_list identifier
Finds and returns all keys for identity,
def extra(request, provider): identity = request.session.get('identity', None) if not identity: raise Http404 if request.method == "POST": form = str_to_class(settings.EXTRA_FORM)(request.POST) if form.is_valid(): user = form.save(request, identity, provider) del request.session['identity'] if not settings.ACTIVATION_REQUIRED: user = auth.authenticate(identity=identity, provider=provider) if user: auth.login(request, user) return redirect(request.session.pop('next_url', settings.LOGIN_REDIRECT_URL)) else: messages.warning(request, lang.ACTIVATION_REQUIRED_TEXT) return redirect(settings.ACTIVATION_REDIRECT_URL) else: initial = request.session['extra'] form = str_to_class(settings.EXTRA_FORM)(initial=initial) return render_to_response('netauth/extra.html', {'form': form }, context_instance=RequestContext(request))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end none if_statement not_operator identifier block raise_statement identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call call identifier argument_list attribute identifier identifier argument_list attribute identifier identifier if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier delete_statement subscript attribute identifier identifier string string_start string_content string_end if_statement not_operator attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier identifier return_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier return_statement call identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call call identifier argument_list attribute identifier identifier argument_list keyword_argument identifier identifier return_statement call identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end identifier keyword_argument identifier call identifier argument_list identifier
Handle registration of new user with extra data for profile
def _get_primary_type(ttypes, parent, logstream=stderr): if len(ttypes) > 1: if logstream: message = '[tag::transcript::primary_transcript]' message += ' WARNING: feature {:s}'.format(parent.slug) message += ' has multiple associated transcript types' message += ' {}'.format(ttypes) print(message, file=logstream) if 'mRNA' not in ttypes: message = ( 'cannot resolve multiple transcript types if "mRNA" is' ' not one of those types {}'.format(ttypes) ) raise Exception(message) ttypes = ['mRNA'] return ttypes[0]
module function_definition identifier parameters identifier identifier default_parameter identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block if_statement identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list identifier keyword_argument identifier identifier if_statement comparison_operator string string_start string_content string_end identifier 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 identifier argument_list identifier raise_statement call identifier argument_list identifier expression_statement assignment identifier list string string_start string_content string_end return_statement subscript identifier integer
Check for multiple transcript types and, if possible, select one.
def toString(self) -> str: return ' '.join(attr.html for attr in self._dict.values())
module function_definition identifier parameters identifier type identifier block return_statement call attribute string string_start string_content string_end identifier generator_expression attribute identifier identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list
Return string representation of collections.
def reapply_sampling_strategies(self): check_sensor = self._inspecting_client.future_check_sensor for sensor_name, strategy in list(self._strategy_cache.items()): try: sensor_exists = yield check_sensor(sensor_name) if not sensor_exists: self._logger.warn('Did not set strategy for non-existing sensor {}' .format(sensor_name)) continue result = yield self.set_sampling_strategy(sensor_name, strategy) except KATCPSensorError as e: self._logger.error('Error reapplying strategy for sensor {0}: {1!s}' .format(sensor_name, e)) except Exception: self._logger.exception('Unhandled exception reapplying strategy for ' 'sensor {}'.format(sensor_name), exc_info=True)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier for_statement pattern_list identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block try_statement block expression_statement assignment identifier yield call identifier argument_list identifier if_statement not_operator identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier continue_statement expression_statement assignment identifier yield call attribute identifier identifier argument_list identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier except_clause identifier block expression_statement call attribute attribute identifier 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 identifier keyword_argument identifier true
Reapply all sensor strategies using cached values
def ask_password(*question: Token) -> str: tokens = get_ask_tokens(question) info(*tokens) answer = read_password() return answer
module function_definition identifier parameters typed_parameter list_splat_pattern identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list list_splat identifier expression_statement assignment identifier call identifier argument_list return_statement identifier
Ask the user to enter a password.
def resources(self): used_resources = self._used_resources() ret = collections.defaultdict(dict) for resource, total in six.iteritems(self._resources): ret[resource]['total'] = total if resource in used_resources: ret[resource]['used'] = used_resources[resource] else: ret[resource]['used'] = 0 return ret
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment subscript subscript identifier identifier string string_start string_content string_end identifier if_statement comparison_operator identifier identifier block expression_statement assignment subscript subscript identifier identifier string string_start string_content string_end subscript identifier identifier else_clause block expression_statement assignment subscript subscript identifier identifier string string_start string_content string_end integer return_statement identifier
get total resources and available ones
def warning(self, msg, *args, **kwargs): self._log("WARNING", msg, args, kwargs)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier
Log 'msg % args' with the warning severity level
def encode_value_using_ma(message_attribute: int, value: Optional[Union[int, float]]) -> int: if message_attribute == MA_TX3AC_100A: if value is None: return 0xfe return int(value) elif message_attribute == MA_TX3AC_10A: if value is None: return 0xfe return int(value * 10) else: if value is None: return 0x80 elif value < 0: return 0x100 + int(value) return int(value)
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type generic_type identifier type_parameter type generic_type identifier type_parameter type identifier type identifier type identifier block if_statement comparison_operator identifier identifier block if_statement comparison_operator identifier none block return_statement integer return_statement call identifier argument_list identifier elif_clause comparison_operator identifier identifier block if_statement comparison_operator identifier none block return_statement integer return_statement call identifier argument_list binary_operator identifier integer else_clause block if_statement comparison_operator identifier none block return_statement integer elif_clause comparison_operator identifier integer block return_statement binary_operator integer call identifier argument_list identifier return_statement call identifier argument_list identifier
Encode special sensor value using the message attribute.
def homogeneous_poisson(self): return (1. - 2. / 3. * self.g_vrh / self.k_vrh) / \ (2. + 2. / 3. * self.g_vrh / self.k_vrh)
module function_definition identifier parameters identifier block return_statement binary_operator parenthesized_expression binary_operator float binary_operator binary_operator binary_operator float float attribute identifier identifier attribute identifier identifier line_continuation parenthesized_expression binary_operator float binary_operator binary_operator binary_operator float float attribute identifier identifier attribute identifier identifier
returns the homogeneous poisson ratio
def paragraph_spans(self): if not self.is_tagged(PARAGRAPHS): self.tokenize_paragraphs() return self.spans(PARAGRAPHS)
module function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier
The list of spans representing ``paragraphs`` layer elements.
def _build_url(*args, **kwargs) -> str: resource_url = API_RESOURCES_URLS for key in args: resource_url = resource_url[key] if kwargs: resource_url = resource_url.format(**kwargs) return urljoin(URL, resource_url)
module function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier type identifier block expression_statement assignment identifier identifier for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier return_statement call identifier argument_list identifier identifier
Return a valid url.
def transformer_base_v3(): hparams = transformer_base_v2() hparams.optimizer_adam_beta2 = 0.997 hparams.learning_rate_schedule = ( "constant*linear_warmup*rsqrt_decay*rsqrt_hidden_size") hparams.learning_rate_constant = 2.0 return hparams
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier float expression_statement assignment attribute identifier identifier parenthesized_expression string string_start string_content string_end expression_statement assignment attribute identifier identifier float return_statement identifier
Base parameters for Transformer model.
def lookup(ctx, number, comment, cache): phone = PhoneNumber(number, comment=comment) info('{0} | {1}'.format(phone.number, ctx.obj['config']['lookups'].keys())) if phone.number in ctx.obj['config']['lookups']: info('{0} is already cached:'.format(phone.number)) info(jsonify(ctx.obj['config']['lookups'][phone.number])) return data = phone.lookup() info('carrier = {0}'.format(phone.carrier)) info('type = {0}'.format(phone.type)) info('cache = {0}'.format(cache)) if cache: ctx.obj['config']['lookups'][phone.number] = phone.raw with open(CONFIG_FILE, 'wb') as cfg: cfg.write(json.dumps(ctx.obj['config'], indent=2))
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier call attribute subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list if_statement comparison_operator attribute identifier identifier subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call identifier argument_list call identifier argument_list subscript subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end attribute identifier identifier return_statement expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier if_statement identifier block expression_statement assignment subscript subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end attribute identifier identifier attribute identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier integer
Get the carrier and country code for a phone number
def emit_metadata_for_region_py(self, region, region_filename, module_prefix): terrobj = self.territory[region] with open(region_filename, "w") as outfile: prnt(_REGION_METADATA_PROLOG % {'region': terrobj.identifier(), 'module': module_prefix}, file=outfile) prnt("PHONE_METADATA_%s = %s" % (terrobj.identifier(), terrobj), file=outfile)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call identifier argument_list binary_operator identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end identifier keyword_argument identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
Emit Python code generating the metadata for the given region
def readBimFile(basefilename): bim_fn = basefilename+'.bim' rv = SP.loadtxt(bim_fn,delimiter='\t',usecols = (0,3),dtype=int) return rv
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content escape_sequence string_end keyword_argument identifier tuple integer integer keyword_argument identifier identifier return_statement identifier
Helper fuinction that reads bim files
def combobox_set_model_from_list(cb, items): cb.clear() model = gtk.ListStore(str) for i in items: model.append([i]) cb.set_model(model) if type(cb) == gtk.ComboBoxEntry: cb.set_text_column(0) elif type(cb) == gtk.ComboBox: cell = gtk.CellRendererText() cb.pack_start(cell, True) cb.add_attribute(cell, 'text', 0)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list list identifier expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list integer elif_clause comparison_operator call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier true expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end integer
Setup a ComboBox or ComboBoxEntry based on a list of strings.
def _setse(self, i): if i > 0: u = (i * 2) - 1 else: u = -2 * i self._setue(u)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier integer integer else_clause block expression_statement assignment identifier binary_operator unary_operator integer identifier expression_statement call attribute identifier identifier argument_list identifier
Initialise bitstring with signed exponential-Golomb code for integer i.
def import_from_string(full_class_name): s = full_class_name.split('.') class_name = s[-1] module_name = full_class_name[:-len(class_name)-1] module = importlib.import_module(module_name) klass = getattr(module, class_name) return klass
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript identifier unary_operator integer expression_statement assignment identifier subscript identifier slice binary_operator unary_operator call identifier argument_list identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement identifier
return a class based on it's full class name
def _show_psrs(): sep = os.linesep types = "Supported types: " + ", ".join(API.list_types()) cids = "IDs: " + ", ".join(c for c, _ps in API.list_by_cid()) x_vs_ps = [" %s: %s" % (x, ", ".join(p.cid() for p in ps)) for x, ps in API.list_by_extension()] exts = "File extensions:" + sep + sep.join(x_vs_ps) _exit_with_output(sep.join([types, exts, cids]))
module function_definition identifier parameters block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier generator_expression identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier list_comprehension binary_operator string string_start string_content string_end tuple identifier call attribute string string_start string_content string_end identifier generator_expression call attribute identifier identifier argument_list for_in_clause identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list call attribute identifier identifier argument_list list identifier identifier identifier
Show list of info of parsers available
def info_1(*tokens: Token, **kwargs: Any) -> None: info(bold, blue, "::", reset, *tokens, **kwargs)
module function_definition identifier parameters typed_parameter list_splat_pattern identifier type identifier typed_parameter dictionary_splat_pattern identifier type identifier type none block expression_statement call identifier argument_list identifier identifier string string_start string_content string_end identifier list_splat identifier dictionary_splat identifier
Print an important informative message
def visit_num(self, node, parent): return nodes.Const( node.n, getattr(node, "lineno", None), getattr(node, "col_offset", None), parent, )
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier call identifier argument_list identifier string string_start string_content string_end none call identifier argument_list identifier string string_start string_content string_end none identifier
visit a Num node by returning a fresh instance of Const
def specialRound(number, rounding): temp = 0 if rounding == 0: temp = number else: temp = round(number, rounding) if temp % 1 == 0: return int(temp) else: return float(temp)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier integer if_statement comparison_operator identifier integer block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement comparison_operator binary_operator identifier integer integer block return_statement call identifier argument_list identifier else_clause block return_statement call identifier argument_list identifier
A method used to round a number in the way that UsefulUtils rounds.
def load_projects(self): server_config = Config.instance().get_section_config("Server") projects_path = os.path.expanduser(server_config.get("projects_path", "~/GNS3/projects")) os.makedirs(projects_path, exist_ok=True) try: for project_path in os.listdir(projects_path): project_dir = os.path.join(projects_path, project_path) if os.path.isdir(project_dir): for file in os.listdir(project_dir): if file.endswith(".gns3"): try: yield from self.load_project(os.path.join(project_dir, file), load=False) except (aiohttp.web_exceptions.HTTPConflict, NotImplementedError): pass except OSError as e: log.error(str(e))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true try_statement block for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block for_statement identifier call attribute identifier identifier argument_list identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block try_statement block expression_statement yield call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier false except_clause tuple attribute attribute identifier identifier identifier identifier block pass_statement except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier
Preload the list of projects from disk
def _set_element_property(parent_to_parse, element_path, prop_name, value): element = get_element(parent_to_parse) if element is None: return None if element_path and not element_exists(element, element_path): element = insert_element(element, 0, element_path) if not isinstance(value, string_types): value = u'' setattr(element, prop_name, value) return element
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block return_statement none if_statement boolean_operator identifier not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier integer identifier if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier string string_start string_end expression_statement call identifier argument_list identifier identifier identifier return_statement identifier
Assigns the value to the parsed parent element and then returns it
def kernel(self): stop_words = [ y.lower() for y in self.abbreviations.values() + self.filler_words ] kernel = ' '.join([ x for x in self.expand().split() if x.lower() not in stop_words ]) kernel = re.sub(r'\s*United States', '', kernel) return kernel
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list for_in_clause identifier binary_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list_comprehension identifier for_in_clause identifier call attribute call attribute identifier identifier argument_list identifier argument_list if_clause comparison_operator call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier return_statement identifier
The 'kernel' is an attempt to get at just the most pithy words in the name
def to_file_mode(self): for message_no in range(len(self.messages)): self.__to_file(message_no)
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list call identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
Write all the messages to files
def _won_in(self): if not self._summary['finished']: return starting_age = self._summary['settings']['starting_age'].lower() if starting_age == 'post imperial': starting_age = 'imperial' ages_reached = set([starting_age]) for player in self._summary['players']: for age, reached in player['ages'].items(): if reached: ages_reached.add(age) ages = ['imperial', 'castle', 'feudal', 'dark'] for age in ages: if age in ages_reached: return age
module function_definition identifier parameters identifier block if_statement not_operator subscript attribute identifier identifier string string_start string_content string_end block return_statement expression_statement assignment identifier call attribute subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list list identifier for_statement identifier subscript attribute identifier identifier string string_start string_content string_end block for_statement pattern_list identifier identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list block if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block if_statement comparison_operator identifier identifier block return_statement identifier
Get age the game was won in.
def _get_goslimids_norel(self, dagslim): go_slims = set() go2obj = self.gosubdag.go2obj for goid in dagslim: goobj = go2obj[goid] if not goobj.relationship: go_slims.add(goobj.id) return go_slims
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier attribute attribute identifier identifier identifier for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
Get all GO slim GO IDs that do not have a relationship.
def cli(ctx, project_dir): exit_code = SCons(project_dir).verify() ctx.exit(exit_code)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier
Verify the verilog code.
def list_commands(self, ctx): rv = defaults.list_commands(ctx) if self._commands_dir: for filename in os.listdir(self._commands_dir): if _is_command_file(filename) and filename[:-3] not in rv: rv.append(filename[:-3]) rv.sort() return rv
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement attribute identifier identifier block for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement boolean_operator call identifier argument_list identifier comparison_operator subscript identifier slice unary_operator integer identifier block expression_statement call attribute identifier identifier argument_list subscript identifier slice unary_operator integer expression_statement call attribute identifier identifier argument_list return_statement identifier
List commands from the commands dir and default group
def close(self): if self._device is not None: ibsta = self._lib.ibonl(self._device, 0) self._check_status(ibsta) self._device = None
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier none
Closes the gpib transport.
def _normalize_branch_node(self, node): not_blank_items_count = sum(1 for x in range(17) if node[x]) assert not_blank_items_count >= 1 if not_blank_items_count > 1: self._encode_node(node) return node not_blank_index = [i for i, item in enumerate(node) if item][0] if not_blank_index == 16: o = [pack_nibbles(with_terminator([])), node[16]] self._encode_node(o) return o sub_node = self._decode_to_node(node[not_blank_index]) sub_node_type = self._get_node_type(sub_node) if is_key_value_type(sub_node_type): self._delete_node_storage(sub_node) new_key = [not_blank_index] + \ unpack_to_nibbles(sub_node[0]) o = [pack_nibbles(new_key), sub_node[1]] self._encode_node(o) return o if sub_node_type == NODE_TYPE_BRANCH: o = [pack_nibbles([not_blank_index]), node[not_blank_index]] self._encode_node(o) return o assert False
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier generator_expression integer for_in_clause identifier call identifier argument_list integer if_clause subscript identifier identifier assert_statement comparison_operator identifier integer if_statement comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier expression_statement assignment identifier subscript list_comprehension identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier if_clause identifier integer if_statement comparison_operator identifier integer block expression_statement assignment identifier list call identifier argument_list call identifier argument_list list subscript identifier integer expression_statement call attribute identifier identifier argument_list identifier return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator list identifier line_continuation call identifier argument_list subscript identifier integer expression_statement assignment identifier list call identifier argument_list identifier subscript identifier integer expression_statement call attribute identifier identifier argument_list identifier return_statement identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier list call identifier argument_list list identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier assert_statement false
node should have only one item changed
def remove_server(self, name): for i in self._server_list: if i['key'] == name: try: self._server_list.remove(i) logger.debug("Remove server %s from the list" % name) logger.debug("Updated servers list (%s servers): %s" % ( len(self._server_list), self._server_list)) except ValueError: logger.error( "Cannot remove server %s from the list" % name)
module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple call identifier argument_list attribute identifier identifier attribute identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier
Remove a server from the dict.
def close(self): self.fire(JSONStreamer.DOC_END_EVENT) self._stack = None self._parser.close()
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier none expression_statement call attribute attribute identifier identifier identifier argument_list
Closes the streamer which causes a `DOC_END_EVENT` to be fired and frees up memory used by yajl
def _collected_label(collect, label): if not collect.__name__.startswith('<'): return label + ' ' + collect.__name__ else: return label
module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block return_statement binary_operator binary_operator identifier string string_start string_content string_end attribute identifier identifier else_clause block return_statement identifier
Label of a collected column.
def canonical_name(sgf_name): sgf_name = os.path.normpath(sgf_name) assert sgf_name.endswith('.sgf'), sgf_name sgf_name = sgf_name[:-4] with_folder = re.search(r'/([^/]*/eval/.*)', sgf_name) if with_folder: return with_folder.group(1) return os.path.basename(sgf_name)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier assert_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier subscript identifier slice unary_operator integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block return_statement call attribute identifier identifier argument_list integer return_statement call attribute attribute identifier identifier identifier argument_list identifier
Keep filename and some date folders
def which(cmd, path="PATH"): if os.path.exists(cmd): return cmd if cmd[0] == '/': return None for segment in os.getenv(path).split(":"): program = os.path.normpath(os.path.join(segment, cmd)) if os.path.exists(program): return program return None
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block if_statement call attribute attribute identifier identifier identifier argument_list identifier block return_statement identifier if_statement comparison_operator subscript identifier integer string string_start string_content string_end block return_statement none for_statement identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block return_statement identifier return_statement none
Find cmd on PATH.
def from_module(self, path): bundles = PythonLoader(path).load_bundles() for name in bundles: self.register(name, bundles[name])
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier subscript identifier identifier
Register bundles from a Python module
def __install_ssh_config(self, config): if not config.is_affirmative('use_global_ssh', default="no"): ssh_config_injection = self._build_ssh_config(config) if not os.path.exists(ssh_config_path): if self.injections.in_noninjected_file(ssh_config_path, "Host %s" % config.get('host')): if config.is_affirmative('override'): self.injections.inject(ssh_config_path, ssh_config_injection) else: self.injections.inject(ssh_config_path, ssh_config_injection) else: self.injections.inject(ssh_config_path, ssh_config_injection) self.injections.commit()
module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier 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 binary_operator string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Install the ssh configuration
def _get_release_params(): release_name = request.form.get('release_name') utils.jsonify_assert(release_name, 'release_name required') release_number = request.form.get('release_number', type=int) utils.jsonify_assert(release_number is not None, 'release_number required') return release_name, release_number
module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list comparison_operator identifier none string string_start string_content string_end return_statement expression_list identifier identifier
Gets the release params from the current request.
async def get_alarms(self): url = '{}{}'.format(self.base_url, self.endpoint) try: with async_timeout.timeout(5, loop=self._loop): response = await self._session.get(url) _LOGGER.debug( "Response from Netdata: %s", response.status) data = await response.text() _LOGGER.debug(data) self.alarms = data except (asyncio.TimeoutError, aiohttp.ClientError, socket.gaierror): _LOGGER.error("Can not load data from Netdata") raise exceptions.NetdataConnectionError()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier try_statement block with_statement with_clause with_item call attribute identifier identifier argument_list integer keyword_argument identifier attribute identifier identifier block expression_statement assignment identifier await call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier await call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier except_clause tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end raise_statement call attribute identifier identifier argument_list
Get alarms for a Netdata instance.
def readline(self) -> bytes: assert self._state == ConnectionState.created, \ 'Expect conn created. Got {}.'.format(self._state) with self._close_timer.with_timeout(): data = yield from \ self.run_network_operation( self.reader.readline(), close_timeout=self._timeout, name='Readline') return data
module function_definition identifier parameters identifier type identifier block assert_statement comparison_operator attribute identifier identifier attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier with_statement with_clause with_item call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier yield line_continuation call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end return_statement identifier
Read a line of data.
def host_context(func): "Sets the context of the setting to the current host" @wraps(func) def decorator(*args, **kwargs): hosts = get_hosts_settings() with settings(**hosts[env.host]): return func(*args, **kwargs) return decorator
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list with_statement with_clause with_item call identifier argument_list dictionary_splat subscript identifier attribute identifier identifier block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier return_statement identifier
Sets the context of the setting to the current host
def metadata(self): from sqlalchemy import MetaData metadata = MetaData(bind=self.engine, schema=self._schema) metadata.reflect(self.engine) return metadata
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
Return an SqlAlchemy MetaData object, bound to the engine.
def automeshgrid( x, y, step=0.02, xstep=None, ystep=None, pad=0.5, xpad=None, ypad=None ): if xpad is None: xpad = pad if xstep is None: xstep = step if ypad is None: ypad = pad if ystep is None: ystep = step xmin = x.min() - xpad xmax = x.max() + xpad ymin = y.min() - ypad ymax = y.max() + ypad return meshgrid(xmin, xmax, step, ymin, ymax, ystep)
module function_definition identifier parameters identifier identifier default_parameter identifier float default_parameter identifier none default_parameter identifier none default_parameter identifier float default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier identifier identifier identifier identifier identifier
Make a meshgrid, inferred from data.
def parse_leehom_logs(self, f): regexes = { 'total': r"Total reads[\s\:]+(\d+)", 'merged_trimming': r"Merged \(trimming\)\s+(\d+)", 'merged_overlap': r"Merged \(overlap\)\s+(\d+)", 'kept': r"Kept PE/SR\s+(\d+)", 'trimmed': r"Trimmed SR\s+(\d+)", 'adapter_dimers_chimeras': r"Adapter dimers/chimeras\s+(\d+)", 'failed_key': r"Failed Key\s+(\d+)" } parsed_data = dict() for l in f['f']: for k, r in regexes.items(): match = re.search(r, l) if match: parsed_data[k] = int(match.group(1)) return parsed_data
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list for_statement identifier subscript identifier string string_start string_content string_end block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement assignment subscript identifier identifier call identifier argument_list call attribute identifier identifier argument_list integer return_statement identifier
Go through log file looking for leehom output
def stop(self): if self._timer: self._timer.stop() self._timer.deleteLater()
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list
Stop the current timer if there is one and cancel the async call.
def add_scope(self, scope_type, scope_name, scope_start, is_method=False): if self._curr is not None: self._curr['end'] = scope_start - 1 self._curr = { 'type': scope_type, 'name': scope_name, 'start': scope_start, 'end': scope_start } if is_method and self._positions: last = self._positions[-1] if not 'methods' in last: last['methods'] = [] last['methods'].append(self._curr) else: self._positions.append(self._curr)
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier false block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end binary_operator identifier integer expression_statement assignment attribute identifier identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier if_statement boolean_operator identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier unary_operator integer if_statement not_operator comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end list expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list attribute identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
we identified a scope and add it to positions.
def length(self, t0=0, t1=1, error=None, min_depth=None): return abs(self.end - self.start)*(t1-t0)
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer default_parameter identifier none default_parameter identifier none block return_statement binary_operator call identifier argument_list binary_operator attribute identifier identifier attribute identifier identifier parenthesized_expression binary_operator identifier identifier
returns the length of the line segment between t0 and t1.
def unstruct_strat(self): return ( UnstructureStrategy.AS_DICT if self._unstructure_attrs == self.unstructure_attrs_asdict else UnstructureStrategy.AS_TUPLE )
module function_definition identifier parameters identifier block return_statement parenthesized_expression conditional_expression attribute identifier identifier comparison_operator attribute identifier identifier attribute identifier identifier attribute identifier identifier
The default way of unstructuring ``attrs`` classes.
def secured_clipboard(item): expire_clock = time.time() def set_text(clipboard, selectiondata, info, data): if 15.0 >= time.time() - expire_clock: selectiondata.set_text(item.get_secret()) clipboard.clear() def clear(clipboard, data): pass targets = [("STRING", 0, 0) ,("TEXT", 0, 1) ,("COMPOUND_TEXT", 0, 2) ,("UTF8_STRING", 0, 3)] cp = gtk.clipboard_get() cp.set_with_data(targets, set_text, clear)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator float binary_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list function_definition identifier parameters identifier identifier block pass_statement expression_statement assignment identifier list tuple string string_start string_content string_end integer integer tuple string string_start string_content string_end integer integer tuple string string_start string_content string_end integer integer tuple string string_start string_content string_end integer integer expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier identifier
This clipboard only allows 1 paste
def action(route, template='', methods=['GET']): def real_decorator(function): function.pi_api_action = True function.pi_api_route = route function.pi_api_template = template function.pi_api_methods = methods if hasattr(function, 'pi_api_crossdomain'): if not function.pi_api_crossdomain_data['methods']: function.pi_api_crossdomain_data['methods'] = methods if 'OPTIONS' not in function.pi_api_methods: function.pi_api_methods += ['OPTIONS'] return function return real_decorator
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end default_parameter identifier list string string_start string_content string_end block function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end block if_statement not_operator subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier list string string_start string_content string_end return_statement identifier return_statement identifier
Decorator to create an action
def destroy(self): result = self._result( ["heroku", "apps:destroy", "--app", self.name, "--confirm", self.name] ) return result
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end 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 return_statement identifier
Destroy an app and all its add-ons
def send(self, message): serialized = message.SerializeToString() log_binary(_LOGGER, '>> Send', Data=serialized) if self._chacha: serialized = self._chacha.encrypt(serialized) log_binary(_LOGGER, '>> Send', Encrypted=serialized) data = write_variant(len(serialized)) + serialized self._transport.write(data) _LOGGER.debug('>> Send: Protobuf=%s', message)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment identifier binary_operator call identifier argument_list call identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Send message to device.
def remove_routes(self, item, routes): for route in routes: items = self._routes.get(route) try: items.remove(item) LOG.debug('removed item from route %s', route) except ValueError: pass if not items: self._routes.pop(route) LOG.debug('removed route %s', route)
module function_definition identifier parameters identifier identifier identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier except_clause identifier block pass_statement if_statement not_operator identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Removes item from matching routes
def update(self): stats = self.get_init_value() if self.input_method == 'local': self.uptime = datetime.now() - datetime.fromtimestamp(psutil.boot_time()) stats = str(self.uptime).split('.')[0] elif self.input_method == 'snmp': uptime = self.get_stats_snmp(snmp_oid=snmp_oid)['_uptime'] try: stats = str(timedelta(seconds=int(uptime) / 100)) except Exception: pass self.stats = stats return self.stats
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier binary_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier subscript call attribute call identifier argument_list attribute identifier identifier identifier argument_list string string_start string_content string_end integer elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier subscript call attribute identifier identifier argument_list keyword_argument identifier identifier string string_start string_content string_end try_statement block expression_statement assignment identifier call identifier argument_list call identifier argument_list keyword_argument identifier binary_operator call identifier argument_list identifier integer except_clause identifier block pass_statement expression_statement assignment attribute identifier identifier identifier return_statement attribute identifier identifier
Update uptime stat using the input method.
def _add_image(collection, image): image_prep = { 'id': image.id, 'name': image.name, 'created_at': image.created_at, 'file': image.file, 'min_disk': image.min_disk, 'min_ram': image.min_ram, 'owner': image.owner, 'protected': image.protected, 'status': image.status, 'tags': image.tags, 'updated_at': image.updated_at, 'visibility': image.visibility, } for attr in ['container_format', 'disk_format', 'size']: if attr in image: image_prep[attr] = image[attr] if type(collection) is dict: collection[image.name] = image_prep elif type(collection) is list: collection.append(image_prep) else: msg = '"collection" is {0}'.format(type(collection)) +\ 'instead of dict or list.' log.error(msg) raise TypeError(msg) return collection
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier 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 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 for_statement identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier subscript identifier identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment subscript identifier attribute identifier identifier identifier elif_clause comparison_operator call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier binary_operator call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier raise_statement call identifier argument_list identifier return_statement identifier
Add image to given dictionary
def _find_in_columncollection(columns, name): for col in columns: if col.name == name or getattr(col, '_label', None) == name: return col return None
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier identifier comparison_operator call identifier argument_list identifier string string_start string_content string_end none identifier block return_statement identifier return_statement none
Find a column in a column collection by name or _label
async def _retransmit(self, sequence_number): packet = self.__rtp_history.get(sequence_number % RTP_HISTORY_SIZE) if packet and packet.sequence_number == sequence_number: if self.__rtx_payload_type is not None: packet = wrap_rtx(packet, payload_type=self.__rtx_payload_type, sequence_number=self.__rtx_sequence_number, ssrc=self._rtx_ssrc) self.__rtx_sequence_number = uint16_add(self.__rtx_sequence_number, 1) self.__log_debug('> %s', packet) packet_bytes = packet.serialize(self.__rtp_header_extensions_map) await self.transport._send_rtp(packet_bytes)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list binary_operator identifier identifier if_statement boolean_operator identifier comparison_operator attribute identifier identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement await call attribute attribute identifier identifier identifier argument_list identifier
Retransmit an RTP packet which was reported as lost.
def update_earthquake_info(self): self.label_earthquake_model() current_index = self.earthquake_function.currentIndex() model = EARTHQUAKE_FUNCTIONS[current_index] notes = '' for note in model['notes']: notes += note + '\n\n' citations = '' for citation in model['citations']: citations += citation['text'] + '\n\n' text = tr( 'Description:\n\n%s\n\n' 'Notes:\n\n%s\n\n' 'Citations:\n\n%s') % ( model['description'], notes, citations) self.earthquake_fatality_model_notes.setText(text)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier string string_start string_end for_statement identifier subscript identifier string string_start string_content string_end block expression_statement augmented_assignment identifier binary_operator identifier string string_start string_content escape_sequence escape_sequence string_end expression_statement assignment identifier string string_start string_end for_statement identifier subscript identifier string string_start string_content string_end block expression_statement augmented_assignment identifier binary_operator subscript identifier string string_start string_content string_end string string_start string_content escape_sequence escape_sequence string_end expression_statement assignment identifier binary_operator call identifier argument_list concatenated_string string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence string_end string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence string_end string string_start string_content escape_sequence escape_sequence string_end tuple subscript identifier string string_start string_content string_end identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Update information about earthquake info.
def check_status_logfile(self, checker_func): self.status = checker_func(self.logfile) return self.status
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier return_statement attribute identifier identifier
Check on the status of this particular job using the logfile
def configure_logger(logger, filename, folder, log_level): fmt = logging.Formatter('%(asctime)s %(levelname)s: %(message)s') if folder is not None: log_file = os.path.join(folder, filename) hdl = logging.FileHandler(log_file) hdl.setFormatter(fmt) hdl.setLevel(log_level) logger.addHandler(hdl) shdl = logging.StreamHandler() shdl.setLevel(log_level) shdl.setFormatter(fmt) logger.addHandler(shdl) logger.setLevel(log_level)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
Configure logging behvior for the simulations.
def dynamic_sum(values, limit_n=1000, acc=0, depth=4): if len(values) < limit_n: return acc + sum(values) if depth > 0: half = len(values) // 2 return add( dynamic_sum(values[:half], limit_n, acc, depth=depth-1), dynamic_sum(values[half:], limit_n, 0, depth=depth-1)) return dynamic_sum(values[limit_n:], limit_n, acc + sum(values[:limit_n]), depth)
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer default_parameter identifier integer block if_statement comparison_operator call identifier argument_list identifier identifier block return_statement binary_operator identifier call identifier argument_list identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator call identifier argument_list identifier integer return_statement call identifier argument_list call identifier argument_list subscript identifier slice identifier identifier identifier keyword_argument identifier binary_operator identifier integer call identifier argument_list subscript identifier slice identifier identifier integer keyword_argument identifier binary_operator identifier integer return_statement call identifier argument_list subscript identifier slice identifier identifier binary_operator identifier call identifier argument_list subscript identifier slice identifier identifier
Example of dynamic sum.
def _handle_tag_fileattributes(self): obj = _make_object("FileAttributes") bc = BitConsumer(self._src) bc.u_get(1) obj.UseDirectBlit = bc.u_get(1) obj.UseGPU = bc.u_get(1) obj.HasMetadata = bc.u_get(1) obj.ActionScript3 = bc.u_get(1) bc.u_get(2) obj.UseNetwork = bc.u_get(1) bc.u_get(24) return obj
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list integer expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list integer expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list integer expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list integer expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list integer expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list integer return_statement identifier
Handle the FileAttributes tag.
def query_one(cls, *args, **kwargs): doc = cls._coll.find_one(*args, **kwargs) if doc: return cls.from_storage(doc)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list list_splat identifier dictionary_splat identifier if_statement identifier block return_statement call attribute identifier identifier argument_list identifier
Same as collection.find_one, but return Document then dict
def _default_format(self, occur): if self.text or self.children: return self.start_tag() + "%s" + self.end_tag() return self.start_tag(empty=True)
module function_definition identifier parameters identifier identifier block if_statement boolean_operator attribute identifier identifier attribute identifier identifier block return_statement binary_operator binary_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list keyword_argument identifier true
Return the default serialization format.
def generate_moffat_profile(seeing_fwhm, alpha): scale = 2 * math.sqrt(2**(1.0 / alpha) - 1) gamma = seeing_fwhm / scale amplitude = 1.0 / math.pi * (alpha - 1) / gamma**2 seeing_model = Moffat2D(amplitude=amplitude, x_mean=0.0, y_mean=0.0, gamma=gamma, alpha=alpha) return seeing_model
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator integer call attribute identifier identifier argument_list binary_operator binary_operator integer parenthesized_expression binary_operator float identifier integer expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator binary_operator binary_operator float attribute identifier identifier parenthesized_expression binary_operator identifier integer binary_operator identifier integer expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier float keyword_argument identifier float keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier
Generate a normalized Moffat profile from its FWHM and alpha
def encode_images_as_png(images): if tf.executing_eagerly(): for image in images: yield tf.image.encode_png(image).numpy() else: (height, width, channels) = images[0].shape with tf.Graph().as_default(): image_t = tf.placeholder(dtype=tf.uint8, shape=(height, width, channels)) encoded_image_t = tf.image.encode_png(image_t) with tf.Session() as sess: for image in images: enc_string = sess.run(encoded_image_t, feed_dict={image_t: image}) yield enc_string
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list block for_statement identifier identifier block expression_statement yield call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list else_clause block expression_statement assignment tuple_pattern identifier identifier identifier attribute subscript identifier integer identifier with_statement with_clause with_item call attribute call attribute identifier identifier argument_list identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier tuple identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier dictionary pair identifier identifier expression_statement yield identifier
Yield images encoded as pngs.
def validate(collection, onerror: Callable[[str, List], None] = None): BioCValidator(onerror).validate(collection)
module function_definition identifier parameters identifier typed_default_parameter identifier type generic_type identifier type_parameter type list identifier identifier type none none block expression_statement call attribute call identifier argument_list identifier identifier argument_list identifier
Validate BioC data structure.
def setup_hob(self): if self.m.hob is None: return hob_out_unit = self.m.hob.iuhobsv new_hob_out_fname = os.path.join(self.m.model_ws,self.m.get_output_attribute(unit=hob_out_unit)) org_hob_out_fname = os.path.join(self.org_model_ws,self.m.get_output_attribute(unit=hob_out_unit)) if not os.path.exists(org_hob_out_fname): self.logger.warn("could not find hob out file: {0}...skipping".format(hob_out_fname)) return shutil.copy2(org_hob_out_fname,new_hob_out_fname) hob_df = pyemu.gw_utils.modflow_hob_to_instruction_file(new_hob_out_fname) self.obs_dfs["hob"] = hob_df self.tmp_files.append(os.path.split(hob_out_fname))
module function_definition identifier parameters identifier block if_statement comparison_operator attribute attribute identifier identifier identifier none block return_statement expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier 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 expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier
setup observations from the MODFLOW HOB package
def _insert(self, key, records, count): if key not in self.records: assert key not in self.counts self.records[key] = records self.counts[key] = count else: self.records[key] = np.vstack((self.records[key], records)) assert key in self.counts self.counts[key] += count
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block assert_statement comparison_operator identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier else_clause block expression_statement assignment subscript attribute identifier identifier identifier call attribute identifier identifier argument_list tuple subscript attribute identifier identifier identifier identifier assert_statement comparison_operator identifier attribute identifier identifier expression_statement augmented_assignment subscript attribute identifier identifier identifier identifier
Insert records according to key
def parse_sam(sam, qual): for line in sam: if line.startswith('@'): continue line = line.strip().split() if int(line[4]) == 0 or int(line[4]) < qual: continue yield line
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block continue_statement expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list if_statement boolean_operator comparison_operator call identifier argument_list subscript identifier integer integer comparison_operator call identifier argument_list subscript identifier integer identifier block continue_statement expression_statement yield identifier
parse sam file and check mapping quality
def chunkWidgets(self, group): ui_groups = [] subgroup = [] for index, item in enumerate(group['items']): if getin(item, ['options', 'full_width'], False): ui_groups.append(subgroup) ui_groups.append([item]) subgroup = [] else: subgroup.append(item) if len(subgroup) == getin(group, ['options', 'columns'], 2) \ or item == group['items'][-1]: ui_groups.append(subgroup) subgroup = [] return ui_groups
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list subscript identifier string string_start string_content string_end block if_statement call identifier argument_list identifier list string string_start string_content string_end string string_start string_content string_end false block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list list identifier expression_statement assignment identifier list else_clause block expression_statement call attribute identifier identifier argument_list identifier if_statement boolean_operator comparison_operator call identifier argument_list identifier call identifier argument_list identifier list string string_start string_content string_end string string_start string_content string_end integer line_continuation comparison_operator identifier subscript subscript identifier string string_start string_content string_end unary_operator integer block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier list return_statement identifier
chunk the widgets up into groups based on their sizing hints
def _check_arguments(self): if self.argument_checked: return assert(self.symbol is not None) self.argument_checked = True _check_arguments(self.symbol) if self.allow_extra_params: if self.arg_params: arg_names = set(self.symbol.list_arguments()) self.arg_params = {k : v for k, v in self.arg_params.items() if k in arg_names} if self.aux_params: aux_names = set(self.symbol.list_auxiliary_states()) self.aux_params = {k : v for k, v in self.aux_params.items() if k in aux_names}
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement assert_statement parenthesized_expression comparison_operator attribute identifier identifier none expression_statement assignment attribute identifier identifier true expression_statement call identifier argument_list attribute identifier identifier if_statement attribute identifier identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_clause comparison_operator identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_clause comparison_operator identifier identifier
verify the argument of the default symbol and user provided parameters
def prepare_file(filename): directory = os.path.join(utils.get_project_root(), "analyzation/") if not os.path.exists(directory): os.makedirs(directory) workfilename = os.path.join(directory, filename) open(workfilename, 'w').close() return workfilename
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end 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 assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute call identifier argument_list identifier string string_start string_content string_end identifier argument_list return_statement identifier
Truncate the file and return the filename.
def _get_controller_type(self): if self.node_type == self.NODE_CONTROLLER_ROOT and self.name in self.CONTROLLERS: return self.name elif self.parent: return self.parent.controller_type else: return None
module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier comparison_operator attribute identifier identifier attribute identifier identifier block return_statement attribute identifier identifier elif_clause attribute identifier identifier block return_statement attribute attribute identifier identifier identifier else_clause block return_statement none
Returns the current node's controller type
def _csr_matrix_indices(S): m, n = S.shape for i in range(m): for j in range(S.indptr[i], S.indptr[i+1]): row_index, col_index = i, S.indices[j] yield row_index, col_index
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier attribute identifier identifier for_statement identifier call identifier argument_list identifier block for_statement identifier call identifier argument_list subscript attribute identifier identifier identifier subscript attribute identifier identifier binary_operator identifier integer block expression_statement assignment pattern_list identifier identifier expression_list identifier subscript attribute identifier identifier identifier expression_statement yield expression_list identifier identifier
Generate the indices of nonzero entries of a csr_matrix S
def arrows_at(self, x, y): for arrow in self.arrows(): if arrow.collide_point(x, y): yield arrow
module function_definition identifier parameters identifier identifier identifier block for_statement identifier call attribute identifier identifier argument_list block if_statement call attribute identifier identifier argument_list identifier identifier block expression_statement yield identifier
Iterate over arrows that collide the given point.
def imeicsum(text): digs = [] for i in range(14): v = int(text[i]) if i % 2: v *= 2 [digs.append(int(x)) for x in str(v)] chek = 0 valu = sum(digs) remd = valu % 10 if remd != 0: chek = 10 - remd return str(chek)
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call identifier argument_list integer block expression_statement assignment identifier call identifier argument_list subscript identifier identifier if_statement binary_operator identifier integer block expression_statement augmented_assignment identifier integer expression_statement list_comprehension call attribute identifier identifier argument_list call identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier expression_statement assignment identifier integer expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator identifier integer if_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator integer identifier return_statement call identifier argument_list identifier
Calculate the imei check byte.
def normalize_dictionary_values(dictionary): for key, val in dictionary.iteritems(): if isinstance(val, dict): dictionary[key] = normalize_dictionary_values(val) elif isinstance(val, list): dictionary[key] = list(val) else: dictionary[key] = normalize_value(val) return dictionary
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier else_clause block expression_statement assignment subscript identifier identifier call identifier argument_list identifier return_statement identifier
Normalizes the values in a dictionary recursivly.
def steady_connection(self): return SteadyPgConnection(self._maxusage, self._setsession, True, *self._args, **self._kwargs)
module function_definition identifier parameters identifier block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier true list_splat attribute identifier identifier dictionary_splat attribute identifier identifier
Get a steady, unpooled PostgreSQL connection.
def redis(self): if self._redis is None: self._redis = redis.StrictRedis(host=self.args.redis_host, port=self.args.redis_port) return self._redis
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier return_statement attribute identifier identifier
Return instance of Redis.
def example_clinical_data(study_name, environment): odm = ODM("test system")( ClinicalData("Mediflex", "DEV")( SubjectData("MDSOL", "IJS TEST4", transaction_type="Insert")( StudyEventData("SUBJECT")( FormData("EN", transaction_type="Update")( ItemGroupData()( ItemData("SUBJINIT", "AAA")( AuditRecord(edit_point=AuditRecord.EDIT_DATA_MANAGEMENT, used_imputation_method= False, identifier='X2011', include_file_oid=False)( UserRef("isparks"), LocationRef("MDSOL"), ReasonForChange("Data Entry Error"), DateTimeStamp(datetime(2015, 9, 11, 10, 15, 22, 80)) ), MdsolQuery(value="Subject initials should be 2 chars only.", recipient="Site from System", status=QueryStatusType.Open) ), ItemData("SUBJID", '001') ) ) ) ) ) ) return odm
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call call identifier argument_list string string_start string_content string_end argument_list call call identifier argument_list string string_start string_content string_end string string_start string_content string_end argument_list call call identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end argument_list call call identifier argument_list string string_start string_content string_end argument_list call call identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end argument_list call call identifier argument_list argument_list call call identifier argument_list string string_start string_content string_end string string_start string_content string_end argument_list call call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier false keyword_argument identifier string string_start string_content string_end keyword_argument identifier false argument_list call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end call identifier argument_list call identifier argument_list integer integer integer integer integer integer integer call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier call identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement identifier
Test demonstrating building clinical data
def position_scales(self): l = [s for s in self if ('x' in s.aesthetics) or ('y' in s.aesthetics)] return Scales(l)
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause boolean_operator parenthesized_expression comparison_operator string string_start string_content string_end attribute identifier identifier parenthesized_expression comparison_operator string string_start string_content string_end attribute identifier identifier return_statement call identifier argument_list identifier
Return a list of the position scales that are present
def _get_adj_list_adjacency(self, umis, counts, threshold): adj_list = {umi: [] for umi in umis} if len(umis) > 25: umi_length = len(umis[0]) substr_idx = build_substr_idx(umis, umi_length, threshold) iter_umi_pairs = iter_nearest_neighbours(umis, substr_idx) else: iter_umi_pairs = itertools.combinations(umis, 2) for umi1, umi2 in iter_umi_pairs: if edit_distance(umi1, umi2) <= threshold: adj_list[umi1].append(umi2) adj_list[umi2].append(umi1) return adj_list
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier dictionary_comprehension pair identifier list for_in_clause identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call identifier argument_list subscript identifier integer expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier integer for_statement pattern_list identifier identifier identifier block if_statement comparison_operator call identifier argument_list identifier identifier identifier block expression_statement call attribute subscript identifier identifier identifier argument_list identifier expression_statement call attribute subscript identifier identifier identifier argument_list identifier return_statement identifier
identify all umis within hamming distance threshold
def _resume(self): try: self._cursor.close() except PyMongoError: pass self._cursor = self._create_cursor()
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list except_clause identifier block pass_statement expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list
Reestablish this change stream after a resumable error.
def zrem(self, key, member, *members): return self.execute(b'ZREM', key, member, *members)
module function_definition identifier parameters identifier identifier identifier list_splat_pattern identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier list_splat identifier
Remove one or more members from a sorted set.
def file_upload_to(self, instance, filename): ext = filename.split(".")[-1] filename = "{}.{}".format(uuid.uuid4(), ext) return os.path.join("document", filename)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier
Callable passed to the FileField's upload_to kwarg on Document.file
def Forget(self, obj): obj = _get_idstr(obj) try: self.memo.remove(obj) except ValueError: pass
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block pass_statement
Forget we've seen this object.
def roll(self): x, y, z, w = self.x, self.y, self.z, self.w return math.atan2(2*y*w - 2*x*z, 1 - 2*y*y - 2*z*z)
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier identifier expression_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list binary_operator binary_operator binary_operator integer identifier identifier binary_operator binary_operator integer identifier identifier binary_operator binary_operator integer binary_operator binary_operator integer identifier identifier binary_operator binary_operator integer identifier identifier
Calculates the Roll of the Quaternion.