code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def copy(self, new_fn): new_file = self.__class__(fn=str(new_fn)) new_file.write(data=self.read()) new_file.utime(self.atime, self.mtime) return new_file
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_...
copy the file to the new_fn, preserving atime and mtime
def validate_gaslimit(self, header: BlockHeader) -> None: parent_header = self.get_block_header_by_hash(header.parent_hash) low_bound, high_bound = compute_gas_limit_bounds(parent_header) if header.gas_limit < low_bound: raise ValidationError( "The gas limit on block ...
module function_definition identifier parameters identifier typed_parameter identifier type identifier type none block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment pattern_list identifier identifier call ide...
Validate the gas limit on the given header.
def readAxes(self): for axisElement in self.root.findall(".axes/axis"): axis = {} axis['name'] = name = axisElement.attrib.get("name") axis['tag'] = axisElement.attrib.get("tag") axis['minimum'] = float(axisElement.attrib.get("minimum")) axis['maximum'...
module function_definition identifier parameters identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier dictionary expression_statement assignment subscript identifie...
Read the axes element.
def buffer(self, item): key = self.get_key_from_item(item) if not self.grouping_info.is_first_file_item(key): self.items_group_files.add_item_separator_to_file(key) self.grouping_info.ensure_group_info(key) self.items_group_files.add_item_to_file(item, key)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement ca...
Receive an item and write it.
def _structure_unicode(self, obj, cl): if not isinstance(obj, (bytes, unicode)): return cl(str(obj)) else: return obj
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call identifier argument_list identifier tuple identifier identifier block return_statement call identifier argument_list call identifier argument_list identifier else_clause block return_statement identifi...
Just call ``cl`` with the given ``obj``
def do_exit(self, arg): if self.current: self.current.close() self.resource_manager.close() del self.resource_manager return True
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list delete...
Exit the shell session.
def _proxy_process(proxyname, test): changes_old = [] changes_new = [] if not _is_proxy_running(proxyname): if not test: __salt__['cmd.run_all']( 'salt-proxy --proxyid={0} -l info -d'.format(salt.ext.six.moves.shlex_quote(proxyname)), timeout=5) ...
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier list if_statement not_operator call identifier argument_list identifier block if_statement not_operator identifier block expression_statement call subsc...
Check and execute proxy process
def cloneWindow(self): settings = QtCore.QSettings() settings.beginGroup(self.argosApplication.windowGroupName(self.windowNumber)) try: self.saveProfile(settings) name = self.inspectorRegItem.fullName newWindow = self.argosApplication.addNewMainWindow(settings...
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identi...
Opens a new window with the same inspector as the current window.
def show_command(parameter): section = "cli" if "." in parameter: section, parameter = parameter.split(".", 1) value = lookup_option(parameter, section=section) if value is None: safeprint("{} not set".format(parameter)) else: safeprint("{} = {}".format(parameter, value))
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment pattern_list identifier identifier ca...
Executor for `globus config show`
def check_for_stalled_tasks(): from api.models.tasks import Task for task in Task.objects.filter(status_is_running=True): if not task.is_responsive(): task.system_error() if task.is_timed_out(): task.timeout_error()
module function_definition identifier parameters block import_from_statement dotted_name identifier identifier identifier dotted_name identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier true block if_statement not_operator call attribut...
Check for tasks that are no longer sending a heartbeat
def min_heapify(arr, start, simulation, iteration): end = len(arr) - 1 last_parent = (end - start - 1) // 2 for parent in range(last_parent, -1, -1): current_parent = parent while current_parent <= last_parent: child = 2 * current_parent + 1 if child + 1 <= end - star...
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier binary_operator call identifier argument_list identifier integer expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operat...
Min heapify helper for min_heap_sort
def _raise_fail(self, response, expected): try: if self.logger: self.logger.error("Status code " "{} != {}. \n\n " "Payload: {}".format(response.status_code, exp...
module function_definition identifier parameters identifier identifier identifier block try_statement block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute concatenated_string string string_start string_conten...
Raise a TestStepFail with neatly formatted error message
def run(self): channel = self._ssh_client.get_transport().open_session() self._channel = channel channel.exec_command("gerrit stream-events") stdout = channel.makefile() stderr = channel.makefile_stderr() while not self._stop.is_set(): try: if ...
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement cal...
Listen to the stream and send events to the client.
async def info(self) -> Optional[JobDef]: info = await self.result_info() if not info: v = await self._redis.get(job_key_prefix + self.job_id, encoding=None) if v: info = unpickle_job(v) if info: info.score = await self._redis.zscore(queue_name...
module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier await call attribute identifier identifier argument_list if_statement not_operator identifier block expression_statement assignment identifier await ca...
All information on a job, including its result if it's available, does not wait for the result.
async def listCronJobs(self): crons = [] for iden, cron in self.cell.agenda.list(): useriden = cron['useriden'] if not (self.user.admin or useriden == self.user.iden): continue user = self.cell.auth.user(useriden) cron['username'] = '<unkno...
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list block expression_statement assignment identifier subscript ident...
Get information about all the cron jobs accessible to the current user
async def _read_rowdata_packet(self): rows = [] while True: packet = await self.connection._read_packet() if self._check_packet_is_eof(packet): self.connection = None break rows.append(self._read_row_from_packet(packet)) self.af...
module function_definition identifier parameters identifier block expression_statement assignment identifier list while_statement true block expression_statement assignment identifier await call attribute attribute identifier identifier identifier argument_list if_statement call attribute identifier identifier argument...
Read a rowdata packet for each data row in the result set.
def _ask_for_ledger_status(self, node_name: str, ledger_id): self.request_msg(LEDGER_STATUS, {f.LEDGER_ID.nm: ledger_id}, [node_name, ]) logger.info("{} asking {} for ledger status of ledger {}".format(self, node_name, ledger_id))
module function_definition identifier parameters identifier typed_parameter identifier type identifier identifier block expression_statement call attribute identifier identifier argument_list identifier dictionary pair attribute attribute identifier identifier identifier identifier list identifier expression_statement ...
Ask other node for LedgerStatus
def _parse_args(arg): yaml_args = salt.utils.args.yamlify_arg(arg) if yaml_args is None: return [] elif not isinstance(yaml_args, list): return [yaml_args] else: return yaml_args
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement list elif_clause not_operator call ...
yamlify `arg` and ensure it's outermost datatype is a list
def check_dependee_order(depender, dependee, dependee_id): shutit_global.shutit_global_object.yield_to_draw() if dependee.run_order > depender.run_order: return 'depender module id:\n\n' + depender.module_id + '\n\n(run order: ' + str(depender.run_order) + ') ' + 'depends on dependee module_id:\n\n' + dependee_id +...
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator attribute identifier identifier attribute identifier identifier block return_statement binary_operator bin...
Checks whether run orders are in the appropriate order.
def delete_all_possible_task_files(self, courseid, taskid): if not id_checker(courseid): raise InvalidNameException("Course with invalid name: " + courseid) if not id_checker(taskid): raise InvalidNameException("Task with invalid name: " + taskid) task_fs = self.get_task_...
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement not_operator call identifie...
Deletes all possibles task files in directory, to allow to change the format
def _initialize_from_model(self, model): for name, value in model.__dict__.items(): if name in self._properties: setattr(self, name, value)
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call identifi...
Loads a model from
def _fullqualname_method_py2(obj): if obj.__self__ is None: module = obj.im_class.__module__ cls = obj.im_class.__name__ else: if inspect.isclass(obj.__self__): module = obj.__self__.__module__ cls = obj.__self__.__name__ else: module = obj.__s...
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifi...
Fully qualified name for 'instancemethod' objects in Python 2.
def index(self, strictindex): return self._select(self._pointer.index(self.ruamelindex(strictindex)))
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier
Return a chunk in a sequence referenced by index.
def cli(yamlfile, format, output, context): print(RDFGenerator(yamlfile, format).serialize(output=output, context=context))
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call identifier argument_list call attribute call identifier argument_list identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Generate an RDF representation of a biolink model
def StopPreviousService(self): StopService( service_name=config.CONFIG["Nanny.service_name"], service_binary_name=config.CONFIG["Nanny.service_binary_name"]) if not config.CONFIG["Client.fleetspeak_enabled"]: return StopService(service_name=config.CONFIG["Client.fleetspeak_service_name...
module function_definition identifier parameters identifier block expression_statement call identifier argument_list keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier subscript attribute identifier identifier string string_sta...
Stops the Windows service hosting the GRR process.
def user_name(self, user_id): user = self.users.get(user_id) if user is None: return "Unknown user ({})".format(user_id) return user["name"]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement call attribute string string_start string_con...
Return name for user.
def start(queue, profile=None, tag='salt/engine/sqs', owner_acct_id=None): if __opts__.get('__role') == 'master': fire_master = salt.utils.event.get_master_event( __opts__, __opts__['sock_dir'], listen=False).fire_event else: fire_master = __salt__['event.send...
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier none block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_...
Listen to sqs and fire message on event bus
def _to_numpy(nd4j_array): buff = nd4j_array.data() address = buff.pointer().address() dtype = get_context_dtype() mapping = { 'double': ctypes.c_double, 'float': ctypes.c_float } Pointer = ctypes.POINTER(mapping[dtype]) pointer = ctypes.cast(address, Pointer) np_array = ...
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assig...
Convert nd4j array to numpy array
def from_points(cls, point1, point2): if isinstance(point1, Point) and isinstance(point2, Point): displacement = point1.substract(point2) return cls(displacement.x, displacement.y, displacement.z) raise TypeError
module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_lis...
Return a Vector instance from two given points.
def _endmsg(self, rd): msg = "" s = "" if rd.hours > 0: if rd.hours > 1: s = "s" msg += colors.bold(str(rd.hours)) + " hour" + s + " " s = "" if rd.minutes > 0: if rd.minutes > 1: s = "s" msg += color...
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier string string_start string_end if_statement comparison_operator attribute identifier identifier integer block if_statement com...
Returns an end message with elapsed time
def get(self, action, version=None): by_version = self._by_action[action] if version in by_version: return by_version[version] else: return by_version[None]
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement comparison_operator identifier identifier block return_statement subscript identifier identifier els...
Get the method class handing the given action and version.
def _guess_name(desc, taken=None): taken = taken or [] name = "" for word in desc.split(): c = word[0].lower() if not c.isalnum(): continue name += c if name not in taken: break count = 2 while name in taken: name = name + str(count) ...
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier list expression_statement assignment identifier string string_start string_end for_statement identifier call attribute identifier identifier argument...
Attempts to guess the menu entry name from the function name.
def _verify_same_spaces(self): if self._envs is None: raise ValueError("Environments not initialized.") if not isinstance(self._envs, list): tf.logging.warning("Not checking observation and action space " "compatibility across envs, since there is just one.") return ...
module function_definition identifier parameters 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 not_operator call identifier argument_list attribute identifier identifie...
Verifies that all the envs have the same observation and action space.
def rate_limits(self): if not self._rate_limits: self._rate_limits = utilities.get_rate_limits(self._response) return self._rate_limits
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement attribute identifier ident...
Returns list of rate limit information from the response
def cmd_gyrocal(self, args): mav = self.master mav.mav.command_long_send(mav.target_system, mav.target_component, mavutil.mavlink.MAV_CMD_PREFLIGHT_CALIBRATION, 0, 1, 0, 0, 0, 0, 0, 0)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute a...
do a full gyro calibration
def meta_set(self, key, metafield, value): self._meta.setdefault(key, {})[metafield] = value
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment subscript call attribute attribute identifier identifier identifier argument_list identifier dictionary identifier identifier
Set the meta field for a key to a new value.
def _extract_conjuction_elements_from_expression(expression): if isinstance(expression, BinaryComposition) and expression.operator == u'&&': for element in _extract_conjuction_elements_from_expression(expression.left): yield element for element in _extract_conjuction_elements_from_expres...
module function_definition identifier parameters identifier block if_statement boolean_operator call identifier argument_list identifier identifier comparison_operator attribute identifier identifier string string_start string_content string_end block for_statement identifier call identifier argument_list attribute ide...
Return a generator for expressions that are connected by `&&`s in the given expression.
def read_cf1_config(self): target = self._cload.targets[0xFF] config_page = target.flash_pages - 1 return self._cload.read_flash(addr=0xFF, page=config_page)
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier integer expression_statement assignment identifier binary_operator attribute identifier identifier integer return_statement call attribute attribute...
Read a flash page from the specified target
def extract_ape (archive, compression, cmd, verbosity, interactive, outdir): outfile = util.get_single_outfile(outdir, archive, extension=".wav") return [cmd, archive, outfile, '-d']
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end return_st...
Decompress an APE archive to a WAV file.
def start(self): self._poll_thread = threading.Thread(target=self._run_poll_server, name='Vera Poll Thread') self._poll_thread.deamon = True self._poll_thread.start()
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end expre...
Start a thread to handle Vera blocked polling.
def _add_path(dir_name, payload_info_list): for payload_info_dict in payload_info_list: file_name = payload_info_dict['filename'] or payload_info_dict['pid'] payload_info_dict['path'] = d1_common.utils.filesystem.gen_safe_path( dir_name, 'data', file_name )
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement assignment identifier boolean_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end express...
Add a key with the path to each payload_info_dict.
def modify_filename_id(filename): split_filename = os.path.splitext(filename) id_num_re = re.compile('(\(\d\))') id_num = re.findall(id_num_re, split_filename[-2]) if id_num: new_id_num = int(id_num[-1].lstrip('(').rstrip(')')) + 1 filename = ''.join((re.sub(id_num_re, '({0})'.format(new...
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content...
Modify filename to have a unique numerical identifier.
def viable_source_types_for_generator (generator): assert isinstance(generator, Generator) if generator not in __viable_source_types_cache: __vstg_cached_generators.append(generator) __viable_source_types_cache[generator] = viable_source_types_for_generator_real (generator) return __viable_s...
module function_definition identifier parameters identifier block assert_statement call identifier argument_list identifier identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript...
Caches the result of 'viable_source_types_for_generator'.
def _step_end(self, log=True): if log: step_end_time = self.log(u"STEP %d END (%s)" % (self.step_index, self.step_label)) diff = (step_end_time - self.step_begin_time) diff = float(diff.seconds + diff.microseconds / 1000000.0) self.step_total += diff s...
module function_definition identifier parameters identifier default_parameter identifier true block if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identif...
Log end of a step
def choices(self): if self._choices: return self._choices for n in os.listdir(self._voicedir): if len(n) == 1 and os.path.isdir(os.path.join(self._voicedir, n)): self._choices.append(n) return self._choices
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement attribute identifier identifier for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement boolean_operator comparison...
Available choices for characters to be generated.
def dup_token(th): sec_attr = win32security.SECURITY_ATTRIBUTES() sec_attr.bInheritHandle = True return win32security.DuplicateTokenEx( th, win32security.SecurityImpersonation, win32con.MAXIMUM_ALLOWED, win32security.TokenPrimary, sec_attr, )
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier true return_statement call attribute identifier identifier argument_list identifier attribute id...
duplicate the access token
def headloss_kozeny(Length, Diam, Vel, Porosity, Nu): ut.check_range([Length, ">0", "Length"], [Diam, ">0", "Diam"], [Vel, ">0", "Velocity"], [Nu, ">0", "Nu"], [Porosity, "0-1", "Porosity"]) return (K_KOZENY * Length * Nu / gravity.magnitude * (1-Porosity)**2 ...
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list list identifier string string_start string_content string_end string string_start string_content string_end list identifier string string_...
Return the Carmen Kozeny Sand Bed head loss.
def gen_url_regex(resource): " URL regex for resource class generator. " if resource._meta.parent: yield resource._meta.parent._meta.url_regex.rstrip('/$').lstrip('^') for p in resource._meta.url_params: yield '%(name)s/(?P<%(name)s>[^/]+)' % dict(name=p) if resource._meta.prefix: ...
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement attribute attribute identifier identifier identifier block expression_statement yield call attribute call attribute attribute attribute attribute attribute identifier identif...
URL regex for resource class generator.
def _serialize(cls, key, value, fields): converter = cls._get_converter_for_field(key, None, fields) return converter.serialize(value)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier none identifier return_statement call attribute identifier identifier argument_list identifier
Marshal outgoing data into Taskwarrior's JSON format.
def identity(self): if self.dataset is None: s = object_session(self) ds = s.query(Dataset).filter(Dataset.id_ == self.d_id).one() else: ds = self.dataset d = { 'id': self.id, 'vid': self.vid, 'name': self.name, ...
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute call attribute call attribute identi...
Return this partition information as a PartitionId.
def create_alias(self, alias_name): return self._es_conn.indices.put_alias(index=self._es_index, name=alias_name)
module function_definition identifier parameters identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier
Creates an alias pointing to the index configured in this connection
def value(self, value, *args, **kwargs): from datetime import datetime value = self.obj.value(value, *args, **kwargs) try: rv = datetime.strptime(value, self.format) except ValueError as _: rv = None return rv
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument...
Takes a string value and returns the Date based on the format
def printBasicInfo(onto): rdfGraph = onto.rdfGraph print("_" * 50, "\n") print("TRIPLES = %s" % len(rdfGraph)) print("_" * 50) print("\nNAMESPACES:\n") for x in onto.ontologyNamespaces: print("%s : %s" % (x[0], x[1])) print("_" * 50, "\n") print("ONTOLOGY METADATA:\n") for x,...
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end integer string string_start string_content escape_sequence string_...
Terminal printing of basic ontology information
def register(self): loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) loop.run_until_complete(self._register())
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call ...
Pair client with tv.
def clean(self): clean_files = ['blotImage','crmaskImage','finalMask', 'staticMask','singleDrizMask','outSky', 'outSContext','outSWeight','outSingle', 'outMedian','dqmask','tmpmask', 'skyMatchMask'] log.info(...
module function_definition identifier parameters identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start st...
Deletes intermediate products generated for this imageObject.
def turn_right(self): self.at(ardrone.at.pcmd, True, 0, 0, 0, self.speed)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier true integer integer integer attribute identifier identifier
Make the drone rotate right.
def filter(self, filter): if hasattr(filter, '__call__'): return [entry for entry in self.entries if filter(entry)] else: pattern = re.compile(filter, re.IGNORECASE) return [entry for entry in self.entries if pattern.match(entry)]
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause call identifier argumen...
Filter entries by calling function or applying regex.
def root_sync(args, l, config): from requests.exceptions import ConnectionError all_remote_names = [ r.short_name for r in l.remotes ] if args.all: remotes = all_remote_names else: remotes = args.refs prt("Sync with {} remotes or bundles ".format(len(remotes))) if not remotes: ...
module function_definition identifier parameters identifier identifier identifier block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier if...
Sync with the remote. For more options, use library sync
def _evaluate(self): retrieved_records = SortedDict() for record_id, record in six.iteritems(self._elements): if record is self._field._unset: try: record = self.target_app.records.get(id=record_id) except SwimlaneHTTP400Error: ...
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement comparison_operator identifier...
Scan for orphaned records and retrieve any records that have not already been grabbed
def stream_fastq(file_handler): next_element = '' for i, line in enumerate(file_handler): next_element += line if i % 4 == 3: yield next_element next_element = ''
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement augmented_assignment identifier identifier if_statement compari...
Generator which gives all four lines if a fastq read as one string
def contrib_inline_aff(contrib_tag): aff_tags = [] for child_tag in contrib_tag: if child_tag and child_tag.name and child_tag.name == "aff": aff_tags.append(child_tag) return aff_tags
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier identifier block if_statement boolean_operator boolean_operator identifier attribute identifier identifier comparison_operator attribute identifier identifier string string_start st...
Given a contrib tag, look for an aff tag directly inside it
def run_command_orig(cmd): process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate() if process.returncode == 0: os.killpg(os.getpgid(pro.pid), signal.SIGTERM) else: raise BadRCError("Bad rc (%s) for cmd '%s': %s" %...
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identif...
No idea how th f to get this to work
def intent(self, intent): def _handler(func): self._handlers['IntentRequest'][intent] = func return func return _handler
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier block expression_statement assignment subscript subscript attribute identifier identifier string string_start string_content string_end identifier identifier return_statement identifier retu...
Decorator to register intent handler
def _build_session_metric_values(self, session_name): result = [] metric_infos = self._experiment.metric_infos for metric_info in metric_infos: metric_name = metric_info.name try: metric_eval = metrics.last_metric_eval( self._context.multiplexer, session_name, ...
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier attribute attribute identifier identifier identifier for_statement identifier identifier block expression_statement assignment identifier attribute iden...
Builds the session metric values.
def requestCreateDetails(self): createReq = sc_pb.RequestCreateGame( realtime = self.realtime, disable_fog = self.fogDisabled, random_seed = int(time.time()), local_map = sc_pb.LocalMap(map_path=self.mapLocalPath, map_...
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier call identif...
add configuration to the SC2 protocol create request
def _validate_annotation(self, annotation): required_keys = set(self._required_keys) keys = set(key for key, val in annotation.items() if val) missing_keys = required_keys.difference(keys) if missing_keys: error = 'Annotation missing required fields: {0}'.format( ...
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier generator_expression identifier for_in_clause pattern_list identifier identifie...
Ensures that the annotation has the right fields.
def _combine_attribute(attr_1, attr_2, len_1, len_2): if isinstance(attr_1, list) or isinstance(attr_2, list): attribute = np.concatenate((attr_1, attr_2), axis=0) attribute_changes = True else: if isinstance(attr_1, list) and isinstance(attr_2, list) and np.allclose(...
module function_definition identifier parameters identifier identifier identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier a...
Helper function to combine trajectory properties such as site_properties or lattice
def __find_and_remove_value(list, compare): try: found = next(value for value in list if value['name'] == compare['name'] and value['switch'] == compare['switch']) except: return None list.remove(found) return found
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call identifier generator_expression identifier for_in_clause identifier identifier if_clause boolean_operator comparison_operator subscript identifier string string_start string_c...
Finds the value in the list that corresponds with the value of compare.
def _node_info(conn): raw = conn.getInfo() info = {'cpucores': raw[6], 'cpumhz': raw[3], 'cpumodel': six.text_type(raw[0]), 'cpus': raw[2], 'cputhreads': raw[7], 'numanodes': raw[4], 'phymemory': raw[1], 'sockets': raw[5]} r...
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end subscript identifier integer pair string string_start s...
Internal variant of node_info taking a libvirt connection as parameter
def update(self): if self.input_method == 'local': stats = self.update_local() elif self.input_method == 'snmp': stats = self.update_snmp() else: stats = self.get_init_value() self.stats = stats return self.stats
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list elif_clause comparison_operator attribute i...
Update CPU stats using the input method.
def verify_log(opts): level = LOG_LEVELS.get(str(opts.get('log_level')).lower(), logging.NOTSET) if level < logging.INFO: log.warning('Insecure logging configuration detected! Sensitive data may be logged.')
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier argumen...
If an insecre logging configuration is found, show a warning
def regex(self) -> Pattern: if self._regex is None: self._regex = re.compile(self.regex_text, re.IGNORECASE | re.DOTALL) return self._regex
module function_definition identifier parameters identifier type identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier binary_operator...
Returns a compiled regex for this drug.
def content_disposition(self) -> Optional[ContentDispositionHeader]: try: return cast(ContentDispositionHeader, self[b'content-disposition'][0]) except (KeyError, IndexError): return None
module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block try_statement block return_statement call identifier argument_list identifier subscript subscript identifier string string_start string_content string_end integer except_clause tuple identifier ...
The ``Content-Disposition`` header.
def pointcloud2ply(vertices, normals, out_file=None): from pathlib import Path import pandas as pd from pyntcloud import PyntCloud df = pd.DataFrame(np.hstack((vertices, normals))) df.columns = ['x', 'y', 'z', 'nx', 'ny', 'nz'] cloud = PyntCloud(df) if out_file is None: out_file = Pa...
module function_definition identifier parameters identifier identifier default_parameter identifier none block import_from_statement dotted_name identifier dotted_name identifier import_statement aliased_import dotted_name identifier identifier import_from_statement dotted_name identifier dotted_name identifier express...
Converts the file to PLY format
def run(self, test=False): self._request = self._parse_request() log.debug('Handling incoming request for %s', self.request.path) items = self._dispatch(self.request.path) if hasattr(self, '_unsynced_storages'): for storage in self._unsynced_storages.values(): ...
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_conte...
The main entry point for a plugin.
def update_evt_types(self): self.event_types = self.parent.notes.annot.event_types self.idx_evt_type.clear() self.frequency['norm_evt_type'].clear() for ev in self.event_types: self.idx_evt_type.addItem(ev) self.frequency['norm_evt_type'].addItem(ev)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier attribute attribute attribute attribute identifier identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list ex...
Update the event types list when dialog is opened.
def _init_incremental_search(self, searchfun, init_event): u log("init_incremental_search") self.subsearch_query = u'' self.subsearch_fun = searchfun self.subsearch_old_line = self.l_buffer.get_line_text() queue = self.process_keyevent_queue queue.append(sel...
module function_definition identifier parameters identifier identifier identifier block expression_statement identifier expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier string string_start string_end expressi...
u"""Initialize search prompt
def _render_border_line(self, t, settings): s = self._es(settings, self.SETTING_WIDTH, self.SETTING_MARGIN, self.SETTING_MARGIN_LEFT, self.SETTING_MARGIN_RIGHT) w = self.calculate_width_widget(**s) s = self._es(settings, self.SETTING_BORDER_STYLE, self.SETTING_BORDER_FORMATING) border_li...
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier...
Render box border line.
def iter_code_cells(self): for ws in self.nb.worksheets: for cell in ws.cells: if cell.cell_type == 'code': yield cell
module function_definition identifier parameters identifier block for_statement identifier attribute attribute identifier identifier identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_...
Iterate over the notebook cells containing code.
def depthtospace(attrs, inputs, proto_obj): new_attrs = translation_utils._fix_attribute_names(attrs, {'blocksize':'block_size'}) return "depth_to_space", new_attrs, inputs
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary pair string string_start string_content string_end string string_start string_content string_end return_statement ex...
Rearranges data from depth into blocks of spatial data.
def _load_matcher(self) -> None: for id_key in self._rule_lst: if self._rule_lst[id_key].active: pattern_lst = [a_pattern.spacy_token_lst for a_pattern in self._rule_lst[id_key].patterns] for spacy_rule_id, spacy_rule in enumerate(itertools.product(*pattern_lst)): ...
module function_definition identifier parameters identifier type none block for_statement identifier attribute identifier identifier block if_statement attribute subscript attribute identifier identifier identifier identifier block expression_statement assignment identifier list_comprehension attribute identifier ident...
Add constructed spacy rule to Matcher
def format_custom_fields(list_of_custom_fields): output_payload = {} if list_of_custom_fields: for custom_field in list_of_custom_fields: for key, value in custom_field.items(): output_payload["custom_fields[" + key + "]"] = value return output_pay...
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary if_statement identifier block for_statement identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement a...
Custom fields formatting for submission
def _get_tab(cls): if not cls._tabs['dec_cobs']: cls._tabs['dec_cobs']['\xff'] = (255, '') cls._tabs['dec_cobs'].update(dict((chr(l), (l, '\0')) for l in range(1, 255))) cls._tabs['enc_cobs'] = [(255, '\xff'), ...
module function_definition identifier parameters identifier block if_statement not_operator subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment subscript subscript attribute identifier identifier string string_start string_content string_end stri...
Generate and return the COBS table.
def _wait(jid): if jid is None: jid = salt.utils.jid.gen_jid(__opts__) states = _prior_running_states(jid) while states: time.sleep(1) states = _prior_running_states(jid)
module function_definition identifier parameters identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier expression_statement assignment identifier call iden...
Wait for all previously started state jobs to finish running
def strip_label(mapper, connection, target): if target.label is not None: target.label = target.label.strip()
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list
Strip labels at ORM level so the unique=True means something.
def strip_html(text): def reply_to(text): replying_to = [] split_text = text.split() for index, token in enumerate(split_text): if token.startswith('@'): replying_to.append(token[1:]) else: message = split_text[index:] break rpl...
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call...
Get rid of ugly twitter html
def user_has_super_roles(): member = api.get_current_user() super_roles = ["LabManager", "Manager"] diff = filter(lambda role: role in super_roles, member.getRoles()) return len(diff) > 0
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end expression_statement assignment...
Return whether the current belongs to superuser roles
def safe_url(url): parsed = urlparse(url) if parsed.password is not None: pwd = ':%s@' % parsed.password url = url.replace(pwd, ':*****@') return url
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier binary_operator string string_start string_content ...
Remove password from printed connection URLs.
def dump(self, *args, **kwargs): lxml.etree.dump(self._obj, *args, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier list_splat identifier dictionary_splat identifier
Dumps a representation of the Model on standard output.
def sunRelation(obj, sun): if obj.id == const.SUN: return None dist = abs(angle.closestdistance(sun.lon, obj.lon)) if dist < 0.2833: return CAZIMI elif dist < 8.0: return COMBUST elif dist < 16.0: return UNDER_SUN else: return None
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block return_statement none expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument...
Returns an object's relation with the sun.
def remove_feature(self, feature_name): self.clear_feature_symlinks(feature_name) if os.path.exists(self.install_directory(feature_name)): self.__remove_path(self.install_directory(feature_name))
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier block express...
Remove an feature from the environment root folder.
def explain_prediction_lightning(estimator, doc, vec=None, top=None, target_names=None, targets=None, feature_names=None, vectorized=False, coef_scale=None): return explain_weights_lightning_not_supported(estimator, d...
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier false default_parameter identifier none block retu...
Return an explanation of a lightning estimator predictions
def types(gandi): options = {} types = gandi.paas.type_list(options) for type_ in types: gandi.echo(type_['name']) return types
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attrib...
List types PaaS instances.
def b(self): b = Point(self.center) if self.xAxisIsMinor: b.x += self.minorRadius else: b.y += self.minorRadius return b
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier attribute identifier ide...
Positive antipodal point on the minor axis, Point class.
def _should_run(het_file): has_hets = False with open(het_file) as in_handle: for i, line in enumerate(in_handle): if i > 1: has_hets = True break return has_hets
module function_definition identifier parameters identifier block expression_statement assignment identifier false with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block for_statement pattern_list identifier identifier call identifier argument_list id...
Check for enough input data to proceed with analysis.
def setSignalName(self, name: str): self.isHook = False self.messengerName = name
module function_definition identifier parameters identifier typed_parameter identifier type identifier block expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier identifier
Specify that the message will be delivered with the signal ``name``.
def _set_id_from_xml_frameid(self, xml, xmlpath, var): e = xml.find(xmlpath) if e is not None: setattr(self, var, e.attrib['frameid'])
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call identifier argument_list identifier...
Set a single variable with the frameids of matching entity
def runcall(self, func, *args, **kw): self.enable_by_count() try: return func(*args, **kw) finally: self.disable_by_count()
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list try_statement block return_statement call identifier argument_list list_splat identifier dictionary_splat...
Profile a single function call.
def openSheet(self, name): if name not in self.__sheetNameDict: sheet = self.__workbook.add_sheet(name) self.__sheetNameDict[name] = sheet self.__sheet = self.__sheetNameDict[name]
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment sub...
set a sheet to write
def cosh(x, context=None): return _apply_function_in_current_context( BigFloat, mpfr.mpfr_cosh, (BigFloat._implicit_convert(x),), context, )
module function_definition identifier parameters identifier default_parameter identifier none block return_statement call identifier argument_list identifier attribute identifier identifier tuple call attribute identifier identifier argument_list identifier identifier
Return the hyperbolic cosine of x.