code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def save(self, notes=None): if notes: self._changes['notes'] = notes super(Issue, self).save()
module function_definition identifier parameters identifier default_parameter identifier none block if_statement identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list
Save all changes back to Redmine with optional notes.
def load(app_id): path_to_data = find_experiment_export(app_id) if path_to_data is None: raise IOError("Dataset {} could not be found.".format(app_id)) return Data(path_to_data)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement call identifier argument_list identifier
Load the data from wherever it is found.
def local_scope(self): self.scope = self.scope.new_child() try: yield self.scope finally: self.scope = self.scope.parents
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list try_statement block expression_statement yield attribute identifier identifier finally_clause block expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier
Assign symbols to local variables.
async def disconnect(self, requested=True): if self.state == PlayerState.DISCONNECTING: return await self.update_state(PlayerState.DISCONNECTING) if not requested: log.debug( f"Forcing player disconnect for guild {self.channel.guild.id}" f" due to player manager request." ) guild_id = self.channel.guild.id voice_ws = self.node.get_voice_ws(guild_id) if not voice_ws.closed: await voice_ws.voice_state(guild_id, None) await self.node.destroy_guild(guild_id) await self.close() self.manager.remove_player(self)
module function_definition identifier parameters identifier default_parameter identifier true block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block return_statement expression_statement await call attribute identifier identifier argument_list attribute identifier identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content interpolation attribute attribute attribute identifier identifier identifier identifier string_end string string_start string_content string_end expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator attribute identifier identifier block expression_statement await call attribute identifier identifier argument_list identifier none expression_statement await call attribute attribute identifier identifier identifier argument_list identifier expression_statement await call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Disconnects this player from it's voice channel.
def run(self): try: answer = urlopen(self.url + "&mode=queue").read().decode() except (HTTPError, URLError) as error: self.output = { "full_text": str(error.reason), "color": " } return answer = json.loads(answer) if not answer.get("status", True): self.output = { "full_text": answer["error"], "color": " } return queue = answer["queue"] self.status = queue["status"] if self.is_paused(): color = self.color_paused elif self.is_downloading(): color = self.color_downloading else: color = self.color if self.is_downloading(): full_text = self.format.format(**queue) else: full_text = self.format_paused.format(**queue) self.output = { "full_text": full_text, "color": color }
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call attribute call attribute call identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end identifier argument_list identifier argument_list except_clause as_pattern tuple identifier identifier as_pattern_target identifier block expression_statement assignment attribute identifier identifier dictionary pair string string_start string_content string_end call identifier argument_list attribute identifier identifier pair string string_start string_content string_end string string_start string_end return_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end true block expression_statement assignment attribute identifier identifier 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 string string_start string_end return_statement expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier attribute identifier identifier elif_clause call attribute identifier identifier argument_list block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier expression_statement assignment attribute identifier identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier
Connect to SABnzbd and get the data.
def calculate_payload_hash(payload, algorithm, content_type): p_hash = hashlib.new(algorithm) parts = [] parts.append('hawk.' + str(HAWK_VER) + '.payload\n') parts.append(parse_content_type(content_type) + '\n') parts.append(payload or '') parts.append('\n') for i, p in enumerate(parts): if not isinstance(p, six.binary_type): p = p.encode('utf8') p_hash.update(p) parts[i] = p log.debug('calculating payload hash from:\n{parts}' .format(parts=pprint.pformat(parts))) return b64encode(p_hash.digest())
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 expression_statement call attribute identifier identifier argument_list binary_operator binary_operator string string_start string_content string_end call identifier argument_list identifier string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list binary_operator call identifier argument_list identifier string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list boolean_operator identifier string string_start string_end expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list call attribute identifier identifier argument_list
Calculates a hash for a given payload.
def CheckMounts(filename): with io.open(filename, "r") as fd: for line in fd: try: device, mnt_point, fs_type, _ = line.split(" ", 3) except ValueError: continue if fs_type in ACCEPTABLE_FILESYSTEMS: if os.path.exists(device): yield device, fs_type, mnt_point
module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier identifier block try_statement block expression_statement assignment pattern_list identifier identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end integer except_clause identifier block continue_statement if_statement comparison_operator identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement yield expression_list identifier identifier identifier
Parses the currently mounted devices.
def _learner_distributed(learn:Learner, cuda_id:int, cache_dir:PathOrStr='tmp'): "Put `learn` on distributed training with `cuda_id`." learn.callbacks.append(DistributedTrainer(learn, cuda_id)) learn.callbacks.append(DistributedRecorder(learn, cuda_id, cache_dir)) return learn
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier string string_start string_content string_end block expression_statement string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier identifier identifier return_statement identifier
Put `learn` on distributed training with `cuda_id`.
def _initial_guess(self, countsmat): if self.theta_ is not None: return self.theta_ if self.guess == 'log': transmat, pi = _transmat_mle_prinz(countsmat) K = np.real(scipy.linalg.logm(transmat)) / self.lag_time elif self.guess == 'pseudo': transmat, pi = _transmat_mle_prinz(countsmat) K = (transmat - np.eye(self.n_states_)) / self.lag_time elif isinstance(self.guess, np.ndarray): pi = _solve_ratemat_eigensystem(self.guess)[1][:, 0] K = self.guess S = np.multiply(np.sqrt(np.outer(pi, 1/pi)), K) sflat = np.maximum(S[np.triu_indices_from(countsmat, k=1)], 0) theta0 = np.concatenate((sflat, np.log(pi))) return theta0
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block return_statement attribute identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier elif_clause call identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier subscript subscript call identifier argument_list attribute identifier identifier integer slice integer expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier binary_operator integer identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier call attribute identifier identifier argument_list identifier keyword_argument identifier integer integer expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier call attribute identifier identifier argument_list identifier return_statement identifier
Generate an initial guess for \theta.
def _parse_filter_word(self, word): if isinstance(word, str): word = "'{}'".format(word) elif isinstance(word, dt.date): if isinstance(word, dt.datetime): if word.tzinfo is None: word = self.protocol.timezone.localize( word) if word.tzinfo != pytz.utc: word = word.astimezone( pytz.utc) if '/' in self._attribute: word = "'{}'".format( word.isoformat()) else: word = "{}".format( word.isoformat()) elif isinstance(word, bool): word = str(word).lower() return word
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier elif_clause call identifier argument_list identifier attribute identifier identifier block if_statement call identifier argument_list identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list return_statement identifier
Converts the word parameter into the correct format
def flightmode_colours(): from MAVProxy.modules.lib.grapher import flightmode_colours mapping = {} idx = 0 for (mode,t0,t1) in flightmodes: if not mode in mapping: mapping[mode] = flightmode_colours[idx] idx += 1 if idx >= len(flightmode_colours): idx = 0 return mapping
module function_definition identifier parameters block import_from_statement dotted_name identifier identifier identifier identifier dotted_name identifier expression_statement assignment identifier dictionary expression_statement assignment identifier integer for_statement tuple_pattern identifier identifier identifier identifier block if_statement not_operator comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier subscript identifier identifier expression_statement augmented_assignment identifier integer if_statement comparison_operator identifier call identifier argument_list identifier block expression_statement assignment identifier integer return_statement identifier
return mapping of flight mode to colours
def wait_func_accept_retry_state(wait_func): if not six.callable(wait_func): return wait_func if func_takes_retry_state(wait_func): return wait_func if func_takes_last_result(wait_func): @_utils.wraps(wait_func) def wrapped_wait_func(retry_state): warn_about_non_retry_state_deprecation( 'wait', wait_func, stacklevel=4) return wait_func( retry_state.attempt_number, retry_state.seconds_since_start, last_result=retry_state.outcome, ) else: @_utils.wraps(wait_func) def wrapped_wait_func(retry_state): warn_about_non_retry_state_deprecation( 'wait', wait_func, stacklevel=4) return wait_func( retry_state.attempt_number, retry_state.seconds_since_start, ) return wrapped_wait_func
module function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block return_statement identifier if_statement call identifier argument_list identifier block return_statement identifier if_statement call identifier argument_list identifier block decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier block expression_statement call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier integer return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier else_clause block decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier block expression_statement call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier integer return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier return_statement identifier
Wrap wait function to accept "retry_state" parameter.
def merge(self, another): if isinstance(another, Result): another = another.errors self.errors = self.merge_errors(self.errors, another)
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier identifier
Merges another validation result graph into itself
def from_dict(d): warnings_ = d.get('warnings', []) query = d.get('query') or None if query: query = Person.from_dict(query) person = d.get('person') or None if person: person = Person.from_dict(person) records = d.get('records') if records: records = [Record.from_dict(record) for record in records] suggested_searches = d.get('suggested_searches') if suggested_searches: suggested_searches = [Record.from_dict(record) for record in suggested_searches] return SearchAPIResponse(query=query, person=person, records=records, suggested_searches=suggested_searches, warnings_=warnings_)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list expression_statement assignment identifier boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end none if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end none if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Transform the dict to a response object and return the response.
def url_quote(url): try: return quote(url, safe=URL_SAFE) except KeyError: return quote(encode(url), safe=URL_SAFE)
module function_definition identifier parameters identifier block try_statement block return_statement call identifier argument_list identifier keyword_argument identifier identifier except_clause identifier block return_statement call identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier
Ensure url is valid
def validate_rpc_host(ip): if not is_valid_ipv4(ip) and not is_valid_ipv6(ip): raise ApplicationException( desc='Invalid RPC ip address: %s' % ip) return ip
module function_definition identifier parameters identifier block if_statement boolean_operator not_operator call identifier argument_list identifier not_operator call identifier argument_list identifier block raise_statement call identifier argument_list keyword_argument identifier binary_operator string string_start string_content string_end identifier return_statement identifier
Validates the given ip for use as RPC server address.
def _get_key(args, kwargs, remove_callback): weak_args = tuple(_try_weakref(arg, remove_callback) for arg in args) weak_kwargs = tuple(sorted( (key, _try_weakref(value, remove_callback)) for (key, value) in kwargs.items())) return weak_args, weak_kwargs
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier generator_expression call identifier argument_list identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list call identifier generator_expression tuple identifier call identifier argument_list identifier identifier for_in_clause tuple_pattern identifier identifier call attribute identifier identifier argument_list return_statement expression_list identifier identifier
Calculate the cache key, using weak references where possible.
def _aside_from_xml(self, node, block_def_id, block_usage_id, id_generator): id_generator = id_generator or self.id_generator aside_type = node.tag aside_class = self.load_aside_type(aside_type) aside_def_id, aside_usage_id = id_generator.create_aside(block_def_id, block_usage_id, aside_type) keys = ScopeIds(None, aside_type, aside_def_id, aside_usage_id) aside = aside_class.parse_xml(node, self, keys, id_generator) aside.save()
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier boolean_operator identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list none identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list
Create an aside from the xml and attach it to the given block
def tableexists(tablename): result = True try: t = table(tablename, ack=False) except: result = False return result
module function_definition identifier parameters identifier block expression_statement assignment identifier true try_statement block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier false except_clause block expression_statement assignment identifier false return_statement identifier
Test if a table exists.
def trigger(queue, user=None, group=None, mode=None, trigger=_c.FSQ_TRIGGER): user, group, mode = _dflts(user, group, mode) trigger_path = fsq_path.trigger(queue, trigger=trigger) created = False try: try: os.mkfifo(trigger_path.encode(_c.FSQ_CHARSET), mode) created = True except (OSError, IOError, ), e: if e.errno != errno.EEXIST: raise e os.chmod(trigger_path, mode) if user is not None or group is not None: os.chown(trigger_path, *uid_gid(user, group, path=trigger_path)) except (OSError, IOError, ), e: if created: _cleanup(trigger_path, e) _raise(trigger_path, e)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier attribute identifier identifier block expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier false try_statement block try_statement block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier true except_clause tuple identifier identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement identifier expression_statement call attribute identifier identifier argument_list identifier identifier if_statement boolean_operator comparison_operator identifier none comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier list_splat call identifier argument_list identifier identifier keyword_argument identifier identifier except_clause tuple identifier identifier identifier block if_statement identifier block expression_statement call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier identifier
Installs a trigger for the specified queue.
def unsubscribe_all(self): topics = list(self.topics.keys()) for topic in topics: self.unsubscribe(topic)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
Unsubscribe from all topics.
def _load_data(self): if self.raw_data is None and self.data_format is not FormatType.PYTHON: if self.file_path is None: raise ArgumentInvalid('One of "raw_data" or "file_path" should be set!') if not os.path.isfile(self.file_path) or not os.access(self.file_path, os.R_OK): raise ArgumentInvalid('"file_path" should be a valid path to an exist file with read permission!') with open(self.file_path) as f: self.raw_data = f.read()
module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list string string_start string_content string_end if_statement boolean_operator not_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier not_operator call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier as_pattern_target identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list
Load data from raw_data or file_path
def libv8_object(object_name): filename = join(V8_LIB_DIRECTORY, 'out.gn/x64.release/obj/{}'.format(object_name)) if not isfile(filename): filename = join(local_path('vendor/v8/out.gn/libv8/obj/{}'.format(object_name))) if not isfile(filename): filename = join(V8_LIB_DIRECTORY, 'out.gn/x64.release/obj/{}'.format(object_name)) return filename
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement not_operator call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier if_statement not_operator call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier
Return a path for object_name which is OS independent
def prep_shell_environment(nova_env, nova_creds): new_env = {} for key, value in prep_nova_creds(nova_env, nova_creds): if type(value) == six.binary_type: value = value.decode() new_env[key] = value return new_env
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call identifier argument_list identifier identifier block if_statement comparison_operator call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier identifier identifier return_statement identifier
Appends new variables to the current shell environment temporarily.
def main(): framework = pelix.framework.create_framework(( "pelix.ipopo.core", "pelix.shell.core", "pelix.shell.console")) framework.start() context = framework.get_bundle_context() context.install_bundle("spell_dictionary_EN").start() context.install_bundle("spell_dictionary_FR").start() context.install_bundle("spell_checker").start() ref_config = context.get_service_reference("spell_checker_service") with use_service(context, ref_config) as svc_config: passage = "Welcome to our framwork iPOPO" print("1. Testing Spell Checker:", passage) misspelled_words = svc_config.check(passage) print("> Misspelled_words are:", misspelled_words) context.install_bundle("spell_client").start() framework.wait_for_stop()
module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list expression_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list expression_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list identifier identifier as_pattern_target identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content string_end identifier expression_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list expression_statement call attribute identifier identifier argument_list
Starts a Pelix framework and waits for it to stop
def migration(resource, version, previous_version=''): def decorator(func): @wraps(func) def wrapper(*args, **kwargs): migrated = func(*args, **kwargs) return migrated m = Migration(wrapper, resource, version, previous_version) m.register() return m return decorator
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_end block function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list list_splat identifier dictionary_splat identifier return_statement identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier return_statement identifier
Register a migration function
def add_or_update(self, row, value, kind): i = bisect.bisect_left(self.keys, row) if i < len(self.keys) and self.keys[i].row == row: self.keys[i].update(value, kind) else: self.keys.insert(i, TrackKey(row, value, kind))
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier if_statement boolean_operator comparison_operator identifier call identifier argument_list attribute identifier identifier comparison_operator attribute subscript attribute identifier identifier identifier identifier identifier block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier call identifier argument_list identifier identifier identifier
Add or update a track value
def update_existing_pivot(self, id, attributes, touch=True): if self.updated_at() in self._pivot_columns: attributes = self.set_timestamps_on_attach(attributes, True) updated = self._new_picot_statement_for_id(id).update(attributes) if touch: self.touch_if_touching() return updated
module function_definition identifier parameters identifier identifier identifier default_parameter identifier true block if_statement comparison_operator call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier true expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list return_statement identifier
Update an existing pivot record on the table.
def output(self): "Print out the f-score table." FScore.output_header() nts = list(self.nt_score.keys()) nts.sort() for nt in nts: self.nt_score[nt].output_row(nt) print() self.total_score.output_row("total")
module function_definition identifier parameters 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 call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier expression_statement call identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
Print out the f-score table.
def setportprio(self, port, prio): _runshell([brctlexe, 'setportprio', self.name, port, str(prio)], "Could not set priority in port %s in %s." % (port, self.name))
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list list identifier string string_start string_content string_end attribute identifier identifier identifier call identifier argument_list identifier binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier
Set port priority value.
def toProtocolElement(self): protocolElement = protocol.VariantSet() protocolElement.id = self.getId() protocolElement.dataset_id = self.getParentContainer().getId() protocolElement.reference_set_id = self._referenceSet.getId() protocolElement.metadata.extend(self.getMetadata()) protocolElement.dataset_id = self.getParentContainer().getId() protocolElement.reference_set_id = self._referenceSet.getId() protocolElement.name = self.getLocalId() self.serializeAttributes(protocolElement) return protocolElement
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Converts this VariantSet into its GA4GH protocol equivalent.
def _render(roster_file, **kwargs): renderers = salt.loader.render(__opts__, {}) domain = __opts__.get('roster_domain', '') try: result = salt.template.compile_template(roster_file, renderers, __opts__['renderer'], __opts__['renderer_blacklist'], __opts__['renderer_whitelist'], mask_value='passw*', **kwargs) result.setdefault('host', '{}.{}'.format(os.path.basename(roster_file), domain)) return result except: log.warning('Unable to render roster file "%s".', roster_file, exc_info=True) return {}
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end dictionary_splat identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement identifier except_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier keyword_argument identifier true return_statement dictionary
Render the roster file
def setMaxDaysBack(self, maxDaysBack): assert isinstance(maxDaysBack, int), "maxDaysBack value has to be a positive integer" assert maxDaysBack >= 1 self.topicPage["maxDaysBack"] = maxDaysBack
module function_definition identifier parameters identifier identifier block assert_statement call identifier argument_list identifier identifier string string_start string_content string_end assert_statement comparison_operator identifier integer expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier
what is the maximum allowed age of the results?
def list_pool(self): attr = XhrController.extract_pool_attr(request.json) try: pools = Pool.list(attr) except NipapError, e: return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__}) return json.dumps(pools, cls=NipapJSONEncoder)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier identifier block return_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end integer pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute call identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
List pools and return JSON encoded result.
def actually_possibly_award(self, **state): user = state["user"] force_timestamp = state.pop("force_timestamp", None) awarded = self.award(**state) if awarded is None: return if awarded.level is None: assert len(self.levels) == 1 awarded.level = 1 awarded = awarded.level - 1 assert awarded < len(self.levels) if ( not self.multiple and BadgeAward.objects.filter(user=user, slug=self.slug, level=awarded) ): return extra_kwargs = {} if force_timestamp is not None: extra_kwargs["awarded_at"] = force_timestamp badge = BadgeAward.objects.create( user=user, slug=self.slug, level=awarded, **extra_kwargs ) self.send_badge_messages(badge) badge_awarded.send(sender=self, badge_award=badge)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier subscript identifier 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 dictionary_splat identifier if_statement comparison_operator identifier none block return_statement if_statement comparison_operator attribute identifier identifier none block assert_statement comparison_operator call identifier argument_list attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment identifier binary_operator attribute identifier identifier integer assert_statement comparison_operator identifier call identifier argument_list attribute identifier identifier if_statement parenthesized_expression boolean_operator not_operator attribute identifier identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier block return_statement expression_statement assignment identifier dictionary if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Does the actual work of possibly awarding a badge.
def to_python(self, value): if value == "": return None try: if isinstance(value, six.string_types): return self.deserializer(value) elif isinstance(value, bytes): return self.deserializer(value.decode('utf8')) except ValueError: pass return value
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier string string_start string_end block return_statement none try_statement block if_statement call identifier argument_list identifier attribute identifier identifier block return_statement call attribute identifier identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end except_clause identifier block pass_statement return_statement identifier
Convert a string from the database to a Python value.
def _read_stderr(self): try: while self._process.returncode is None: line = yield from self._process.stderr.readline() if not line: break if self._stderr_callback: yield from self._stderr_callback(line) except Exception: _logger.exception('Unhandled read stderr exception.') raise
module function_definition identifier parameters identifier block try_statement block while_statement comparison_operator attribute attribute identifier identifier identifier none block expression_statement assignment identifier yield call attribute attribute attribute identifier identifier identifier identifier argument_list if_statement not_operator identifier block break_statement if_statement attribute identifier identifier block expression_statement yield call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end raise_statement
Continuously read stderr for error messages.
def empty_trivial(cls, ops, kwargs): from qnet.algebra.core.hilbert_space_algebra import TrivialSpace if len(ops) == 0: return TrivialSpace else: return ops, kwargs
module function_definition identifier parameters identifier identifier identifier block import_from_statement dotted_name identifier identifier identifier identifier dotted_name identifier if_statement comparison_operator call identifier argument_list identifier integer block return_statement identifier else_clause block return_statement expression_list identifier identifier
A ProductSpace of zero Hilbert spaces should yield the TrivialSpace
def sibling(self, offs=1): indx = self.pindex + offs if indx < 0: return None if indx >= len(self.parent.kids): return None return self.parent.kids[indx]
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier binary_operator attribute identifier identifier identifier if_statement comparison_operator identifier integer block return_statement none if_statement comparison_operator identifier call identifier argument_list attribute attribute identifier identifier identifier block return_statement none return_statement subscript attribute attribute identifier identifier identifier identifier
Return sibling node by relative offset from self.
def shell_config_for(shell, vexrc, environ): here = os.path.dirname(os.path.abspath(__file__)) path = os.path.join(here, 'shell_configs', shell) try: with open(path, 'rb') as inp: data = inp.read() except FileNotFoundError as error: if error.errno != 2: raise return b'' ve_base = vexrc.get_ve_base(environ).encode('ascii') if ve_base and not scary_path(ve_base) and os.path.exists(ve_base): data = data.replace(b'$WORKON_HOME', ve_base) return data
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end identifier try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier integer block raise_statement return_statement string string_start string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator boolean_operator identifier not_operator call identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement identifier
return completion config for the named shell.
def top_corr(self, df): tag_freq = df.sum() tag_freq.sort(ascending=False) corr = df.corr().fillna(1) corr_dict = corr.to_dict() for tag, count in tag_freq.iteritems(): print ' %s%s: %s%s%s (' % (color.Green, tag, color.LightBlue, count, color.Normal), tag_corrs = sorted(corr_dict[tag].iteritems(), key=operator.itemgetter(1), reverse=True) for corr_tag, value in tag_corrs[:5]: if corr_tag != tag and (value > .2): print '%s%s:%s%.1f' % (color.Green, corr_tag, color.LightBlue, value), print '%s)' % color.Normal
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list keyword_argument identifier false expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block print_statement binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier attribute identifier identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list call attribute subscript identifier identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list integer keyword_argument identifier true for_statement pattern_list identifier identifier subscript identifier slice integer block if_statement boolean_operator comparison_operator identifier identifier parenthesized_expression comparison_operator identifier float block print_statement binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier attribute identifier identifier identifier print_statement binary_operator string string_start string_content string_end attribute identifier identifier
Give aggregation counts and correlations
def can_edit(self, user): return user.is_admin or not self.is_locked and self in user.admin_for
module function_definition identifier parameters identifier identifier block return_statement boolean_operator attribute identifier identifier boolean_operator not_operator attribute identifier identifier comparison_operator identifier attribute identifier identifier
Return whether or not `user` can make changes to the class.
def label(self): for c in self.table.columns: if c.parent == self.name and 'label' in c.valuetype: return PartitionColumn(c, self._partition)
module function_definition identifier parameters identifier block for_statement identifier attribute attribute identifier identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier comparison_operator string string_start string_content string_end attribute identifier identifier block return_statement call identifier argument_list identifier attribute identifier identifier
Return first child that of the column that is marked as a label
def execute_sql(self, *args, **kwargs): assert self._allow_sync, ( "Error, sync query is not allowed! Call the `.set_allow_sync()` " "or use the `.allow_sync()` context manager.") if self._allow_sync in (logging.ERROR, logging.WARNING): logging.log(self._allow_sync, "Error, sync query is not allowed: %s %s" % (str(args), str(kwargs))) return super().execute_sql(*args, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block assert_statement attribute identifier identifier parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator attribute identifier identifier tuple attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier binary_operator string string_start string_content string_end tuple call identifier argument_list identifier call identifier argument_list identifier return_statement call attribute call identifier argument_list identifier argument_list list_splat identifier dictionary_splat identifier
Sync execute SQL query, `allow_sync` must be set to True.
def _check_same_length(self, trajs_tuple): lens = [len(trajs) for trajs in trajs_tuple] if len(set(lens)) > 1: err = "Each dataset must be the same length. You gave: {}" err = err.format(lens) raise ValueError(err)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier identifier if_statement comparison_operator call identifier argument_list call identifier argument_list identifier integer block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier raise_statement call identifier argument_list identifier
Check that the datasets are the same length
def _get_row_str(self, i): row_data = ["{:s}".format(self.data['eventID'][i]), "{:g}".format(self.data['year'][i]), "{:g}".format(self.data['month'][i]), "{:g}".format(self.data['day'][i]), "{:g}".format(self.data['hour'][i]), "{:g}".format(self.data['minute'][i]), "{:.1f}".format(self.data['second'][i]), "{:.3f}".format(self.data['longitude'][i]), "{:.3f}".format(self.data['latitude'][i]), "{:.1f}".format(self.data['depth'][i]), "{:.1f}".format(self.data['magnitude'][i])] return " ".join(row_data)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list call attribute string string_start string_content string_end identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end identifier call attribute string string_start string_content string_end identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end identifier call attribute string string_start string_content string_end identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end identifier call attribute string string_start string_content string_end identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end identifier call attribute string string_start string_content string_end identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end identifier call attribute string string_start string_content string_end identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end identifier call attribute string string_start string_content string_end identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end identifier call attribute string string_start string_content string_end identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end identifier call attribute string string_start string_content string_end identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end identifier call attribute string string_start string_content string_end identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end identifier call attribute string string_start string_content string_end identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end identifier return_statement call attribute string string_start string_content string_end identifier argument_list identifier
Returns a string representation of the key information in a row
def set(self, mode, disable): global logger try: if logger: if disable: logger.disabled = True else: if mode in ('STREAM', 'FILE'): logger = logd.getLogger(mode, __version__) except Exception as e: logger.exception( '%s: Problem incurred during logging setup' % inspect.stack()[0][3] ) return False return True
module function_definition identifier parameters identifier identifier identifier block global_statement identifier try_statement block if_statement identifier block if_statement identifier block expression_statement assignment attribute identifier identifier true else_clause block if_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end subscript subscript call attribute identifier identifier argument_list integer integer return_statement false return_statement true
create logger object, enable or disable logging
def list_credentials_by_name(type_name): accounts = get_all_external_accounts(api, type_name) account_names = [account.name for account in accounts] print ("List of credential names for '{0}': [{1}]".format( type_name, COMMA_WITH_SPACE.join(map(str, account_names))))
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier call attribute identifier identifier argument_list call identifier argument_list identifier identifier
Prints a list of available credential names for the given type_name.
def naive(self): return self.__class__( self.year, self.month, self.day, self.hour, self.minute, self.second, self.microsecond, )
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
Return the DateTime without timezone information.
def find_lines(self, line): for other_line in self.lines: if other_line.match(line): yield other_line
module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement yield identifier
Find all lines matching a given line.
def setup(app): app.add_domain(EverettDomain) app.add_directive('autocomponent', AutoComponentDirective) return { 'version': __version__, 'parallel_read_safe': True, 'parallel_write_safe': True }
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end true pair string string_start string_content string_end true
Register domain and directive in Sphinx.
def cancelled(self): self._refresh_and_update() return ( self._operation.HasField("error") and self._operation.error.code == code_pb2.CANCELLED )
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list return_statement parenthesized_expression boolean_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end comparison_operator attribute attribute attribute identifier identifier identifier identifier attribute identifier identifier
True if the operation was cancelled.
def cmd_average_response_time(self): average = [ line.time_wait_response for line in self._valid_lines if line.time_wait_response >= 0 ] divisor = float(len(average)) if divisor > 0: return sum(average) / float(len(average)) return 0
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator attribute identifier identifier integer expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier if_statement comparison_operator identifier integer block return_statement binary_operator call identifier argument_list identifier call identifier argument_list call identifier argument_list identifier return_statement integer
Returns the average response time of all, non aborted, requests.
def dumps(obj, pretty=False, escaped=True): if not isinstance(obj, dict): raise TypeError("Expected data to be an instance of``dict``") if not isinstance(pretty, bool): raise TypeError("Expected pretty to be of type bool") if not isinstance(escaped, bool): raise TypeError("Expected escaped to be of type bool") return ''.join(_dump_gen(obj, pretty, escaped))
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier true block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement call attribute string string_start string_end identifier argument_list call identifier argument_list identifier identifier identifier
Serialize ``obj`` to a VDF formatted ``str``.
def drop(manager: Manager, network_id: Optional[int], yes): if network_id: manager.drop_network_by_id(network_id) elif yes or click.confirm('Drop all networks?'): manager.drop_networks()
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type generic_type identifier type_parameter type identifier identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier elif_clause boolean_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list
Drop a network by its identifier or drop all networks.
def shutdown(self, exitcode=0): logger.info("shutting down system stats and metadata service") self._system_stats.shutdown() self._meta.shutdown() if self._cloud: logger.info("stopping streaming files and file change observer") self._stop_file_observer() self._end_file_syncing(exitcode) self._run.history.close()
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list
Stops system stats, streaming handlers, and uploads files without output, used by wandb.monitor
def _validate_fname(fname, arg_name): if fname is not None: msg = "Argument `{0}` is not valid".format(arg_name) if (not isinstance(fname, str)) or (isinstance(fname, str) and ("\0" in fname)): raise RuntimeError(msg) try: if not os.path.exists(fname): os.access(fname, os.W_OK) except (TypeError, ValueError): raise RuntimeError(msg)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement boolean_operator parenthesized_expression not_operator call identifier argument_list identifier identifier parenthesized_expression boolean_operator call identifier argument_list identifier identifier parenthesized_expression comparison_operator string string_start string_content escape_sequence string_end identifier block raise_statement call identifier argument_list identifier try_statement block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier except_clause tuple identifier identifier block raise_statement call identifier argument_list identifier
Validate that a string is a valid file name.
def show_warning(message): try: import Tkinter, tkMessageBox root = Tkinter.Tk() root.withdraw() tkMessageBox.showerror("Spyder", message) except ImportError: pass raise RuntimeError(message)
module function_definition identifier parameters identifier block try_statement block import_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier except_clause identifier block pass_statement raise_statement call identifier argument_list identifier
Show warning using Tkinter if available
def isoformat(dt, localtime=False, *args, **kwargs): if localtime and dt.tzinfo is not None: localized = dt else: if dt.tzinfo is None: localized = UTC.localize(dt) else: localized = dt.astimezone(UTC) return localized.isoformat(*args, **kwargs)
module function_definition identifier parameters identifier default_parameter identifier false list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement boolean_operator identifier comparison_operator attribute identifier identifier none block expression_statement assignment identifier identifier else_clause block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier
Return the ISO8601-formatted UTC representation of a datetime object.
def conn_has_method(conn, method_name): if method_name in dir(conn): return True log.error('Method \'%s\' not yet supported!', method_name) return False
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier call identifier argument_list identifier block return_statement true expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end identifier return_statement false
Find if the provided connection object has a specific method
def cross(environment, book, row, sheet_source, column_source, column_key): a = book.sheets[sheet_source] return environment.copy(a.get(**{column_key: row[column_key]})[column_source])
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier return_statement call attribute identifier identifier argument_list subscript call attribute identifier identifier argument_list dictionary_splat dictionary pair identifier subscript identifier identifier identifier
Returns a single value from a column from a different dataset, matching by the key.
def regular(self): try: return self.info.meta['regular'] except (TypeError, KeyError): if self.info.meta is None: self.info.meta = {} self.info.meta['regular'] = self.is_regular() return self.info.meta['regular']
module function_definition identifier parameters identifier block try_statement block return_statement subscript attribute attribute identifier identifier identifier string string_start string_content string_end except_clause tuple identifier identifier block if_statement comparison_operator attribute attribute identifier identifier identifier none block expression_statement assignment attribute attribute identifier identifier identifier dictionary expression_statement assignment subscript attribute attribute identifier identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list return_statement subscript attribute attribute identifier identifier identifier string string_start string_content string_end
`True` if this index is linearly increasing
def html_for_check(self, check) -> str: check["logs"].sort(key=lambda c: LOGLEVELS.index(c["status"])) logs = "<ul>" + "".join([self.log_html(log) for log in check["logs"]]) + "</ul>" return logs
module function_definition identifier parameters identifier identifier type identifier block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list keyword_argument identifier lambda lambda_parameters identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end call attribute string string_start string_end identifier argument_list list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier subscript identifier string string_start string_content string_end string string_start string_content string_end return_statement identifier
Return HTML string for complete single check.
def serve_dtool_directory(directory, port): os.chdir(directory) server_address = ("localhost", port) httpd = DtoolHTTPServer(server_address, DtoolHTTPRequestHandler) httpd.serve_forever()
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier tuple string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list
Serve the datasets in a directory over HTTP.
def load_files(self, path): if self.verbose == 2: print("Indexing {}".format(path)) for filename in os.listdir(path): file_path = path + "/" + filename if os.path.isdir(file_path): self.load_files(file_path) elif filename.endswith(".yaml") or filename.endswith(".yml"): self.unfold_yaml(file_path)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier integer block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier binary_operator binary_operator identifier string string_start string_content string_end identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier elif_clause boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier
Loads files in a given path and all its subdirectories
def remove_tmp_prefix_from_filename(filename): if not filename.startswith(dju_settings.DJU_IMG_UPLOAD_TMP_PREFIX): raise RuntimeError(ERROR_MESSAGES['filename_hasnt_tmp_prefix'] % {'filename': filename}) return filename[len(dju_settings.DJU_IMG_UPLOAD_TMP_PREFIX):]
module function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list binary_operator subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end identifier return_statement subscript identifier slice call identifier argument_list attribute identifier identifier
Remove tmp prefix from filename.
def optimized(code, silent=True, ignore_errors=True): return constant_fold(code, silent=silent, ignore_errors=ignore_errors)
module function_definition identifier parameters identifier default_parameter identifier true default_parameter identifier true block return_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier
Performs optimizations on already parsed code.
def async_mail_task(subject_or_message, to=None, template=None, **kwargs): to = to or kwargs.pop('recipients', []) msg = make_message(subject_or_message, to, template, **kwargs) with mail.connect() as connection: connection.send(msg)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment identifier boolean_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end list expression_statement assignment identifier call identifier argument_list identifier identifier identifier dictionary_splat identifier with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier
Celery task to send emails asynchronously using the mail bundle.
def _get_stddevs(self, C, distance, stddev_types): stddevs = [] for stddev_type in stddev_types: assert stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES if stddev_type == const.StdDev.TOTAL: sigma = C["s1"] + (C["s2"] / (1.0 + ((distance / C["s3"]) ** 2.))) stddevs.append(sigma + np.zeros_like(distance)) return stddevs
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block assert_statement comparison_operator identifier attribute identifier identifier if_statement comparison_operator identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier binary_operator subscript identifier string string_start string_content string_end parenthesized_expression binary_operator subscript identifier string string_start string_content string_end parenthesized_expression binary_operator float parenthesized_expression binary_operator parenthesized_expression binary_operator identifier subscript identifier string string_start string_content string_end float expression_statement call attribute identifier identifier argument_list binary_operator identifier call attribute identifier identifier argument_list identifier return_statement identifier
Returns the total standard deviation, which is a function of distance
def split_comp_info(self, catalog_name, split_ver, split_key): return self._split_comp_info_dicts["%s_%s" % (catalog_name, split_ver)][split_key]
module function_definition identifier parameters identifier identifier identifier identifier block return_statement subscript subscript attribute identifier identifier binary_operator string string_start string_content string_end tuple identifier identifier identifier
Return the info for a particular split key
def executeTask(self, inputs, outSR=None, processSR=None, returnZ=False, returnM=False, f="json", method="POST" ): params = { "f" : f } url = self._url + "/execute" params = { "f" : "json" } if not outSR is None: params['env:outSR'] = outSR if not processSR is None: params['end:processSR'] = processSR params['returnZ'] = returnZ params['returnM'] = returnM for p in inputs: if isinstance(p, BaseGPObject): params[p.paramName] = p.value del p if method.lower() == "post": return self._post(url=url, param_dict=params, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port) else: return self._get(url=url, param_dict=params, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier false default_parameter identifier false default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end if_statement not_operator comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement not_operator comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment subscript identifier attribute identifier identifier attribute identifier identifier delete_statement identifier if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier else_clause block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
performs the execute task method
def run(self, tool, args, new_import_path=''): if new_import_path != '': sys.path.append(new_import_path) print('main called ' + tool['file'] + '->' + tool['function'] + ' with ', args, ' = ', tool['return']) mod = __import__( os.path.basename(tool['file']).split('.')[0]) func = getattr(mod, tool['function']) tool['return'] = func(args) return tool['return']
module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_end block if_statement comparison_operator identifier string string_start string_end block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call identifier argument_list binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end subscript identifier string string_start string_content string_end string string_start string_content string_end subscript identifier string string_start string_content string_end string string_start string_content string_end identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list subscript call attribute call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier call identifier argument_list identifier subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier return_statement subscript identifier string string_start string_content string_end
import the tool and call the function, passing the args.
def print_item_with_children(ac, classes, level): print_row(ac.id, ac.name, f"{ac.allocation:,.2f}", level) print_children_recursively(classes, ac, level + 1)
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier string string_start interpolation attribute identifier identifier format_specifier string_end identifier expression_statement call identifier argument_list identifier identifier binary_operator identifier integer
Print the given item and all children items
def _batched_op_msg( operation, command, docs, check_keys, ack, opts, ctx): buf = StringIO() buf.write(_ZERO_64) buf.write(b"\x00\x00\x00\x00\xdd\x07\x00\x00") to_send, length = _batched_op_msg_impl( operation, command, docs, check_keys, ack, opts, ctx, buf) buf.seek(4) request_id = _randint() buf.write(_pack_int(request_id)) buf.seek(0) buf.write(_pack_int(length)) return request_id, buf.getvalue(), to_send
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence string_end expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list integer expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier return_statement expression_list identifier call attribute identifier identifier argument_list identifier
OP_MSG implementation entry point.
def cli(env, identifier, postinstall, key): hardware = SoftLayer.HardwareManager(env.client) hardware_id = helpers.resolve_id(hardware.resolve_ids, identifier, 'hardware') key_list = [] if key: for single_key in key: resolver = SoftLayer.SshKeyManager(env.client).resolve_ids key_id = helpers.resolve_id(resolver, single_key, 'SshKey') key_list.append(key_id) if not (env.skip_confirmations or formatting.no_going_back(hardware_id)): raise exceptions.CLIAbort('Aborted') hardware.reload(hardware_id, postinstall, key_list)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier list if_statement identifier block for_statement identifier identifier block expression_statement assignment identifier attribute call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier if_statement not_operator parenthesized_expression boolean_operator attribute identifier identifier call attribute identifier identifier argument_list identifier block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier identifier
Reload operating system on a server.
def _invokeRead(self, fileIO, directory, filename, session, spatial=False, spatialReferenceID=4236, replaceParamFile=None, **kwargs): path = os.path.join(directory, filename) if os.path.isfile(path): instance = fileIO() instance.projectFile = self instance.read(directory, filename, session, spatial=spatial, spatialReferenceID=spatialReferenceID, replaceParamFile=replaceParamFile, **kwargs) return instance else: self._readBatchOutputForFile(directory, fileIO, filename, session, spatial, spatialReferenceID, replaceParamFile)
module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier false default_parameter identifier integer default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier dictionary_splat identifier return_statement identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier identifier
Invoke File Read Method on Other Files
def convert_none(key, val, attr_type, attr={}, cdata=False): LOG.info('Inside convert_none(): key="%s"' % (unicode_me(key))) key, attr = make_valid_xml_name(key, attr) if attr_type: attr['type'] = get_xml_type(val) attrstring = make_attrstring(attr) return '<%s%s></%s>' % (key, attrstring, key)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier dictionary default_parameter identifier false block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression call identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier return_statement binary_operator string string_start string_content string_end tuple identifier identifier identifier
Converts a null value into an XML element
def reload_configuration(self, event): if event.target == self.uniquename: self.log('Reloading configuration') self._read_config()
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list
Event triggered configuration reload
def currencies(self) -> CurrenciesAggregate: if not self.__currencies_aggregate: self.__currencies_aggregate = CurrenciesAggregate(self.book) return self.__currencies_aggregate
module function_definition identifier parameters identifier type identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier return_statement attribute identifier identifier
Returns the Currencies aggregate
def pop_local_cache(self, port_uuid, mac, net_uuid, lvid, vdp_vlan, segmentation_id): LOG.info("Populating the OVS VDP cache with port %(port_uuid)s, " "mac %(mac)s net %(net_uuid)s lvid %(lvid)s vdpvlan " "%(vdp_vlan)s seg %(seg)s", {'port_uuid': port_uuid, 'mac': mac, 'net_uuid': net_uuid, 'lvid': lvid, 'vdp_vlan': vdp_vlan, 'seg': segmentation_id}) lvm = self.local_vlan_map.get(net_uuid) if not lvm: lvm = LocalVlan(lvid, segmentation_id) self.local_vlan_map[net_uuid] = lvm lvm.lvid = lvid lvm.set_port_uuid(port_uuid, vdp_vlan, None) if vdp_vlan != cconstants.INVALID_VLAN: lvm.late_binding_vlan = vdp_vlan lvm.vdp_nego_req = False
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier none if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier false
Populate the local cache after restart.
def _observe_keep_screen_on(self, change): def set_screen_on(window): from .android_window import Window window = Window(__id__=window) if self.keep_screen_on: window.addFlags(Window.FLAG_KEEP_SCREEN_ON) else: window.clearFlags(Window.FLAG_KEEP_SCREEN_ON) self.widget.getWindow().then(set_screen_on)
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list identifier
Sets or clears the flag to keep the screen on.
def delete_job(job_id, deployment_name, token_manager=None, app_url=defaults.APP_URL): headers = token_manager.get_access_token_headers() data_url = get_data_url_for_job(job_id, deployment_name, token_manager=token_manager, app_url=app_url) url = '%s/api/v1/jobs/%s' % (data_url, job_id) response = requests.delete(url, headers=headers) if response.status_code != 200: raise JutException('Error %s: %s' % (response.status_code, response.text))
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier if_statement comparison_operator attribute identifier identifier integer block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier
delete a job with a specific job id
def AFF4AddChild(self, subject, child, extra_attributes=None): precondition.AssertType(child, Text) attributes = { DataStore.AFF4_INDEX_DIR_TEMPLATE % child: [DataStore.EMPTY_DATA_PLACEHOLDER] } if extra_attributes: attributes.update(extra_attributes) self.MultiSet(subject, attributes)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier dictionary pair binary_operator attribute identifier identifier identifier list attribute identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier
Adds a child to the specified parent.
def almost_eq(arr1, arr2, thresh=1E-11, ret_error=False): error = np.abs(arr1 - arr2) passed = error < thresh if ret_error: return passed, error return passed
module function_definition identifier parameters identifier identifier default_parameter identifier float default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier identifier expression_statement assignment identifier comparison_operator identifier identifier if_statement identifier block return_statement expression_list identifier identifier return_statement identifier
checks if floating point number are equal to a threshold
def widget_from_abbrev(cls, abbrev, default=empty): if isinstance(abbrev, ValueWidget) or isinstance(abbrev, fixed): return abbrev if isinstance(abbrev, tuple): widget = cls.widget_from_tuple(abbrev) if default is not empty: try: widget.value = default except Exception: pass return widget widget = cls.widget_from_single_value(abbrev) if widget is not None: return widget if isinstance(abbrev, Iterable): widget = cls.widget_from_iterable(abbrev) if default is not empty: try: widget.value = default except Exception: pass return widget return None
module function_definition identifier parameters identifier identifier default_parameter identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier identifier block return_statement identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block try_statement block expression_statement assignment attribute identifier identifier identifier except_clause identifier block pass_statement return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block try_statement block expression_statement assignment attribute identifier identifier identifier except_clause identifier block pass_statement return_statement identifier return_statement none
Build a ValueWidget instance given an abbreviation or Widget.
def from_filename(file_name): base, extension = os.path.splitext(file_name) if extension in COMPRESS_EXT: extension = os.path.splitext(base)[1] return from_extension(extension)
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list identifier integer return_statement call identifier argument_list identifier
Look up the BioPython file type corresponding to an input file name.
def _TransmissionThreadProc(self): reconnect = True while not self._shutdown: self._new_updates.clear() if reconnect: service = self._BuildService() reconnect = False reconnect, delay = self._TransmitBreakpointUpdates(service) self._new_updates.wait(delay)
module function_definition identifier parameters identifier block expression_statement assignment identifier true while_statement not_operator attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier false expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Entry point for the transmission worker thread.
def urlparse(d, keys=None): d = d.copy() if keys is None: keys = d.keys() for key in keys: d[key] = _urlparse(d[key]) return d
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list subscript identifier identifier return_statement identifier
Returns a copy of the given dictionary with url values parsed.
def static_sum(values, limit_n=1000): if len(values) < limit_n: return sum(values) else: half = len(values) // 2 return add( static_sum(values[:half], limit_n), static_sum(values[half:], limit_n))
module function_definition identifier parameters identifier default_parameter identifier integer block if_statement comparison_operator call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier else_clause block expression_statement assignment identifier binary_operator call identifier argument_list identifier integer return_statement call identifier argument_list call identifier argument_list subscript identifier slice identifier identifier call identifier argument_list subscript identifier slice identifier identifier
Example of static sum routine.
def on(self, event, new_state): if self.name == new_state.name: raise RuntimeError("Use loop method to define {} -> {} -> {}".format(self.name, event.name, new_state.name)) self._register_transition(event, new_state)
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier
add a valid transition to this state
def spec(self, postf_un_ops: str) -> list: spec = [(l + op, {'pat': self.pat(pat), 'postf': self.postf(r, postf_un_ops), 'regex': None}) for op, pat in self.styles.items() for l, r in self.brackets] spec[0][1]['regex'] = self.regex_pat.format( _ops_regex(l for l, r in self.brackets), _ops_regex(self.styles.keys()) ) return spec
module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier list_comprehension tuple binary_operator identifier identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier identifier pair string string_start string_content string_end none for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list for_in_clause pattern_list identifier identifier attribute identifier identifier expression_statement assignment subscript subscript subscript identifier integer integer string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list call identifier generator_expression identifier for_in_clause pattern_list identifier identifier attribute identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list return_statement identifier
Return prefix unary operators list
def decode(self, frame: Frame, *, max_size: Optional[int] = None) -> Frame: if frame.opcode in CTRL_OPCODES: return frame if frame.opcode == OP_CONT: if not self.decode_cont_data: return frame if frame.fin: self.decode_cont_data = False else: if not frame.rsv1: return frame if not frame.fin: self.decode_cont_data = True if self.remote_no_context_takeover: self.decoder = zlib.decompressobj(wbits=-self.remote_max_window_bits) data = frame.data if frame.fin: data += _EMPTY_UNCOMPRESSED_BLOCK max_length = 0 if max_size is None else max_size data = self.decoder.decompress(data, max_length) if self.decoder.unconsumed_tail: raise PayloadTooBig( f"Uncompressed payload length exceeds size limit (? > {max_size} bytes)" ) if frame.fin and self.remote_no_context_takeover: del self.decoder return frame._replace(data=data, rsv1=False)
module function_definition identifier parameters identifier typed_parameter identifier type identifier keyword_separator typed_default_parameter identifier type generic_type identifier type_parameter type identifier none type identifier block if_statement comparison_operator attribute identifier identifier identifier block return_statement identifier if_statement comparison_operator attribute identifier identifier identifier block if_statement not_operator attribute identifier identifier block return_statement identifier if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier false else_clause block if_statement not_operator attribute identifier identifier block return_statement identifier if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier true if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier unary_operator attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement augmented_assignment identifier identifier expression_statement assignment identifier conditional_expression integer comparison_operator identifier none identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement attribute attribute identifier identifier identifier block raise_statement call identifier argument_list string string_start string_content interpolation identifier string_content string_end if_statement boolean_operator attribute identifier identifier attribute identifier identifier block delete_statement attribute identifier identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier false
Decode an incoming frame.
def fastp_read_qual_plot(self): data_labels, pdata = self.filter_pconfig_pdata_subplots(self.fastp_qual_plotdata, 'Sequence Quality') pconfig = { 'id': 'fastp-seq-quality-plot', 'title': 'Fastp: Sequence Quality', 'xlab': 'Read Position', 'ylab': 'R1 Before filtering: Sequence Quality', 'ymin': 0, 'xDecimals': False, 'data_labels': data_labels } return linegraph.plot(pdata, pconfig)
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end integer pair string string_start string_content string_end false pair string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list identifier identifier
Make the read quality plot for Fastp
def update(self, instance, validated_data): instance.title = validated_data.get('title', instance.title) instance.code = validated_data.get('code', instance.code) instance.linenos = validated_data.get('linenos', instance.linenos) instance.language = validated_data.get('language', instance.language) instance.style = validated_data.get('style', instance.style) instance.save() return instance
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
Update and return an existing `Snippet` instance, given the validated data.
def load_module(self, fullname): root, base, target = fullname.partition(self.root_name + '.') for prefix in self.search_path: try: extant = prefix + target __import__(extant) mod = sys.modules[extant] sys.modules[fullname] = mod if prefix and sys.version_info > (3, 3): del sys.modules[extant] return mod except ImportError: pass else: raise ImportError( "The '{target}' package is required; " "normally this is bundled with this package so if you get " "this warning, consult the packager of your " "distribution.".format(**locals()) )
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end for_statement identifier attribute identifier identifier block try_statement block expression_statement assignment identifier binary_operator identifier identifier expression_statement call identifier argument_list identifier expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier if_statement boolean_operator identifier comparison_operator attribute identifier identifier tuple integer integer block delete_statement subscript attribute identifier identifier identifier return_statement identifier except_clause identifier block pass_statement else_clause block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier argument_list dictionary_splat call identifier argument_list
Iterate over the search path to locate and load fullname.
def clean_process_meta(self): ds = self.dataset ds.config.build.clean() ds.config.process.clean() ds.commit() self.state = self.STATES.CLEANED
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier
Remove all process and build metadata
def execute(self, input_data): if (input_data['meta']['type_tag'] != 'exe'): return {'error': self.__class__.__name__+': called on '+input_data['meta']['type_tag']} view = {} view['indicators'] = list(set([item['category'] for item in input_data['pe_indicators']['indicator_list']])) view['peid_matches'] = input_data['pe_peid']['match_list'] view['yara_sigs'] = input_data['yara_sigs']['matches'].keys() view['classification'] = input_data['pe_classifier']['classification'] view['disass'] = self.safe_get(input_data, ['pe_disass', 'decode'])[:15] view.update(input_data['meta']) return view
module function_definition identifier parameters identifier identifier block if_statement parenthesized_expression comparison_operator subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block return_statement dictionary pair string string_start string_content string_end binary_operator binary_operator attribute attribute identifier identifier identifier string string_start string_content string_end subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list call identifier argument_list list_comprehension subscript identifier string string_start string_content string_end for_in_clause identifier subscript 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 subscript 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 call attribute subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end subscript 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 subscript call attribute identifier identifier argument_list identifier list string string_start string_content string_end string string_start string_content string_end slice integer expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end return_statement identifier
Execute the ViewPE worker
def build_api_url(host=REMOTES['default']['ip'], port=REMOTES['default']['port'], path=REMOTES['default']['path'], username=None, password=None, ssl=False): credentials = make_http_credentials(username, password) scheme = 'http' if not path: path = '' if path and not path.startswith('/'): path = "/%s" % path if ssl: scheme += 's' return "%s://%s%s:%i%s" % (scheme, credentials, host, port, path)
module function_definition identifier parameters default_parameter identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end default_parameter identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end default_parameter identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end default_parameter identifier none default_parameter identifier none default_parameter identifier false block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier string string_start string_content string_end if_statement not_operator identifier block expression_statement assignment identifier string string_start string_end if_statement boolean_operator identifier not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier if_statement identifier block expression_statement augmented_assignment identifier string string_start string_content string_end return_statement binary_operator string string_start string_content string_end tuple identifier identifier identifier identifier identifier
Build API URL from components.
def encrypt_password(self): if self.password and not self.password.startswith('$pbkdf2'): self.set_password(self.password)
module function_definition identifier parameters identifier block if_statement boolean_operator attribute identifier identifier not_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier
encrypt password if not already encrypted
def newPage(doc, pno=-1, width=595, height=842): doc._newPage(pno, width=width, height=height) return doc[pno]
module function_definition identifier parameters identifier default_parameter identifier unary_operator integer default_parameter identifier integer default_parameter identifier integer block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement subscript identifier identifier
Create and return a new page object.