code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def go_to_epoch(self, checked=False, test_text_str=None): if test_text_str is not None: time_str = test_text_str ok = True else: time_str, ok = QInputDialog.getText(self, 'Go To Epoch', 'Enter start time of the ' 'epoch,\nin seconds ("1560") ' 'or\nas absolute time ' '("22:30")') if not ok: return try: rec_start_time = self.parent.info.dataset.header['start_time'] window_start = _convert_timestr_to_seconds(time_str, rec_start_time) except ValueError as err: error_dialog = QErrorMessage() error_dialog.setWindowTitle('Error moving to epoch') error_dialog.showMessage(str(err)) if test_text_str is None: error_dialog.exec() self.parent.statusBar().showMessage(str(err)) return self.parent.overview.update_position(window_start)
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier identifier expression_statement assignment identifier true else_clause block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end concatenated_string string string_start string_content string_end string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end string string_start string_content string_end if_statement not_operator identifier block return_statement try_statement block expression_statement assignment identifier subscript attribute attribute attribute attribute identifier identifier identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list expression_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list call identifier argument_list identifier return_statement expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier
Go to any window
def return_daily_messages_count(self, sender): h24 = now() - timedelta(days=1) return Message.objects.filter(sender=sender, sent_at__gte=h24).count()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator call identifier argument_list call identifier argument_list keyword_argument identifier integer return_statement call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier identifier argument_list
Returns the number of messages sent in the last 24 hours so we can ensure the user does not exceed his messaging limits
def setup(self): options = "" if self.get_option("port"): options = (options + " -b " + gethostname() + ":%s" % (self.get_option("port"))) for option in ["ssl-certificate", "ssl-key", "ssl-trustfile"]: if self.get_option(option): options = (options + " --%s=" % (option) + self.get_option(option)) self.add_cmd_output([ "qdstat -a" + options, "qdstat -n" + options, "qdstat -c" + options, "qdstat -m" + options ]) self.add_copy_spec([ "/etc/qpid-dispatch/qdrouterd.conf" ])
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier parenthesized_expression binary_operator binary_operator binary_operator identifier string string_start string_content string_end call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier parenthesized_expression binary_operator binary_operator identifier binary_operator string string_start string_content string_end parenthesized_expression identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list list binary_operator string string_start string_content string_end identifier binary_operator string string_start string_content string_end identifier binary_operator string string_start string_content string_end identifier binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end
performs data collection for qpid dispatch router
def _option(value): if value in __opts__: return __opts__[value] master_opts = __pillar__.get('master', {}) if value in master_opts: return master_opts[value] if value in __pillar__: return __pillar__[value]
module function_definition identifier parameters identifier block if_statement comparison_operator identifier identifier block return_statement subscript identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end dictionary if_statement comparison_operator identifier identifier block return_statement subscript identifier identifier if_statement comparison_operator identifier identifier block return_statement subscript identifier identifier
Look up the value for an option.
def remove_known_hosts(overcloud_ip): known_hosts = os.path.expanduser("~/.ssh/known_hosts") if os.path.exists(known_hosts): command = ['ssh-keygen', '-R', overcloud_ip, '-f', known_hosts] subprocess.check_call(command)
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 if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier
For a given IP address remove SSH keys from the known_hosts file
def disable(ctx): if ctx.obj['username'] is None: log('Specify the username with "iso db user --username ..."') return change_user = ctx.obj['db'].objectmodels['user'].find_one({ 'name': ctx.obj['username'] }) change_user.active = False change_user.save() log('Done')
module function_definition identifier parameters identifier block if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end none block expression_statement call identifier argument_list string string_start string_content string_end return_statement expression_statement assignment identifier call attribute subscript attribute subscript attribute identifier identifier string string_start string_content string_end identifier string string_start string_content string_end identifier argument_list dictionary pair string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier false expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end
Disable an existing user
def check_for_new(self): free_slots = self.max_processes - len(self.processes) for item in range(free_slots): key = self.queue.next() if key is not None: self.spawn_new(key)
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator attribute identifier identifier call identifier argument_list attribute identifier identifier for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier
Check if we can start a new process.
def split_denovos(denovo_path, temp_dir): with open(denovo_path, "r") as handle: lines = handle.readlines() header = lines.pop(0) basename = os.path.basename(denovo_path) counts = count_missense_per_gene(lines) counts = dict((k, v) for k, v in counts.items() if v > 1 ) genes = set([]) for line in sorted(lines): gene = line.split("\t")[0] if gene not in genes and gene in counts: genes.add(gene) path = os.path.join(temp_dir, "tmp.{}.txt".format(len(genes))) output = open(path, "w") output.write(header) if gene in counts: output.write(line) return len(genes)
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier generator_expression tuple identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list if_clause comparison_operator identifier integer expression_statement assignment identifier call identifier argument_list list for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end integer if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier
split de novos from an input file into files, one for each gene
def mtime(path): if not os.path.exists(path): return -1 stat = os.stat(path) return stat.st_mtime
module function_definition identifier parameters identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block return_statement unary_operator integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement attribute identifier identifier
Get the modification time of a file, or -1 if the file does not exist.
def send(self, mavmsg, force_mavlink1=False): buf = mavmsg.pack(self, force_mavlink1=force_mavlink1) self.file.write(buf) self.seq = (self.seq + 1) % 256 self.total_packets_sent += 1 self.total_bytes_sent += len(buf) if self.send_callback: self.send_callback(mavmsg, *self.send_callback_args, **self.send_callback_kwargs)
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier binary_operator parenthesized_expression binary_operator attribute identifier identifier integer integer expression_statement augmented_assignment attribute identifier identifier integer expression_statement augmented_assignment attribute identifier identifier call identifier argument_list identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier list_splat attribute identifier identifier dictionary_splat attribute identifier identifier
send a MAVLink message
def _y_axis(self, draw_axes=True): axis = self.svg.node(self.nodes['plot'], class_="axis x gauge") for i, (label, theta) in enumerate(self._y_labels): guides = self.svg.node(axis, class_='guides') self.svg.line( guides, [self.view((.95, theta)), self.view((1, theta))], close=True, class_='line' ) self.svg.line( guides, [self.view((0, theta)), self.view((.95, theta))], close=True, class_='guide line %s' % ('major' if i in (0, len(self._y_labels) - 1) else '') ) x, y = self.view((.9, theta)) self.svg.node(guides, 'text', x=x, y=y).text = label self.svg.node( guides, 'title', ).text = self._y_format(theta)
module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end for_statement pattern_list identifier tuple_pattern identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier list call attribute identifier identifier argument_list tuple float identifier call attribute identifier identifier argument_list tuple integer identifier keyword_argument identifier true keyword_argument identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier list call attribute identifier identifier argument_list tuple integer identifier call attribute identifier identifier argument_list tuple float identifier keyword_argument identifier true keyword_argument identifier binary_operator string string_start string_content string_end parenthesized_expression conditional_expression string string_start string_content string_end comparison_operator identifier tuple integer binary_operator call identifier argument_list attribute identifier identifier integer string string_start string_end expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list tuple float identifier expression_statement assignment attribute call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier identifier identifier expression_statement assignment attribute call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end identifier call attribute identifier identifier argument_list identifier
Override y axis to plot a polar axis
def predict(self, date, obs_code=568): time = Time(date, scale='utc', precision=6) jd = ctypes.c_double(time.jd) self.orbfit.predict.restype = ctypes.POINTER(ctypes.c_double * 5) self.orbfit.predict.argtypes = [ ctypes.c_char_p, ctypes.c_double, ctypes.c_int ] predict = self.orbfit.predict(ctypes.c_char_p(self.abg.name), jd, ctypes.c_int(obs_code)) self.coordinate = coordinates.SkyCoord(predict.contents[0], predict.contents[1], unit=(units.degree, units.degree)) self.dra = predict.contents[2] self.ddec = predict.contents[3] self.pa = predict.contents[4] self.date = str(time)
module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute attribute attribute identifier identifier identifier identifier call attribute identifier identifier argument_list binary_operator attribute identifier identifier integer expression_statement assignment attribute attribute attribute identifier identifier identifier identifier list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list subscript attribute identifier identifier integer subscript attribute identifier identifier integer keyword_argument identifier tuple attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier subscript attribute identifier identifier integer expression_statement assignment attribute identifier identifier subscript attribute identifier identifier integer expression_statement assignment attribute identifier identifier subscript attribute identifier identifier integer expression_statement assignment attribute identifier identifier call identifier argument_list identifier
use the bk predict method to compute the location of the source on the given date.
async def _query_chunked_post( self, path, method="POST", *, params=None, data=None, headers=None, timeout=None ): if headers is None: headers = {} if headers and "content-type" not in headers: headers["content-type"] = "application/octet-stream" response = await self._query( path, method, params=params, data=data, headers=headers, timeout=timeout, chunked=True, ) return response
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end keyword_separator default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier dictionary if_statement boolean_operator identifier comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier await call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier true return_statement identifier
A shorthand for uploading data by chunks
def parse_all_arguments(func): args = dict() if sys.version_info < (3, 0): func_args = inspect.getargspec(func) if func_args.defaults is not None: val = len(func_args.defaults) for i, itm in enumerate(func_args.args[-val:]): args[itm] = func_args.defaults[i] else: func_args = inspect.signature(func) for itm in list(func_args.parameters)[1:]: param = func_args.parameters[itm] if param.default is not param.empty: args[param.name] = param.default return args
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator attribute identifier identifier tuple integer integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list subscript attribute identifier identifier slice unary_operator identifier block expression_statement assignment subscript identifier identifier subscript attribute identifier identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier subscript call identifier argument_list attribute identifier identifier slice integer block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment subscript identifier attribute identifier identifier attribute identifier identifier return_statement identifier
determine all positional and named arguments as a dict
def refresh(self): self.get_devices(refresh=True) self.get_automations(refresh=True)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier true expression_statement call attribute identifier identifier argument_list keyword_argument identifier true
Do a full refresh of all devices and automations.
def ensure_dim(core, dim, dim_): if dim is None: dim = dim_ if not dim: return core, 1 if dim_ == dim: return core, int(dim) if dim > dim_: key_convert = lambda vari: vari[:dim_] else: key_convert = lambda vari: vari + (0,)*(dim-dim_) new_core = {} for key, val in core.items(): key_ = key_convert(key) if key_ in new_core: new_core[key_] += val else: new_core[key_] = val return new_core, int(dim)
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier identifier if_statement not_operator identifier block return_statement expression_list identifier integer if_statement comparison_operator identifier identifier block return_statement expression_list identifier call identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier lambda lambda_parameters identifier subscript identifier slice identifier else_clause block expression_statement assignment identifier lambda lambda_parameters identifier binary_operator identifier binary_operator tuple integer parenthesized_expression binary_operator identifier identifier expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement augmented_assignment subscript identifier identifier identifier else_clause block expression_statement assignment subscript identifier identifier identifier return_statement expression_list identifier call identifier argument_list identifier
Ensure that dim is correct.
def _collapse_header(self, header): out = [] for i, h in enumerate(header): if h.startswith(self._col_quals): out[-1].append(i) else: out.append([i]) return out
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute subscript identifier unary_operator integer identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list list identifier return_statement identifier
Combine header columns into related groups.
def _viewdata_to_view(self, p_data): sorter = Sorter(p_data['sortexpr'], p_data['groupexpr']) filters = [] if not p_data['show_all']: filters.append(DependencyFilter(self.todolist)) filters.append(RelevanceFilter()) filters.append(HiddenTagFilter()) filters += get_filter_list(p_data['filterexpr'].split()) return UIView(sorter, filters, self.todolist, p_data)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier list if_statement not_operator subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list expression_statement call attribute identifier identifier argument_list call identifier argument_list expression_statement augmented_assignment identifier call identifier argument_list call attribute subscript identifier string string_start string_content string_end identifier argument_list return_statement call identifier argument_list identifier identifier attribute identifier identifier identifier
Converts a dictionary describing a view to an actual UIView instance.
def _check_box_toggled(self, widget, data=None): active = widget.get_active() arg_name = data if 'entry' in self.args[arg_name]: self.args[arg_name]['entry'].set_sensitive(active) if 'browse_btn' in self.args[arg_name]: self.args[arg_name]['browse_btn'].set_sensitive(active) self.path_window.show_all()
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier identifier if_statement comparison_operator string string_start string_content string_end subscript attribute identifier identifier identifier block expression_statement call attribute subscript subscript attribute identifier identifier identifier string string_start string_content string_end identifier argument_list identifier if_statement comparison_operator string string_start string_content string_end subscript attribute identifier identifier identifier block expression_statement call attribute subscript subscript attribute identifier identifier identifier string string_start string_content string_end identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Function manipulates with entries and buttons.
def convert_path_to_module_parts(path): module_parts = splitall(path) if module_parts[-1] in ['__init__.py', '__init__.pyc']: module_parts = module_parts[:-1] else: module_parts[-1], _ = os.path.splitext(module_parts[-1]) return module_parts
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator subscript identifier unary_operator integer list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier subscript identifier slice unary_operator integer else_clause block expression_statement assignment pattern_list subscript identifier unary_operator integer identifier call attribute attribute identifier identifier identifier argument_list subscript identifier unary_operator integer return_statement identifier
Convert path to a python file into list of module names.
def _start(self): last_call = 42 while self._focus: sleep(1 / 100) mouse = pygame.mouse.get_pos() last_value = self.get() self.value_px = mouse[0] if self.get() == last_value: continue if last_call + self.interval / 1000 < time(): last_call = time() self.func(self.get())
module function_definition identifier parameters identifier block expression_statement assignment identifier integer while_statement attribute identifier identifier block expression_statement call identifier argument_list binary_operator integer integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier subscript identifier integer if_statement comparison_operator call attribute identifier identifier argument_list identifier block continue_statement if_statement comparison_operator binary_operator identifier binary_operator attribute identifier identifier integer call identifier argument_list block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list
Starts checking if the SB is shifted
def render(pass_info, saltenv='base', sls='', argline='', **kwargs): try: _get_pass_exec() except SaltRenderError: raise os.environ['HOME'] = expanduser('~') return _decrypt_object(pass_info)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_end default_parameter identifier string string_start string_end dictionary_splat_pattern identifier block try_statement block expression_statement call identifier argument_list except_clause identifier block raise_statement expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier
Fetch secret from pass based on pass_path
def resolve(self): 'Resolve pathname shell variables and ~userdir' return os.path.expandvars(os.path.expanduser(self.fqpn))
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end return_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Resolve pathname shell variables and ~userdir
def from_xml(cls, xml): s = parse_string(xml) return Sentence(s.split("\n")[0], token=s.tags, language=s.language)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement call identifier argument_list subscript call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end integer keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Returns a new Text from the given XML string.
def depipe(s): n = 0 for i in reversed(s.split('|')): n = n / 60.0 + float(i) return n
module function_definition identifier parameters identifier block expression_statement assignment identifier integer for_statement identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier binary_operator binary_operator identifier float call identifier argument_list identifier return_statement identifier
Convert a string of the form DD or DD|MM or DD|MM|SS to decimal degrees
def all(self): return { key: value for key, value in chain(self.entry_points.items(), self.factories.items()) }
module function_definition identifier parameters identifier block return_statement dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list
Return a synthetic dictionary of all factories.
def _find_benchmarks(self): def is_bench_method(attrname, prefix="bench"): return attrname.startswith(prefix) and hasattr(getattr(self.__class__, attrname), '__call__') return list(filter(is_bench_method, dir(self.__class__)))
module function_definition identifier parameters identifier block function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block return_statement boolean_operator call attribute identifier identifier argument_list identifier call identifier argument_list call identifier argument_list attribute identifier identifier identifier string string_start string_content string_end return_statement call identifier argument_list call identifier argument_list identifier call identifier argument_list attribute identifier identifier
Return a suite of all tests cases contained in testCaseClass
def on_connect(self, connection): "Called when the stream connects" self._stream = connection._reader self._buffer = SocketBuffer(self._stream, self._read_size) if connection.decode_responses: self.encoding = connection.encoding
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier
Called when the stream connects
def kill_thread(self, name): if name not in self.thread_pool: return self.thread_pool[name].join() del self.thread_pool[name]
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block return_statement expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list delete_statement subscript attribute identifier identifier identifier
Joins the thread in the `thread_pool` dict with the given `name` key.
def validate_non_negative_int_or_basestring(option, value): if isinstance(value, integer_types): return value elif isinstance(value, string_type): try: val = int(value) except ValueError: return value return validate_non_negative_integer(option, val) raise TypeError("Wrong type for %s, value must be an " "non negative integer or a string" % (option,))
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block return_statement identifier elif_clause call identifier argument_list identifier identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block return_statement identifier return_statement call identifier argument_list identifier identifier raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple identifier
Validates that 'value' is an integer or string.
def formatPoint(point, affine): if affine: fmt = "\tx:{}\n\ty:{}" coords = [point.x, point.y] else: fmt = "\tx:{}\n\ty:{}\n\tz:{}" coords = [point.x, point.y, point.z] coordText = map(hexString, coords) return fmt.format(*coordText)
module function_definition identifier parameters identifier identifier block if_statement identifier block expression_statement assignment identifier string string_start string_content escape_sequence escape_sequence escape_sequence string_end expression_statement assignment identifier list attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence string_end expression_statement assignment identifier list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list list_splat identifier
Retrieves a string representation of @point
def make_matepairs(fastafile): assert op.exists(fastafile) matefile = fastafile.rsplit(".", 1)[0] + ".mates" if op.exists(matefile): logging.debug("matepairs file `{0}` found".format(matefile)) else: logging.debug("parsing matepairs from `{0}`".format(fastafile)) matefw = open(matefile, "w") it = SeqIO.parse(fastafile, "fasta") for fwd, rev in zip(it, it): print("{0}\t{1}".format(fwd.id, rev.id), file=matefw) matefw.close() return matefile
module function_definition identifier parameters identifier block assert_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator subscript call attribute identifier identifier argument_list string string_start string_content string_end integer integer string string_start string_content string_end if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end for_statement pattern_list identifier identifier call identifier argument_list identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
Assumes the mates are adjacent sequence records
def _raw_hex_id(obj): packed = struct.pack('@P', id(obj)) return ''.join(map(_replacer, packed))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier return_statement call attribute string string_start string_end identifier argument_list call identifier argument_list identifier identifier
Return the padded hexadecimal id of ``obj``.
def migrate_passwords_to_leader_storage(self, excludes=None): if not is_leader(): log("Skipping password migration as not the lead unit", level=DEBUG) return dirname = os.path.dirname(self.root_passwd_file_template) path = os.path.join(dirname, '*.passwd') for f in glob.glob(path): if excludes and f in excludes: log("Excluding %s from leader storage migration" % (f), level=DEBUG) continue key = os.path.basename(f) with open(f, 'r') as passwd: _value = passwd.read().strip() try: leader_set(settings={key: _value}) if self.delete_ondisk_passwd_file: os.unlink(f) except ValueError: pass
module function_definition identifier parameters identifier default_parameter identifier none block if_statement not_operator call identifier argument_list block expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier return_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list identifier block if_statement boolean_operator identifier comparison_operator identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression identifier keyword_argument identifier identifier continue_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list 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 attribute call attribute identifier identifier argument_list identifier argument_list try_statement block expression_statement call identifier argument_list keyword_argument identifier dictionary pair identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement
Migrate any passwords storage on disk to leader storage.
def login(request): email = verify_login(request) request.response.headers.extend(remember(request, email)) return {'redirect': request.POST.get('came_from', '/'), 'success': True}
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call identifier argument_list identifier identifier return_statement dictionary pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end true
View to check the persona assertion and remember the user
def queue_put_stoppable(self, q, obj): while not self.stopped(): try: q.put(obj, timeout=5) break except queue.Full: pass
module function_definition identifier parameters identifier identifier identifier block while_statement not_operator call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier integer break_statement except_clause attribute identifier identifier block pass_statement
Put obj to queue, but will give up when the thread is stopped
def addFeatureSet(self, featureSet): id_ = featureSet.getId() self._featureSetIdMap[id_] = featureSet self._featureSetIds.append(id_) name = featureSet.getLocalId() self._featureSetNameMap[name] = featureSet
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript attribute identifier identifier identifier identifier
Adds the specified featureSet to this dataset.
def upload_from_fileobject(f, profile=None, label=None): if profile is None: profile = 'default' conf = get_profile_configs(profile) f.seek(0) if not is_image(f, types=conf['TYPES']): msg = (('Format of uploaded file is not allowed. ' 'Allowed formats is: %(formats)s.') % {'formats': ', '.join(map(lambda t: t.upper(), conf['TYPES']))}) raise RuntimeError(msg) return _custom_upload(f, profile, label, conf)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer if_statement not_operator call identifier argument_list identifier keyword_argument identifier subscript identifier string string_start string_content string_end block expression_statement assignment identifier parenthesized_expression binary_operator parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end dictionary pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call identifier argument_list lambda lambda_parameters identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end raise_statement call identifier argument_list identifier return_statement call identifier argument_list identifier identifier identifier identifier
Saves image from f with TMP prefix and returns img_id.
def build_paste(uid, shortid, type, nick, time, fmt, code, filename, mime): "Build a 'paste' object" return locals()
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier identifier block expression_statement string string_start string_content string_end return_statement call identifier argument_list
Build a 'paste' object
def send_template(self, template, to, reply_to=None, **context): mail_data = self.parse_template(template, **context) subject = mail_data["subject"] body = mail_data["body"] del(mail_data["subject"]) del(mail_data["body"]) return self.send(to=to, subject=subject, body=body, reply_to=reply_to, **mail_data)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end delete_statement parenthesized_expression subscript identifier string string_start string_content string_end delete_statement parenthesized_expression subscript identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier dictionary_splat identifier
Send email from template
def prt_ntgos(self, prt, ntgos): for ntgo in ntgos: key2val = ntgo._asdict() prt.write("{GO_LINE}\n".format(GO_LINE=self.prtfmt.format(**key2val)))
module function_definition identifier parameters identifier identifier identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list keyword_argument identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier
Print the Grouper namedtuples.
def read_plain_int64(file_obj, count): return struct.unpack("<{}q".format(count).encode("utf-8"), file_obj.read(8 * count))
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list call attribute call attribute string string_start string_content string_end identifier argument_list identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list binary_operator integer identifier
Read `count` 64-bit ints using the plain encoding.
def draw_pers_eccs(n,**kwargs): pers = draw_raghavan_periods(n) eccs = draw_eccs(n,pers,**kwargs) return pers,eccs
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier dictionary_splat identifier return_statement expression_list identifier identifier
Draw random periods and eccentricities according to empirical survey data.
def as_dict(self): if not self._is_valid: self.validate() from .converters import to_dict return to_dict(self)
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier return_statement call identifier argument_list identifier
Returns the model as a dict
def range_condition(self): if self._proto.HasField('rangeCondition'): return pvalue_pb2.RangeCondition.Name(self._proto.rangeCondition) return None
module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block return_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier return_statement none
If the value is out of limits, this indicates ``LOW`` or ``HIGH``.
def quad_tree(self): value = '' tms_x, tms_y = self.tms tms_y = (2 ** self.zoom - 1) - tms_y for i in range(self.zoom, 0, -1): digit = 0 mask = 1 << (i - 1) if (tms_x & mask) != 0: digit += 1 if (tms_y & mask) != 0: digit += 2 value += str(digit) return value
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operator integer attribute identifier identifier integer identifier for_statement identifier call identifier argument_list attribute identifier identifier integer unary_operator integer block expression_statement assignment identifier integer expression_statement assignment identifier binary_operator integer parenthesized_expression binary_operator identifier integer if_statement comparison_operator parenthesized_expression binary_operator identifier identifier integer block expression_statement augmented_assignment identifier integer if_statement comparison_operator parenthesized_expression binary_operator identifier identifier integer block expression_statement augmented_assignment identifier integer expression_statement augmented_assignment identifier call identifier argument_list identifier return_statement identifier
Gets the tile in the Microsoft QuadTree format, converted from TMS
def aks_versions_table_format(result): from jmespath import compile as compile_jmes, Options parsed = compile_jmes( ) results = parsed.search(result, Options(dict_cls=OrderedDict, custom_functions=_custom_functions())) return sorted(results, key=lambda x: version_to_tuple(x.get('kubernetesVersion')), reverse=True)
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier aliased_import dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier call identifier argument_list return_statement call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true
Format get-versions results as a summary for display with "-o table".
def _update_physical_disk_details(raid_config, server): raid_config['physical_disks'] = [] physical_drives = server.get_physical_drives() for physical_drive in physical_drives: physical_drive_dict = physical_drive.get_physical_drive_dict() raid_config['physical_disks'].append(physical_drive_dict)
module function_definition identifier parameters identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end list expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier
Adds the physical disk details to the RAID configuration passed.
def _update_record_with_name(self, old_record, rtype, new_name, content): new_type = rtype if rtype else old_record['type'] new_ttl = self._get_lexicon_option('ttl') if new_ttl is None and 'ttl' in old_record: new_ttl = old_record['ttl'] new_priority = self._get_lexicon_option('priority') if new_priority is None and 'priority' in old_record: new_priority = old_record['priority'] new_content = content if new_content is None and 'content' in old_record: new_content = old_record['content'] record = self._create_request_record(None, new_type, new_name, new_content, new_ttl, new_priority) self._request_add_dns_record(record) self._request_delete_dns_record_by_id(old_record['id'])
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier conditional_expression identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator comparison_operator identifier none 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 string string_start string_content string_end if_statement boolean_operator comparison_operator identifier none 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 identifier if_statement boolean_operator comparison_operator identifier none 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 none identifier identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end
Updates existing record and changes it's sub-domain name
def main(global_config, **settings): initialize_sentry_integration() config = Configurator(settings=settings) declare_api_routes(config) declare_type_info(config) config.include('pyramid_jinja2') config.add_jinja2_renderer('.rss') config.add_jinja2_renderer('.xml') mandatory_settings = ['exports-directories', 'exports-allowable-types'] for setting in mandatory_settings: if not settings.get(setting, None): raise ValueError('Missing {} config setting.'.format(setting)) config.scan(ignore='.tests') config.include('cnxarchive.events.main') config.add_tween('cnxarchive.tweens.conditional_http_tween_factory') return config.make_wsgi_app()
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement call identifier argument_list expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier none block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list
Main WSGI application factory.
def defaults(self, *args): ns = self.Namespace ns.obj = self.obj def by(source, *ar): for i, prop in enumerate(source): if prop not in ns.obj: ns.obj[prop] = source[prop] _.each(args, by) return self._wrap(ns.obj)
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier function_definition identifier parameters identifier list_splat_pattern identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier
Fill in a given object with default properties.
def clone(cls, srcpath, destpath): try: os.makedirs(destpath) except OSError as e: if not e.errno == errno.EEXIST: raise cmd = [SVNADMIN, 'dump', '--quiet', '.'] dump = subprocess.Popen( cmd, cwd=srcpath, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) repo = cls.create(destpath) repo.load(dump.stdout) stderr = dump.stderr.read() dump.stdout.close() dump.stderr.close() dump.wait() if dump.returncode != 0: raise subprocess.CalledProcessError(dump.returncode, cmd, stderr) return repo
module function_definition identifier parameters identifier identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement not_operator comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement expression_statement assignment identifier list identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier integer block raise_statement call attribute identifier identifier argument_list attribute identifier identifier identifier identifier return_statement identifier
Copy a main repository to a new location.
def close(self) -> None: if self.session_id is not None: self.client.delete_session(self.session_id) self.client.close()
module function_definition identifier parameters identifier type none block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Kill the managed Spark session.
def merge (d, o): for k in o.keys(): if type(o[k]) is dict and k in d: merge(d[k], o[k]) else: d[k] = o[k] return d
module function_definition identifier parameters identifier identifier block for_statement identifier call attribute identifier identifier argument_list block if_statement boolean_operator comparison_operator call identifier argument_list subscript identifier identifier identifier comparison_operator identifier identifier block expression_statement call identifier argument_list subscript identifier identifier subscript identifier identifier else_clause block expression_statement assignment subscript identifier identifier subscript identifier identifier return_statement identifier
Recursively merges keys from o into d and returns d.
def del_record(self, dns_record_type, host): rec = self.get_record(dns_record_type, host) if rec: self._entries = list(set(self._entries) - set([rec])) return True
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement assignment attribute identifier identifier call identifier argument_list binary_operator call identifier argument_list attribute identifier identifier call identifier argument_list list identifier return_statement true
Remove a DNS record
def post_order(parent): n = len(parent) k = 0 p = matrix(0,(n,1)) head = matrix(-1,(n,1)) next = matrix(0,(n,1)) stack = matrix(0,(n,1)) for j in range(n-1,-1,-1): if (parent[j] == j): continue next[j] = head[parent[j]] head[parent[j]] = j for j in range(n): if (parent[j] != j): continue k = __tdfs(j, k, head, next, p, stack) return p
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier integer expression_statement assignment identifier call identifier argument_list integer tuple identifier integer expression_statement assignment identifier call identifier argument_list unary_operator integer tuple identifier integer expression_statement assignment identifier call identifier argument_list integer tuple identifier integer expression_statement assignment identifier call identifier argument_list integer tuple identifier integer for_statement identifier call identifier argument_list binary_operator identifier integer unary_operator integer unary_operator integer block if_statement parenthesized_expression comparison_operator subscript identifier identifier identifier block continue_statement expression_statement assignment subscript identifier identifier subscript identifier subscript identifier identifier expression_statement assignment subscript identifier subscript identifier identifier identifier for_statement identifier call identifier argument_list identifier block if_statement parenthesized_expression comparison_operator subscript identifier identifier identifier block continue_statement expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier identifier return_statement identifier
Post order a forest.
def valid_id(opts, id_): try: if any(x in id_ for x in ('/', '\\', str('\0'))): return False return bool(clean_path(opts['pki_dir'], id_)) except (AttributeError, KeyError, TypeError, UnicodeDecodeError): return False
module function_definition identifier parameters identifier identifier block try_statement block if_statement call identifier generator_expression comparison_operator identifier identifier for_in_clause identifier tuple string string_start string_content string_end string string_start string_content escape_sequence string_end call identifier argument_list string string_start string_content escape_sequence string_end block return_statement false return_statement call identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end identifier except_clause tuple identifier identifier identifier identifier block return_statement false
Returns if the passed id is valid
def coverage(reportdir=None, extra=None): import coverage as coverage_api cov = coverage_api.coverage() opts = {'directory': reportdir} if reportdir else {} cov.start() test(extra) cov.stop() cov.html_report(**opts)
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none block import_statement aliased_import dotted_name identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier conditional_expression dictionary pair string string_start string_content string_end identifier identifier dictionary expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list dictionary_splat identifier
Test this project with coverage reports
def start(self): self.loop.create_task(self._read_line()) self.loop.create_task(self._greeting())
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list
Start the command process loop.
def ConsultarTipoActividadRepresentado(self, sep="||"): "Consulta de Tipos de Actividad inscripta en el RUOCA." try: ret = self.client.tipoActividadRepresentadoConsultar( auth={ 'token': self.Token, 'sign': self.Sign, 'cuit': self.Cuit, }, )['tipoActividadReturn'] self.__analizar_errores(ret) array = ret.get('tiposActividad', []) self.Excepcion = self.Traceback = "" return [("%s %%s %s %%s %s" % (sep, sep, sep)) % (it['codigoDescripcion']['codigo'], it['codigoDescripcion']['descripcion']) for it in array] except Exception: ex = utils.exception_info() self.Excepcion = ex['msg'] self.Traceback = ex['tb'] if sep: return ["ERROR"]
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement string string_start string_content string_end try_statement block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list keyword_argument identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier 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 string string_start string_content string_end list expression_statement assignment attribute identifier identifier assignment attribute identifier identifier string string_start string_end return_statement list_comprehension binary_operator parenthesized_expression binary_operator string string_start string_content string_end tuple identifier identifier identifier tuple subscript subscript identifier string string_start string_content string_end string string_start string_content string_end subscript subscript identifier string string_start string_content string_end string string_start string_content string_end for_in_clause identifier identifier except_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end if_statement identifier block return_statement list string string_start string_content string_end
Consulta de Tipos de Actividad inscripta en el RUOCA.
def setup(app): app.add_config_value( 'site_url', default=None, rebuild=False ) try: app.add_config_value( 'html_baseurl', default=None, rebuild=False ) except: pass app.connect('html-page-context', add_html_link) app.connect('build-finished', create_sitemap) app.sitemap_links = [] app.locales = []
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier none keyword_argument identifier false try_statement block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier none keyword_argument identifier false except_clause block pass_statement expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier list expression_statement assignment attribute identifier identifier list
Setup connects events to the sitemap builder
def script_name(self, language=DEFAULT_LANGUAGE, min_score: int=75) -> str: return self._get_name('script', language, min_score)
module function_definition identifier parameters identifier default_parameter identifier identifier typed_default_parameter identifier type identifier integer type identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier
Describe the script part of the language tag in a natural language.
def monkey_patch_flask_security(): if utils.get_hmac != get_hmac: utils.get_hmac = get_hmac if utils.hash_password != hash_password: utils.hash_password = hash_password changeable.hash_password = hash_password recoverable.hash_password = hash_password registerable.hash_password = hash_password def patch_do_nothing(*args, **kwargs): pass LoginManager._set_cookie = patch_do_nothing def patch_reload_anonym(self, *args, **kwargs): self.reload_user() LoginManager._load_from_header = patch_reload_anonym LoginManager._load_from_request = patch_reload_anonym
module function_definition identifier parameters block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block pass_statement expression_statement assignment attribute identifier identifier identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier
Monkey-patch Flask-Security.
def identify(self, data): return self.send(constants.IDENTIFY, json.dumps(data))
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list identifier
Send an identification message
def data(self)->Tensor: "Return the points associated to this object." flow = self.flow if self.transformed: if 'remove_out' not in self.sample_kwargs or self.sample_kwargs['remove_out']: flow = _remove_points_out(flow) self.transformed=False return flow.flow.flip(1)
module function_definition identifier parameters identifier type identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier if_statement attribute identifier identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier false return_statement call attribute attribute identifier identifier identifier argument_list integer
Return the points associated to this object.
def predict(parameters_value, regressor_gp): parameters_value = numpy.array(parameters_value).reshape(-1, len(parameters_value)) mu, sigma = regressor_gp.predict(parameters_value, return_std=True) return mu[0], sigma[0]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list unary_operator integer call identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true return_statement expression_list subscript identifier integer subscript identifier integer
Predict by Gaussian Process Model
def insert(args): string_search = args.str_search mode_search = MODES[args.mode] page = list(TORRENTS[args.torr_page].keys())[0] key_search = TORRENTS[args.torr_page][page]['key_search'] torrent_page = TORRENTS[args.torr_page][page]['page'] domain = TORRENTS[args.torr_page][page]['domain'] return([args, string_search, mode_search, page, key_search, torrent_page, domain])
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier subscript identifier attribute identifier identifier expression_statement assignment identifier subscript call identifier argument_list call attribute subscript identifier attribute identifier identifier identifier argument_list integer expression_statement assignment identifier subscript subscript subscript identifier attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript subscript subscript identifier attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript subscript subscript identifier attribute identifier identifier identifier string string_start string_content string_end return_statement parenthesized_expression list identifier identifier identifier identifier identifier identifier identifier
Insert args values into instance variables.
def firsttime(self): self.config.set('DEFAULT', 'firsttime', 'no') if self.cli_config.getboolean('core', 'collect_telemetry', fallback=False): print(PRIVACY_STATEMENT) else: self.cli_config.set_value('core', 'collect_telemetry', ask_user_for_telemetry()) self.update()
module function_definition identifier parameters identifier block expression_statement 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 string string_start string_content string_end string string_start string_content string_end keyword_argument identifier false block expression_statement call identifier argument_list identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end call identifier argument_list expression_statement call attribute identifier identifier argument_list
sets it as already done
def update_fw_local_router(self, net_id, subnet_id, router_id, os_result): fw_dict = self.get_fw_dict() fw_dict.update({'router_id': router_id, 'router_net_id': net_id, 'router_subnet_id': subnet_id}) self.store_dummy_router_net(net_id, subnet_id, router_id) self.update_fw_local_result(os_result=os_result)
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
Update the FW with router attributes.
def unpack_from(self, buff, offset=0): return self._create(super(DictStruct, self).unpack_from(buff, offset))
module function_definition identifier parameters identifier identifier default_parameter identifier integer block return_statement call attribute identifier identifier argument_list call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier
Unpack the next bytes from a file object.
def _get_struct_cxformwithalpha(self): obj = _make_object("CXformWithAlpha") bc = BitConsumer(self._src) obj.HasAddTerms = bc.u_get(1) obj.HasMultTerms = bc.u_get(1) obj.NBits = nbits = bc.u_get(4) if obj.HasMultTerms: obj.RedMultTerm = bc.s_get(nbits) obj.GreenMultTerm = bc.s_get(nbits) obj.BlueMultTerm = bc.s_get(nbits) obj.AlphaMultTerm = bc.s_get(nbits) if obj.HasAddTerms: obj.RedAddTerm = bc.s_get(nbits) obj.GreenAddTerm = bc.s_get(nbits) obj.BlueAddTerm = bc.s_get(nbits) obj.AlphaAddTerm = bc.s_get(nbits) return obj
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list integer expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list integer expression_statement assignment attribute identifier identifier assignment identifier call attribute identifier identifier argument_list integer if_statement attribute identifier identifier block 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 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 if_statement attribute identifier identifier block 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 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
Get the values for the CXFORMWITHALPHA record.
def load_to(self, last_level_load): assert isinstance(last_level_load, Cache), \ "last_level needs to be a Cache object." assert last_level_load.load_from is None, \ "last_level_load must be a last level cache (.load_from is None)." self.last_level_load = last_level_load
module function_definition identifier parameters identifier identifier block assert_statement call identifier argument_list identifier identifier string string_start string_content string_end assert_statement comparison_operator attribute identifier identifier none string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier
Set level where to load from.
def defnoun(self, singular, plural): self.checkpat(singular) self.checkpatplural(plural) self.pl_sb_user_defined.extend((singular, plural)) self.si_sb_user_defined.extend((plural, singular)) return 1
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier return_statement integer
Set the noun plural of singular to plural.
def inPixels(self,lon,lat,pixels): nside = self.config.params['coords']['nside_pixel'] return ugali.utils.healpix.in_pixels(lon,lat,pixels,nside)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier subscript subscript attribute attribute identifier identifier identifier string string_start string_content string_end string string_start string_content string_end return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier identifier identifier
Function for testing if coordintes in set of ROI pixels.
def check_pypi(modeladmin, request, queryset): for p in queryset: if p.is_editable: logger.debug("Ignoring version update '%s' is editable", p.package_name) else: p.update_from_pypi()
module function_definition identifier parameters identifier identifier identifier block for_statement identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list
Update latest package info from PyPI.
def shell_cmd(args, cwd=None): if cwd is None: cwd = os.path.abspath('.') if not isinstance(args, (list, tuple)): args = [args] ps = Popen(args, shell=True, cwd=cwd, stdout=PIPE, stderr=PIPE, close_fds=True) stdout, stderr = ps.communicate() if ps.returncode != 0: if stderr: stderr = stderr.strip() raise IOError('Shell command %s failed (exit status %r): %s' %\ (args, ps.returncode, stderr)) return stdout.strip()
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement not_operator call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier list identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier true keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier true expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier integer block if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list raise_statement call identifier argument_list binary_operator string string_start string_content string_end line_continuation tuple identifier attribute identifier identifier identifier return_statement call attribute identifier identifier argument_list
Returns stdout as string or None on failure
def body_block_supplementary_material_render(supp_tags, base_url=None): source_data = [] for supp_tag in supp_tags: for block_content in body_block_content_render(supp_tag, base_url=base_url): if block_content != {}: if "content" in block_content: del block_content["content"] source_data.append(block_content) return source_data
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier list for_statement identifier identifier block for_statement identifier call identifier argument_list identifier keyword_argument identifier identifier block if_statement comparison_operator identifier dictionary block if_statement comparison_operator string string_start string_content string_end identifier block delete_statement subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
fig and media tag caption may have supplementary material
def boolean(meshes, operation='difference'): script = operation + '(){' for i in range(len(meshes)): script += 'import(\"$mesh_' + str(i) + '\");' script += '}' return interface_scad(meshes, script)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator identifier string string_start string_content string_end for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement augmented_assignment identifier binary_operator binary_operator string string_start string_content escape_sequence string_end call identifier argument_list identifier string string_start string_content escape_sequence string_end expression_statement augmented_assignment identifier string string_start string_content string_end return_statement call identifier argument_list identifier identifier
Run an operation on a set of meshes
def compile_resource(resource): return re.compile("^" + trim_resource(re.sub(r":(\w+)", r"(?P<\1>[\w-]+?)", resource)) + r"(\?(?P<querystring>.*))?$")
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list binary_operator binary_operator string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier string string_start string_content string_end
Return compiled regex for resource matching
def evaluate(self, x, y, flux, x_0, y_0, sigma): return (flux / 4 * ((self._erf((x - x_0 + 0.5) / (np.sqrt(2) * sigma)) - self._erf((x - x_0 - 0.5) / (np.sqrt(2) * sigma))) * (self._erf((y - y_0 + 0.5) / (np.sqrt(2) * sigma)) - self._erf((y - y_0 - 0.5) / (np.sqrt(2) * sigma)))))
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block return_statement parenthesized_expression binary_operator binary_operator identifier integer parenthesized_expression binary_operator parenthesized_expression binary_operator call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator binary_operator identifier identifier float parenthesized_expression binary_operator call attribute identifier identifier argument_list integer identifier call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator binary_operator identifier identifier float parenthesized_expression binary_operator call attribute identifier identifier argument_list integer identifier parenthesized_expression binary_operator call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator binary_operator identifier identifier float parenthesized_expression binary_operator call attribute identifier identifier argument_list integer identifier call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator binary_operator identifier identifier float parenthesized_expression binary_operator call attribute identifier identifier argument_list integer identifier
Model function Gaussian PSF model.
def check_variable_names(self, ds): msgs = [] count = 0 for k, v in ds.variables.items(): if 'standard_name' in v.ncattrs(): count += 1 else: msgs.append("Variable '{}' missing standard_name attr".format(k)) return Result(BaseCheck.MEDIUM, (count, len(ds.variables)), 'Variable Names', msgs)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier integer for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator string string_start string_content string_end call attribute identifier identifier argument_list block expression_statement augmented_assignment identifier integer else_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement call identifier argument_list attribute identifier identifier tuple identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end identifier
Ensures all variables have a standard_name set.
def check_csrf_token(): if request.method in ("GET",): return token = request.form.get("csrf_token") if token is None: app.logger.warning("Expected CSRF Token: not present") abort(400) if not safe_str_cmp(token, csrf_token()): app.logger.warning("CSRF Token incorrect") abort(400)
module function_definition identifier parameters block if_statement comparison_operator attribute identifier identifier tuple string string_start string_content string_end block return_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list integer if_statement not_operator call identifier argument_list identifier call identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list integer
Checks that token is correct, aborting if not
def _check_dir_meta(name, user, group, mode, follow_symlinks=False): try: stats = __salt__['file.stats'](name, None, follow_symlinks) except CommandExecutionError: stats = {} changes = {} if not stats: changes['directory'] = 'new' return changes if (user is not None and user != stats['user'] and user != stats.get('uid')): changes['user'] = user if (group is not None and group != stats['group'] and group != stats.get('gid')): changes['group'] = group smode = salt.utils.files.normalize_mode(stats['mode']) mode = salt.utils.files.normalize_mode(mode) if mode is not None and mode != smode: changes['mode'] = mode return changes
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier false block try_statement block expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list identifier none identifier except_clause identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier dictionary if_statement not_operator identifier block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end return_statement identifier if_statement parenthesized_expression boolean_operator boolean_operator comparison_operator identifier none comparison_operator identifier subscript identifier string string_start string_content string_end comparison_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement parenthesized_expression boolean_operator boolean_operator comparison_operator identifier none comparison_operator identifier subscript identifier string string_start string_content string_end comparison_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier if_statement boolean_operator comparison_operator identifier none comparison_operator identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier
Check the changes in directory metadata
def StringFinish(self, **_): if self.state == "ARG": return self.InsertArg(string=self.string)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier
StringFinish doesn't act on ATTRIBUTEs here.
def _sumImages(self,numarrayObjectList): if numarrayObjectList in [None, []]: return None tsum = np.zeros(numarrayObjectList[0].shape, dtype=numarrayObjectList[0].dtype) for image in numarrayObjectList: tsum += image return tsum
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier list none list block return_statement none expression_statement assignment identifier call attribute identifier identifier argument_list attribute subscript identifier integer identifier keyword_argument identifier attribute subscript identifier integer identifier for_statement identifier identifier block expression_statement augmented_assignment identifier identifier return_statement identifier
Sum a list of numarray objects.
def InternalInit(self): self.cid = UsbHidTransport.U2FHID_BROADCAST_CID nonce = bytearray(os.urandom(8)) r = self.InternalExchange(UsbHidTransport.U2FHID_INIT, nonce) if len(r) < 17: raise errors.HidError('unexpected init reply len') if r[0:8] != nonce: raise errors.HidError('nonce mismatch') self.cid = bytearray(r[8:12]) self.u2fhid_version = r[12]
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator subscript identifier slice integer integer identifier block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list subscript identifier slice integer integer expression_statement assignment attribute identifier identifier subscript identifier integer
Initializes the device and obtains channel id.
def _calc_T_var(self,X) -> int: shape = X.shape tensor_rank: int = len(shape) if tensor_rank == 0: return 1 if tensor_rank == 1: return shape[0] if tensor_rank == 2: if shape[1] > 1: raise ValueError('Initial value of a variable must have dimension T*1.') return shape[0]
module function_definition identifier parameters identifier identifier type identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier type identifier call identifier argument_list identifier if_statement comparison_operator identifier integer block return_statement integer if_statement comparison_operator identifier integer block return_statement subscript identifier integer if_statement comparison_operator identifier integer block if_statement comparison_operator subscript identifier integer integer block raise_statement call identifier argument_list string string_start string_content string_end return_statement subscript identifier integer
Calculate the number of samples, T, from the shape of X
def to_task(self): from google.appengine.api.taskqueue import Task task_args = self.get_task_args().copy() payload = None if 'payload' in task_args: payload = task_args.pop('payload') kwargs = { 'method': METHOD_TYPE, 'payload': json.dumps(payload) } kwargs.update(task_args) return Task(**kwargs)
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier identifier identifier dotted_name identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assignment identifier none if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list dictionary_splat identifier
Return a task object representing this message.
def _bounds_to_array(bounds): elements = [] for value in bounds: if all_elements_equal(value): elements.append(Scalar(get_single_value(value), ctype='mot_float_type')) else: elements.append(Array(value, ctype='mot_float_type', as_scalar=True)) return CompositeArray(elements, 'mot_float_type', address_space='local')
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier identifier block if_statement call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier true return_statement call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end
Create a CompositeArray to hold the bounds.
def TemplateValidator(value): try: Template(value) except Exception as e: raise ValidationError( _("Cannot compile template (%(exception)s)"), params={"exception": e} )
module function_definition identifier parameters identifier block try_statement block expression_statement call identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list call identifier argument_list string string_start string_content string_end keyword_argument identifier dictionary pair string string_start string_content string_end identifier
Try to compile a string into a Django template
def next(self): rv = self.current self.pos = (self.pos + 1) % len(self.items) return rv
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier binary_operator parenthesized_expression binary_operator attribute identifier identifier integer call identifier argument_list attribute identifier identifier return_statement identifier
Goes one item ahead and returns it.
def detrend(arr, x=None, deg=5, tol=1e-3, maxloop=10): xx = numpy.arange(len(arr)) if x is None else x base = arr.copy() trend = base pol = numpy.ones((deg + 1,)) for _ in range(maxloop): pol_new = numpy.polyfit(xx, base, deg) pol_norm = numpy.linalg.norm(pol) diff_pol_norm = numpy.linalg.norm(pol - pol_new) if diff_pol_norm / pol_norm < tol: break pol = pol_new trend = numpy.polyval(pol, xx) base = numpy.minimum(base, trend) return trend
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier integer default_parameter identifier float default_parameter identifier integer block expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list call identifier argument_list identifier comparison_operator identifier none identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list tuple binary_operator identifier integer for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier 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 binary_operator identifier identifier if_statement comparison_operator binary_operator identifier identifier identifier block break_statement expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier
Compute a baseline trend of a signal
def _reset(self): if self.logger: self.logger.info("Reset DataContainer") self._items_list = [] self._config.data_type = None
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier list expression_statement assignment attribute attribute identifier identifier identifier none
Reset main DataContainer properties
def _theme_and_template_fp(self): ptheme = self._config['theme'][0] if ptheme == "": ptheme = self.site.site_config['default_theme'] pthemedir = os.path.join(self.site.dirs['themes'], ptheme) ptemplate = self._config['template'][0] if ptemplate == "": ptemplate = self.site.site_config['default_template'] ptemplatefname = os.path.join(pthemedir, ptemplate) return (pthemedir, ptemplatefname)
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript subscript attribute identifier identifier string string_start string_content string_end integer if_statement comparison_operator identifier string string_start string_end block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript attribute attribute identifier identifier identifier string string_start string_content string_end identifier expression_statement assignment identifier subscript subscript attribute identifier identifier string string_start string_content string_end integer if_statement comparison_operator identifier string string_start string_end block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement tuple identifier identifier
Return the full paths for theme and template in this page
def _executor(self, host): try: exec_rc = self._executor_internal(host) if not exec_rc.comm_ok: self.callbacks.on_unreachable(host, exec_rc.result) return exec_rc except errors.AnsibleError, ae: msg = str(ae) self.callbacks.on_unreachable(host, msg) return ReturnData(host=host, comm_ok=False, result=dict(failed=True, msg=msg)) except Exception: msg = traceback.format_exc() self.callbacks.on_unreachable(host, msg) return ReturnData(host=host, comm_ok=False, result=dict(failed=True, msg=msg))
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier return_statement identifier except_clause attribute identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier false keyword_argument identifier call identifier argument_list keyword_argument identifier true keyword_argument identifier identifier except_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier false keyword_argument identifier call identifier argument_list keyword_argument identifier true keyword_argument identifier identifier
handler for multiprocessing library
def _get_setting(self, setting, default=None, name=None, inherit=True): if name is None: name = self.name if name == 'DEFAULT': return self._settings.get('webpack.{0}'.format(setting), default) else: val = self._settings.get('webpack.{0}.{1}'.format(name, setting), SENTINEL) if val is SENTINEL: if inherit: return self._get_setting(setting, default, 'DEFAULT') else: return default else: return val
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier true block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block return_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier if_statement comparison_operator identifier identifier block if_statement identifier block return_statement call attribute identifier identifier argument_list identifier identifier string string_start string_content string_end else_clause block return_statement identifier else_clause block return_statement identifier
Helper function to fetch settings, inheriting from the base
def authors_et_al(self, max_authors=5): author_list = self._author_list if len(author_list) <= max_authors: authors_et_al = self.authors else: authors_et_al = ", ".join( self._author_list[:max_authors]) + ", et al." return authors_et_al
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier binary_operator call attribute string string_start string_content string_end identifier argument_list subscript attribute identifier identifier slice identifier string string_start string_content string_end return_statement identifier
Return string with a truncated author list followed by 'et al.'
def make(parser): mds_parser = parser.add_subparsers(dest='subcommand') mds_parser.required = True mds_create = mds_parser.add_parser( 'create', help='Deploy Ceph MDS on remote host(s)' ) mds_create.add_argument( 'mds', metavar='HOST[:NAME]', nargs='+', type=colon_separated, help='host (and optionally the daemon name) to deploy on', ) parser.set_defaults( func=mds, )
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier true expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
Ceph MDS daemon management
def _csv_str(self, param, stats, quantiles, index=None): buffer = param if not index: buffer += ', ' else: buffer += '_' + '_'.join([str(i) for i in index]) + ', ' for stat in ('mean', 'standard deviation', 'mc error'): buffer += str(stats[stat][index]) + ', ' iindex = [key.split()[-1] for key in stats.keys()].index('interval') interval = list(stats.keys())[iindex] buffer += ', '.join(stats[interval].T[index].astype(str)) qvalues = stats['quantiles'] for q in quantiles: buffer += ', ' + str(qvalues[q][index]) return buffer + '\n'
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier identifier if_statement not_operator identifier block expression_statement augmented_assignment identifier string string_start string_content string_end else_clause block expression_statement augmented_assignment identifier binary_operator binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list list_comprehension call identifier argument_list identifier for_in_clause identifier identifier string string_start string_content string_end for_statement identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement augmented_assignment identifier binary_operator call identifier argument_list subscript subscript identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute list_comprehension subscript call attribute identifier identifier argument_list unary_operator integer for_in_clause identifier call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute subscript attribute subscript identifier identifier identifier identifier identifier argument_list identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end for_statement identifier identifier block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end call identifier argument_list subscript subscript identifier identifier identifier return_statement binary_operator identifier string string_start string_content escape_sequence string_end
Support function for write_csv
def _ConvertAnyMessage(self, value, message): if isinstance(value, dict) and not value: return try: type_url = value['@type'] except KeyError: raise ParseError('@type is missing when parsing any message.') sub_message = _CreateMessageFromTypeUrl(type_url) message_descriptor = sub_message.DESCRIPTOR full_name = message_descriptor.full_name if _IsWrapperMessage(message_descriptor): self._ConvertWrapperMessage(value['value'], sub_message) elif full_name in _WKTJSONMETHODS: methodcaller( _WKTJSONMETHODS[full_name][1], value['value'], sub_message)(self) else: del value['@type'] self._ConvertFieldValuePair(value, sub_message) message.value = sub_message.SerializeToString() message.type_url = type_url
module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier not_operator identifier block return_statement try_statement block expression_statement assignment identifier subscript identifier string string_start string_content string_end except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier elif_clause comparison_operator identifier identifier block expression_statement call call identifier argument_list subscript subscript identifier identifier integer subscript identifier string string_start string_content string_end identifier argument_list identifier else_clause block delete_statement subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier
Convert a JSON representation into Any message.