code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def _handle_end_relation(self): self._result.append(Relation(result=self._result, **self._curr)) self._curr = {}
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list keyword_argument identifier attribute identifier identifier dictionary_splat attribute identifier identifier expression_statement assignment attribute identifier identifier dictionary
Handle closing relation element
def romanize(number): roman = [] for numeral, value in NUMERALS: times, number = divmod(number, value) roman.append(times * numeral) return ''.join(roman)
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator identifier identifier return_statement call attribute string string_start string_end identifier argument_list identifier
Convert `number` to a Roman numeral.
def old_values(self): def get_old_values_and_key(item): values = item.old_values values.update({self._key: item.past_dict[self._key]}) return values return [get_old_values_and_key(el) for el in self._get_recursive_difference('all') if el.diffs and el.past_dict]
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list dictionary pair attribute identifier identifier subscript attribute identifier identifier attribute identifier identifier return_statement identifier return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end if_clause boolean_operator attribute identifier identifier attribute identifier identifier
Returns the old values from the diff
def loadable_modules(self): with self._mutex: if not self._loadable_modules: self._loadable_modules = [] for mp in self._obj.get_loadable_modules(): self._loadable_modules.append(utils.nvlist_to_dict(mp.properties)) return self._loadable_modules
module function_definition identifier parameters identifier block with_statement with_clause with_item attribute identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier list for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier return_statement attribute identifier identifier
The list of loadable module profile dictionaries.
def admin_docker_list_view(context, request): return { 'paginator': Page( context.all, url_maker=lambda p: request.path_url + "?page=%s" % p, page=int(request.params.get('page', 1)), items_per_page=6 ) }
module function_definition identifier parameters identifier identifier block return_statement dictionary pair string string_start string_content string_end call identifier argument_list attribute identifier identifier keyword_argument identifier lambda lambda_parameters identifier binary_operator attribute identifier identifier binary_operator string string_start string_content string_end identifier keyword_argument identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer keyword_argument identifier integer
Show list of docker images.
def SendKeys(keys, pause=0.05, with_spaces=False, with_tabs=False, with_newlines=False, turn_off_numlock=True): "Parse the keys and type them" keys = parse_keys(keys, with_spaces, with_tabs, with_newlines) for k in keys: k.Run() time.sleep(pause)
module function_definition identifier parameters identifier default_parameter identifier float default_parameter identifier false default_parameter identifier false default_parameter identifier false default_parameter identifier true block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier
Parse the keys and type them
def insert_def(self, index, def_item): self.defs.insert(index, def_item) for other in self.others: other.insert_def(index, def_item)
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
Inserts a def universally.
def maybe_specialize(term, domain): if isinstance(term, LoadableTerm): return term.specialize(domain) return term
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list identifier return_statement identifier
Specialize a term if it's loadable.
def coerce_value(type, value): if isinstance(type, GraphQLNonNull): return coerce_value(type.of_type, value) if value is None: return None if isinstance(type, GraphQLList): item_type = type.of_type if not isinstance(value, string_types) and isinstance(value, Iterable): return [coerce_value(item_type, item) for item in value] else: return [coerce_value(item_type, value)] if isinstance(type, GraphQLInputObjectType): fields = type.fields obj = {} for field_name, field in fields.items(): if field_name not in value: if field.default_value is not None: field_value = field.default_value obj[field.out_name or field_name] = field_value else: field_value = coerce_value(field.type, value.get(field_name)) obj[field.out_name or field_name] = field_value return type.create_container(obj) assert isinstance(type, (GraphQLScalarType, GraphQLEnumType)), "Must be input type" return type.parse_value(value)
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list attribute identifier identifier identifier if_statement comparison_operator identifier none block return_statement none if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement boolean_operator not_operator call identifier argument_list identifier identifier call identifier argument_list identifier identifier block return_statement list_comprehension call identifier argument_list identifier identifier for_in_clause identifier identifier else_clause block return_statement list call identifier argument_list identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment subscript identifier boolean_operator attribute identifier identifier identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier boolean_operator attribute identifier identifier identifier identifier return_statement call attribute identifier identifier argument_list identifier assert_statement call identifier argument_list identifier tuple identifier identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier
Given a type and any value, return a runtime value coerced to match the type.
def _get_minutes_from_last_update(self, time): time_from_last_update = time - self.last_update_time return int(time_from_last_update.total_seconds() / 60)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator identifier attribute identifier identifier return_statement call identifier argument_list binary_operator call attribute identifier identifier argument_list integer
How much minutes passed from last update to given time
def _get_tls_context(self) -> ssl.SSLContext: if self.tls_context is not None: context = self.tls_context else: context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH) context.check_hostname = bool(self.validate_certs) if self.validate_certs: context.verify_mode = ssl.CERT_REQUIRED else: context.verify_mode = ssl.CERT_NONE if self.cert_bundle is not None: context.load_verify_locations(cafile=self.cert_bundle) if self.client_cert is not None: context.load_cert_chain(self.client_cert, keyfile=self.client_key) return context
module function_definition identifier parameters identifier type attribute identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier return_statement identifier
Build an SSLContext object from the options we've been given.
def force_unicode(value): if not isinstance(value, (str, unicode)): value = unicode(value) if isinstance(value, str): value = value.decode('utf-8') return value
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier call identifier argument_list identifier 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 return_statement identifier
return an utf-8 unicode entry
def read_book_uri_from_console(): db_path: str = input("Enter book_url or leave blank for the default settings value: ") if db_path: if db_path.startswith("sqlite://"): db_path_uri = db_path else: db_path_uri = "file:///" + db_path else: cfg = settings.Settings() db_path_uri = cfg.database_uri return db_path_uri
module function_definition identifier parameters block expression_statement assignment identifier type identifier call identifier argument_list string string_start string_content string_end if_statement identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier attribute identifier identifier return_statement identifier
Prompts the user to enter book url in console
def focused_on_tweet(request): slots = request.get_slot_map() if "Index" in slots and slots["Index"]: index = int(slots['Index']) elif "Ordinal" in slots and slots["Index"]: parse_ordinal = lambda inp : int("".join([l for l in inp if l in string.digits])) index = parse_ordinal(slots['Ordinal']) else: return False index = index - 1 user_state = twitter_cache.get_user_state(request.access_token()) queue = user_state['user_queue'].queue() if index < len(queue): tweet_to_analyze = queue[index] user_state['focus_tweet'] = tweet_to_analyze return index + 1 twitter_cache.serialize() return False
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator string string_start string_content string_end identifier subscript identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end elif_clause boolean_operator comparison_operator string string_start string_content string_end identifier subscript identifier string string_start string_content string_end block expression_statement assignment identifier lambda lambda_parameters identifier call identifier argument_list call attribute string string_start string_end identifier argument_list list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end else_clause block return_statement false expression_statement assignment identifier binary_operator identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list if_statement comparison_operator identifier call identifier argument_list identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement binary_operator identifier integer expression_statement call attribute identifier identifier argument_list return_statement false
Return index if focused on tweet False if couldn't
def _logoutclient(self, useruuid, clientuuid): self.log("Cleaning up client of logged in user.", lvl=debug) try: self._users[useruuid].clients.remove(clientuuid) if len(self._users[useruuid].clients) == 0: self.log("Last client of user disconnected.", lvl=verbose) self.fireEvent(userlogout(useruuid, clientuuid)) del self._users[useruuid] self._clients[clientuuid].useruuid = None except Exception as e: self.log("Error during client logout: ", e, type(e), clientuuid, useruuid, lvl=error, exc=True)
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier try_statement block expression_statement call attribute attribute subscript attribute identifier identifier identifier identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list attribute subscript attribute identifier identifier identifier identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier delete_statement subscript attribute identifier identifier identifier expression_statement assignment attribute subscript attribute identifier identifier identifier identifier none except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier call identifier argument_list identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier true
Log out a client and possibly associated user
def spec(self): return dict( headers=self.header_lines, start=self.start_line, comments=self.comment_lines, end=self.end_line )
module function_definition identifier parameters identifier block return_statement call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Return a dict with values that can be fed directly into SelectiveRowGenerator
def imu_changed(self, val): self.current_imuid = '{}_IMU{}'.format(self.sk8.get_device_name(), val) self.update_data_display(self.get_current_data())
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list
Handle clicks on the IMU index spinner.
def element_type(self, type_): return self.__find_xxx_type( type_, self.element_type_index, self.element_type_typedef, 'container_element_type')
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier string string_start string_content string_end
returns reference to the class value\\mapped type declaration
def entry_stats(entries, top_n=10): wc = Counter() for content in entries.values_list("rendered_content", flat=True): content = strip_tags(content) content = re.sub('\s+', ' ', content) content = re.sub('[^A-Za-z ]+', '', content) words = [w.lower() for w in content.split()] wc.update([w for w in words if w not in IGNORE_WORDS]) return { "total_words": len(wc.values()), "most_common": wc.most_common(top_n), }
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier call identifier argument_list for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list for_in_clause identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier identifier return_statement dictionary pair string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list pair string string_start string_content string_end call attribute identifier identifier argument_list identifier
Calculates stats for the given ``QuerySet`` of ``Entry``s.
def key_file(self): if self.auth_key: key_file_path = os.path.join(orchestration_mkdtemp(), 'key') with open(key_file_path, 'w') as fd: fd.write(self.auth_key) os.chmod(key_file_path, stat.S_IRUSR) return key_file_path
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier return_statement identifier
Get the path to the key file containig our auth key, or None.
def copy(self): return self.__class__(self.record.copy(), self.variables, self.info.copy(), self.vartype)
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Create a shallow copy.
def stream(self, chunk_size=64*1024): 'Returns a generator to iterate over the file contents' return self.jfs.stream(url=self.path, params={'mode':'bin'}, chunk_size=chunk_size)
module function_definition identifier parameters identifier default_parameter identifier binary_operator integer integer block expression_statement string string_start string_content string_end return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier
Returns a generator to iterate over the file contents
def _apply_cond(self, apply_fn, grad, var, *args, **kwargs): grad_acc = self.get_slot(var, "grad_acc") def apply_adam(grad_acc, apply_fn, grad, var, *args, **kwargs): total_grad = (grad_acc + grad) / tf.cast(self._n_t, grad.dtype) adam_op = apply_fn(total_grad, var, *args, **kwargs) with tf.control_dependencies([adam_op]): grad_acc_to_zero_op = grad_acc.assign(tf.zeros_like(grad_acc), use_locking=self._use_locking) return tf.group(adam_op, grad_acc_to_zero_op) def accumulate_gradient(grad_acc, grad): assign_op = tf.assign_add(grad_acc, grad, use_locking=self._use_locking) return tf.group(assign_op) return tf.cond( tf.equal(self._get_iter_variable(), 0), lambda: apply_adam(grad_acc, apply_fn, grad, var, *args, **kwargs), lambda: accumulate_gradient(grad_acc, grad))
module function_definition identifier parameters identifier identifier identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end function_definition identifier parameters identifier identifier identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier list_splat identifier dictionary_splat identifier with_statement with_clause with_item call attribute identifier identifier argument_list list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list integer lambda call identifier argument_list identifier identifier identifier identifier list_splat identifier dictionary_splat identifier lambda call identifier argument_list identifier identifier
Apply conditionally if counter is zero.
def on_go(self, target): if not target: Log.error("expecting target") with self.lock: if not self._go: DEBUG and self._name and Log.note("Adding target to signal {{name|quote}}", name=self.name) if not self.job_queue: self.job_queue = [target] else: self.job_queue.append(target) return (DEBUG_SIGNAL) and Log.note("Signal {{name|quote}} already triggered, running job immediately", name=self.name) target()
module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end with_statement with_clause with_item attribute identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement boolean_operator boolean_operator identifier attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier list identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement expression_statement boolean_operator parenthesized_expression identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement call identifier argument_list
RUN target WHEN SIGNALED
def handle_typical_memberdefs_no_overload(self, signature, memberdef_nodes): for n in memberdef_nodes: self.add_text(['\n', '%feature("docstring") ', signature, ' "', '\n']) if self.with_function_signature: self.add_line_with_subsequent_indent(self.get_function_signature(n)) self.subnode_parse(n, pieces=[], ignore=['definition', 'name']) self.add_text(['";', '\n'])
module function_definition identifier parameters identifier identifier identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list list string string_start string_content escape_sequence string_end string string_start string_content string_end identifier string string_start string_content string_end string string_start string_content escape_sequence string_end if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier list keyword_argument identifier list string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content escape_sequence string_end
Produce standard documentation for memberdef_nodes.
def xml(self, operator='set', indent = ""): xml = indent + "<meta id=\"" + self.key + "\"" if operator != 'set': xml += " operator=\"" + operator + "\"" if not self.value: xml += " />" else: xml += ">" + self.value + "</meta>" return xml
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_end block expression_statement assignment identifier binary_operator binary_operator binary_operator identifier string string_start string_content escape_sequence string_end attribute identifier identifier string string_start string_content escape_sequence string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement augmented_assignment identifier binary_operator binary_operator string string_start string_content escape_sequence string_end identifier string string_start string_content escape_sequence string_end if_statement not_operator attribute identifier identifier block expression_statement augmented_assignment identifier string string_start string_content string_end else_clause block expression_statement augmented_assignment identifier binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end return_statement identifier
Serialize the metadata field to XML
def run(endpoint, name=None): try: if os.isatty(0): for data in stream_skypipe_output(endpoint, name): sys.stdout.write(data) sys.stdout.flush() else: with skypipe_input_stream(endpoint, name) as stream: for line in stream_stdin_lines(): stream.send(line) except KeyboardInterrupt: pass
module function_definition identifier parameters identifier default_parameter identifier none block try_statement block if_statement call attribute identifier identifier argument_list integer block for_statement identifier call identifier argument_list identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list else_clause block with_statement with_clause with_item as_pattern call identifier argument_list identifier identifier as_pattern_target identifier block for_statement identifier call identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement
Runs the skypipe client
def _get_biallelic_variant(self, variant, info, _check_alleles=True): info = info.iloc[0, :] assert not info.multiallelic self._impute2_file.seek(info.seek) genotypes = self._parse_impute2_line(self._impute2_file.readline()) variant_alleles = variant._encode_alleles([ genotypes.reference, genotypes.coded, ]) if (_check_alleles and variant_alleles != variant.alleles): logging.variant_not_found(variant) return [] return [genotypes]
module function_definition identifier parameters identifier identifier identifier default_parameter identifier true block expression_statement assignment identifier subscript attribute identifier identifier integer slice assert_statement not_operator attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list list attribute identifier identifier attribute identifier identifier if_statement parenthesized_expression boolean_operator identifier comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement list return_statement list identifier
Creates a bi-allelic variant.
def ci_data(namespace, name, branch='master'): with repository(namespace, name, branch) as (path, latest, cache): if not path or not latest: return {'build_success': NOT_FOUND, 'status': NOT_FOUND} elif latest in cache: return json.loads(cache[latest]) starting = {'status': 'starting'} cache[latest] = json.dumps(starting) ci_worker(namespace, name, branch=branch, _bg=True) return starting
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block with_statement with_clause with_item as_pattern call identifier argument_list identifier identifier identifier as_pattern_target tuple identifier identifier identifier block if_statement boolean_operator not_operator identifier not_operator identifier block return_statement dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier elif_clause comparison_operator identifier identifier block return_statement call attribute identifier identifier argument_list subscript identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier true return_statement identifier
Returns or starts the ci data collection process
def _assemble_modification(stmt): sub_str = _assemble_agent_str(stmt.sub) if stmt.enz is not None: enz_str = _assemble_agent_str(stmt.enz) if _get_is_direct(stmt): mod_str = ' ' + _mod_process_verb(stmt) + ' ' else: mod_str = ' leads to the ' + _mod_process_noun(stmt) + ' of ' stmt_str = enz_str + mod_str + sub_str else: stmt_str = sub_str + ' is ' + _mod_state_stmt(stmt) if stmt.residue is not None: if stmt.position is None: mod_str = 'on ' + ist.amino_acids[stmt.residue]['full_name'] else: mod_str = 'on ' + stmt.residue + stmt.position else: mod_str = '' stmt_str += ' ' + mod_str return _make_sentence(stmt_str)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement call identifier argument_list identifier block expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end else_clause block expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator identifier identifier identifier else_clause block expression_statement assignment identifier binary_operator binary_operator identifier string string_start string_content string_end call identifier argument_list identifier if_statement comparison_operator attribute identifier identifier none block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier binary_operator string string_start string_content string_end subscript subscript attribute identifier identifier attribute identifier identifier string string_start string_content string_end else_clause block expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier string string_start string_end expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end identifier return_statement call identifier argument_list identifier
Assemble Modification statements into text.
def setSize(self, w, h): self.setW(w) self.setH(h) return self
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Sets the new size of the region
def untlpydict2dcformatteddict(untl_dict, **kwargs): ark = kwargs.get('ark', None) domain_name = kwargs.get('domain_name', None) scheme = kwargs.get('scheme', 'http') resolve_values = kwargs.get('resolve_values', None) resolve_urls = kwargs.get('resolve_urls', None) verbose_vocabularies = kwargs.get('verbose_vocabularies', None) untl_py = untldict2py(untl_dict) dc_py = untlpy2dcpy( untl_py, ark=ark, domain_name=domain_name, resolve_values=resolve_values, resolve_urls=resolve_urls, verbose_vocabularies=verbose_vocabularies, scheme=scheme ) return dcpy2formatteddcdict(dc_py)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list 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 return_statement call identifier argument_list identifier
Convert a UNTL data dictionary to a formatted DC data dictionary.
def _get_redditor_listing(subpath=''): def _listing(self, sort='new', time='all', *args, **kwargs): kwargs.setdefault('params', {}) kwargs['params'].setdefault('sort', sort) kwargs['params'].setdefault('t', time) url = urljoin(self._url, subpath) return self.reddit_session.get_content(url, *args, **kwargs) return _listing
module function_definition identifier parameters default_parameter identifier string string_start string_end block function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end dictionary expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end identifier expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement identifier
Return function to generate Redditor listings.
def _get_md5sum(self, fpath): try: current_md5 = hashlib.md5() if isinstance(fpath, six.string_types) and os.path.exists(fpath): with open(fpath, "rb") as fh: for chunk in self._read_chunks(fh): current_md5.update(chunk) elif (fpath.__class__.__name__ in ["StringIO", "StringO"] or isinstance(fpath, IOBase)): for chunk in self._read_chunks(fpath): current_md5.update(chunk) else: return "" return current_md5.hexdigest() except Exception: msg = ("Failed to calculate the image's md5sum") LOG.error(msg) raise exception.SDKImageOperationError(rs=3)
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator call identifier argument_list identifier attribute identifier identifier call attribute attribute identifier identifier identifier argument_list 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 for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier elif_clause parenthesized_expression boolean_operator comparison_operator attribute attribute identifier identifier identifier list string string_start string_content string_end string string_start string_content string_end call identifier argument_list identifier identifier block for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block return_statement string string_start string_end return_statement call attribute identifier identifier argument_list except_clause identifier block expression_statement assignment identifier parenthesized_expression string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier raise_statement call attribute identifier identifier argument_list keyword_argument identifier integer
Calculate the md5sum of the specific image file
def handle_time(msg): return msg.copy(ack=0, payload=calendar.timegm(time.localtime()))
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list
Process an internal time request message.
def read_yaml(file_path, Loader=yaml.Loader, object_pairs_hook=OrderedDict): class OrderedLoader(Loader): pass def construct_mapping(loader, node): loader.flatten_mapping(node) return object_pairs_hook(loader.construct_pairs(node)) OrderedLoader.add_constructor( yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, construct_mapping) with open(file_path, 'r') as f: return yaml.load(f, OrderedLoader)
module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier default_parameter identifier identifier block class_definition identifier argument_list identifier block pass_statement function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute attribute attribute identifier identifier identifier identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block return_statement call attribute identifier identifier argument_list identifier identifier
Read YAML file and return as python dictionary
def _thread_worker_fn(samples, batchify_fn, dataset): if isinstance(samples[0], (list, tuple)): batch = [batchify_fn([dataset[i] for i in shard]) for shard in samples] else: batch = batchify_fn([dataset[i] for i in samples]) return batch
module function_definition identifier parameters identifier identifier identifier block if_statement call identifier argument_list subscript identifier integer tuple identifier identifier block expression_statement assignment identifier list_comprehension call identifier argument_list list_comprehension subscript identifier identifier for_in_clause identifier identifier for_in_clause identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list list_comprehension subscript identifier identifier for_in_clause identifier identifier return_statement identifier
Threadpool worker function for processing data.
def files_in_dir(path, extension): ends = '.{0}'.format(extension) return (f for f in os.listdir(path) if f.endswith(ends))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier return_statement generator_expression identifier for_in_clause identifier call attribute identifier identifier argument_list identifier if_clause call attribute identifier identifier argument_list identifier
Enumartes the files in path with the given extension
def ndims(self): if self._dims is None: return None else: if self._ndims is None: self._ndims = len(self._dims) return self._ndims
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block return_statement none else_clause block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier return_statement attribute identifier identifier
Returns the rank of this shape, or None if it is unspecified.
def script(vm_): script_name = config.get_cloud_config_value('script', vm_, __opts__) if not script_name: script_name = 'bootstrap-salt' return salt.utils.cloud.os_script( script_name, vm_, __opts__, salt.utils.cloud.salt_config_to_yaml( salt.utils.cloud.minion_config(__opts__, vm_) ) )
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier if_statement not_operator identifier block expression_statement assignment identifier string string_start string_content string_end return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier
Return the script deployment object
def initGrid(self): blinker = [(4, 4), (4, 5), (4, 6)] toad = [(9, 5), (9, 6), (9, 7), (10, 4), (10, 5), (10, 6)] glider = [(4, 11), (5, 12), (6, 10), (6, 11), (6, 12)] r_pentomino = [(10, 60), (9, 61), (10, 61), (11, 61), (9, 62)] self.grid = {} if self.test: for cell in chain(blinker, toad, glider, r_pentomino): self.grid[cell] = 1 else: for _ in range(self.initsize): ry = random.randint(self.y_pad, self.y_grid - 1) rx = random.randint(self.x_pad, self.x_grid - 1) self.grid[(ry, rx)] = 1
module function_definition identifier parameters identifier block expression_statement assignment identifier list tuple integer integer tuple integer integer tuple integer integer expression_statement assignment identifier list tuple integer integer tuple integer integer tuple integer integer tuple integer integer tuple integer integer tuple integer integer expression_statement assignment identifier list tuple integer integer tuple integer integer tuple integer integer tuple integer integer tuple integer integer expression_statement assignment identifier list tuple integer integer tuple integer integer tuple integer integer tuple integer integer tuple integer integer expression_statement assignment attribute identifier identifier dictionary if_statement attribute identifier identifier block for_statement identifier call identifier argument_list identifier identifier identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier integer else_clause block for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier binary_operator attribute identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier binary_operator attribute identifier identifier integer expression_statement assignment subscript attribute identifier identifier tuple identifier identifier integer
Initialise the game grid
def save_var(self, key, value, **kwargs): 'Save one variable to the database.' self.__check_or_create_vars_table() column_type = get_column_type(value) tmp = quote(self.__vars_table_tmp) self.execute(u'DROP TABLE IF EXISTS %s' % tmp, commit = False) self.execute(u'CREATE TABLE %s (`value` %s)' % (tmp, column_type), commit = False) self.execute(u'INSERT INTO %s (`value`) VALUES (?)' % tmp, [value], commit = False) table = (quote(self.__vars_table), tmp) params = [key, column_type] self.execute(u % table, params) self.execute(u'DROP TABLE %s' % tmp, commit = False) self.__commit_if_necessary(kwargs)
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier keyword_argument identifier false expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier keyword_argument identifier false expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier list identifier keyword_argument identifier false expression_statement assignment identifier tuple call identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier list identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator identifier identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier keyword_argument identifier false expression_statement call attribute identifier identifier argument_list identifier
Save one variable to the database.
def load_numpy(self, hash_list): assert len(hash_list) == 1 self._check_hashes(hash_list) with open(self.object_path(hash_list[0]), 'rb') as fd: return np.load(fd, allow_pickle=False)
module function_definition identifier parameters identifier identifier block assert_statement comparison_operator call identifier argument_list identifier integer expression_statement call attribute identifier identifier argument_list identifier with_statement with_clause with_item as_pattern call identifier argument_list call attribute identifier identifier argument_list subscript identifier integer string string_start string_content string_end as_pattern_target identifier block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier false
Loads a numpy array.
def commandline_text(bytestring): 'Convert bytestring from command line to unicode, using default file system encoding' if six.PY3: return bytestring unicode_string = bytestring.decode(sys.getfilesystemencoding()) return unicode_string
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement attribute identifier identifier block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement identifier
Convert bytestring from command line to unicode, using default file system encoding
def conjugate_quat(quat): return Quat(-quat.x, -quat.y, -quat.z, quat.w)
module function_definition identifier parameters identifier block return_statement call identifier argument_list unary_operator attribute identifier identifier unary_operator attribute identifier identifier unary_operator attribute identifier identifier attribute identifier identifier
Negate the vector part of the quaternion.
def _refresh_multi_axis(self): d = self.declaration self.viewbox = pg.ViewBox() _plots = [c for c in self.parent().children() if isinstance(c,AbstractQtPlotItem)] i = _plots.index(self) if i==0: self.axis = self.widget.getAxis('right') self.widget.showAxis('right') else: self.axis = pg.AxisItem('right') self.axis.setZValue(-10000) self.widget.layout.addItem(self.axis,2,i+2) self.viewbox.setXLink(self.widget.vb) self.axis.linkToView(self.viewbox) self.axis.setLabel(d.label_right) self.parent().parent_widget().scene().addItem(self.viewbox)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call attribute call attribute identifier identifier argument_list identifier argument_list if_clause call identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier integer block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list unary_operator integer expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier integer binary_operator identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier 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 call attribute call attribute call attribute identifier identifier argument_list identifier argument_list identifier argument_list identifier argument_list attribute identifier identifier
If linked axis' are used, setup and link them
def _set_box(self): net_volume = 0.0 for idx, mol in enumerate(self.mols): length = max([np.max(mol.cart_coords[:, i])-np.min(mol.cart_coords[:, i]) for i in range(3)]) + 2.0 net_volume += (length**3.0) * float(self.param_list[idx]['number']) length = net_volume**(1.0/3.0) for idx, mol in enumerate(self.mols): self.param_list[idx]['inside box'] = '0.0 0.0 0.0 {} {} {}'.format( length, length, length)
module function_definition identifier parameters identifier block expression_statement assignment identifier float for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier binary_operator call identifier argument_list list_comprehension binary_operator call attribute identifier identifier argument_list subscript attribute identifier identifier slice identifier call attribute identifier identifier argument_list subscript attribute identifier identifier slice identifier for_in_clause identifier call identifier argument_list integer float expression_statement augmented_assignment identifier binary_operator parenthesized_expression binary_operator identifier float call identifier argument_list subscript subscript attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator float float for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment subscript subscript attribute identifier identifier identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier
Set the box size for the molecular assembly
def auto_invalidate(self): current = datetime.now() if current > self._invalidated + timedelta(seconds=self._timetolive): self.invalidate()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier binary_operator attribute identifier identifier call identifier argument_list keyword_argument identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list
Invalidate the cache if the current time is past the time to live.
def sum_transactions(transactions): workdays_per_year = 250 previous_date = None rate = 0 day_sum = 0 for transaction in transactions: date, action, value = _parse_transaction_entry(transaction) if previous_date is None: previous_date = date elapsed = workdays.networkdays(previous_date, date, stat_holidays()) - 1 if action == 'rate': rate = float(value) / workdays_per_year elif action == 'off': elapsed -= 1 day_sum -= 1 day_sum += rate * elapsed if action == 'days': day_sum = value previous_date = date return day_sum
module function_definition identifier parameters identifier block expression_statement assignment identifier integer expression_statement assignment identifier none expression_statement assignment identifier integer expression_statement assignment identifier integer for_statement identifier identifier block expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier identifier call identifier argument_list integer if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator call identifier argument_list identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement augmented_assignment identifier integer expression_statement augmented_assignment identifier integer expression_statement augmented_assignment identifier binary_operator identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier identifier expression_statement assignment identifier identifier return_statement identifier
Sums transactions into a total of remaining vacation days.
def expanded_counts_map(self): if self.hpx._ipix is None: return self.counts output = np.zeros( (self.counts.shape[0], self.hpx._maxpix), self.counts.dtype) for i in range(self.counts.shape[0]): output[i][self.hpx._ipix] = self.counts[i] return output
module function_definition identifier parameters identifier block if_statement comparison_operator attribute attribute identifier identifier identifier none block return_statement attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list tuple subscript attribute attribute identifier identifier identifier integer attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier for_statement identifier call identifier argument_list subscript attribute attribute identifier identifier identifier integer block expression_statement assignment subscript subscript identifier identifier attribute attribute identifier identifier identifier subscript attribute identifier identifier identifier return_statement identifier
return the full counts map
def _get_securitygroupname_id(securitygroupname_list): securitygroupid_set = set() if not isinstance(securitygroupname_list, list): securitygroupname_list = [securitygroupname_list] params = {'Action': 'DescribeSecurityGroups'} for sg in aws.query(params, location=get_location(), provider=get_provider(), opts=__opts__, sigver='4'): if sg['groupName'] in securitygroupname_list: log.debug( 'AWS SecurityGroup ID of %s is %s', sg['groupName'], sg['groupId'] ) securitygroupid_set.add(sg['groupId']) return list(securitygroupid_set)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier list identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list identifier keyword_argument identifier call identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end block if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end return_statement call identifier argument_list identifier
Returns the SecurityGroupId of a SecurityGroupName to use
def _get_thumbnail_filename(filename, append_text="-thumbnail"): name, ext = os.path.splitext(filename) return ''.join([name, append_text, ext])
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute string string_start string_end identifier argument_list list identifier identifier identifier
Returns a thumbnail version of the file name.
def cli(env, account_id, content_url): manager = SoftLayer.CDNManager(env.client) manager.load_content(account_id, content_url)
module function_definition identifier parameters 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
Cache one or more files on all edge nodes.
def _check_ruby(ret, ruby, user=None): match_version = True match_micro_version = False micro_version_regex = re.compile(r'-([0-9]{4}\.[0-9]{2}|p[0-9]+)$') if micro_version_regex.search(ruby): match_micro_version = True if re.search('^[a-z]+$', ruby): match_version = False ruby = re.sub('^ruby-', '', ruby) for impl, version, default in __salt__['rvm.list'](runas=user): if impl != 'ruby': version = '{impl}-{version}'.format(impl=impl, version=version) if not match_micro_version: version = micro_version_regex.sub('', version) if not match_version: version = re.sub('-.*', '', version) if version == ruby: ret['result'] = True ret['comment'] = 'Requested ruby exists.' ret['default'] = default break return ret
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier true expression_statement assignment identifier false expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier true if_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier block expression_statement assignment identifier false expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier for_statement pattern_list identifier identifier identifier call subscript identifier string string_start string_content string_end argument_list keyword_argument identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_end identifier if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end true expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end identifier break_statement return_statement identifier
Check that ruby is installed
def _filter(msgdata, mailparser, mdfolder, mailfilters): if mailfilters: for f in mailfilters: msg = mailparser.parse(StringIO(msgdata)) rule = f(msg, folder=mdfolder) if rule: yield rule return
module function_definition identifier parameters identifier identifier identifier identifier block if_statement identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier if_statement identifier block expression_statement yield identifier return_statement
Filter msgdata by mailfilters
def read_with_selection(func): def wrapper(*args, **kwargs): selection = kwargs.pop('selection', None) or [] tab = func(*args, **kwargs) if selection: return filter_table(tab, selection) return tab return _safe_wraps(wrapper, func)
module function_definition identifier parameters identifier block function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end none list expression_statement assignment identifier call identifier argument_list list_splat identifier dictionary_splat identifier if_statement identifier block return_statement call identifier argument_list identifier identifier return_statement identifier return_statement call identifier argument_list identifier identifier
Decorate a Table read method to apply ``selection`` keyword
def versions_request(self): ret = self.handle_api_exceptions('GET', '', api_ver='') return [str_dict(x) for x in ret.json()]
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end keyword_argument identifier string string_start string_end return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list
List Available REST API Versions
def validate_complex(prop, value, xpath_map=None): if value is not None: validate_type(prop, value, dict) if prop in _complex_definitions: complex_keys = _complex_definitions[prop] else: complex_keys = {} if xpath_map is None else xpath_map for complex_prop, complex_val in iteritems(value): complex_key = '.'.join((prop, complex_prop)) if complex_prop not in complex_keys: _validation_error(prop, None, value, ('keys: {0}'.format(','.join(complex_keys)))) validate_type(complex_key, complex_val, (string_types, list))
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement call identifier argument_list identifier identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript identifier identifier else_clause block expression_statement assignment identifier conditional_expression dictionary comparison_operator identifier none identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list tuple identifier identifier if_statement comparison_operator identifier identifier block expression_statement call identifier argument_list identifier none identifier parenthesized_expression call attribute string string_start string_content string_end identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list identifier identifier tuple identifier identifier
Default validation for single complex data structure
def update(self): stats = self.get_init_value() if self.input_method == 'local': stats = cpu_percent.get(percpu=True) else: pass self.stats = stats return self.stats
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier true else_clause block pass_statement expression_statement assignment attribute identifier identifier identifier return_statement attribute identifier identifier
Update per-CPU stats using the input method.
def order_sections(self, key, reverse=True): fsort = lambda s: s.__dict__[key] return sorted(self.sections, key=fsort, reverse=reverse)
module function_definition identifier parameters identifier identifier default_parameter identifier true block expression_statement assignment identifier lambda lambda_parameters identifier subscript attribute identifier identifier identifier return_statement call identifier argument_list attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Sort sections according to the value of key.
def verification_update(self, cluster_id, status): data = {'verification': {'status': status}} return self._patch("/clusters/%s" % cluster_id, data)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier identifier
Start a verification for a Cluster.
def draw_line(self, ax, line, force_trans=None): coordinates, data = self.process_transform(line.get_transform(), ax, line.get_xydata(), force_trans=force_trans) linestyle = utils.get_line_style(line) if linestyle['dasharray'] is None: linestyle = None markerstyle = utils.get_marker_style(line) if (markerstyle['marker'] in ['None', 'none', None] or markerstyle['markerpath'][0].size == 0): markerstyle = None label = line.get_label() if markerstyle or linestyle: self.renderer.draw_marked_line(data=data, coordinates=coordinates, linestyle=linestyle, markerstyle=markerstyle, label=label, mplobj=line)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator subscript identifier string string_start string_content string_end none block expression_statement assignment identifier none expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement parenthesized_expression boolean_operator comparison_operator subscript identifier string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end none comparison_operator attribute subscript subscript identifier string string_start string_content string_end integer identifier integer block expression_statement assignment identifier none expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Process a matplotlib line and call renderer.draw_line
def json(self): return { "elevation": self.elevation, "latitude": self.latitude, "longitude": self.longitude, "icao_code": self.icao_code, "name": self.name, "quality": self.quality, "wban_ids": self.wban_ids, "recent_wban_id": self.recent_wban_id, "climate_zones": { "iecc_climate_zone": self.iecc_climate_zone, "iecc_moisture_regime": self.iecc_moisture_regime, "ba_climate_zone": self.ba_climate_zone, "ca_climate_zone": self.ca_climate_zone, }, }
module function_definition identifier parameters identifier block return_statement dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier
Return a JSON-serializeable object containing station metadata.
def add_edge(self, u, v, attr_dict=None, **attr): if attr_dict is None: attr_dict = attr else: try: attr_dict.update(attr) except AttributeError: raise NetworkXError( "The attr_dict argument must be a dictionary." ) if u not in self.node: self.node[u] = {} if v not in self.node: self.node[v] = {} if u in self.adj: datadict = self.adj[u].get(v, {}) else: self.adj[u] = {v: {}} datadict = self.adj[u][v] datadict.update(attr_dict) self.succ[u][v] = datadict assert u in self.succ, "Failed to add edge {u}->{v} ({u} not in successors)".format(u=u, v=v) assert v in self.succ[u], "Failed to add edge {u}->{v} ({v} not in succ[{u}])".format(u=u, v=v)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier identifier else_clause block try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier dictionary if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier dictionary if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call attribute subscript attribute identifier identifier identifier identifier argument_list identifier dictionary else_clause block expression_statement assignment subscript attribute identifier identifier identifier dictionary pair identifier dictionary expression_statement assignment identifier subscript subscript attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript subscript attribute identifier identifier identifier identifier identifier assert_statement comparison_operator identifier attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier assert_statement comparison_operator identifier subscript attribute identifier identifier identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Version of add_edge that only writes to the database once
def normalized(self): norm = self.magnitude() return Vector(self.x / norm, self.y / norm, self.z / norm)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call identifier argument_list binary_operator attribute identifier identifier identifier binary_operator attribute identifier identifier identifier binary_operator attribute identifier identifier identifier
Returns a normalized copy of this vector.
def _put(self, timestamp, value): idx = self._lookup(timestamp) if idx is not None: self._values[idx] = (timestamp, value) else: self._values.append((timestamp, value))
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment subscript attribute identifier identifier identifier tuple identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier
Replace the value associated with "timestamp" or add the new value
def _clean_xmldict_single_dic(self, dictionary): for k, v in dictionary.items(): if v is None: dictionary[k] = ''
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 none block expression_statement assignment subscript identifier identifier string string_start string_end
Every None replace by '' in the dic, as xml parsers puts None in those fiels, which is not valid for IAR
def stop(self): if self.interrupted: return for thread in self.worker_threads: thread.interrupted = True self.interrupted = True
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement for_statement identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier true
Stops the coordinator thread and all related threads.
def _find_rule_no(self, mac): ipt_cmd = ['iptables', '-L', '--line-numbers'] cmdo = dsl.execute(ipt_cmd, self._root_helper, log_output=False) for o in cmdo.split('\n'): if mac in o.lower(): rule_no = o.split()[0] LOG.info('Found rule %(rule)s for %(mac)s.', {'rule': rule_no, 'mac': mac}) return rule_no
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier keyword_argument identifier false for_statement identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end block if_statement comparison_operator identifier call attribute identifier identifier argument_list block expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list 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 return_statement identifier
Find rule number associated with a given mac.
def deprecated(function): def IssueDeprecationWarning(*args, **kwargs): warnings.simplefilter('default', DeprecationWarning) warnings.warn('Call to deprecated function: {0:s}.'.format( function.__name__), category=DeprecationWarning, stacklevel=2) return function(*args, **kwargs) IssueDeprecationWarning.__name__ = function.__name__ IssueDeprecationWarning.__doc__ = function.__doc__ IssueDeprecationWarning.__dict__.update(function.__dict__) return IssueDeprecationWarning
module function_definition identifier parameters identifier block function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier integer return_statement call identifier argument_list list_splat identifier dictionary_splat identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier return_statement identifier
Decorator to mark functions or methods as deprecated.
def longest(*args): internal_assert(len(args) >= 2, "longest expects at least two args") matcher = args[0] + skip_whitespace for elem in args[1:]: matcher ^= elem + skip_whitespace return matcher
module function_definition identifier parameters list_splat_pattern identifier block expression_statement call identifier argument_list comparison_operator call identifier argument_list identifier integer string string_start string_content string_end expression_statement assignment identifier binary_operator subscript identifier integer identifier for_statement identifier subscript identifier slice integer block expression_statement augmented_assignment identifier binary_operator identifier identifier return_statement identifier
Match the longest of the given grammar elements.
def _calc_relative_path_lengths(self, x, y): path_lengths = np.sqrt(np.diff(x) ** 2 + np.diff(y) ** 2) total_length = np.sum(path_lengths) cummulative_lengths = np.cumsum(path_lengths) relative_path_lengths = cummulative_lengths / total_length return relative_path_lengths
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator call attribute identifier identifier argument_list identifier integer binary_operator call attribute identifier identifier argument_list identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator identifier identifier return_statement identifier
Determine the relative path length at each x,y position.
def charge(self, user, vault_id=None): assert self.is_in_vault(user) if vault_id: user_vault = self.get(user=user, vault_id=vault_id) else: user_vault = self.get(user=user)
module function_definition identifier parameters identifier identifier default_parameter identifier none block assert_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier
If vault_id is not passed this will assume that there is only one instane of user and vault_id in the db.
def get(args): m = RiverManager(args.hosts) r = m.get(args.name) if r: print(json.dumps(r, indent=2)) else: sys.exit(1)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement identifier block expression_statement call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier integer else_clause block expression_statement call attribute identifier identifier argument_list integer
Get a river by name.
def printDeadCells(self): columnCasualties = numpy.zeros(self.numberOfColumns()) for cell in self.deadCells: col = self.columnForCell(cell) columnCasualties[col] += 1 for col in range(self.numberOfColumns()): print col, columnCasualties[col]
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement augmented_assignment subscript identifier identifier integer for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block print_statement identifier subscript identifier identifier
Print statistics for the dead cells
def startswith(self, other): try: other = UrlPath.from_object(other) except ValueError: raise TypeError('startswith first arg must be UrlPath, str, PathParam, not {}'.format(type(other))) else: return self._nodes[:len(other._nodes)] == other._nodes
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier else_clause block return_statement comparison_operator subscript attribute identifier identifier slice call identifier argument_list attribute identifier identifier attribute identifier identifier
Return True if this path starts with the other path.
def show_options(self): from safe.gui.tools.options_dialog import OptionsDialog dialog = OptionsDialog( iface=self.iface, parent=self.iface.mainWindow()) dialog.show_option_dialog() if dialog.exec_(): self.dock_widget.read_settings() from safe.gui.widgets.message import getting_started_message send_static_message(self.dock_widget, getting_started_message()) self.dock_widget.get_layers()
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier identifier identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list if_statement call attribute identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list import_from_statement dotted_name identifier identifier identifier identifier dotted_name identifier expression_statement call identifier argument_list attribute identifier identifier call identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list
Show the options dialog.
def _storeAccessContext(snmpEngine): execCtx = snmpEngine.observer.getExecutionContext('rfc3412.receiveMessage:request') return { 'securityModel': execCtx['securityModel'], 'securityName': execCtx['securityName'], 'securityLevel': execCtx['securityLevel'], 'contextName': execCtx['contextName'], 'pduType': execCtx['pdu'].getTagSet() }
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end call attribute subscript identifier string string_start string_content string_end identifier argument_list
Copy received message metadata while it lasts
def have_authenticated_user(client_ip, repository, session_token): if repository not in config['repositories']: return False repository_path = config['repositories'][repository]['path'] conn = auth_db_connect(cpjoin(repository_path, 'auth_transient.db')) user_lock = read_user_lock(repository_path) active_commit = user_lock['session_token'] if user_lock != None else None if active_commit != None: conn.execute("delete from session_tokens where expires < ? and token != ?", (time.time(), active_commit)) else: conn.execute("delete from session_tokens where expires < ?", (time.time(),)) res = conn.execute("select * from session_tokens where token = ? and ip = ?", (session_token, client_ip)).fetchall() if res != [] and repository in config['users'][res[0]['username']]['uses_repositories']: conn.execute("update session_tokens set expires = ? where token = ? and ip = ?", (time.time() + extend_session_duration, session_token, client_ip)) conn.commit() return res[0] conn.commit() return False
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier subscript identifier string string_start string_content string_end block return_statement false expression_statement assignment identifier subscript subscript subscript identifier string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier conditional_expression subscript identifier string string_start string_content string_end comparison_operator identifier none none if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end tuple call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end tuple call attribute identifier identifier argument_list expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end tuple identifier identifier identifier argument_list if_statement boolean_operator comparison_operator identifier list comparison_operator identifier subscript subscript subscript identifier string string_start string_content string_end subscript subscript identifier integer string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end tuple binary_operator call attribute identifier identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list return_statement subscript identifier integer expression_statement call attribute identifier identifier argument_list return_statement false
check user submitted session token against the db and that ip has not changed
def on_failure(self, exc, task_id, args, kwargs, einfo): log.error('[{}] failed due to {}'.format(task_id, getattr(einfo, 'traceback', None))) super(LoggedTask, self).on_failure(exc, task_id, args, kwargs, einfo)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier call identifier argument_list identifier string string_start string_content string_end none expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier identifier identifier identifier
Capture the exception that caused the task to fail, if any.
def all_host_infos(): output = [] output.append(["Operating system", os()]) output.append(["CPUID information", cpu()]) output.append(["CC information", compiler()]) output.append(["JDK information", from_cmd("java -version")]) output.append(["MPI information", from_cmd("mpirun -version")]) output.append(["Scala information", from_cmd("scala -version")]) output.append(["OpenCL headers", from_cmd( "find /usr/include|grep opencl.h")]) output.append(["OpenCL libraries", from_cmd( "find /usr/lib/ -iname '*opencl*'")]) output.append(["NVidia SMI", from_cmd("nvidia-smi -q")]) output.append(["OpenCL Details", opencl()]) return output
module function_definition identifier parameters block expression_statement assignment identifier list expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end call identifier argument_list expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end call identifier argument_list expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end call identifier argument_list expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end call identifier argument_list return_statement identifier
Summarize all host information.
def extendMarkdown(self, md, md_globals=None): if any( x not in md.treeprocessors for x in self.REQUIRED_EXTENSION_INTERNAL_NAMES): raise RuntimeError( "The attr_cols markdown extension depends the following" " extensions which must preceded it in the extension" " list: %s" % ", ".join(self.REQUIRED_EXTENSIONS)) processor = AttrColTreeProcessor(md, self.conf) md.treeprocessors.register( processor, 'attr_cols', 5)
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement call identifier generator_expression comparison_operator identifier attribute identifier identifier for_in_clause identifier attribute identifier 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 string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end integer
Initializes markdown extension components.
def skip_common_stack_elements(stacktrace, base_case): for i, (trace, base) in enumerate(zip(stacktrace, base_case)): if trace != base: return stacktrace[i:] return stacktrace[-1:]
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier tuple_pattern identifier identifier call identifier argument_list call identifier argument_list identifier identifier block if_statement comparison_operator identifier identifier block return_statement subscript identifier slice identifier return_statement subscript identifier slice unary_operator integer
Skips items that the target stacktrace shares with the base stacktrace.
def _explode_lines(shape): if shape.geom_type == 'LineString': return [shape] elif shape.geom_type == 'MultiLineString': return shape.geoms elif shape.geom_type == 'GeometryCollection': lines = [] for geom in shape.geoms: lines.extend(_explode_lines(geom)) return lines return []
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement list identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement attribute identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier return_statement identifier return_statement list
Return a list of LineStrings which make up the shape.
def _CreateRouter(self, router_cls, params=None): if not router_cls.params_type and params: raise ApiCallRouterDoesNotExpectParameters( "%s is not configurable" % router_cls) rdf_params = None if router_cls.params_type: rdf_params = router_cls.params_type() if params: rdf_params.FromDict(params) return router_cls(params=rdf_params)
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement boolean_operator not_operator attribute identifier identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier none if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list keyword_argument identifier identifier
Creates a router with a given name and params.
def reformat(found_sequences): for (pdb_id, chain, file_name), sequence in sorted(found_sequences.iteritems()): header = sequence[0] assert(header[0] == '>') tokens = header.split('|') tokens[0] = tokens[0][:5] assert(len(tokens[0]) == 5) sequence[0] = "|".join(tokens)
module function_definition identifier parameters identifier block for_statement pattern_list tuple_pattern identifier identifier identifier identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement assignment identifier subscript identifier integer assert_statement parenthesized_expression comparison_operator subscript identifier integer 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 subscript identifier integer subscript subscript identifier integer slice integer assert_statement parenthesized_expression comparison_operator call identifier argument_list subscript identifier integer integer expression_statement assignment subscript identifier integer call attribute string string_start string_content string_end identifier argument_list identifier
Truncate the FASTA headers so that the first field is a 4-character ID.
def add_date(self, date): self.lines = self.parser.add_date(date, self.lines)
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier
Add the given date to the textual representation.
def _compute_e2_factor(self, imt, vs30): e2 = np.zeros_like(vs30) if imt.name == "PGV": period = 1 elif imt.name == "PGA": period = 0 else: period = imt.period if period < 0.35: return e2 else: idx = vs30 <= 1000 if period >= 0.35 and period <= 2.0: e2[idx] = (-0.25 * np.log(vs30[idx] / 1000) * np.log(period / 0.35)) elif period > 2.0: e2[idx] = (-0.25 * np.log(vs30[idx] / 1000) * np.log(2.0 / 0.35)) return e2
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier integer elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier integer else_clause block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier float block return_statement identifier else_clause block expression_statement assignment identifier comparison_operator identifier integer if_statement boolean_operator comparison_operator identifier float comparison_operator identifier float block expression_statement assignment subscript identifier identifier parenthesized_expression binary_operator binary_operator unary_operator float call attribute identifier identifier argument_list binary_operator subscript identifier identifier integer call attribute identifier identifier argument_list binary_operator identifier float elif_clause comparison_operator identifier float block expression_statement assignment subscript identifier identifier parenthesized_expression binary_operator binary_operator unary_operator float call attribute identifier identifier argument_list binary_operator subscript identifier identifier integer call attribute identifier identifier argument_list binary_operator float float return_statement identifier
Compute and return e2 factor, equation 19, page 80.
def import_seaborn(): with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") try: import seaborn.apionly as sns if (w and issubclass(w[-1].category, UserWarning) and ("seaborn.apionly module" in str(w[-1].message))): raise ImportError except ImportError: import seaborn as sns finally: warnings.resetwarnings() return sns
module function_definition identifier parameters block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list keyword_argument identifier true as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end try_statement block import_statement aliased_import dotted_name identifier identifier identifier if_statement parenthesized_expression boolean_operator boolean_operator identifier call identifier argument_list attribute subscript identifier unary_operator integer identifier identifier parenthesized_expression comparison_operator string string_start string_content string_end call identifier argument_list attribute subscript identifier unary_operator integer identifier block raise_statement identifier except_clause identifier block import_statement aliased_import dotted_name identifier identifier finally_clause block expression_statement call attribute identifier identifier argument_list return_statement identifier
import seaborn and handle deprecation of apionly module
def load_from_json(file_path): if os.path.exists(file_path): raw_data = open(file_path, 'rb').read() return json.loads(base64.decodestring(raw_data).decode('utf-8'))
module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier string string_start string_content string_end identifier argument_list return_statement call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end
Load the stored data from json, and return as a dict.
def projector_functions(self): projector_functions = OrderedDict() for (mesh, values, attrib) in self._parse_all_radfuncs("projector_function"): state = attrib["state"] projector_functions[state] = RadialFunction(mesh, values) return projector_functions
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement tuple_pattern identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier identifier call identifier argument_list identifier identifier return_statement identifier
Dictionary with the PAW projectors indexed by state.
def remove_parameter(self, parameter_name): if parameter_name in self.paramorder: index = self.paramorder.index(parameter_name) del self.paramorder[index] if parameter_name in self._parameters: del self._parameters[parameter_name]
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier delete_statement subscript attribute identifier identifier identifier if_statement comparison_operator identifier attribute identifier identifier block delete_statement subscript attribute identifier identifier identifier
Removes the specified parameter from the list.
def field_pk_from_json(self, data): model = get_model(data['app'], data['model']) return PkOnlyModel(self, model, data['pk'])
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end return_statement call identifier argument_list identifier identifier subscript identifier string string_start string_content string_end
Load a PkOnlyModel from a JSON dict.
def rescan(self): self._pathfiles = {} for path in self.basepaths: self.scan_path(path)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier dictionary for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
Rescans the base paths to find new code files.
def colorize(lead, num, color): if num != 0 and ANSIBLE_COLOR and color is not None: return "%s%s%-15s" % (stringc(lead, color), stringc("=", color), stringc(str(num), color)) else: return "%s=%-4s" % (lead, str(num))
module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator boolean_operator comparison_operator identifier integer identifier comparison_operator identifier none block return_statement binary_operator string string_start string_content string_end tuple call identifier argument_list identifier identifier call identifier argument_list string string_start string_content string_end identifier call identifier argument_list call identifier argument_list identifier identifier else_clause block return_statement binary_operator string string_start string_content string_end tuple identifier call identifier argument_list identifier
Print 'lead' = 'num' in 'color'
def get(self, object_type, object_id): if object_id == 0: return json_success(json.dumps([])) query = db.session.query(TaggedObject).filter(and_( TaggedObject.object_type == object_type, TaggedObject.object_id == object_id)) tags = [{'id': obj.tag.id, 'name': obj.tag.name} for obj in query] return json_success(json.dumps(tags))
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier integer block return_statement call identifier argument_list call attribute identifier identifier argument_list list expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list call identifier argument_list comparison_operator attribute identifier identifier identifier comparison_operator attribute identifier identifier identifier expression_statement assignment identifier list_comprehension dictionary pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end attribute attribute identifier identifier identifier for_in_clause identifier identifier return_statement call identifier argument_list call attribute identifier identifier argument_list identifier
List all tags a given object has.
def create_cell_renderer_text(self, tree_view, title="title", assign=0, editable=False): renderer = Gtk.CellRendererText() renderer.set_property('editable', editable) column = Gtk.TreeViewColumn(title, renderer, text=assign) tree_view.append_column(column)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier integer default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Function creates a CellRendererText with title
def __ipv4_netmask(value): valid, errmsg = False, 'dotted quad or integer CIDR (0->32)' valid, value, _ = __int(value) if not (valid and 0 <= value <= 32): valid = salt.utils.validate.net.netmask(value) return (valid, value, errmsg)
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier expression_list false string string_start string_content string_end expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier if_statement not_operator parenthesized_expression boolean_operator identifier comparison_operator integer identifier integer block expression_statement assignment identifier call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list identifier return_statement tuple identifier identifier identifier
validate an IPv4 dotted quad or integer CIDR netmask
def updatePlayer(name, settings): player = delPlayer(name) _validate(settings) player.update(settings) player.save() getKnownPlayers()[player.name] = player return player
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment subscript call identifier argument_list attribute identifier identifier identifier return_statement identifier
update an existing PlayerRecord setting and save to disk file
def _parse(data, obj_name, attr_map): parsed_xml = minidom.parseString(data) parsed_objects = [] for obj in parsed_xml.getElementsByTagName(obj_name): parsed_obj = {} for (py_name, xml_name) in attr_map.items(): parsed_obj[py_name] = _get_minidom_tag_value(obj, xml_name) parsed_objects.append(parsed_obj) return parsed_objects
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier dictionary for_statement tuple_pattern identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
parse xml data into a python map