code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def next_video(self, _): self.cnt_video += 1 lg.info('Update video to ' + str(self.cnt_video))
module function_definition identifier parameters identifier identifier block expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list attribute identifier identifier
Also runs when file is loaded, so index starts at 2.
def value(self, raw_value): try: return base64.b64decode(bytes(raw_value, 'utf-8')).decode('utf-8') except binascii.Error as err: raise ValueError(str(err))
module function_definition identifier parameters identifier identifier block try_statement block return_statement call attribute call attribute identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end except_clause as_pattern attribute identifier identifier as_pattern_target identifier block raise_statement call identifier argument_list call identifier argument_list identifier
Decode param with Base64.
def remove_variants(self, variants): chroms = set([i.chrom for i in variants]) for chrom in chroms: if self.append_chromosome: chrom = 'chr%s' % chrom to_delete = [pos for pos in self.positions[chrom] if pos in variants] for pos in to_delete: del self.positions[chrom][pos]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list list_comprehension attribute identifier identifier for_in_clause identifier identifier for_statement identifier identifier block if_statement attribute identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier subscript attribute identifier identifier identifier if_clause comparison_operator identifier identifier for_statement identifier identifier block delete_statement subscript subscript attribute identifier identifier identifier identifier
Remove a list of variants from the positions we are scanning
def main(): log.setup_main_logger(console=True, file_logging=False) log.log_sockeye_version(logger) params = argparse.ArgumentParser(description="Rerank nbest lists of translations." " Reranking sorts a list of hypotheses according" " to their score compared to a common reference.") arguments.add_rerank_args(params) args = params.parse_args() logger.info(args) rerank(args)
module function_definition identifier parameters block expression_statement call attribute identifier identifier argument_list keyword_argument identifier true keyword_argument identifier false expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier concatenated_string 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 identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list identifier
Commandline interface to rerank nbest lists.
def open(cls, filename): file_info = cls.parse_remote(filename) blob_service = cls.connect(filename) return BlobHandle(blob_service=blob_service, container=file_info.container, blob=file_info.blob, chunk_size=cls._BLOB_CHUNK_DATA_SIZE)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Provide a handle-like object for streaming.
def build(content_directory=None, out_directory=None): content_directory = content_directory or '.' out_directory = os.path.abspath(out_directory or default_out_directory) repo = require_repo(content_directory) if out_directory == '.': raise ValueError('Output directory must be different than the source directory: ' + repr(out_directory)) if os.path.basename(os.path.relpath(out_directory, content_directory)) == '..': raise ValueError('Output directory must not contain the source directory: ' + repr(out_directory)) files = presentation_files(repo) remove_directory(out_directory) copy_files(files, out_directory, repo) return out_directory
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list boolean_operator identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier identifier identifier return_statement identifier
Builds the site from its content and presentation repository.
def extend(self, *keys, **kwargs): this = copy.deepcopy(self) value_type = kwargs.get('value_type', EnumValue) if not keys: raise EnumEmptyError() keys = tuple(keys) values = [None] * len(keys) for i, key in enumerate(keys): value = value_type(this, i, key) values[i] = value try: super(Enum, this).__setattr__(key, value) except TypeError: raise EnumBadKeyError(key) this.__dict__['_keys'] = this.__dict__['_keys'] + keys this.__dict__['_values'] += values return this
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern 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 identifier if_statement not_operator identifier block raise_statement call identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator list none call identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment subscript identifier identifier identifier try_statement block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier except_clause identifier block raise_statement call identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end binary_operator subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement augmented_assignment subscript attribute identifier identifier string string_start string_content string_end identifier return_statement identifier
Return a new enumeration object extended with the specified items.
def was_run_code(self, get_all=True): if self.stored is None: return "" else: if get_all: self.stored = ["\n".join(self.stored)] return self.stored[-1]
module function_definition identifier parameters identifier default_parameter identifier true block if_statement comparison_operator attribute identifier identifier none block return_statement string string_start string_end else_clause block if_statement identifier block expression_statement assignment attribute identifier identifier list call attribute string string_start string_content escape_sequence string_end identifier argument_list attribute identifier identifier return_statement subscript attribute identifier identifier unary_operator integer
Get all the code that was run.
def _newConsole(cls, console): self = cls.__new__(cls) _BaseConsole.__init__(self) self.console_c = console self.console = self self.width = _lib.TCOD_console_get_width(console) self.height = _lib.TCOD_console_get_height(console) return self
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier return_statement identifier
Make a Console instance, from a console ctype
def showpath(path): if logger.verbose: return os.path.abspath(path) else: path = os.path.relpath(path) if path.startswith(os.curdir + os.sep): path = path[len(os.curdir + os.sep):] return path
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier subscript identifier slice call identifier argument_list binary_operator attribute identifier identifier attribute identifier identifier return_statement identifier
Format a path for displaying.
def save(self, path: Union[str, bytes, int]) -> None: with open(path, 'w') as f: def write(s: str) -> None: f.write(s) self._write_qasm(write)
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier type identifier type none 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 function_definition identifier parameters typed_parameter identifier type identifier type none block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
Write QASM output to a file specified by path.
def _did_retrieve(self, connection): response = connection.response try: self.from_dict(response.data[0]) except: pass return self._did_perform_standard_operation(connection)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier integer except_clause block pass_statement return_statement call attribute identifier identifier argument_list identifier
Callback called after fetching the object
def adjacent(geohash, direction): assert direction in 'nsew', "Invalid direction: %s"%direction assert geohash, "Invalid geohash: %s"%geohash neighbor = { 'n': [ 'p0r21436x8zb9dcf5h7kjnmqesgutwvy', 'bc01fg45238967deuvhjyznpkmstqrwx' ], 's': [ '14365h7k9dcfesgujnmqp0r2twvyx8zb', '238967debc01fg45kmstqrwxuvhjyznp' ], 'e': [ 'bc01fg45238967deuvhjyznpkmstqrwx', 'p0r21436x8zb9dcf5h7kjnmqesgutwvy' ], 'w': [ '238967debc01fg45kmstqrwxuvhjyznp', '14365h7k9dcfesgujnmqp0r2twvyx8zb' ] } border = { 'n': [ 'prxz', 'bcfguvyz' ], 's': [ '028b', '0145hjnp' ], 'e': [ 'bcfguvyz', 'prxz' ], 'w': [ '0145hjnp', '028b' ] } last = geohash[-1] parent = geohash[0:-1] t = len(geohash) % 2 if (last in border[direction][t]) and (parent): parent = adjacent(parent, direction) return parent + BASESEQUENCE[neighbor[direction][t].index(last)]
module function_definition identifier parameters identifier identifier block assert_statement comparison_operator identifier string string_start string_content string_end binary_operator string string_start string_content string_end identifier assert_statement identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier subscript identifier unary_operator integer expression_statement assignment identifier subscript identifier slice integer unary_operator integer expression_statement assignment identifier binary_operator call identifier argument_list identifier integer if_statement boolean_operator parenthesized_expression comparison_operator identifier subscript subscript identifier identifier identifier parenthesized_expression identifier block expression_statement assignment identifier call identifier argument_list identifier identifier return_statement binary_operator identifier subscript identifier call attribute subscript subscript identifier identifier identifier identifier argument_list identifier
Return the adjacent geohash for a given direction.
def readline(self, size=None): (line, nl) = self.__buffer.read_until_nl(self.__retrieve_data) if self.__sf.access_type_has_universal_nl and nl is not None: self.__newlines[nl] = True return line
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment tuple_pattern identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement boolean_operator attribute attribute identifier identifier identifier comparison_operator identifier none block expression_statement assignment subscript attribute identifier identifier identifier true return_statement identifier
Read a single line of text with EOF.
def fetch(self, remote='origin'): git(self.gitdir, "fetch", remote, _env=self.env())
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end identifier keyword_argument identifier call attribute identifier identifier argument_list
fetch from a remote
def leader_for_partition(self, partition): if partition.topic not in self._partitions: return None elif partition.partition not in self._partitions[partition.topic]: return None return self._partitions[partition.topic][partition.partition].leader
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block return_statement none elif_clause comparison_operator attribute identifier identifier subscript attribute identifier identifier attribute identifier identifier block return_statement none return_statement attribute subscript subscript attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier
Return node_id of leader, -1 unavailable, None if unknown.
def load_path(self, path): containing_module, _, last_item = path.rpartition('.') if last_item[0].isupper(): path = containing_module imported_obj = importlib.import_module(path) if last_item[0].isupper(): try: imported_obj = getattr(imported_obj, last_item) except AttributeError: msg = 'Cannot import "%s". ' \ '(Hint: CamelCase is only for classes)' % last_item raise ConfigurationError(msg) return imported_obj
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement call attribute subscript identifier integer identifier argument_list block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement call attribute subscript identifier integer identifier argument_list block try_statement block expression_statement assignment identifier call identifier argument_list identifier identifier except_clause identifier block expression_statement assignment identifier binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end identifier raise_statement call identifier argument_list identifier return_statement identifier
Load and return a given import path to a module or class
def _get_var_name(self, register_name, mode): var_name = { "pre": self._translator.get_name_init(register_name), "post": self._translator.get_name_curr(register_name), } return var_name[mode]
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier return_statement subscript identifier identifier
Get variable name for a register considering pre and post mode.
def _add_internal_event(self, name, send_event=False, internal_event_factory=None): if not internal_event_factory: internal_event_factory = self.internal_event_factory return self.add_event(names, send_event=send_event, event_factory=internal_event_factory)
module function_definition identifier parameters identifier identifier default_parameter identifier false default_parameter identifier none block if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier
This is only here to ensure my constant hatred for Python 2's horrid variable argument support.
def val(self, strictkey): ruamelkey = self.ruamelindex(strictkey) return self._select(self._pointer.val(ruamelkey, strictkey))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier
Return a chunk referencing a value in a mapping with the key 'key'.
async def send(self, sender, **kwargs): if not self.receivers: return [] responses = [] futures = [] for receiver in self._get_receivers(sender): method = receiver() if callable(method): futures.append(method(sender=sender, **kwargs)) if len(futures) > 0: responses = await asyncio.gather(*futures) return responses
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block if_statement not_operator attribute identifier identifier block return_statement list expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list if_statement call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier identifier dictionary_splat identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier await call attribute identifier identifier argument_list list_splat identifier return_statement identifier
send a signal from the sender to all connected receivers
def shell_exec(command): out = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0] return out.decode('utf-8')
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript call attribute call attribute identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier identifier argument_list integer return_statement call attribute identifier identifier argument_list string string_start string_content string_end
Executes the given shell command and returns its output.
def process_message(self, message, *args, **kwargs): if not message.level in PERSISTENT_MESSAGE_LEVELS: return message user = kwargs.get("user") or self.get_user() try: anonymous = user.is_anonymous() except TypeError: anonymous = user.is_anonymous if anonymous: raise NotImplementedError('Persistent message levels cannot be used for anonymous users.') message_persistent = PersistentMessage() message_persistent.level = message.level message_persistent.message = message.message message_persistent.extra_tags = message.extra_tags message_persistent.user = user if "expires" in kwargs: message_persistent.expires = kwargs["expires"] message_persistent.save() return None
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement not_operator comparison_operator attribute identifier identifier identifier block return_statement identifier expression_statement assignment identifier boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list except_clause identifier block expression_statement assignment identifier attribute identifier identifier if_statement identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list return_statement none
If its level is into persist levels, convert the message to models and save it
def shell( state, fancy=False, shell_args=None, anyway=False, ): from ..core import load_dot_env, do_shell if "PIPENV_ACTIVE" in os.environ: venv_name = os.environ.get("VIRTUAL_ENV", "UNKNOWN_VIRTUAL_ENVIRONMENT") if not anyway: echo( "{0} {1} {2}\nNo action taken to avoid nested environments.".format( crayons.normal("Shell for"), crayons.green(venv_name, bold=True), crayons.normal("already activated.", bold=True), ), err=True, ) sys.exit(1) load_dot_env() if os.name == "nt": fancy = True do_shell( three=state.three, python=state.python, fancy=fancy, shell_args=shell_args, pypi_mirror=state.pypi_mirror, )
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier none default_parameter identifier false block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier dotted_name identifier if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end if_statement not_operator identifier block expression_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier keyword_argument identifier true call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true keyword_argument identifier true expression_statement call attribute identifier identifier argument_list integer expression_statement call identifier argument_list if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier true expression_statement call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier
Spawns a shell within the virtualenv.
def requests_for_variant(self, request, variant_id=None): requests = ProductRequest.objects.filter(variant__id=variant_id) serializer = self.serializer_class(requests, many=True) return Response(data=serializer.data, status=status.HTTP_200_OK)
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true return_statement call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Get all the requests for a single variant
def fw_update(self, data, fw_name=None): LOG.debug("FW Update %s", data) self._fw_update(fw_name, data)
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier identifier
Top level FW update function.
def delete(self, object_type, object_id): tag_names = request.get_json(force=True) if not tag_names: return Response(status=403) db.session.query(TaggedObject).filter(and_( TaggedObject.object_type == object_type, TaggedObject.object_id == object_id), TaggedObject.tag.has(Tag.name.in_(tag_names)), ).delete(synchronize_session=False) db.session.commit() return Response(status=204)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier true if_statement not_operator identifier block return_statement call identifier argument_list keyword_argument identifier integer expression_statement call attribute call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list call identifier argument_list comparison_operator attribute identifier identifier identifier comparison_operator attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list keyword_argument identifier false expression_statement call attribute attribute identifier identifier identifier argument_list return_statement call identifier argument_list keyword_argument identifier integer
Remove tags from an object.
def encode_location(location: BioCLocation): return etree.Element('location', {'offset': str(location.offset), 'length': str(location.length)})
module function_definition identifier parameters typed_parameter identifier type identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end call identifier argument_list attribute identifier identifier pair string string_start string_content string_end call identifier argument_list attribute identifier identifier
Encode a single location.
def remove_dns_challenge_txt(self, zone_id, domain, txt_challenge): print("Deleting DNS challenge..") resp = self.route53.change_resource_record_sets( HostedZoneId=zone_id, ChangeBatch=self.get_dns_challenge_change_batch('DELETE', domain, txt_challenge) ) return resp
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier return_statement identifier
Remove DNS challenge TXT.
def pil2tensor(image:Union[NPImage,NPArray],dtype:np.dtype)->TensorImage: "Convert PIL style `image` array to torch style image tensor." a = np.asarray(image) if a.ndim==2 : a = np.expand_dims(a,2) a = np.transpose(a, (1, 0, 2)) a = np.transpose(a, (2, 1, 0)) return torch.from_numpy(a.astype(dtype, copy=False) )
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier typed_parameter identifier type attribute identifier identifier type identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier tuple integer integer integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier tuple integer integer integer return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier false
Convert PIL style `image` array to torch style image tensor.
def richardson(vals, k, c=None): if c is None: c = richardson_parameter(vals, k) return vals[k] - (vals[k] - vals[k - 1]) / c
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list identifier identifier return_statement binary_operator subscript identifier identifier binary_operator parenthesized_expression binary_operator subscript identifier identifier subscript identifier binary_operator identifier integer identifier
Richardson extrapolation with parameter estimation
def _initialize_lists(model_class, name, bases, attrs): model_class._lists = {} for k, v in attrs.iteritems(): if isinstance(v, ListField): model_class._lists[k] = v v.name = v.name or k
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment attribute identifier identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment attribute identifier identifier boolean_operator attribute identifier identifier identifier
Stores the list fields descriptors of a model.
def do_dir(self, args, unknown): if unknown: self.perror("dir does not take any positional arguments:", traceback_war=False) self.do_help('dir') self._last_result = cmd2.CommandResult('', 'Bad arguments') return contents = os.listdir(self.cwd) fmt = '{} ' if args.long: fmt = '{}\n' for f in contents: self.stdout.write(fmt.format(f)) self.stdout.write('\n') self._last_result = cmd2.CommandResult(data=contents)
module function_definition identifier parameters identifier identifier identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier false expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_end string string_start string_content string_end return_statement expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier string string_start string_content string_end if_statement attribute identifier identifier block expression_statement assignment identifier string string_start string_content escape_sequence string_end for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier identifier
List contents of current directory.
def run_mash(self): self.pipeline = True mash.Mash(inputobject=self, analysistype='mash')
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end
Run MASH to determine the closest refseq genomes
def skeletonize_labels(labels): colors = color_labels(labels) max_color = np.max(colors) if max_color == 0: return labels result = np.zeros(labels.shape, labels.dtype) for i in range(1,max_color+1): mask = skeletonize(colors==i) result[mask] = labels[mask] return result
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier integer block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier for_statement identifier call identifier argument_list integer binary_operator identifier integer block expression_statement assignment identifier call identifier argument_list comparison_operator identifier identifier expression_statement assignment subscript identifier identifier subscript identifier identifier return_statement identifier
Skeletonize a labels matrix
def index(): stats = dict((k, {"count": 0}) for k, tt in conf.InputTables) countminmax = "SUM(count) AS count, MIN(day) AS first, MAX(day) AS last" for input, table in [(x, t) for x, tt in conf.InputTables for t in tt]: row = db.fetchone("counts", countminmax, type=table) if not row["count"]: continue stats[input]["count"] += row["count"] for func, key in [(min, "first"), (max, "last")]: stats[input][key] = (row[key] if key not in stats[input] else func(stats[input][key], row[key])) return bottle.template("index.tpl", locals(), conf=conf)
module function_definition identifier parameters block expression_statement assignment identifier call identifier generator_expression tuple identifier dictionary pair string string_start string_content string_end integer for_in_clause pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier string string_start string_content string_end for_statement pattern_list identifier identifier list_comprehension tuple identifier identifier for_in_clause pattern_list identifier identifier attribute identifier identifier for_in_clause identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier keyword_argument identifier identifier if_statement not_operator subscript identifier string string_start string_content string_end block continue_statement expression_statement augmented_assignment subscript subscript identifier identifier string string_start string_content string_end subscript identifier string string_start string_content string_end for_statement pattern_list identifier identifier list tuple identifier string string_start string_content string_end tuple identifier string string_start string_content string_end block expression_statement assignment subscript subscript identifier identifier identifier parenthesized_expression conditional_expression subscript identifier identifier comparison_operator identifier subscript identifier identifier call identifier argument_list subscript subscript identifier identifier identifier subscript identifier identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list keyword_argument identifier identifier
Handler for showing the GUI index page.
def vtt_talk_sources(ttFont) -> List[str]: VTT_SOURCE_TABLES = {'TSI0', 'TSI1', 'TSI2', 'TSI3', 'TSI5'} tables_found = [tag for tag in ttFont.keys() if tag in VTT_SOURCE_TABLES] return tables_found
module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier set 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 string_content string_end expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call attribute identifier identifier argument_list if_clause comparison_operator identifier identifier return_statement identifier
Return the tags of VTT source tables found in a font.
def remove_step_method(self, step_method): try: for s in step_method.stochastics: self.step_method_dict[s].remove(step_method) if hasattr(self, "step_methods"): self.step_methods.discard(step_method) self._sm_assigned = False except AttributeError: for sm in step_method: self.remove_step_method(sm)
module function_definition identifier parameters identifier identifier block try_statement block for_statement identifier attribute identifier identifier block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier false except_clause identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
Removes a step method.
def sample_trajectories(self, rollout_length, batch_info) -> Trajectories: indexes = self.backend.sample_batch_trajectories(rollout_length) transition_tensors = self.backend.get_trajectories(indexes, rollout_length) return Trajectories( num_steps=rollout_length, num_envs=self.backend.num_envs, environment_information=None, transition_tensors={k: torch.from_numpy(v) for k, v in transition_tensors.items()}, rollout_tensors={} )
module function_definition identifier parameters identifier identifier identifier type identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier none keyword_argument identifier dictionary_comprehension pair identifier call attribute identifier identifier argument_list identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list keyword_argument identifier dictionary
Sample batch of trajectories and return them
def _create_drawables(self, tokensource): lineno = charno = maxcharno = 0 for ttype, value in tokensource: while ttype not in self.styles: ttype = ttype.parent style = self.styles[ttype] value = value.expandtabs(4) lines = value.splitlines(True) for i, line in enumerate(lines): temp = line.rstrip('\n') if temp: self._draw_text( self._get_text_pos(charno, lineno), temp, font = self._get_style_font(style), fill = self._get_text_color(style) ) charno += len(temp) maxcharno = max(maxcharno, charno) if line.endswith('\n'): charno = 0 lineno += 1 self.maxcharno = maxcharno self.maxlineno = lineno
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier assignment identifier assignment identifier integer for_statement pattern_list identifier identifier identifier block while_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list true for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier keyword_argument identifier call attribute identifier identifier argument_list identifier keyword_argument identifier call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier if_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end block expression_statement assignment identifier integer expression_statement augmented_assignment identifier integer expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier
Create drawables for the token content.
def generate_unique_name(self, basename): counts = self.__counts try: count = counts[basename] counts[basename] += 1 except KeyError: count = 0 counts[basename] = 1 prefix = self.Naming_prefix if count == 0: name = prefix + basename else: name = prefix + basename + "_" + str(count) if prefix != "" or count != 0: try: count = counts[name] return self.generate_unique_name(name) except KeyError: counts[name] = 1 return name
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier try_statement block expression_statement assignment identifier subscript identifier identifier expression_statement augmented_assignment subscript identifier identifier integer except_clause identifier block expression_statement assignment identifier integer expression_statement assignment subscript identifier identifier integer expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator identifier identifier else_clause block expression_statement assignment identifier binary_operator binary_operator binary_operator identifier identifier string string_start string_content string_end call identifier argument_list identifier if_statement boolean_operator comparison_operator identifier string string_start string_end comparison_operator identifier integer block try_statement block expression_statement assignment identifier subscript identifier identifier return_statement call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement assignment subscript identifier identifier integer return_statement identifier
Generates a unique name for a child given a base name.
def _series_mdgel(self): self.pages.useframes = False self.pages.keyframe = 0 md = self.mdgel_metadata if md['FileTag'] in (2, 128): dtype = numpy.dtype('float32') scale = md['ScalePixel'] scale = scale[0] / scale[1] if md['FileTag'] == 2: def transform(a): return a.astype('float32')**2 * scale else: def transform(a): return a.astype('float32') * scale else: transform = None page = self.pages[0] self.is_uniform = False return [TiffPageSeries([page], page.shape, dtype, page.axes, transform=transform, kind='MDGel')]
module function_definition identifier parameters identifier block expression_statement assignment attribute attribute identifier identifier identifier false expression_statement assignment attribute attribute identifier identifier identifier integer expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator subscript identifier string string_start string_content string_end tuple integer integer block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier binary_operator subscript identifier integer subscript identifier integer if_statement comparison_operator subscript identifier string string_start string_content string_end integer block function_definition identifier parameters identifier block return_statement binary_operator binary_operator call attribute identifier identifier argument_list string string_start string_content string_end integer identifier else_clause block function_definition identifier parameters identifier block return_statement binary_operator call attribute identifier identifier argument_list string string_start string_content string_end identifier else_clause block expression_statement assignment identifier none expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment attribute identifier identifier false return_statement list call identifier argument_list list identifier attribute identifier identifier identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end
Return image series in MD Gel file.
def read_utf(self, offset, len): try: result = self.data[offset:offset + len].decode('utf-8') except UnicodeDecodeError: result = str('') return result
module function_definition identifier parameters identifier identifier identifier block try_statement block expression_statement assignment identifier call attribute subscript attribute identifier identifier slice identifier binary_operator identifier identifier identifier argument_list string string_start string_content string_end except_clause identifier block expression_statement assignment identifier call identifier argument_list string string_start string_end return_statement identifier
Reads a UTF-8 string of a given length from the packet
def check_available(self): success = True start_time = datetime.datetime.utcnow() message = '' LOGGER.debug('Checking layer id %s' % self.id) signals.post_save.disconnect(layer_post_save, sender=Layer) try: self.update_thumbnail() except ValueError, err: if str(err).startswith("unknown url type:"): LOGGER.debug('Thumbnail can not be updated: %s' % str(err)) except Exception, err: message = str(err) success = False signals.post_save.connect(layer_post_save, sender=Layer) end_time = datetime.datetime.utcnow() delta = end_time - start_time response_time = '%s.%s' % (delta.seconds, delta.microseconds) check = Check( content_object=self, success=success, response_time=response_time, message=message ) check.save() LOGGER.debug('Layer checked in %s seconds, status is %s' % (response_time, success)) return success, message
module function_definition identifier parameters identifier block expression_statement assignment identifier true expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier string string_start string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier identifier block if_statement call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier except_clause identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier false expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement expression_list identifier identifier
Check for availability of a layer and provide run metrics.
def _name_with_flags(self, include_restricted, title=None): name = "Special: " if self.special else "" name += self.name if title: name += " - {}".format(title) if include_restricted and self.restricted: name += " (R)" name += " (BB)" if self.both_blocks else "" name += " (A)" if self.administrative else "" name += " (S)" if self.sticky else "" name += " (Deleted)" if self.deleted else "" return name
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier conditional_expression string string_start string_content string_end attribute identifier identifier string string_start string_end expression_statement augmented_assignment identifier attribute identifier identifier if_statement identifier block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement boolean_operator identifier attribute identifier identifier block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier conditional_expression string string_start string_content string_end attribute identifier identifier string string_start string_end expression_statement augmented_assignment identifier conditional_expression string string_start string_content string_end attribute identifier identifier string string_start string_end expression_statement augmented_assignment identifier conditional_expression string string_start string_content string_end attribute identifier identifier string string_start string_end expression_statement augmented_assignment identifier conditional_expression string string_start string_content string_end attribute identifier identifier string string_start string_end return_statement identifier
Generate the name with flags.
def addFailure(self, test, err, capt=None, tbinfo=None): self.__insert_test_result(constants.State.FAILURE, test, err)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier identifier
After a test failure, we want to record testcase run information.
def stop_NoteContainer(self, nc, channel=1): self.notify_listeners(self.MSG_PLAY_NC, {'notes': nc, 'channel': channel}) if nc is None: return True for note in nc: if not self.stop_Note(note, channel): return False return True
module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement call attribute identifier identifier argument_list attribute identifier identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier if_statement comparison_operator identifier none block return_statement true for_statement identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier identifier block return_statement false return_statement true
Stop playing the notes in NoteContainer nc.
def _repr_html_(): from bonobo.commands.version import get_versions return ( '<div style="padding: 8px;">' ' <div style="float: left; width: 20px; height: 20px;">{}</div>' ' <pre style="white-space: nowrap; padding-left: 8px">{}</pre>' "</div>" ).format(__logo__, "<br/>".join(get_versions(all=True)))
module function_definition identifier parameters block import_from_statement dotted_name identifier identifier identifier dotted_name identifier return_statement call attribute parenthesized_expression 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 identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list keyword_argument identifier true
This allows to easily display a version snippet in Jupyter.
def use_plenary_book_view(self): self._book_view = PLENARY for session in self._get_provider_sessions(): try: session.use_plenary_book_view() except AttributeError: pass
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier identifier for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement
Pass through to provider CommentBookSession.use_plenary_book_view
def watering_time(self): index = self.id - 1 auto_watering_time =\ self._attributes['rain_delay_mode'][index]['auto_watering_time'] manual_watering_time =\ self._attributes['rain_delay_mode'][index]['manual_watering_time'] if auto_watering_time > manual_watering_time: watering_time = auto_watering_time else: watering_time = manual_watering_time return watering_time
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator attribute identifier identifier integer expression_statement assignment identifier line_continuation subscript subscript subscript attribute identifier identifier string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier line_continuation subscript subscript subscript attribute identifier identifier string string_start string_content string_end identifier string string_start string_content string_end if_statement comparison_operator identifier identifier block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier identifier return_statement identifier
Return watering_time from zone.
def delete(self, docids): logger.info("asked to drop %i documents" % len(docids)) for index in [self.opt_index, self.fresh_index]: if index is not None: index.delete(docids) self.flush(save_index=True)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier for_statement identifier list attribute identifier identifier attribute identifier identifier block if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier true
Delete specified documents from the index.
def returner(ret): if __salt__['config.option']('returner.kafka.topic'): topic = __salt__['config.option']('returner.kafka.topic') conn = _get_conn() producer = Producer({'bootstrap.servers': conn}) producer.poll(0) producer.produce(topic, salt.utils.json.dumps(ret), str(ret).encode('utf-8'), callback=_delivery_report) producer.flush() else: log.error('Unable to find kafka returner config option: topic')
module function_definition identifier parameters identifier block if_statement call subscript identifier string string_start string_content string_end argument_list string string_start string_content string_end block expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list dictionary pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Return information to a Kafka server
def distance(latitude_1, longitude_1, latitude_2, longitude_2): coef = mod_math.cos(latitude_1 / 180. * mod_math.pi) x = latitude_1 - latitude_2 y = (longitude_1 - longitude_2) * coef return mod_math.sqrt(x * x + y * y) * ONE_DEGREE
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator identifier float attribute identifier identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier identifier identifier return_statement binary_operator call attribute identifier identifier argument_list binary_operator binary_operator identifier identifier binary_operator identifier identifier identifier
Distance between two points.
def median_date(dt_list): idx = len(dt_list)/2 if len(dt_list) % 2 == 0: md = mean_date([dt_list[idx-1], dt_list[idx]]) else: md = dt_list[idx] return md
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator call identifier argument_list identifier integer if_statement comparison_operator binary_operator call identifier argument_list identifier integer integer block expression_statement assignment identifier call identifier argument_list list subscript identifier binary_operator identifier integer subscript identifier identifier else_clause block expression_statement assignment identifier subscript identifier identifier return_statement identifier
Calcuate median datetime from datetime list
def verify_signature(self, addr): return verify(virtualchain.address_reencode(addr), self.get_plaintext_to_sign(), self.sig)
module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list attribute identifier identifier
Given an address, verify whether or not it was signed by it
def log_percent(self): done = self.total - self.todo percent = int(float(done) / self.total * 100) if not hasattr(self, 'prev_percent'): self.prev_percent = 0 self.progress('Sent %s of data in %d %s task(s)', humansize(self.sent.sum()), self.total, self.name) elif percent > self.prev_percent: self.progress('%s %3d%% [of %d tasks]', self.name, percent, len(self.tasks)) self.prev_percent = percent return done
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator binary_operator call identifier argument_list identifier attribute identifier identifier integer if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier elif_clause comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
Log the progress of the computation in percentage
def run_file(self, filename): import __main__ __main__.__dict__.clear() __main__.__dict__.update({ "__name__": "__main__", "__file__": filename, "__builtins__": __builtins__, }) with open(filename, "rb") as fp: statement = compile(fp.read(), filename, 'exec') self.run(statement, filename)
module function_definition identifier parameters identifier identifier block import_statement dotted_name identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier
Run the file `filename` with trace
def drawQuad(self, img=None, quad=None, thickness=30): if img is None: img = self.img if quad is None: quad = self.quad q = np.int32(quad) c = int(img.max()) cv2.line(img, tuple(q[0]), tuple(q[1]), c, thickness) cv2.line(img, tuple(q[1]), tuple(q[2]), c, thickness) cv2.line(img, tuple(q[2]), tuple(q[3]), c, thickness) cv2.line(img, tuple(q[3]), tuple(q[0]), c, thickness) return img
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier integer block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer identifier identifier expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer identifier identifier expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer identifier identifier expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer identifier identifier return_statement identifier
Draw the quad into given img
def kill(self, sig): if self.is_alive() and self._loop: self._loop.call_soon_threadsafe(self._loop.stop)
module function_definition identifier parameters identifier identifier block if_statement boolean_operator call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier
Invoke the stop on the event loop method.
def close(self): if not (yield from super().close()): return False adapters = self._ethernet_adapters + self._serial_adapters for adapter in adapters: if adapter is not None: for nio in adapter.ports.values(): if nio and isinstance(nio, NIOUDP): self.manager.port_manager.release_udp_port(nio.lport, self._project) yield from self.stop()
module function_definition identifier parameters identifier block if_statement not_operator parenthesized_expression yield call attribute call identifier argument_list identifier argument_list block return_statement false expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier for_statement identifier identifier block if_statement comparison_operator identifier none block for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement boolean_operator identifier call identifier argument_list identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement yield call attribute identifier identifier argument_list
Closes this IOU VM.
def json_encode(obj, serialize): if hasattr(obj, 'to_dict'): return obj.to_dict(serialize=serialize) elif isinstance(obj, datetime): return obj.date().isoformat() elif isinstance(obj, date): return obj.isoformat() elif isinstance(obj, ProxyDict): return dict(obj) elif isinstance(obj, ProxyList): return list(obj) elif is_iterable_but_not_string(obj): return list(obj)
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 call attribute identifier identifier argument_list keyword_argument identifier identifier elif_clause call identifier argument_list identifier identifier block return_statement call attribute call attribute identifier identifier argument_list identifier argument_list elif_clause call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list elif_clause call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier elif_clause call identifier argument_list identifier block return_statement call identifier argument_list identifier
Handle encoding complex types.
def recv(self, mac_addr=broadcast_addr, timeout=0): if self.keep_listening: try: return self.inq[str(mac_addr)].get(timeout=timeout) except Empty: return "" else: self.log("is down.")
module function_definition identifier parameters identifier default_parameter identifier identifier default_parameter identifier integer block if_statement attribute identifier identifier block try_statement block return_statement call attribute subscript attribute identifier identifier call identifier argument_list identifier identifier argument_list keyword_argument identifier identifier except_clause identifier block return_statement string string_start string_end else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
read packet off the recv queue for a given address, optional timeout to block and wait for packet
def _checker_mixer(slice1, slice2, checker_size=None): checkers = _get_checkers(slice1.shape, checker_size) if slice1.shape != slice2.shape or slice2.shape != checkers.shape: raise ValueError('size mismatch between cropped slices and checkers!!!') mixed = slice1.copy() mixed[checkers > 0] = slice2[checkers > 0] return mixed
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier if_statement boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier comparison_operator identifier integer subscript identifier comparison_operator identifier integer return_statement identifier
Mixes the two slices in alternating areas specified by checkers
def collapse_fastq(args): try: umi_fn = args.fastq if _is_umi(args.fastq): umis = collapse(args.fastq) umi_fn = os.path.join(args.out, splitext_plus(os.path.basename(args.fastq))[0] + "_umi_trimmed.fastq") write_output(umi_fn, umis, args.minimum) seqs = collapse(umi_fn) out_file = splitext_plus(os.path.basename(args.fastq))[0] + "_trimmed.fastq" except IOError as e: logger.error("I/O error({0}): {1}".format(e.errno, e.strerror)) raise "Can not read file" out_file = os.path.join(args.out, out_file) write_output(out_file, seqs, args.minimum) return out_file
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier attribute identifier identifier if_statement call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier binary_operator subscript call identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier integer string string_start string_content string_end expression_statement call identifier argument_list identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator subscript call identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier integer string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier raise_statement string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier expression_statement call identifier argument_list identifier identifier attribute identifier identifier return_statement identifier
collapse fasq files after adapter trimming
def common_api_auth_options(f): @click.option( "-k", "--api-key", hide_input=True, envvar="CLOUDSMITH_API_KEY", help="The API key for authenticating with the API.", ) @click.pass_context @functools.wraps(f) def wrapper(ctx, *args, **kwargs): opts = config.get_or_create_options(ctx) opts.api_key = kwargs.pop("api_key") kwargs["opts"] = opts return ctx.invoke(f, *args, **kwargs) return wrapper
module function_definition identifier parameters identifier block decorated_definition decorator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier true keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end decorator attribute identifier identifier decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement identifier
Add common API authentication options to commands.
def cli(ctx): dir_path = os.path.join(os.path.expanduser('~'), '.keep', '.credentials') if os.path.exists(dir_path): if click.confirm('[CRITICAL] Reset credentials saved in ~/.keep/.credentials ?', abort=True): os.remove(dir_path) utils.register()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Register user over server.
def check_updates(self, startup=False): from spyder.workers.updates import WorkerUpdates self.check_updates_action.setDisabled(True) if self.thread_updates is not None: self.thread_updates.terminate() self.thread_updates = QThread(self) self.worker_updates = WorkerUpdates(self, startup=startup) self.worker_updates.sig_ready.connect(self._check_updates_ready) self.worker_updates.sig_ready.connect(self.thread_updates.quit) self.worker_updates.moveToThread(self.thread_updates) self.thread_updates.started.connect(self.worker_updates.start) self.thread_updates.start()
module function_definition identifier parameters identifier default_parameter identifier false block import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement call attribute attribute identifier identifier identifier argument_list true if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Check for spyder updates on github releases using a QThread.
def options(self): self.engine.configure({}) conf = self.engine.as_dict() conf["returns"] = [oname for oname in six.iterkeys(self._outputs)] conf["args"] = [iname for iname in six.iterkeys(self._inputs)] return jsonify(conf)
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list dictionary expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end list_comprehension identifier for_in_clause identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end list_comprehension identifier for_in_clause identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement call identifier argument_list identifier
Engine options discover HTTP entry point
def ending_long_process(self, message=""): QApplication.restoreOverrideCursor() self.show_message(message, timeout=2000) QApplication.processEvents()
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list
Clear main window's status bar and restore mouse cursor.
def int_to_alpha(n, upper=True): "Generates alphanumeric labels of form A-Z, AA-ZZ etc." casenum = 65 if upper else 97 label = '' count= 0 if n == 0: return str(chr(n + casenum)) while n >= 0: mod, div = n % 26, n for _ in range(count): div //= 26 div %= 26 if count == 0: val = mod else: val = div label += str(chr(val + casenum)) count += 1 n -= 26**count return label[::-1]
module function_definition identifier parameters identifier default_parameter identifier true block expression_statement string string_start string_content string_end expression_statement assignment identifier conditional_expression integer identifier integer expression_statement assignment identifier string string_start string_end expression_statement assignment identifier integer if_statement comparison_operator identifier integer block return_statement call identifier argument_list call identifier argument_list binary_operator identifier identifier while_statement comparison_operator identifier integer block expression_statement assignment pattern_list identifier identifier expression_list binary_operator identifier integer identifier for_statement identifier call identifier argument_list identifier block expression_statement augmented_assignment identifier integer expression_statement augmented_assignment identifier integer if_statement comparison_operator identifier integer block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier identifier expression_statement augmented_assignment identifier call identifier argument_list call identifier argument_list binary_operator identifier identifier expression_statement augmented_assignment identifier integer expression_statement augmented_assignment identifier binary_operator integer identifier return_statement subscript identifier slice unary_operator integer
Generates alphanumeric labels of form A-Z, AA-ZZ etc.
def bail(self, msg): client_name = self.event['client'].get('name', 'error:no-client-name') check_name = self.event['check'].get('name', 'error:no-check-name') print('{}: {}/{}'.format(msg, client_name, check_name)) sys.exit(0)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list integer
Gracefully terminate with message
def process_rules(self, path: Path, system: System): self.context.update({ 'system': system, }) document = FileSystem.load_yaml(path, required=True) for module, rules in document.items(): click.secho('process: {0}'.format(module), fg='green') self._process_rules(rules, system)
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier
writes the templates read from the rules document
def run(self, node, expr=None, lineno=None, with_raise=True): if time.time() - self.start_time > self.max_time: raise RuntimeError(ERR_MAX_TIME.format(self.max_time)) out = None if len(self.error) > 0: return out if node is None: return out if isinstance(node, str): node = self.parse(node) if lineno is not None: self.lineno = lineno if expr is not None: self.expr = expr try: handler = self.node_handlers[node.__class__.__name__.lower()] except KeyError: return self.unimplemented(node) try: ret = handler(node) if isinstance(ret, enumerate): ret = list(ret) return ret except: if with_raise: self.raise_exception(node, expr=expr)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier true block if_statement comparison_operator binary_operator call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier none if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block return_statement 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 none block expression_statement assignment attribute identifier identifier identifier if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier identifier try_statement block expression_statement assignment identifier subscript attribute identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list except_clause identifier block return_statement call attribute identifier identifier argument_list identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement identifier except_clause block if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
Execute parsed Ast representation for an expression.
def _compute_nonlinear_magnitude_term(self, C, mag): return self._compute_linear_magnitude_term(C, mag) +\ C["b3"] * ((mag - 7.0) ** 2.)
module function_definition identifier parameters identifier identifier identifier block return_statement binary_operator call attribute identifier identifier argument_list identifier identifier line_continuation binary_operator subscript identifier string string_start string_content string_end parenthesized_expression binary_operator parenthesized_expression binary_operator identifier float float
Computes the non-linear magnitude term
def server_static(filepath): mimetype = "image/svg+xml" if filepath.endswith(".svg") else "auto" return bottle.static_file(filepath, root=conf.StaticPath, mimetype=mimetype)
module function_definition identifier parameters identifier block expression_statement assignment identifier conditional_expression string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier
Handler for serving static files.
def ping(self): msg_code = riak.pb.messages.MSG_CODE_PING_REQ codec = self._get_codec(msg_code) msg = codec.encode_ping() resp_code, _ = self._request(msg, codec) if resp_code == riak.pb.messages.MSG_CODE_PING_RESP: return True else: return False
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier attribute attribute attribute identifier identifier identifier identifier block return_statement true else_clause block return_statement false
Ping the remote server
def noise_gaussian(self, mean, std): assert std > 0 ng = self.sym.sym('ng_{:d}'.format(len(self.scope['ng']))) self.scope['ng'].append(ng) return mean + std*ng
module function_definition identifier parameters identifier identifier identifier block assert_statement comparison_operator identifier integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list identifier return_statement binary_operator identifier binary_operator identifier identifier
Create a gaussian noise variable
def ingest(topic, text, **kwargs): if not text: raise ValueError('No text given to ingest for topic: ' + topic) data = {'topic': topic, 'text': text.strip()} data.update(kwargs) db.markovify.insert(data)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block if_statement not_operator identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Ingest the given text for the topic
def escapeForIRI(xri): xri = xri.replace('%', '%25') xri = _xref_re.sub(_escape_xref, xri) return xri
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier
Escape things that need to be escaped when transforming to an IRI.
def getProductUIDs(self): uids = [] for orderitem in self.objectValues('XupplyOrderItem'): product = orderitem.getProduct() if product is not None: uids.append(orderitem.getProduct().UID()) return uids
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list return_statement identifier
return the uids of the products referenced by order items
def _expand_users(device_users, common_users): expected_users = deepcopy(common_users) expected_users.update(device_users) return expected_users
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Creates a longer list of accepted users on the device.
def parent_directory(self): self.chdir(os.path.join(getcwd_or_home(), os.path.pardir))
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call identifier argument_list attribute attribute identifier identifier identifier
Change working directory to parent directory
def bedInterval(self, who): "return a BED6 entry, thus DOES coordinate conversion for minus strands" if who == 't': st, en = self.tStart, self.tEnd if self.tStrand == '-': st, en = self.tSize-en, self.tSize-st return (self.tName, st, en, self.id, self.score, self.tStrand) else: st, en = self.qStart, self.qEnd if self.qStrand == '-': st, en = self.qSize-en, self.qSize-st assert en-st == self.qEnd - self.qStart return (self.qName, st, en, self.id, self.score, self.qStrand)
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier expression_list attribute identifier identifier 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 expression_list binary_operator attribute identifier identifier identifier binary_operator attribute identifier identifier identifier return_statement tuple attribute identifier identifier identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment pattern_list identifier identifier expression_list attribute identifier identifier 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 expression_list binary_operator attribute identifier identifier identifier binary_operator attribute identifier identifier identifier assert_statement comparison_operator binary_operator identifier identifier binary_operator attribute identifier identifier attribute identifier identifier return_statement tuple attribute identifier identifier identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
return a BED6 entry, thus DOES coordinate conversion for minus strands
def cli(ctx, timeout, proxy, output, quiet, lyric, again): ctx.obj = NetEase(timeout, proxy, output, quiet, lyric, again)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list identifier identifier identifier identifier identifier identifier
A command tool to download NetEase-Music's songs.
def discover(self): if self.transport: if self.discovery_countdown <= 0: self.discovery_countdown = self.discovery_interval msg = GetService(BROADCAST_MAC, self.source_id, seq_num=0, payload={}, ack_requested=False, response_requested=True) self.transport.sendto(msg.generate_packed_message(), (self.broadcast_ip, UDP_BROADCAST_PORT)) else: self.discovery_countdown -= self.discovery_step self.loop.call_later(self.discovery_step, self.discover)
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier keyword_argument identifier integer keyword_argument identifier dictionary keyword_argument identifier false keyword_argument identifier true expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list tuple attribute identifier identifier identifier else_clause block expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier
Method to send a discovery message
def _process_oauth_response(self, response): "Extracts the fields from an oauth response" if response.status_code == 200: credentials = parse_qs(response.text) self._init_oauth( credentials.get('oauth_token')[0], credentials.get('oauth_token_secret')[0] ) self.oauth_session_handle = credentials.get( 'oauth_session_handle', [None])[0] oauth_expires_in = credentials.get( 'oauth_expires_in', [OAUTH_EXPIRY_SECONDS])[0] oauth_authorisation_expires_in = credentials.get( 'oauth_authorization_expires_in', [OAUTH_EXPIRY_SECONDS])[0] self.oauth_expires_at = datetime.datetime.now() + \ datetime.timedelta(seconds=int( oauth_expires_in)) self.oauth_authorization_expires_at = \ datetime.datetime.now() + \ datetime.timedelta(seconds=int( oauth_authorisation_expires_in)) else: self._handle_error_response(response)
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list subscript call attribute identifier identifier argument_list string string_start string_content string_end integer subscript call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment attribute identifier identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end list none integer expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end list identifier integer expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end list identifier integer expression_statement assignment attribute identifier identifier binary_operator call attribute attribute identifier identifier identifier argument_list line_continuation call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier line_continuation binary_operator call attribute attribute identifier identifier identifier argument_list line_continuation call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier
Extracts the fields from an oauth response
def make_url(domain, location): url = urlparse(location) if url.scheme == '' and url.netloc == '': return domain + url.path elif url.scheme == '': return 'http://' + url.netloc + url.path else: return url.geturl()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator comparison_operator attribute identifier identifier string string_start string_end comparison_operator attribute identifier identifier string string_start string_end block return_statement binary_operator identifier attribute identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_end block return_statement binary_operator binary_operator string string_start string_content string_end attribute identifier identifier attribute identifier identifier else_clause block return_statement call attribute identifier identifier argument_list
This function helps to make full url path.
def P(Document, *fields, **kw): __always__ = kw.pop('__always__', set()) projected = set() omitted = set() for field in fields: if field[0] in ('-', '!'): omitted.add(field[1:]) elif field[0] == '+': projected.add(field[1:]) else: projected.add(field) if not projected: names = set(getattr(Document, '__projection__', Document.__fields__) or Document.__fields__) projected = {name for name in (names - omitted)} projected |= __always__ if not projected: projected = {'_id'} return {unicode(traverse(Document, name, name)): True for name in projected}
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block if_statement comparison_operator subscript identifier integer tuple string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript identifier slice integer elif_clause comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript identifier slice integer else_clause block expression_statement call attribute identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list boolean_operator call identifier argument_list identifier string string_start string_content string_end attribute identifier identifier attribute identifier identifier expression_statement assignment identifier set_comprehension identifier for_in_clause identifier parenthesized_expression binary_operator identifier identifier expression_statement augmented_assignment identifier identifier if_statement not_operator identifier block expression_statement assignment identifier set string string_start string_content string_end return_statement dictionary_comprehension pair call identifier argument_list call identifier argument_list identifier identifier identifier true for_in_clause identifier identifier
Generate a MongoDB projection dictionary using the Django ORM style.
def _format_ret(self, full_ret): ret = {} out = '' retcode = 0 for key, data in six.iteritems(full_ret): ret[key] = data['ret'] if 'out' in data: out = data['out'] ret_retcode = self._get_retcode(data) if ret_retcode > retcode: retcode = ret_retcode return ret, out, retcode
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier string string_start string_end expression_statement assignment identifier integer for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block expression_statement assignment subscript identifier identifier subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end 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 identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier identifier return_statement expression_list identifier identifier identifier
Take the full return data and format it to simple output
def update_bgp_speaker(self, bgp_speaker_id, body=None): return self.put(self.bgp_speaker_path % bgp_speaker_id, body=body)
module function_definition identifier parameters identifier identifier default_parameter identifier none block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier identifier keyword_argument identifier identifier
Update a BGP speaker.
def _find_last_good_run(build): run_name = request.form.get('run_name', type=str) utils.jsonify_assert(run_name, 'run_name required') last_good_release = ( models.Release.query .filter_by( build_id=build.id, status=models.Release.GOOD) .order_by(models.Release.created.desc()) .first()) last_good_run = None if last_good_release: logging.debug('Found last good release for: build_id=%r, ' 'release_name=%r, release_number=%d', build.id, last_good_release.name, last_good_release.number) last_good_run = ( models.Run.query .filter_by(release_id=last_good_release.id, name=run_name) .first()) if last_good_run: logging.debug('Found last good run for: build_id=%r, ' 'release_name=%r, release_number=%d, ' 'run_name=%r', build.id, last_good_release.name, last_good_release.number, last_good_run.name) return last_good_release, last_good_run
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier parenthesized_expression call attribute call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier identifier argument_list call attribute attribute attribute identifier identifier identifier identifier argument_list identifier argument_list expression_statement assignment identifier none if_statement 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 attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier parenthesized_expression call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier identifier argument_list if_statement 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 attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier return_statement expression_list identifier identifier
Finds the last good release and run for a build.
def stop(self): if self._process is None: return if self._shared: BackendManager.SHARE_COUNT -= 1 if BackendManager.SHARE_COUNT: return comm('stopping backend process') for s in self._sockets: s._callback = None s.close() self._sockets[:] = [] self._process._prevent_logs = True while self._process.state() != self._process.NotRunning: self._process.waitForFinished(1) if sys.platform == 'win32': self._process.kill() else: self._process.terminate() self._process._prevent_logs = False self._heartbeat_timer.stop() comm('backend process terminated')
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block return_statement if_statement attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier integer if_statement attribute identifier identifier block return_statement expression_statement call identifier argument_list string string_start string_content string_end for_statement identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier none expression_statement call attribute identifier identifier argument_list expression_statement assignment subscript attribute identifier identifier slice list expression_statement assignment attribute attribute identifier identifier identifier true while_statement comparison_operator call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list integer if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier false expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end
Stops the backend process.
def _add_task(self, task): if hasattr(task, '_task_group'): raise RuntimeError('task is already part of a group') if self._closed: raise RuntimeError('task group is closed') task._task_group = self if task.done(): self._done.append(task) else: self._pending.add(task) task.add_done_callback(self._on_done)
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end if_statement attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier if_statement call attribute identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Add an already existing task to the task group.
def _print_links(self, model, links): for link in links: if link['o2o'] is True: link_type = self._one_to_one elif link['m2m'] is True: link_type = self._many_to_many else: link_type = self._one_to_many linked_model = link['mdl'](super_context) self._print('%s %s %s' % (model.title, link_type, linked_model.title))
module function_definition identifier parameters identifier identifier identifier block for_statement identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end true block expression_statement assignment identifier attribute identifier identifier elif_clause comparison_operator subscript identifier string string_start string_content string_end true block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier attribute identifier identifier
Print links that start from model.
def getfield(self, pkt, buf): self.set_endianess(pkt) return self.fld.getfield(pkt, buf)
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
retrieve the field with endianness
def unblock_worker(self, worker_id, reason): params = {'WorkerId': worker_id, 'Reason': reason} return self._process_request('UnblockWorker', params)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Unblock a worker from working on my tasks.
def simple_tokenize(name): last_names, first_names = name.split(',') last_names = _RE_NAME_TOKEN_SEPARATOR.split(last_names) first_names = _RE_NAME_TOKEN_SEPARATOR.split(first_names) first_names = [NameToken(n) if len(n) > 1 else NameInitial(n) for n in first_names if n] last_names = [NameToken(n) if len(n) > 1 else NameInitial(n) for n in last_names if n] return {'lastnames': last_names, 'nonlastnames': first_names}
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension conditional_expression call identifier argument_list identifier comparison_operator call identifier argument_list identifier integer call identifier argument_list identifier for_in_clause identifier identifier if_clause identifier expression_statement assignment identifier list_comprehension conditional_expression call identifier argument_list identifier comparison_operator call identifier argument_list identifier integer call identifier argument_list identifier for_in_clause identifier identifier if_clause identifier return_statement dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier
Simple tokenizer function to be used with the normalizers.
def make_op_return_outputs(data, inputs, change_address, fee=OP_RETURN_FEE, send_amount=0, format='bin'): return [ { "script_hex": make_op_return_script(data, format=format), "value": send_amount }, { "script_hex": make_pay_to_address_script(change_address), "value": calculate_change_amount(inputs, send_amount, fee) } ]
module function_definition identifier parameters identifier identifier identifier default_parameter identifier identifier default_parameter identifier integer default_parameter identifier string string_start string_content string_end block return_statement list dictionary pair string string_start string_content string_end call identifier argument_list identifier keyword_argument identifier identifier pair string string_start string_content string_end identifier dictionary pair string string_start string_content string_end call identifier argument_list identifier pair string string_start string_content string_end call identifier argument_list identifier identifier identifier
Builds the outputs for an OP_RETURN transaction.
def _get_drive_url(self, url, session): response = session.get(url, stream=True) if response.status_code != 200: raise DownloadError( 'Failed to get url %s. HTTP code: %d.' % (url, response.status_code)) for k, v in response.cookies.items(): if k.startswith('download_warning'): return url + '&confirm=' + v return url
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true 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 identifier attribute identifier identifier for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block return_statement binary_operator binary_operator identifier string string_start string_content string_end identifier return_statement identifier
Returns url, possibly with confirmation token.
def task_config(self, task: Task) -> Any: return self.get(task.__class__.__name__)
module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block return_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier
Return the task-specific configuration.