code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def url_replace_param(url, name, value): url_components = urlparse(force_str(url)) query_params = parse_qs(url_components.query) query_params[name] = value query = urlencode(query_params, doseq=True) return force_text( urlunparse( [ url_components.scheme, url_components.netloc, url_components.path, url_components.params, query, url_components.fragment, ] ) )
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment subscript identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier true return_statement call identifier argument_list call identifier argument_list list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier attribute identifier identifier
Replace a GET parameter in an URL
def api_url(self): return pathjoin(Request.path, self.id, url=self.bin.api_url)
module function_definition identifier parameters identifier block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier
return the api url of this request
def CreateTasksFilter(pc, tasks): if not tasks: return None objspecs = [vmodl.query.PropertyCollector.ObjectSpec(obj=task) for task in tasks] propspec = vmodl.query.PropertyCollector.PropertySpec( type=vim.Task, pathSet=[], all=True) filterspec = vmodl.query.PropertyCollector.FilterSpec() filterspec.objectSet = objspecs filterspec.propSet = [propspec] return pc.CreateFilter(filterspec, True)
module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement none expression_statement assignment identifier list_comprehension call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier list keyword_argument identifier true expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier list identifier return_statement call attribute identifier identifier argument_list identifier true
Create property collector filter for tasks
def _pattern_match(self, item, pattern): if pattern.endswith('*'): return item.startswith(pattern[:-1]) else: return item == pattern
module function_definition identifier parameters identifier identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block return_statement call attribute identifier identifier argument_list subscript identifier slice unary_operator integer else_clause block return_statement comparison_operator identifier identifier
Determine whether the item supplied is matched by the pattern.
def visit_IfExp(self, node: ast.IfExp) -> Any: test = self.visit(node=node.test) if test: result = self.visit(node=node.body) else: result = self.visit(node=node.orelse) self.recomputed_values[node] = result return result
module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement identifier
Visit the ``test``, and depending on its outcome, the ``body`` or ``orelse``.
def replace_values(in_m, out_m, map_from=(), map_to=()): for link in in_m.match(): new_link = list(link) if map_from: if link[ORIGIN] in map_from: new_link[ORIGIN] = map_to[map_from.index(link[ORIGIN])] new_link[ATTRIBUTES] = link[ATTRIBUTES].copy() out_m.add(*new_link) return
module function_definition identifier parameters identifier identifier default_parameter identifier tuple default_parameter identifier tuple block for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block if_statement comparison_operator subscript identifier identifier identifier block expression_statement assignment subscript identifier identifier subscript identifier call attribute identifier identifier argument_list subscript identifier identifier expression_statement assignment subscript identifier identifier call attribute subscript identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list list_splat identifier return_statement
Make a copy of a model with one value replaced with another
def create_virtualenv(pkg, repo_dest, python): workon_home = os.environ.get('WORKON_HOME') venv_cmd = find_executable('virtualenv') python_bin = find_executable(python) if not python_bin: raise EnvironmentError('%s is not installed or not ' 'available on your $PATH' % python) if workon_home: venv = os.path.join(workon_home, pkg) else: venv = os.path.join(repo_dest, '.virtualenv') if venv_cmd: if not verbose: log.info('Creating virtual environment in %r' % venv) args = ['--python', python_bin, venv] if not verbose: args.insert(0, '-q') subprocess.check_call([venv_cmd] + args) else: raise EnvironmentError('Could not locate the virtualenv. Install with ' 'pip install virtualenv.') return venv
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator identifier block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end identifier if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end if_statement identifier block if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier list string string_start string_content string_end identifier identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list integer string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator list identifier identifier else_clause block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end return_statement identifier
Creates a virtualenv within which to install your new application.
def involved_tags(self): if len(self._addresses) < 2: return frozenset() parent_sets = [] common_parents = set() for addr in self._addresses: parents = set() if addr.attr == 'text': parents.add(addr.element) parents.update(addr.element.iterancestors()) parent_sets.append((addr, parents)) if not common_parents: common_parents = parents else: common_parents &= parents involved_tags = set() prev_addr = None for addr, parents in parent_sets: parents = parents - common_parents involved_tags.update(p.tag for p in parents) is_tail_of_hidden = ( prev_addr and addr.attr == 'tail' and prev_addr.element != addr.element ) if is_tail_of_hidden: involved_tags.add(addr.element) prev_addr = addr return frozenset(involved_tags)
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block return_statement call identifier argument_list expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list tuple identifier identifier if_statement not_operator identifier block expression_statement assignment identifier identifier else_clause block expression_statement augmented_assignment identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier none for_statement pattern_list identifier identifier identifier block expression_statement assignment identifier binary_operator identifier identifier expression_statement call attribute identifier identifier generator_expression attribute identifier identifier for_in_clause identifier identifier expression_statement assignment identifier parenthesized_expression boolean_operator boolean_operator identifier comparison_operator attribute identifier identifier string string_start string_content string_end comparison_operator attribute identifier identifier attribute identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier identifier return_statement call identifier argument_list identifier
Provides all HTML tags directly involved in this string.
def copy(self): return self.__class__(self._key, self._load, self._iteritems())
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list
Return a shallow copy of the sorted dictionary.
def inspect(self): policy = self.policy image_name = format_image_tag((self.config_id.config_name, self.config_id.instance_name)) image_id = policy.images[self.client_name].get(image_name) if image_id: self.detail = {'Id': image_id} else: self.detail = NOT_FOUND
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list tuple attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute subscript attribute identifier identifier attribute identifier identifier identifier argument_list identifier if_statement identifier block expression_statement assignment attribute identifier identifier dictionary pair string string_start string_content string_end identifier else_clause block expression_statement assignment attribute identifier identifier identifier
Fetches image information from the client.
def touch(self): key = self.get_related().get_key_name() columns = self.get_related_fresh_update() ids = self.get_related_ids() if len(ids) > 0: self.get_related().new_query().where_in(key, ids).update(columns)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute call attribute call attribute call attribute identifier identifier argument_list identifier argument_list identifier argument_list identifier identifier identifier argument_list identifier
Touch all of the related models of the relationship.
def list_views(self, name='', is_visible=True): children = self.findChildren(QWidget) return [child.view for child in children if isinstance(child, QDockWidget) and child.view.name.startswith(name) and (child.isVisible() if is_visible else True) and child.width() >= 10 and child.height() >= 10 ]
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end default_parameter identifier true block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement list_comprehension attribute identifier identifier for_in_clause identifier identifier if_clause boolean_operator boolean_operator boolean_operator boolean_operator call identifier argument_list identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier parenthesized_expression conditional_expression call attribute identifier identifier argument_list identifier true comparison_operator call attribute identifier identifier argument_list integer comparison_operator call attribute identifier identifier argument_list integer
List all views which name start with a given string.
def _zero_based_index(self, onebased: Union[int, str]) -> int: result = int(onebased) if result > 0: result -= 1 return result
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier integer block expression_statement augmented_assignment identifier integer return_statement identifier
Convert a one-based index to a zero-based index.
def float_constructor(loader, node): s = loader.construct_scalar(node) if s == '.inf': return Decimal('Infinity') elif s == '-.inf': return -Decimal('Infinity') elif s == '.nan': return Decimal('NaN') return Decimal(s)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block return_statement call identifier argument_list string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block return_statement unary_operator call identifier argument_list string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier
Construct Decimal from YAML float encoding.
def create_fw(self, tenant_id, data): try: return self._create_fw(tenant_id, data) except Exception as exc: LOG.error("Failed to create FW for device native, tenant " "%(tenant)s data %(data)s Exc %(exc)s", {'tenant': tenant_id, 'data': data, 'exc': exc}) return False
module function_definition identifier parameters identifier identifier identifier block try_statement block return_statement call attribute identifier identifier argument_list identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end 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 return_statement false
Top level routine called when a FW is created.
def fetch_pcr(*args, **kwargs): kwargs['token'] = os.getenv("PCR_AUTH_TOKEN", "public") return fetch(DOMAIN, *args, **kwargs)['result']
module function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement subscript call identifier argument_list identifier list_splat identifier dictionary_splat identifier string string_start string_content string_end
Wrapper for fetch to automatically parse results from the PCR API.
def match_route(self, reqpath): route_dicts = [routes for _, routes in self.api.http.routes.items()][0] routes = [route for route, _ in route_dicts.items()] if reqpath in routes: return reqpath for route in routes: if re.match(re.sub(r'/{[^{}]+}', '/\w+', route) + '$', reqpath): return route return reqpath
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript list_comprehension identifier for_in_clause pattern_list identifier identifier call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list integer expression_statement assignment identifier list_comprehension identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier identifier block return_statement identifier for_statement identifier identifier block if_statement call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier string string_start string_content string_end identifier block return_statement identifier return_statement identifier
match a request with parameter to it's corresponding route
def lookup(self,value): for k,v in self.iteritems(): if value == v: return k return None
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block return_statement identifier return_statement none
return the first key in dict where value is name
def end_output (self, **kwargs): if self.has_part("stats"): self.write_stats() if self.has_part("outro"): self.write_outro() self.close_fileoutput()
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Write end of checking info as HTML.
def _dict_to_json_pretty(d, sort_keys=True): return salt.utils.json.dumps(d, indent=4, separators=(',', ': '), sort_keys=sort_keys)
module function_definition identifier parameters identifier default_parameter identifier true block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier keyword_argument identifier integer keyword_argument identifier tuple string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier
helper function to generate pretty printed json output
def _match(self, doc, where): assert isinstance(where, dict), "where is not a dictionary" assert isinstance(doc, dict), "doc is not a dictionary" try: return all([doc[k] == v for k, v in where.items()]) except KeyError: return False
module function_definition identifier parameters identifier identifier identifier block assert_statement call identifier argument_list identifier identifier string string_start string_content string_end assert_statement call identifier argument_list identifier identifier string string_start string_content string_end try_statement block return_statement call identifier argument_list list_comprehension comparison_operator subscript identifier identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list except_clause identifier block return_statement false
Return True if 'doc' matches the 'where' condition.
def make_mine(self, request, queryset): author = Author.objects.get(pk=request.user.pk) for entry in queryset: if author not in entry.authors.all(): entry.authors.add(author) self.message_user( request, _('The selected entries now belong to you.'))
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier for_statement identifier identifier block if_statement comparison_operator identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list string string_start string_content string_end
Set the entries to the current user.
def add_get(self, *args, **kwargs): return self.add_route(hdrs.METH_GET, *args, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier list_splat identifier dictionary_splat identifier
Shortcut for add_route with method GET
def _add_atom_info(self, atom_info): self.atoms_by_number[atom_info.number] = atom_info self.atoms_by_symbol[atom_info.symbol.lower()] = atom_info
module function_definition identifier parameters identifier identifier block expression_statement assignment subscript attribute identifier identifier attribute identifier identifier identifier expression_statement assignment subscript attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier
Add an atom info object to the database
def cli(yamlfile, format, classes, directory): print(YumlGenerator(yamlfile, format).serialize(classes=classes, directory=directory), end="")
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call identifier argument_list call attribute call identifier argument_list identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_end
Generate a UML representation of a biolink model
def cli(env, account_id, content_url, type, cname): manager = SoftLayer.CDNManager(env.client) manager.add_origin(account_id, type, content_url, cname)
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier
Create an origin pull mapping.
def pubticker(self, symbol='btcusd'): url = self.base_url + '/v1/pubticker/' + symbol return requests.get(url)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator binary_operator attribute identifier identifier string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list identifier
Send a request for latest ticker info, return the response.
def add_url (self, url, line=0, column=0, page=0, name=u"", base=None): if base: base_ref = urlutil.url_norm(base)[0] else: base_ref = None url_data = get_url_from(url, self.recursion_level+1, self.aggregate, parent_url=self.url, base_ref=base_ref, line=line, column=column, page=page, name=name, parent_content_type=self.content_type) self.aggregate.urlqueue.put(url_data)
module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier integer default_parameter identifier integer default_parameter identifier string string_start string_end default_parameter identifier none block if_statement identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list identifier integer else_clause block expression_statement assignment identifier none expression_statement assignment identifier call identifier argument_list identifier binary_operator attribute identifier identifier integer attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier
Add new URL to queue.
def run(self, fct, input_): if tf.executing_eagerly(): return fct(input_).numpy() else: if not isinstance(input_, np.ndarray): input_ = np.array(input_) run_args = RunArgs(fct=fct, input=input_) signature = self._build_signature(run_args) if signature not in self._graph_run_cache: graph_run = self._build_graph_run(run_args) self._graph_run_cache[signature] = graph_run else: graph_run = self._graph_run_cache[signature] return graph_run.session.run( graph_run.output, feed_dict={graph_run.placeholder: input_}, )
module function_definition identifier parameters identifier identifier identifier block if_statement call attribute identifier identifier argument_list block return_statement call attribute call identifier argument_list identifier identifier argument_list else_clause block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier identifier identifier else_clause block expression_statement assignment identifier subscript attribute identifier identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier dictionary pair attribute identifier identifier identifier
Execute the given TensorFlow function.
def reset_cmd_timeout(self): if self._cmd_timeout: self._cmd_timeout.cancel() self._cmd_timeout = self.loop.call_later(self.client.timeout, self.transport.close)
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 assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier
Reset timeout for command execution.
def examples(self): for examples in product(*[spc.examples for spc in self.spaces]): name = ', '.join(name for name, _ in examples) element = self.element([elem for _, elem in examples]) yield (name, element)
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list list_splat list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier generator_expression identifier for_in_clause pattern_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list list_comprehension identifier for_in_clause pattern_list identifier identifier identifier expression_statement yield tuple identifier identifier
Return examples from all sub-spaces.
def run_sixteens(self): SixteensFull(args=self, pipelinecommit=self.commit, startingtime=self.starttime, scriptpath=self.homepath, analysistype='sixteens_full', cutoff=0.985)
module function_definition identifier parameters identifier block expression_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier float
Run the 16S analyses using the filtered database
def destroy(self, folder=None): ameans = [(0, 0, 0) for _ in range(3)] ret = [self.save_info(folder, ameans)] aiomas.run(until=self.stop_slaves(folder)) self._pool.close() self._pool.terminate() self._pool.join() self._env.shutdown() return ret
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier list_comprehension tuple integer integer integer for_in_clause identifier call identifier argument_list integer expression_statement assignment identifier list call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list return_statement identifier
Destroy the environment and the subprocesses.
def hide(self, event): if self.content.isHidden(): self.content.show() self.hideBtn.setIcon(self.hideIcon) self.setMaximumHeight(16777215) else: self.content.hide() self.hideBtn.setIcon(self.showIcon) self.setFixedHeight(30)
module function_definition identifier parameters identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list integer else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list integer
Toggles the visiblity of the content widget
def fw_policy_create(self, data, fw_name=None, cache=False): LOG.debug("FW Policy Debug") self._fw_policy_create(fw_name, data, cache)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier false block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier identifier
Top level policy create routine.
def xmltreefromstring(s): if sys.version < '3': if isinstance(s,unicode): s = s.encode('utf-8') try: return ElementTree.parse(StringIO(s), ElementTree.XMLParser(collect_ids=False)) except TypeError: return ElementTree.parse(StringIO(s), ElementTree.XMLParser()) else: if isinstance(s,str): s = s.encode('utf-8') try: return ElementTree.parse(BytesIO(s), ElementTree.XMLParser(collect_ids=False)) except TypeError: return ElementTree.parse(BytesIO(s), ElementTree.XMLParser())
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end try_statement block return_statement call attribute identifier identifier argument_list call identifier argument_list identifier call attribute identifier identifier argument_list keyword_argument identifier false except_clause identifier block return_statement call attribute identifier identifier argument_list call identifier argument_list identifier call attribute identifier identifier argument_list else_clause block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end try_statement block return_statement call attribute identifier identifier argument_list call identifier argument_list identifier call attribute identifier identifier argument_list keyword_argument identifier false except_clause identifier block return_statement call attribute identifier identifier argument_list call identifier argument_list identifier call attribute identifier identifier argument_list
Internal function, deals with different Python versions, unicode strings versus bytes, and with the leak bug in lxml
def pretrain(self, train_set, validation_set=None): self.do_pretrain = True def set_params_func(autoenc, autoencgraph): params = autoenc.get_parameters(graph=autoencgraph) self.encoding_w_.append(params['enc_w']) self.encoding_b_.append(params['enc_b']) return SupervisedModel.pretrain_procedure( self, self.autoencoders, self.autoencoder_graphs, set_params_func=set_params_func, train_set=train_set, validation_set=validation_set)
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment attribute identifier identifier true function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Perform Unsupervised pretraining of the autoencoder.
def __SetTotal(self, info): if 'content-range' in info: _, _, total = info['content-range'].rpartition('/') if total != '*': self.__total_size = int(total) if self.total_size is None: self.__total_size = 0
module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call identifier argument_list identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier integer
Sets the total size based off info if possible otherwise 0.
def _getEventsOnDay(self, request, day): home = request.site.root_page return getAllEventsByDay(request, day, day, home=home)[0]
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier return_statement subscript call identifier argument_list identifier identifier identifier keyword_argument identifier identifier integer
Return all the events in this site for a given day.
def deleteable(self, request): return self.apply_deleteable(self.get_queryset(), request) if self.check_deleteable(self.model, request) is not False else self.get_queryset().none()
module function_definition identifier parameters identifier identifier block return_statement conditional_expression call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier comparison_operator call attribute identifier identifier argument_list attribute identifier identifier identifier false call attribute call attribute identifier identifier argument_list identifier argument_list
Checks the both, check_deleteable and apply_deleteable, against the owned model and it's instance set
def load(self, filename): try: with open(filename, 'rb') as fp: self.counters = cPickle.load(fp) except: logging.debug("can't load counter from file: %s", filename) return False return True
module function_definition identifier parameters identifier identifier block try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier except_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement false return_statement true
Load counters to file
def clean(self): while len(self.queue) > 0 and self._pair_stale(self.queue[0]): self.queue.pop(0)
module function_definition identifier parameters identifier block while_statement boolean_operator comparison_operator call identifier argument_list attribute identifier identifier integer call attribute identifier identifier argument_list subscript attribute identifier identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list integer
Get rid of stale connections.
def drop_columns(self, model, *names, **kwargs): fields = [field for field in model._meta.fields.values() if field.name in names] cascade = kwargs.pop('cascade', True) for field in fields: self.__del_field__(model, field) if field.unique: index_name = make_index_name(model._meta.table_name, [field.column_name]) self.ops.append(self.migrator.drop_index(model._meta.table_name, index_name)) self.ops.append( self.migrator.drop_column( model._meta.table_name, field.column_name, cascade=cascade)) return model
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call attribute attribute attribute identifier identifier identifier identifier argument_list if_clause comparison_operator attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end true for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier keyword_argument identifier identifier return_statement identifier
Remove fields from model.
def cwd_decorator(func): def wrapper(*args, **kw): cur_dir = os.getcwd() found = False for arg in sys.argv: if arg.endswith(".rst"): found = arg break if found: directory = os.path.dirname(found) if directory: os.chdir(directory) data = func(*args, **kw) os.chdir(cur_dir) return data return wrapper
module function_definition identifier parameters identifier block function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier false for_statement identifier attribute identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier identifier break_statement if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list list_splat identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier return_statement identifier
decorator to change cwd to directory containing rst for this function
def get(key, profile=None): if not profile: return None _, cur, table = _connect(profile) q = profile.get('get_query', ('SELECT value FROM {0} WHERE ' 'key=:key'.format(table))) res = cur.execute(q, {'key': key}) res = res.fetchone() if not res: return None return salt.utils.msgpack.unpackb(res[0])
module function_definition identifier parameters identifier default_parameter identifier none block if_statement not_operator identifier block return_statement none expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end parenthesized_expression call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator identifier block return_statement none return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list subscript identifier integer
Get a value from sqlite3
def varnames(self): return self._argnames + tuple(sorted({ instr.arg for instr in self.instrs if instr.uses_varname and instr.arg not in self._argnames }))
module function_definition identifier parameters identifier block return_statement binary_operator attribute identifier identifier call identifier argument_list call identifier argument_list set_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier if_clause boolean_operator attribute identifier identifier comparison_operator attribute identifier identifier attribute identifier identifier
The names of all of the local variables in this code object.
def decode_sid(cls, secret, cookie_value): if len(cookie_value) > SIG_LENGTH + SID_LENGTH: logging.warn("cookie value is incorrect length") return None cookie_sig = cookie_value[:SIG_LENGTH] cookie_sid = cookie_value[SIG_LENGTH:] secret_bytes = secret.encode("utf-8") cookie_sid_bytes = cookie_sid.encode("utf-8") actual_sig = hmac.new(secret_bytes, cookie_sid_bytes, hashlib.sha512).hexdigest() if not Session.is_signature_equal(cookie_sig, actual_sig): return None return cookie_sid
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator call identifier argument_list identifier binary_operator identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement none expression_statement assignment identifier subscript identifier slice identifier expression_statement assignment identifier subscript identifier slice identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier attribute identifier identifier identifier argument_list if_statement not_operator call attribute identifier identifier argument_list identifier identifier block return_statement none return_statement identifier
Decodes a cookie value and returns the sid if value or None if invalid.
def create_system(self, new_machine_id=False): client_hostname = determine_hostname() machine_id = generate_machine_id(new_machine_id) branch_info = self.branch_info if not branch_info: return False remote_branch = branch_info['remote_branch'] remote_leaf = branch_info['remote_leaf'] data = {'machine_id': machine_id, 'remote_branch': remote_branch, 'remote_leaf': remote_leaf, 'hostname': client_hostname} if self.config.display_name is not None: data['display_name'] = self.config.display_name data = json.dumps(data) post_system_url = self.api_url + '/v1/systems' logger.debug("POST System: %s", post_system_url) logger.debug(data) net_logger.info("POST %s", post_system_url) return self.session.post(post_system_url, headers={'Content-Type': 'application/json'}, data=data)
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier if_statement not_operator identifier block return_statement false expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier if_statement comparison_operator attribute attribute identifier identifier identifier none block expression_statement assignment subscript identifier string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier dictionary pair string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier
Create the machine via the API
def _clean(self, value): value = (str(v) for v in value) if self.strip: value = (v.strip() for v in value) if not self.empty: value = (v for v in value if v) return value
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier generator_expression call identifier argument_list identifier for_in_clause identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier generator_expression call attribute identifier identifier argument_list for_in_clause identifier identifier if_statement not_operator attribute identifier identifier block expression_statement assignment identifier generator_expression identifier for_in_clause identifier identifier if_clause identifier return_statement identifier
Perform a standardized pipline of operations across an iterable.
def _get_memory_base(gallery_conf): if not gallery_conf['show_memory']: memory_base = 0 else: from memory_profiler import memory_usage sleep, timeout = (1, 2) if sys.platform == 'win32' else (0.5, 1) proc = subprocess.Popen( [sys.executable, '-c', 'import time, sys; time.sleep(%s); sys.exit(0)' % sleep], close_fds=True) memories = memory_usage(proc, interval=1e-3, timeout=timeout) kwargs = dict(timeout=timeout) if sys.version_info >= (3, 5) else {} proc.communicate(**kwargs) memories = [mem for mem in memories if mem is not None] + [0.] memory_base = max(memories) return memory_base
module function_definition identifier parameters identifier block if_statement not_operator subscript identifier string string_start string_content string_end block expression_statement assignment identifier integer else_clause block import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment pattern_list identifier identifier conditional_expression tuple integer integer comparison_operator attribute identifier identifier string string_start string_content string_end tuple float integer expression_statement assignment identifier call attribute identifier identifier argument_list list attribute identifier identifier string string_start string_content string_end binary_operator string string_start string_content string_end identifier keyword_argument identifier true expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier float keyword_argument identifier identifier expression_statement assignment identifier conditional_expression call identifier argument_list keyword_argument identifier identifier comparison_operator attribute identifier identifier tuple integer integer dictionary expression_statement call attribute identifier identifier argument_list dictionary_splat identifier expression_statement assignment identifier binary_operator list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier none list float expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
Get the base amount of memory used by running a Python process.
def _safe_string(self, source, encoding='utf-8'): if not isinstance(source, str): return source.encode(encoding) return str(source)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block if_statement not_operator call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier
Convert unicode to string as gnomekeyring barfs on unicode
def kw_str_parse(a_string): try: return dict((k, eval(v.rstrip(','))) for k, v in kw_list_re.findall(a_string)) except (AttributeError, TypeError): if isinstance(a_string, collections.Mapping): return a_string return {}
module function_definition identifier parameters identifier block try_statement block return_statement call identifier generator_expression tuple identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list identifier except_clause tuple identifier identifier block if_statement call identifier argument_list identifier attribute identifier identifier block return_statement identifier return_statement dictionary
convert a string in the form 'a=b, c=d, e=f' to a dict
def ping(self): status, _, body = self._request('GET', self.ping_path()) return(status is not None) and (bytes_to_str(body) == 'OK')
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list return_statement boolean_operator parenthesized_expression comparison_operator identifier none parenthesized_expression comparison_operator call identifier argument_list identifier string string_start string_content string_end
Check server is alive over HTTP
def popenCatch(command, stdinString=None): logger.debug("Running the command: %s" % command) if stdinString != None: process = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, bufsize=-1) output, nothing = process.communicate(stdinString) else: process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=sys.stderr, bufsize=-1) output, nothing = process.communicate() sts = process.wait() if sts != 0: raise RuntimeError("Command: %s with stdin string '%s' exited with non-zero status %i" % (command, stdinString, sts)) return output
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier unary_operator integer expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier unary_operator integer expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier integer block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier identifier return_statement identifier
Runs a command and return standard out.
def remove_folder_content(path, ignore_hidden_file=False): for file in os.listdir(path): if ignore_hidden_file and file.startswith('.'): continue file_path = os.path.join(path, file) if os.path.isdir(file_path): shutil.rmtree(file_path) else: os.remove(file_path)
module function_definition identifier parameters identifier default_parameter identifier false block for_statement identifier call attribute identifier identifier argument_list identifier block if_statement boolean_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end block continue_statement 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 expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier
Remove all content in the given folder.
def markup_join(seq): buf = [] iterator = imap(soft_unicode, seq) for arg in iterator: buf.append(arg) if hasattr(arg, '__html__'): return Markup(u'').join(chain(buf, iterator)) return concat(buf)
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement call attribute call identifier argument_list string string_start string_end identifier argument_list call identifier argument_list identifier identifier return_statement call identifier argument_list identifier
Concatenation that escapes if necessary and converts to unicode.
def translate_key_to_config(p_key): if len(p_key) > 1: key = p_key.capitalize() if key.startswith('Ctrl') or key.startswith('Meta'): key = key[0] + '-' + key[5:] key = '<' + key + '>' else: key = p_key return key
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier binary_operator binary_operator subscript identifier integer string string_start string_content string_end subscript identifier slice integer expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end else_clause block expression_statement assignment identifier identifier return_statement identifier
Translates urwid key event to form understandable by topydo config parser.
def _get_ntgpadnt(self, ver, add_ns): hdrs = self.gpad_columns[ver] if add_ns: hdrs = hdrs + ['NS'] return cx.namedtuple("ntgpadobj", hdrs)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement identifier block expression_statement assignment identifier binary_operator identifier list string string_start string_content string_end return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Create a namedtuple object for each annotation
def serialize_action(action_type, payload, **extra_fields): action_dict = dict( action_type=action_type, payload=payload, **extra_fields ) return json.dumps(action_dict)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier dictionary_splat identifier return_statement call attribute identifier identifier argument_list identifier
This function returns the conventional form of the actions.
def _chunk_write(chunk, local_file, progress): local_file.write(chunk) if progress is not None: progress.update(len(chunk))
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier
Write a chunk to file and update the progress bar.
def create_figure(n_subplots, figsize): "Create the plot figure and subplot axes" fig = plt.figure(figsize=figsize) axes = [] for i in range(n_subplots): axes.append(fig.add_subplot(n_subplots, 1, i+1)) return fig, axes
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier list for_statement identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier integer binary_operator identifier integer return_statement expression_list identifier identifier
Create the plot figure and subplot axes
def count_courses(self): c = 0 for x in self.tuning: if type(x) == list: c += len(x) else: c += 1 return float(c) / len(self.tuning)
module function_definition identifier parameters identifier block expression_statement assignment identifier integer for_statement identifier attribute identifier identifier block if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement augmented_assignment identifier call identifier argument_list identifier else_clause block expression_statement augmented_assignment identifier integer return_statement binary_operator call identifier argument_list identifier call identifier argument_list attribute identifier identifier
Return the average number of courses per string.
def add_error(self, property_name, message): if property_name not in self.errors: self.errors[property_name] = [] self.errors[property_name].append(message)
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier list expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier
Add an error for the given property.
def _init_setup_console_data(self, order: str = "C") -> None: global _root_console self._key_color = None if self.console_c == ffi.NULL: _root_console = self self._console_data = lib.TCOD_ctx.root else: self._console_data = ffi.cast( "struct TCOD_Console*", self.console_c ) self._tiles = np.frombuffer( ffi.buffer(self._console_data.tiles[0 : self.width * self.height]), dtype=self.DTYPE, ).reshape((self.height, self.width)) self._order = tcod._internal.verify_order(order)
module function_definition identifier parameters identifier typed_default_parameter identifier type identifier string string_start string_content string_end type none block global_statement identifier expression_statement assignment attribute identifier identifier none if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier identifier expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier else_clause block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list subscript attribute attribute identifier identifier identifier slice integer binary_operator attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier identifier argument_list tuple attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier
Setup numpy arrays over libtcod data buffers.
def reprompt_error(self, message=None): try: session_id = session.sessionId self.session_machines.rollback_fsm(session_id) current_state = self.session_machines.current_state(session_id) if message is None: err_msg = choice(self._scenario_steps[current_state]['reprompt']) else: err_msg = message return question(err_msg) except UninitializedStateMachine as e: logger.error(e) return statement(INTERNAL_ERROR_MSG)
module function_definition identifier parameters identifier default_parameter identifier none block try_statement block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list subscript subscript attribute identifier identifier identifier string string_start string_content string_end else_clause block expression_statement assignment identifier identifier return_statement call identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier
Intended to be used in case of erroneous input data
def sspro8_results(self): return ssbio.protein.sequence.utils.fasta.load_fasta_file_as_dict_of_seqs(self.out_sspro8)
module function_definition identifier parameters identifier block return_statement call attribute attribute attribute attribute attribute identifier identifier identifier identifier identifier identifier argument_list attribute identifier identifier
Parse the SSpro8 output file and return a dict of secondary structure compositions.
def profile_view(name, **kwargs): ctx = Context(**kwargs) ctx.execute_action('profile:view', **{ 'storage': ctx.repo.create_secure_service('storage'), 'name': name, })
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list dictionary_splat identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end dictionary_splat dictionary pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end identifier
Show profile configuration content.
def list_all(dev: Device): for name, service in dev.services.items(): click.echo(click.style("\nService %s" % name, bold=True)) for method in service.methods: click.echo(" %s" % method.name)
module function_definition identifier parameters typed_parameter identifier type identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end identifier keyword_argument identifier true for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier
List all available API calls.
def to_internal_value(self, data): if 'properties' in data: data = self.unformat_geojson(data) return super(GeoFeatureModelSerializer, self).to_internal_value(data)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier
Override the parent method to first remove the GeoJSON formatting
def _change_schema(self, schema, action, name=None, func=None): if self.oport.schema.schema() == schema.schema(): return self if func is None: func = streamsx.topology.functions.identity _name = name if _name is None: _name = action css = self._map(func, schema, name=_name) if self._placeable: self._colocate(css, action) return css
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none block if_statement comparison_operator call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute identifier identifier argument_list block return_statement identifier if_statement comparison_operator identifier none block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier
Internal method to change a schema.
def comma_converter(float_string): trans_table = maketrans(b',', b'.') return float(float_string.translate(trans_table))
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement call identifier argument_list call attribute identifier identifier argument_list identifier
Convert numbers to floats whether the decimal point is '.' or ',
def call(self): data = self._downloader.download() if sys.version >= "2.7": data = data.decode("utf-8", errors="ignore") else: data = data.decode("utf-8") self.update(json.loads(data)) self._fetched = True
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list 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 string string_start string_content string_end keyword_argument identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier true
Make the API call again and fetch fresh data.
def flush(self, batch_size=1000): keys = self.database.keys(self.namespace + ':*') for i in range(0, len(keys), batch_size): self.database.delete(*keys[i:i + batch_size])
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end for_statement identifier call identifier argument_list integer call identifier argument_list identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list list_splat subscript identifier slice identifier binary_operator identifier identifier
Delete all autocomplete indexes and metadata.
def _rec_owner_number(self): player = self._header.initial.players[self._header.replay.rec_player] return player.attributes.player_color + 1
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute attribute attribute identifier identifier identifier identifier attribute attribute attribute identifier identifier identifier identifier return_statement binary_operator attribute attribute identifier identifier identifier integer
Get rec owner number.
def vary_name(name: Text): snake = re.match(r'^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$', name) if not snake: fail('The project name is not a valid snake-case Python variable name') camel = [x[0].upper() + x[1:] for x in name.split('_')] return { 'project_name_snake': name, 'project_name_camel': ''.join(camel), 'project_name_readable': ' '.join(camel), }
module function_definition identifier parameters typed_parameter identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement not_operator identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier list_comprehension binary_operator call attribute subscript identifier integer identifier argument_list subscript identifier slice integer for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute string string_start string_end identifier argument_list identifier pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier
Validates the name and creates variations
def getGroundResolution(self, latitude, level): latitude = self.clipValue(latitude, self.min_lat, self.max_lat); mapSize = self.getMapDimensionsByZoomLevel(level) return math.cos( latitude * math.pi / 180) * 2 * math.pi * self.earth_radius / \ mapSize
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement binary_operator binary_operator binary_operator binary_operator call attribute identifier identifier argument_list binary_operator binary_operator identifier attribute identifier identifier integer integer attribute identifier identifier attribute identifier identifier line_continuation identifier
returns the ground resolution for based on latitude and zoom level.
def dict(self): res = copy(self) if MATCHES in res: del res[MATCHES] if NAME in res: del res[NAME] res = {self.name: res} for k, v in self.matches.items(): res[k] = v if NAME in res[k]: del res[k][NAME] return res
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier identifier block delete_statement subscript identifier identifier if_statement comparison_operator identifier identifier block delete_statement subscript identifier identifier expression_statement assignment identifier dictionary pair attribute identifier identifier identifier for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment subscript identifier identifier identifier if_statement comparison_operator identifier subscript identifier identifier block delete_statement subscript subscript identifier identifier identifier return_statement identifier
Dictionary representing this match and all child symbol matches.
def _assertsanity(self): assert self.len >= 0 assert 0 <= self._offset, "offset={0}".format(self._offset) assert (self.len + self._offset + 7) // 8 == self._datastore.bytelength + self._datastore.byteoffset return True
module function_definition identifier parameters identifier block assert_statement comparison_operator attribute identifier identifier integer assert_statement comparison_operator integer attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier assert_statement comparison_operator binary_operator parenthesized_expression binary_operator binary_operator attribute identifier identifier attribute identifier identifier integer integer binary_operator attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier return_statement true
Check internal self consistency as a debugging aid.
def register(self, pattern, view=None): if view is None: return partial(self.register, pattern) self.patterns.append(self._make_url((pattern, view))) return view
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block return_statement call identifier argument_list attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list tuple identifier identifier return_statement identifier
Allow decorator-style construction of URL pattern lists.
def urls(self): for base_url, mapping in self.routes.items(): for url, _ in mapping.items(): yield base_url + url
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement yield binary_operator identifier identifier
Returns a generator of all URLs attached to this API
def update(self, typ, id, **kwargs): return self._load(self._request(typ, id=id, method='PUT', data=kwargs))
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier
update just fields sent by keyword args
def convex_conj(self): conj_exp = conj_exponent(self.pointwise_norm.exponent) return IndicatorGroupL1UnitBall(self.domain, exponent=conj_exp)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier return_statement call identifier argument_list attribute identifier identifier keyword_argument identifier identifier
The convex conjugate functional of the group L1-norm.
def display_eventtype(self): if self.annot is not None: event_types = sorted(self.annot.event_types, key=str.lower) else: event_types = [] self.idx_eventtype.clear() evttype_group = QGroupBox('Event Types') layout = QVBoxLayout() evttype_group.setLayout(layout) self.check_all_eventtype = check_all = QCheckBox('All event types') check_all.setCheckState(Qt.Checked) check_all.clicked.connect(self.toggle_eventtype) layout.addWidget(check_all) self.idx_eventtype_list = [] for one_eventtype in event_types: self.idx_eventtype.addItem(one_eventtype) item = QCheckBox(one_eventtype) layout.addWidget(item) item.setCheckState(Qt.Checked) item.stateChanged.connect(self.update_annotations) item.stateChanged.connect(self.toggle_check_all_eventtype) self.idx_eventtype_list.append(item) self.idx_eventtype_scroll.setWidget(evttype_group)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier else_clause block expression_statement assignment identifier list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier assignment identifier call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier list for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Read the list of event types in the annotations and update widgets.
def sync_objects_in(self): self.dstate = self.STATES.BUILDING self.build_source_files.record_to_objects()
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Synchronize from records to objects
def read_mm_uic2(fd, byte_order, dtype, count): result = {'number_planes': count} values = numpy.fromfile(fd, byte_order+'I', 6*count) result['z_distance'] = values[0::6] // values[1::6] return result
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier binary_operator identifier string string_start string_content string_end binary_operator integer identifier expression_statement assignment subscript identifier string string_start string_content string_end binary_operator subscript identifier slice integer integer subscript identifier slice integer integer return_statement identifier
Read MM_UIC2 tag from file and return as dictionary.
def run(self) -> None: fd = self._fd encoding = self._encoding line_terminators = self._line_terminators queue = self._queue buf = "" while True: try: c = fd.read(1).decode(encoding) except UnicodeDecodeError as e: log.warning("Decoding error from {!r}: {!r}", self._cmdargs, e) if self._suppress_decoding_errors: continue else: raise if not c: return buf += c for t in line_terminators: try: t_idx = buf.index(t) + len(t) fragment = buf[:t_idx] buf = buf[t_idx:] queue.put(fragment) except ValueError: pass
module function_definition identifier parameters identifier type none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier string string_start string_end while_statement true block try_statement block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list integer identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier if_statement attribute identifier identifier block continue_statement else_clause block raise_statement if_statement not_operator identifier block return_statement expression_statement augmented_assignment identifier identifier for_statement identifier identifier block try_statement block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier call identifier argument_list identifier expression_statement assignment identifier subscript identifier slice identifier expression_statement assignment identifier subscript identifier slice identifier expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement
Read lines and put them on the queue.
def format_template_file(filename, content): with open(filename, 'r') as f: template = f.read() if type(template) != str: template = template.decode('utf-8') return format_template(template, content)
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier identifier
Render a given pystache template file with given content
def ls(): heading, body = cli_syncthing_adapter.ls() if heading: click.echo(heading) if body: click.echo(body.strip())
module function_definition identifier parameters block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list
List all synchronized directories.
def make_reader_task(self, stream, callback): return self.loop.create_task(self.executor_wrapper(background_reader, stream, self.loop, callback))
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier attribute identifier identifier identifier
Create a reader executor task for a stream.
def splitSong(songToSplit, start1, start2): print "start1 " + str(start1) print "start2 " + str(start2) songs = [songToSplit[:start1], songToSplit[start2:]] return songs
module function_definition identifier parameters identifier identifier identifier block print_statement binary_operator string string_start string_content string_end call identifier argument_list identifier print_statement binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier list subscript identifier slice identifier subscript identifier slice identifier return_statement identifier
Split a song into two parts, one starting at start1, the other at start2
def base_url(root): for attr, value in root.attrib.iteritems(): if attr.endswith('base') and 'http' in value: return value return None
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end comparison_operator string string_start string_content string_end identifier block return_statement identifier return_statement none
Determine the base url for a root element.
def send_file(self, file): if self.logger: self.logger.debug("[ioc.extra.tornado.RouterHandler] send file %s" % file) self.send_file_header(file) fp = open(file, 'rb') self.write(fp.read()) fp.close()
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Send a file to the client, it is a convenient method to avoid duplicated code
def Z(self, value): if isinstance(value, (int, float, long, types.NoneType)): self._z = value
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier tuple identifier identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier
sets the Z coordinate
def _find_usage_application_versions(self): versions = self.conn.describe_application_versions() self.limits['Application versions']._add_current_usage( len(versions['ApplicationVersions']), aws_type='AWS::ElasticBeanstalk::ApplicationVersion', )
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end
find usage for ElasticBeanstalk application verions
def update_transfer( self, nonce: Nonce, balance_hash: BalanceHash, additional_hash: AdditionalHash, partner_signature: Signature, signature: Signature, block_identifier: BlockSpecification, ): self.token_network.update_transfer( channel_identifier=self.channel_identifier, partner=self.participant2, balance_hash=balance_hash, nonce=nonce, additional_hash=additional_hash, closing_signature=partner_signature, non_closing_signature=signature, given_block_identifier=block_identifier, )
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Updates the channel using the provided balance proof.
def _NormalizeDiscoveryUrls(discovery_url): if discovery_url.startswith('http'): return [discovery_url] elif '.' not in discovery_url: raise ValueError('Unrecognized value "%s" for discovery url') api_name, _, api_version = discovery_url.partition('.') return [ 'https://www.googleapis.com/discovery/v1/apis/%s/%s/rest' % ( api_name, api_version), 'https://%s.googleapis.com/$discovery/rest?version=%s' % ( api_name, api_version), ]
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block return_statement list identifier elif_clause comparison_operator string string_start string_content string_end identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement list binary_operator string string_start string_content string_end tuple identifier identifier binary_operator string string_start string_content string_end tuple identifier identifier
Expands a few abbreviations into full discovery urls.
def before_processing(eng, objects): super(InvenioProcessingFactory, InvenioProcessingFactory)\ .before_processing(eng, objects) eng.save(WorkflowStatus.RUNNING) db.session.commit()
module function_definition identifier parameters identifier identifier block expression_statement call attribute call identifier argument_list identifier identifier line_continuation identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Execute before processing the workflow.
def default(value): if isinstance(value, Decimal): primative = float(value) if int(primative) == primative: return int(primative) else: return primative elif isinstance(value, set): return list(value) elif isinstance(value, Binary): return b64encode(value.value) raise TypeError("Cannot encode %s value %r" % (type(value), value))
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier else_clause block return_statement identifier elif_clause call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block return_statement call identifier argument_list attribute identifier identifier raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple call identifier argument_list identifier identifier
Default encoder for JSON
def histograms_route(self, request): tag = request.args.get('tag') run = request.args.get('run') try: (body, mime_type) = self.histograms_impl( tag, run, downsample_to=self.SAMPLE_SIZE) code = 200 except ValueError as e: (body, mime_type) = (str(e), 'text/plain') code = 400 return http_util.Respond(request, body, mime_type, code=code)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment tuple_pattern identifier identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier integer except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment tuple_pattern identifier identifier tuple call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier integer return_statement call attribute identifier identifier argument_list identifier identifier identifier keyword_argument identifier identifier
Given a tag and single run, return array of histogram values.
def instantiate(self): code_lines = [] if not self.instantiated: code_lines.append("%s = %s()" % (self.variable_name, self.model.__name__)) self.instantiated = True pk_name = self.instance._meta.pk.name key = '%s_%s' % (self.model.__name__, getattr(self.instance, pk_name)) self.context[key] = self.variable_name return code_lines
module function_definition identifier parameters identifier block expression_statement assignment identifier list if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier true expression_statement assignment identifier attribute attribute attribute attribute identifier identifier identifier identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute attribute identifier identifier identifier call identifier argument_list attribute identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier attribute identifier identifier return_statement identifier
Write lines for instantiation