code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def separators(self, reordered = True): if reordered: return [list(self.snrowidx[self.sncolptr[k]+self.snptr[k+1]-self.snptr[k]:self.sncolptr[k+1]]) for k in range(self.Nsn)] else: return [list(self.__p[self.snrowidx[self.sncolptr[k]+self.snptr[k+1]-self.snptr[k]:self.sncolptr[k+1]]]) for k in range(self.Nsn)]
module function_definition identifier parameters identifier default_parameter identifier true block if_statement identifier block return_statement list_comprehension call identifier argument_list subscript attribute identifier identifier slice binary_operator binary_operator subscript attribute identifier identifier identifier subscript attribute identifier identifier binary_operator identifier integer subscript attribute identifier identifier identifier subscript attribute identifier identifier binary_operator identifier integer for_in_clause identifier call identifier argument_list attribute identifier identifier else_clause block return_statement list_comprehension call identifier argument_list subscript attribute identifier identifier subscript attribute identifier identifier slice binary_operator binary_operator subscript attribute identifier identifier identifier subscript attribute identifier identifier binary_operator identifier integer subscript attribute identifier identifier identifier subscript attribute identifier identifier binary_operator identifier integer for_in_clause identifier call identifier argument_list attribute identifier identifier
Returns a list of separator sets
def _open_file(cls, writer_spec, filename_suffix, use_tmp_bucket=False): if use_tmp_bucket: bucket = cls._get_tmp_gcs_bucket(writer_spec) account_id = cls._get_tmp_account_id(writer_spec) else: bucket = cls._get_gcs_bucket(writer_spec) account_id = cls._get_account_id(writer_spec) filename = "/%s/%s" % (bucket, filename_suffix) content_type = writer_spec.get(cls.CONTENT_TYPE_PARAM, None) options = {} if cls.ACL_PARAM in writer_spec: options["x-goog-acl"] = writer_spec.get(cls.ACL_PARAM) return cloudstorage.open(filename, mode="w", content_type=content_type, options=options, _account_id=account_id)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier none expression_statement assignment identifier dictionary if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Opens a new gcs file for writing.
def tilt(poly): num = len(poly) - 1 vec = unit_normal(poly[0], poly[1], poly[num]) vec_alt = np.array([vec[0], vec[1], vec[2]]) vec_z = np.array([0, 0, 1]) return angle2vecs(vec_alt, vec_z)
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator call identifier argument_list identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier integer subscript identifier integer subscript identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list list subscript identifier integer subscript identifier integer subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list list integer integer integer return_statement call identifier argument_list identifier identifier
Tilt of a polygon poly
def kill_all(self): logger.info('Job {0} killing all currently running tasks'.format(self.name)) for task in self.tasks.itervalues(): if task.started_at and not task.completed_at: task.kill()
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement boolean_operator attribute identifier identifier not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list
Kill all currently running jobs.
def autoencoder_residual_discrete(): hparams = autoencoder_residual() hparams.bottleneck_bits = 1024 hparams.bottleneck_noise = 0.05 hparams.add_hparam("discretize_warmup_steps", 16000) hparams.add_hparam("bottleneck_kind", "tanh_discrete") hparams.add_hparam("isemhash_noise_dev", 0.5) hparams.add_hparam("isemhash_mix_prob", 0.5) hparams.add_hparam("isemhash_filter_size_multiplier", 2.0) hparams.add_hparam("vq_beta", 0.25) hparams.add_hparam("vq_decay", 0.999) hparams.add_hparam("vq_epsilon", 1e-5) return hparams
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier float expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end float expression_statement call attribute identifier identifier argument_list string string_start string_content string_end float expression_statement call attribute identifier identifier argument_list string string_start string_content string_end float expression_statement call attribute identifier identifier argument_list string string_start string_content string_end float expression_statement call attribute identifier identifier argument_list string string_start string_content string_end float expression_statement call attribute identifier identifier argument_list string string_start string_content string_end float return_statement identifier
Residual discrete autoencoder model.
def to_python(self): mapping = {} for row in self.rows: mapping[row[0]] = _format_python_value(row[1]) return mapping
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement identifier attribute identifier identifier block expression_statement assignment subscript identifier subscript identifier integer call identifier argument_list subscript identifier integer return_statement identifier
Decode this KeyValueTable object to standard Python types.
def keyPressEvent(self, evt): incr = 0 if evt.modifiers() == Qt.ControlModifier: n = self.tabWidget.count() if evt.key() in [Qt.Key_PageUp, Qt.Key_Backtab]: incr = -1 elif evt.key() in [Qt.Key_PageDown, Qt.Key_Tab]: incr = 1 if incr != 0: new_index = self._get_tab_index() + incr if new_index < 0: new_index = n - 1 elif new_index >= n: new_index = 0 self.tabWidget.setCurrentIndex(new_index)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier integer if_statement comparison_operator call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator call attribute identifier identifier argument_list list attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier unary_operator integer elif_clause comparison_operator call attribute identifier identifier argument_list list attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier integer if_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator identifier integer elif_clause comparison_operator identifier identifier block expression_statement assignment identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list identifier
This handles Ctrl+PageUp, Ctrl+PageDown, Ctrl+Tab, Ctrl+Shift+Tab
def _combine_out_files(chr_files, work_dir, data): out_file = "%s.bed" % sshared.outname_from_inputs(chr_files) if not utils.file_exists(out_file): with file_transaction(data, out_file) as tx_out_file: with open(tx_out_file, "w") as out_handle: for chr_file in chr_files: with open(chr_file) as in_handle: is_empty = in_handle.readline().startswith("track name=empty") if not is_empty: with open(chr_file) as in_handle: shutil.copyfileobj(in_handle, out_handle) return out_file
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier identifier as_pattern_target identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end if_statement not_operator identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier
Concatenate all CNV calls into a single file.
def convert_unit(self, column, value): "If the user has provided a unit in the query, convert it into the column unit, if present." if column not in self.units: return value value = self.ureg(value) if isinstance(value, numbers.Number): return value column_unit = self.ureg(self.units[column]) return value.to(column_unit).magnitude
module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end if_statement comparison_operator identifier attribute identifier identifier block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement call identifier argument_list identifier attribute identifier identifier block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript attribute identifier identifier identifier return_statement attribute call attribute identifier identifier argument_list identifier identifier
If the user has provided a unit in the query, convert it into the column unit, if present.
def metadata(self, filename): meta = self.get_metadata(filename) meta['mime'] = meta.get('mime') or files.mime(filename, self.DEFAULT_MIME) return meta
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier attribute identifier identifier return_statement identifier
Fetch all available metadata for a given file
def namespace_to_dict(o): d = {} for k, v in o.__dict__.items(): if not callable(v): d[k] = v return d
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement not_operator call identifier argument_list identifier block expression_statement assignment subscript identifier identifier identifier return_statement identifier
Convert an argparse namespace object to a dictionary.
def disconnect(self): if self.connection_receive: self.connection_receive.close() if self.connection_respond: self.connection_respond.close() if self.connection_send: self.connection_send.close()
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list
Close all connections that are set on this wire
def wrap(self, other): if other.childs: raise TagError(self, "Wrapping in a non empty Tag is forbidden.") if self.parent: self.before(other) self.parent.pop(self._own_index) other.append(self) return self
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block raise_statement call identifier argument_list identifier string string_start string_content string_end if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Wraps this element inside another empty tag.
def start_timer(self, reprate): print 'starting digital output at rate {} Hz'.format(reprate) self.trigger_task = DigitalOutTask(self.trigger_src, reprate) self.trigger_task.start()
module function_definition identifier parameters identifier identifier block print_statement call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Start the digital output task that serves as the acquistion trigger
def install_hg(path): hook = op.join(path, 'hgrc') if not op.isfile(hook): open(hook, 'w+').close() c = ConfigParser() c.readfp(open(hook, 'r')) if not c.has_section('hooks'): c.add_section('hooks') if not c.has_option('hooks', 'commit'): c.set('hooks', 'commit', 'python:pylama.hooks.hg_hook') if not c.has_option('hooks', 'qrefresh'): c.set('hooks', 'qrefresh', 'python:pylama.hooks.hg_hook') c.write(open(hook, 'w+'))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute call identifier argument_list identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end
Install hook in Mercurial repository.
def option2tuple(opt): if isinstance(opt[0], int): tup = opt[1], opt[2:] else: tup = opt[0], opt[1:] return tup
module function_definition identifier parameters identifier block if_statement call identifier argument_list subscript identifier integer identifier block expression_statement assignment identifier expression_list subscript identifier integer subscript identifier slice integer else_clause block expression_statement assignment identifier expression_list subscript identifier integer subscript identifier slice integer return_statement identifier
Return a tuple of option, taking possible presence of level into account
def run_socket_event_loop(self): try: while True: self._pool.join() if len(self._logger_data.keys()) == 0: time.sleep(0.5) except KeyboardInterrupt: pass finally: self._pool.kill()
module function_definition identifier parameters identifier block try_statement block while_statement true block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator call identifier argument_list call attribute attribute identifier identifier identifier argument_list integer block expression_statement call attribute identifier identifier argument_list float except_clause identifier block pass_statement finally_clause block expression_statement call attribute attribute identifier identifier identifier argument_list
Start monitoring managed loggers.
def render_node(node, context=None, edit=True): output = node.render(**context or {}) or u'' if edit: return u'<span data-i18n="{0}">{1}</span>'.format(node.uri.clone(scheme=None, ext=None, version=None), output) else: return output
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier true block expression_statement assignment identifier boolean_operator call attribute identifier identifier argument_list dictionary_splat boolean_operator identifier dictionary string string_start string_end if_statement identifier block return_statement call attribute string string_start string_content string_end identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier none keyword_argument identifier none keyword_argument identifier none identifier else_clause block return_statement identifier
Render node as html for templates, with edit tagging.
def multiplicon_file(self, value): assert os.path.isfile(value), "%s is not a valid file" % value self._multiplicon_file = value
module function_definition identifier parameters identifier identifier block assert_statement call attribute attribute identifier identifier identifier argument_list identifier binary_operator string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier identifier
Setter for _multiplicon_file attribute
def first(self): csvsource = CSVSource(self.source, self.factory, self.key()) try: item = csvsource.items().next() return item except StopIteration: return None
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list return_statement identifier except_clause identifier block return_statement none
Returns the first ICachableItem in the ICachableSource
def fetch_appl(): yql = YQL('AAPL', '2014-01-01', '2014-01-10') for item in yql: print item.get('date'), item.get('price') yql.select('AAPL', '2014-01-01', '2014-01-10') for item in yql: print item.get('date'), item.get('price')
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block print_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute 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 for_statement identifier identifier block print_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end
Returns stock prices for Apple company.
def update(self): for device in self.devices: device.update() for i in range(len(self._channel_dict["devices"])): device_dict = self._channel_dict["devices"][i] for device in self._devices: if device.name == device_dict["common.ALLTYPES_NAME"]: self._channel_dict["devices"][i] = device.as_dict()
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list for_statement identifier call identifier argument_list call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier subscript subscript attribute identifier identifier string string_start string_content string_end identifier for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier subscript identifier string string_start string_content string_end block expression_statement assignment subscript subscript attribute identifier identifier string string_start string_content string_end identifier call attribute identifier identifier argument_list
Updates the dictionary of the channel
def focusOutEvent(self, event): event.ignore() if sys.platform == "darwin": if event.reason() != Qt.ActiveWindowFocusReason: self.close() else: self.close()
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block if_statement comparison_operator call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list
Reimplement Qt method to close the widget when loosing focus.
def __del_frozen(self): self.__delattr__('_frozen') for attr, val in self.__dict__.items(): if isinstance(val, Config) and hasattr(val, '_frozen'): val.__del_frozen()
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list
Removes _frozen attribute from this instance and all its child configurations.
def _get_struct_gradientbevelfilter(self): obj = _make_object("GradientBevelFilter") obj.NumColors = num_colors = unpack_ui8(self._src) obj.GradientColors = [self._get_struct_rgba() for _ in range(num_colors)] obj.GradientRatio = [unpack_ui8(self._src) for _ in range(num_colors)] obj.BlurX = unpack_fixed16(self._src) obj.BlurY = unpack_fixed16(self._src) obj.Angle = unpack_fixed16(self._src) obj.Distance = unpack_fixed16(self._src) obj.Strength = unpack_fixed8(self._src) bc = BitConsumer(self._src) obj.InnerShadow = bc.u_get(1) obj.Knockout = bc.u_get(1) obj.CompositeSource = bc.u_get(1) obj.OnTop = bc.u_get(1) obj.Passes = bc.u_get(4) 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 attribute identifier identifier assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier list_comprehension call attribute identifier identifier argument_list for_in_clause identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier list_comprehension call identifier argument_list attribute identifier identifier for_in_clause identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier 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 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 call attribute identifier identifier argument_list integer return_statement identifier
Get the values for the GRADIENTBEVELFILTER record.
def bind(self, field_name, parent): assert parent.Meta.model is not None, \ "DRYPermissions is used on '{}' without a model".format(parent.__class__.__name__) for action in self.actions: if not self.object_only: global_method_name = "has_{action}_permission".format(action=action) if hasattr(parent.Meta.model, global_method_name): self.action_method_map[action] = {'global': global_method_name} if not self.global_only: object_method_name = "has_object_{action}_permission".format(action=action) if hasattr(parent.Meta.model, object_method_name): if self.action_method_map.get(action, None) is None: self.action_method_map[action] = {} self.action_method_map[action]['object'] = object_method_name super(DRYPermissionsField, self).bind(field_name, parent)
module function_definition identifier parameters identifier identifier identifier block assert_statement comparison_operator attribute attribute identifier identifier identifier none call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier for_statement identifier attribute identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier if_statement call identifier argument_list attribute attribute identifier identifier identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier dictionary pair string string_start string_content string_end identifier if_statement not_operator attribute identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier if_statement call identifier argument_list attribute attribute identifier identifier identifier identifier block if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list identifier none none block expression_statement assignment subscript attribute identifier identifier identifier dictionary expression_statement assignment subscript subscript attribute identifier identifier identifier string string_start string_content string_end identifier expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier
Check the model attached to the serializer to see what methods are defined and save them.
def parse(cls, detail_string): split = detail_string.split(':') if len(split) != 4: raise Exception('invalid credentials') ltpk = binascii.unhexlify(split[0]) ltsk = binascii.unhexlify(split[1]) atv_id = binascii.unhexlify(split[2]) client_id = binascii.unhexlify(split[3]) return Credentials(ltpk, ltsk, atv_id, client_id)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier integer return_statement call identifier argument_list identifier identifier identifier identifier
Parse a string represention of Credentials.
def preloop(self): if not self.already_prelooped: self.already_prelooped = True open('.psiturk_history', 'a').close() readline.read_history_file('.psiturk_history') for i in range(readline.get_current_history_length()): if readline.get_history_item(i) is not None: self.history.append(readline.get_history_item(i))
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier true expression_statement call attribute call identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block if_statement comparison_operator call attribute identifier identifier argument_list identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier
Keep persistent command history.
def create_program_action(parent, text, name, icon=None, nt_name=None): if is_text_string(icon): icon = get_icon(icon) if os.name == 'nt' and nt_name is not None: name = nt_name path = programs.find_program(name) if path is not None: return create_action(parent, text, icon=icon, triggered=lambda: programs.run_program(name))
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none block if_statement call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator comparison_operator attribute identifier identifier string string_start string_content string_end comparison_operator identifier none block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement call identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier lambda call attribute identifier identifier argument_list identifier
Create action to run a program
def resize_for_flows(self): if self.system.config.dime_enable: self.system.tds.config.compute_flows = True if self.system.tds.config.compute_flows: nflows = 2 * self.system.Bus.n + \ 8 * self.system.Line.n + \ 2 * self.system.Area.n_combination self.unamey.extend([''] * nflows) self.fnamey.extend([''] * nflows)
module function_definition identifier parameters identifier block if_statement attribute attribute attribute identifier identifier identifier identifier block expression_statement assignment attribute attribute attribute attribute identifier identifier identifier identifier identifier true if_statement attribute attribute attribute attribute identifier identifier identifier identifier identifier block expression_statement assignment identifier binary_operator binary_operator binary_operator integer attribute attribute attribute identifier identifier identifier identifier line_continuation binary_operator integer attribute attribute attribute identifier identifier identifier identifier line_continuation binary_operator integer attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator list string string_start string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator list string string_start string_end identifier
Extend `unamey` and `fnamey` for bus injections and line flows
def pre_process(self, xout, y0, params=()): for pre_processor in self.pre_processors: xout, y0, params = pre_processor(xout, y0, params) return [self.numpy.atleast_1d(arr) for arr in (xout, y0, params)]
module function_definition identifier parameters identifier identifier identifier default_parameter identifier tuple block for_statement identifier attribute identifier identifier block expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier identifier identifier return_statement list_comprehension call attribute attribute identifier identifier identifier argument_list identifier for_in_clause identifier tuple identifier identifier identifier
Transforms input to internal values, used internally.
def SendVersion(self): m = Message("version", VersionPayload(settings.NODE_PORT, self.remote_nodeid, settings.VERSION_NAME)) self.SendSerializedMessage(m)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Send our client version.
def _gegetate_args(self, options): for optkey, optval in self._normalize_options(options): yield optkey if isinstance(optval, (list, tuple)): assert len(optval) == 2 and optval[0] and optval[ 1], 'Option value can only be either a string or a (tuple, list) of 2 items' yield optval[0] yield optval[1] else: yield optval
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block expression_statement yield identifier if_statement call identifier argument_list identifier tuple identifier identifier block assert_statement boolean_operator boolean_operator comparison_operator call identifier argument_list identifier integer subscript identifier integer subscript identifier integer string string_start string_content string_end expression_statement yield subscript identifier integer expression_statement yield subscript identifier integer else_clause block expression_statement yield identifier
Generator of args parts based on options specification.
def __update_service_status(self, statuscode): if self.__service_status != statuscode: self.__service_status = statuscode self.__send_service_status_to_frontend()
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list
Set the internal status of the service object, and notify frontend.
def _connect(dbfile: 'PathLike') -> apsw.Connection: conn = apsw.Connection(os.fspath(dbfile)) _set_foreign_keys(conn, 1) assert _get_foreign_keys(conn) == 1 return conn
module function_definition identifier parameters typed_parameter identifier type string string_start string_content string_end type attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list identifier integer assert_statement comparison_operator call identifier argument_list identifier integer return_statement identifier
Connect to SQLite database file.
def forward_backward(self, data_batch): self.forward(data_batch, is_train=True) self.backward()
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list
A convenient function that calls both ``forward`` and ``backward``.
def to_native_units(self, motor): assert abs(self.rotations_per_second) <= motor.max_rps,\ "invalid rotations-per-second: {} max RPS is {}, {} was requested".format( motor, motor.max_rps, self.rotations_per_second) return self.rotations_per_second/motor.max_rps * motor.max_speed
module function_definition identifier parameters identifier identifier block assert_statement comparison_operator call identifier argument_list attribute identifier identifier attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier attribute identifier identifier return_statement binary_operator binary_operator attribute identifier identifier attribute identifier identifier attribute identifier identifier
Return the native speed measurement required to achieve desired rotations-per-second
def format_label(self, field, counter): return '<label for="id_formfield_%s" %s>%s</label>' % ( counter, field.field.required and 'class="required"', field.label)
module function_definition identifier parameters identifier identifier identifier block return_statement binary_operator string string_start string_content string_end tuple identifier boolean_operator attribute attribute identifier identifier identifier string string_start string_content string_end attribute identifier identifier
Format the label for each field
def delete_user(self, user): assert self.user == 'catroot' or self.user == 'postgres' assert not user == 'public' con = self.connection or self._connect() cur = con.cursor() cur.execute('DROP SCHEMA {user} CASCADE;'.format(user=user)) cur.execute('REVOKE USAGE ON SCHEMA public FROM {user};' .format(user=user)) cur.execute( 'REVOKE SELECT ON ALL TABLES IN SCHEMA public FROM {user};' .format(user=user)) cur.execute( 'DROP ROLE {user};'.format(user=user)) self.stdout.write( 'REMOVED USER {user}\n'.format(user=user)) if self.connection is None: con.commit() con.close() return self
module function_definition identifier parameters identifier identifier block assert_statement boolean_operator comparison_operator attribute identifier identifier string string_start string_content string_end comparison_operator attribute identifier identifier string string_start string_content string_end assert_statement not_operator comparison_operator identifier string string_start string_content string_end expression_statement assignment identifier boolean_operator attribute identifier identifier call attribute identifier identifier argument_list 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 string_end identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list keyword_argument identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement identifier
Delete user and all data
def resolve_att(a, fallback): if a is None: return fallback if a.background in ['default', '']: bg = fallback.background else: bg = a.background if a.foreground in ['default', '']: fg = fallback.foreground else: fg = a.foreground return AttrSpec(fg, bg)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block return_statement identifier if_statement comparison_operator attribute identifier identifier list string string_start string_content string_end string string_start string_end block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier list string string_start string_content string_end string string_start string_end block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier return_statement call identifier argument_list identifier identifier
replace '' and 'default' by fallback values
def download_if_not_exists(url: str, filename: str, skip_cert_verify: bool = True, mkdir: bool = True) -> None: if os.path.isfile(filename): log.info("No need to download, already have: {}", filename) return if mkdir: directory, basename = os.path.split(os.path.abspath(filename)) mkdir_p(directory) download(url=url, filename=filename, skip_cert_verify=skip_cert_verify)
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier true typed_default_parameter identifier type identifier true type none block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement if_statement identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Downloads a URL to a file, unless the file already exists.
def rollback(self, date): if self.onOffset(date): return date else: return date - QuarterEnd(month=self.month)
module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list identifier block return_statement identifier else_clause block return_statement binary_operator identifier call identifier argument_list keyword_argument identifier attribute identifier identifier
Roll date backward to nearest end of quarter
def force_to_string(unknown): result = '' if type(unknown) is str: result = unknown if type(unknown) is int: result = str(unknown) if type(unknown) is float: result = str(unknown) if type(unknown) is dict: result = Dict2String(unknown) if type(unknown) is list: result = List2String(unknown) return result
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
converts and unknown type to string for display purposes.
def desc(self): if 'ects' in self: fmt = '%s (%s, S%d) [%s, %.2f ECTS]' fields = ('title', 'code', 'semester', 'status', 'ects') else: fmt = '%s' fields = ('title',) s = fmt % tuple([self[f] for f in fields]) if self['followed'] and self['session']: res = self['result'] if self.get('jury', 0) > 0: res = self['jury'] s += ' --> %.2f/20 (%s)' % (res, self['session']) return s
module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier tuple string string_start string_content string_end expression_statement assignment identifier binary_operator identifier call identifier argument_list list_comprehension subscript identifier identifier for_in_clause identifier identifier if_statement boolean_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end integer integer block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end tuple identifier subscript identifier string string_start string_content string_end return_statement identifier
A textual description of this course
def ast2expr(ast): if ast[0] == 'const': return _CONSTS[ast[1]] elif ast[0] == 'var': return exprvar(ast[1], ast[2]) else: xs = [ast2expr(x) for x in ast[1:]] return ASTOPS[ast[0]](*xs, simplify=False)
module function_definition identifier parameters identifier block if_statement comparison_operator subscript identifier integer string string_start string_content string_end block return_statement subscript identifier subscript identifier integer elif_clause comparison_operator subscript identifier integer string string_start string_content string_end block return_statement call identifier argument_list subscript identifier integer subscript identifier integer else_clause block expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier subscript identifier slice integer return_statement call subscript identifier subscript identifier integer argument_list list_splat identifier keyword_argument identifier false
Convert an abstract syntax tree to an Expression.
def _get_lonely_contract(self): contracts = {} try: raw_res = yield from self._session.get(MAIN_URL, timeout=self._timeout) except OSError: raise PyHydroQuebecError("Can not get main page") content = yield from raw_res.text() soup = BeautifulSoup(content, 'html.parser') info_node = soup.find("div", {"class": "span3 contrat"}) if info_node is None: raise PyHydroQuebecError("Can not found contract") research = re.search("Contrat ([0-9]{4} [0-9]{5})", info_node.text) if research is not None: contracts[research.group(1).replace(" ", "")] = None if contracts == {}: raise PyHydroQuebecError("Can not found contract") return contracts
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary try_statement block expression_statement assignment identifier yield call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier yield call attribute identifier identifier argument_list 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 string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment subscript identifier call attribute call attribute identifier identifier argument_list integer identifier argument_list string string_start string_content string_end string string_start string_end none if_statement comparison_operator identifier dictionary block raise_statement call identifier argument_list string string_start string_content string_end return_statement identifier
Get contract number when we have only one contract.
def reject_all(self): keys = self.list_keys() for key in keys[self.PEND]: try: shutil.move( os.path.join( self.opts['pki_dir'], self.PEND, key), os.path.join( self.opts['pki_dir'], self.REJ, key) ) eload = {'result': True, 'act': 'reject', 'id': key} self.event.fire_event(eload, salt.utils.event.tagify(prefix='key')) except (IOError, OSError): pass self.check_minion_cache() if self.opts.get('rotate_aes_key'): salt.crypt.dropfile(self.opts['cachedir'], self.opts['user']) return self.list_keys()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier subscript identifier attribute identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end true pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end except_clause tuple identifier identifier block pass_statement expression_statement call attribute identifier identifier argument_list if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list
Reject all keys in pre
def dispense(self): self.sendcommand(Vendapin.DISPENSE) time.sleep(1) response = self.receivepacket() print('Vendapin.dispense(): ' + str(response)) if not self.was_packet_accepted(response): raise Exception('DISPENSE packet not accepted: ' + str(response)) return self.parsedata(response)[0]
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier return_statement subscript call attribute identifier identifier argument_list identifier integer
dispense a card if ready, otherwise throw an Exception
def list_revisions_of_build_configuration(id=None, name=None, page_size=200, page_index=0, sort=""): data = list_revisions_of_build_configuration_raw(id, name, page_size, page_index, sort) if data: return utils.format_json_list(data)
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none default_parameter identifier integer default_parameter identifier integer default_parameter identifier string string_start string_end block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier if_statement identifier block return_statement call attribute identifier identifier argument_list identifier
List audited revisions of a BuildConfiguration
def LocalPathToCanonicalPath(path): path_components = path.split("/") result = [] for component in path_components: m = re.match(r"\\\\.\\", component) if not m: component = component.replace("\\", "/") result.append(component) return utils.JoinPath(*result)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list list_splat identifier
Converts path from the local system's convention to the canonical.
def op_at_on(operation: ops.Operation, time: Timestamp, device: Device): return ScheduledOperation(time, device.duration_of(operation), operation)
module function_definition identifier parameters typed_parameter identifier type attribute identifier identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block return_statement call identifier argument_list identifier call attribute identifier identifier argument_list identifier identifier
Creates a scheduled operation with a device-determined duration.
def workaround_type_coercions_in_recursions(match_query): new_match_traversals = [] for current_traversal in match_query.match_traversals: new_traversal = [] for match_step in current_traversal: new_match_step = match_step has_coerce_type = match_step.coerce_type_block is not None has_recurse_root = isinstance(match_step.root_block, Recurse) if has_coerce_type and has_recurse_root: new_where_block = convert_coerce_type_and_add_to_where_block( match_step.coerce_type_block, match_step.where_block) new_match_step = match_step._replace(coerce_type_block=None, where_block=new_where_block) new_traversal.append(new_match_step) new_match_traversals.append(new_traversal) return match_query._replace(match_traversals=new_match_traversals)
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier comparison_operator attribute identifier identifier none expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier if_statement boolean_operator identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier none keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
Lower CoerceType blocks into Filter blocks within Recurse steps.
def close_window(self): if self.undocked_window is not None: self.undocked_window.close() self.undocked_window = None self.undock_action.setDisabled(False) self.close_plugin_action.setDisabled(False)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none expression_statement call attribute attribute identifier identifier identifier argument_list false expression_statement call attribute attribute identifier identifier identifier argument_list false
Close QMainWindow instance that contains this plugin.
def _match_metric(self, metric): if len(self._compiled_filters) == 0: return True for (collector, filter_regex) in self._compiled_filters: if collector != metric.getCollectorPath(): continue if filter_regex.match(metric.getMetricPath()): return True return False
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block return_statement true for_statement tuple_pattern identifier identifier attribute identifier identifier block if_statement comparison_operator identifier call attribute identifier identifier argument_list block continue_statement if_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list block return_statement true return_statement false
matches the metric path, if the metrics are empty, it shorts to True
def ms_to_datetime(ms, tzinfo=None): if not isinstance(ms, (int, long)): raise TypeError('expected integer, not %s' % type(ms)) if tzinfo is None: tzinfo = mktz() return datetime.datetime.fromtimestamp(ms * 1e-3, tzinfo)
module function_definition identifier parameters identifier default_parameter identifier none block if_statement not_operator call identifier argument_list identifier tuple identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list return_statement call attribute attribute identifier identifier identifier argument_list binary_operator identifier float identifier
Convert a millisecond time value to an offset-aware Python datetime object.
def list_to_scope(scope): if isinstance(scope, unicode_type) or scope is None: return scope elif isinstance(scope, (set, tuple, list)): return " ".join([unicode_type(s) for s in scope]) else: raise ValueError("Invalid scope (%s), must be string, tuple, set, or list." % scope)
module function_definition identifier parameters identifier block if_statement boolean_operator call identifier argument_list identifier identifier comparison_operator identifier none block return_statement identifier elif_clause call identifier argument_list identifier tuple identifier identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list list_comprehension call identifier argument_list identifier for_in_clause identifier identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
Convert a list of scopes to a space separated string.
def _coord2offset(self, coord): size = self.size offset = 0 for dim, index in enumerate(coord): size //= self._normshape[dim] offset += size * index return offset
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier integer for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement augmented_assignment identifier subscript attribute identifier identifier identifier expression_statement augmented_assignment identifier binary_operator identifier identifier return_statement identifier
Convert a normalized coordinate to an item offset.
def streams(self): if self._streams is None: self._streams = list(self._stream_df["STREAM"].values) return self._streams
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call identifier argument_list attribute subscript attribute identifier identifier string string_start string_content string_end identifier return_statement attribute identifier identifier
A list of available streams
def auto_override_class(cls, force = False, force_recursive = False): if not pytypes.checking_enabled: return cls assert(isclass(cls)) if not force and is_no_type_check(cls): return cls keys = [key for key in cls.__dict__] for key in keys: memb = cls.__dict__[key] if force_recursive or not is_no_type_check(memb): if isfunction(memb) or ismethod(memb) or ismethoddescriptor(memb): if util._has_base_method(memb, cls): setattr(cls, key, override(memb)) elif isclass(memb): auto_override_class(memb, force_recursive, force_recursive) return cls
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier false block if_statement not_operator attribute identifier identifier block return_statement identifier assert_statement parenthesized_expression call identifier argument_list identifier if_statement boolean_operator not_operator identifier call identifier argument_list identifier block return_statement identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier attribute identifier identifier for_statement identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement boolean_operator identifier not_operator call identifier argument_list identifier block if_statement boolean_operator boolean_operator call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier block if_statement call attribute identifier identifier argument_list identifier identifier block expression_statement call identifier argument_list identifier identifier call identifier argument_list identifier elif_clause call identifier argument_list identifier block expression_statement call identifier argument_list identifier identifier identifier return_statement identifier
Works like auto_override, but is only applicable to classes.
def _get_remarks_component(self, string, initial_pos): remarks_code = string[initial_pos:initial_pos + self.ADDR_CODE_LENGTH] if remarks_code != 'REM': raise ish_reportException("Parsing remarks. Expected REM but got %s." % (remarks_code,)) expected_length = int(string[0:4]) + self.PREAMBLE_LENGTH position = initial_pos + self.ADDR_CODE_LENGTH while position < expected_length: key = string[position:position + self.ADDR_CODE_LENGTH] if key == 'EQD': break chars_to_read = string[position + self.ADDR_CODE_LENGTH:position + \ (self.ADDR_CODE_LENGTH * 2)] chars_to_read = int(chars_to_read) position += (self.ADDR_CODE_LENGTH * 2) string_value = string[position:position + chars_to_read] self._remarks[key] = string_value position += chars_to_read
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript identifier slice identifier binary_operator identifier attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier expression_statement assignment identifier binary_operator call identifier argument_list subscript identifier slice integer integer attribute identifier identifier expression_statement assignment identifier binary_operator identifier attribute identifier identifier while_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript identifier slice identifier binary_operator identifier attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block break_statement expression_statement assignment identifier subscript identifier slice binary_operator identifier attribute identifier identifier binary_operator identifier line_continuation parenthesized_expression binary_operator attribute identifier identifier integer expression_statement assignment identifier call identifier argument_list identifier expression_statement augmented_assignment identifier parenthesized_expression binary_operator attribute identifier identifier integer expression_statement assignment identifier subscript identifier slice identifier binary_operator identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement augmented_assignment identifier identifier
Parse the remarks into the _remarks dict
def create(self, item, dry_run=None): return self.backend.create(validate(item, version=self.version, context=self.context), dry_run=dry_run)
module function_definition identifier parameters identifier identifier default_parameter identifier none block return_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier
Create a new item in backend.
def OnCellBorderWidth(self, event): with undo.group(_("Border width")): self.grid.actions.set_border_attr("borderwidth", event.width, event.borders) self.grid.ForceRefresh() self.grid.update_attribute_toolbar() event.Skip()
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier 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
Cell border width event handler
def emit_function(self, return_type=None, argtypes=[], proxy=True): if argtypes is not None: make_func = ctypes.CFUNCTYPE(return_type, *argtypes) else: make_func = ctypes.CFUNCTYPE(return_type) code = self.emit() func = make_func(code.value) func.address = code if proxy: self.functions.append(func) return weakref.proxy(func) else: return func
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier list default_parameter identifier true block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier list_splat identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier identifier if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier else_clause block return_statement identifier
Compiles code and returns a Python-callable function.
def _ExpandPath(self, target, vals, paths): if target not in self._TARGETS: return expanded = [] for val in vals: shellvar = self._SHELLVAR_RE.match(val) if not val: expanded.append(".") elif shellvar: existing = paths.get(shellvar.group(1).upper()) if existing: expanded.extend(existing) else: expanded.append(val) else: expanded.append(val) paths[target] = expanded
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block return_statement expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end elif_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list integer identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier
Extract path information, interpolating current path values as needed.
def archaius(self): bucket = self.format['s3_bucket'].format(**self.data) path = self.format['s3_bucket_path'].format(**self.data) archaius_name = self.format['s3_archaius_name'].format(**self.data) archaius = {'s3': archaius_name, 'bucket': bucket, 'path': path} return archaius
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list dictionary_splat attribute identifier identifier expression_statement assignment identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list dictionary_splat attribute identifier identifier expression_statement assignment identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list dictionary_splat attribute identifier identifier expression_statement assignment identifier 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 return_statement identifier
Generate archaius bucket path.
def colour_rgb(self): hexvalue = self.status()[self.DPS][self.DPS_INDEX_COLOUR] return BulbDevice._hexvalue_to_rgb(hexvalue)
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript subscript call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier
Return colour as RGB value
def parse_char(self, c): self.buf.extend(c) self.total_bytes_received += len(c) if self.native: if native_testing: self.test_buf.extend(c) m = self.__parse_char_native(self.test_buf) m2 = self.__parse_char_legacy() if m2 != m: print("Native: %s\nLegacy: %s\n" % (m, m2)) raise Exception('Native vs. Legacy mismatch') else: m = self.__parse_char_native(self.buf) else: m = self.__parse_char_legacy() if m != None: self.total_packets_received += 1 self.__callbacks(m) else: if self.buf_len() == 0 and self.buf_index != 0: self.buf = bytearray() self.buf_index = 0 return m
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement augmented_assignment attribute identifier identifier call identifier argument_list identifier if_statement attribute identifier identifier block if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence string_end tuple identifier identifier raise_statement call identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list identifier else_clause block if_statement boolean_operator comparison_operator call attribute identifier identifier argument_list integer comparison_operator attribute identifier identifier integer block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier integer return_statement identifier
input some data bytes, possibly returning a new message
def user_disable_throw_rest_endpoint(self, username, url='rest/scriptrunner/latest/custom/disableUser', param='userName'): url = "{}?{}={}".format(url, param, username) return self.get(path=url)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
The disable method throw own rest enpoint
def Parse(factory, file): entities = [] while 1: data = GetNextStruct(file) if not data: break entities.extend(ProcessStruct(factory, data)) return entities
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list while_statement integer block expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator identifier block break_statement expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier return_statement identifier
Parses the input file and returns C code and corresponding header file.
def purview_indices(self, direction): return { Direction.CAUSE: self.cause_indices, Direction.EFFECT: self.effect_indices }[direction]
module function_definition identifier parameters identifier identifier block return_statement subscript dictionary pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier identifier
The indices of nodes in the purview system.
def sampleLocationFromFeature(self, feature): if feature == "topDisc": return self._sampleLocationOnDisc(top=True) elif feature == "topEdge": return self._sampleLocationOnEdge(top=True) elif feature == "bottomDisc": return self._sampleLocationOnDisc(top=False) elif feature == "bottomEdge": return self._sampleLocationOnEdge(top=False) elif feature == "side": return self._sampleLocationOnSide() elif feature == "random": return self.sampleLocation() else: raise NameError("No such feature in {}: {}".format(self, feature))
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list keyword_argument identifier true elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list keyword_argument identifier true elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list keyword_argument identifier false elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list keyword_argument identifier false elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier
Samples a location from the provided specific features.
def _build_session_groups(self): groups_by_name = {} run_to_tag_to_content = self._context.multiplexer.PluginRunToTagToContent( metadata.PLUGIN_NAME) for (run, tag_to_content) in six.iteritems(run_to_tag_to_content): if metadata.SESSION_START_INFO_TAG not in tag_to_content: continue start_info = metadata.parse_session_start_info_plugin_data( tag_to_content[metadata.SESSION_START_INFO_TAG]) end_info = None if metadata.SESSION_END_INFO_TAG in tag_to_content: end_info = metadata.parse_session_end_info_plugin_data( tag_to_content[metadata.SESSION_END_INFO_TAG]) session = self._build_session(run, start_info, end_info) if session.status in self._request.allowed_statuses: self._add_session(session, start_info, groups_by_name) groups = groups_by_name.values() for group in groups: group.sessions.sort(key=operator.attrgetter('name')) self._aggregate_metrics(group) return groups
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier for_statement tuple_pattern identifier identifier call attribute identifier identifier argument_list identifier block if_statement comparison_operator attribute identifier identifier identifier block continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier attribute identifier identifier expression_statement assignment identifier none if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier if_statement comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Returns a list of SessionGroups protobuffers from the summary data.
def remove_duplicate_notes(self): res = [] for x in self.notes: if x not in res: res.append(x) self.notes = res return res
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
Remove duplicate and enharmonic notes from the container.
def get(self, oid, host, port, community): ret = {} if not isinstance(oid, tuple): oid = self._convert_to_oid(oid) host = socket.gethostbyname(host) snmpAuthData = cmdgen.CommunityData( 'agent-{}'.format(community), community) snmpTransportData = cmdgen.UdpTransportTarget( (host, port), int(self.config['timeout']), int(self.config['retries'])) result = self.snmpCmdGen.getCmd(snmpAuthData, snmpTransportData, oid) varBind = result[3] for o, v in varBind: ret[str(o)] = v.prettyPrint() return ret
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier dictionary if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier identifier call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier subscript identifier integer for_statement pattern_list identifier identifier identifier block expression_statement assignment subscript identifier call identifier argument_list identifier call attribute identifier identifier argument_list return_statement identifier
Perform SNMP get for a given OID
def do_ls(self, table=None): if table is None: fields = OrderedDict( [ ("Name", "name"), ("Status", "status"), ("Read", "total_read_throughput"), ("Write", "total_write_throughput"), ] ) tables = self.engine.describe_all() sizes = [ 1 + max([len(str(getattr(t, f))) for t in tables] + [len(title)]) for title, f in iteritems(fields) ] for size, title in zip(sizes, fields): print(title.ljust(size), end="") print() for row_table in tables: for size, field in zip(sizes, fields.values()): print(str(getattr(row_table, field)).ljust(size), end="") print() else: print(self.engine.describe(table, refresh=True, metrics=True).pformat())
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list list tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier list_comprehension binary_operator integer call identifier argument_list binary_operator list_comprehension call identifier argument_list call identifier argument_list call identifier argument_list identifier identifier for_in_clause identifier identifier list call identifier argument_list identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list identifier identifier block expression_statement call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_end expression_statement call identifier argument_list for_statement identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier call attribute identifier identifier argument_list block expression_statement call identifier argument_list call attribute call identifier argument_list call identifier argument_list identifier identifier identifier argument_list identifier keyword_argument identifier string string_start string_end expression_statement call identifier argument_list else_clause block expression_statement call identifier argument_list call attribute call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier true identifier argument_list
List all tables or print details of one table
def collect(self): cmd = [self.config['bin'], "list"] if str_to_bool(self.config['reset']): cmd.append("reset") if str_to_bool(self.config['use_sudo']): cmd.insert(0, self.config['sudo_cmd']) matcher = re.compile("{ pkts = (.*), bytes = (.*) } = (.*);") lines = Popen(cmd, stdout=PIPE).communicate()[0].strip().splitlines() for line in lines: matches = re.match(matcher, line) if matches: num_packets = int(matches.group(1)) num_bytes = int(matches.group(2)) name = matches.group(3) self.publish(name + ".pkts", num_packets) self.publish(name + ".bytes", num_bytes)
module function_definition identifier parameters identifier block expression_statement assignment identifier list subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end if_statement call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list integer subscript attribute identifier 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 expression_statement assignment identifier call attribute call attribute subscript call attribute call identifier argument_list identifier keyword_argument identifier identifier identifier argument_list integer identifier argument_list identifier argument_list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list integer 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 integer expression_statement call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end identifier
Collect and publish netfilter counters
def _get_simple_assignments(tree): result = {} for node in ast.walk(tree): if isinstance(node, ast.Assign): for target in node.targets: if isinstance(target, ast.Name): result[target.id] = node.value return result
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement identifier call attribute identifier identifier argument_list identifier block if_statement call identifier argument_list identifier attribute identifier identifier block for_statement identifier attribute identifier identifier block if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment subscript identifier attribute identifier identifier attribute identifier identifier return_statement identifier
Get simple assignments from node tree.
def _validate_extra_component(bs_data): assert len(bs_data['elements']) > 0 for el in bs_data['elements'].values(): if not 'electron_shells' in el: continue for s in el['electron_shells']: nprim = len(s['exponents']) if nprim <= 0: raise RuntimeError("Invalid number of primitives: {}".format(nprim)) for g in s['coefficients']: if nprim != len(g): raise RuntimeError("Number of coefficients doesn't match number of primitives ({} vs {}".format( len(g), nprim)) nam = len(s['angular_momentum']) if nam > 1: ngen = len(s['coefficients']) if ngen != nam: raise RuntimeError("Number of general contractions doesn't match combined AM ({} vs {}".format( ngen, nam))
module function_definition identifier parameters identifier block assert_statement comparison_operator call identifier argument_list subscript identifier string string_start string_content string_end integer for_statement identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list block if_statement not_operator comparison_operator string string_start string_content string_end identifier block continue_statement for_statement identifier subscript identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator identifier integer block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier for_statement identifier subscript identifier string string_start string_content string_end block if_statement comparison_operator identifier call identifier argument_list identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator identifier integer block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier
Extra checks for component basis files
def remove_text_structure(self, text_structure): idx = self.hucit_has_structure.index(text_structure) ts = self.hucit_has_structure.pop(idx) ts.remove() self.update() return
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement
Remove any citable text structure to the work.
def major_extent(self) -> complex: return max((self.max() - self.null, self.null - self.min()))
module function_definition identifier parameters identifier type identifier block return_statement call identifier argument_list tuple binary_operator call attribute identifier identifier argument_list attribute identifier identifier binary_operator attribute identifier identifier call attribute identifier identifier argument_list
Maximum deviation from null.
def parent_dir(path): return os.path.abspath(os.path.join(path, os.pardir, os.pardir, '_build'))
module function_definition identifier parameters identifier block return_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier string string_start string_content string_end
Return the parent of a directory.
def relations_for_id(relid=None): relation_data = [] relid = relid or relation_ids() for unit in related_units(relid): unit_data = relation_for_unit(unit, relid) unit_data['__relid__'] = relid relation_data.append(unit_data) return relation_data
module function_definition identifier parameters default_parameter identifier none block expression_statement assignment identifier list expression_statement assignment identifier boolean_operator identifier call identifier argument_list for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Get relations of a specific relation ID
def dav_index(context, data): url = data.get('url') result = context.http.request('PROPFIND', url) for resp in result.xml.findall('./{DAV:}response'): href = resp.findtext('./{DAV:}href') if href is None: continue rurl = urljoin(url, href) rdata = data.copy() rdata['url'] = rurl rdata['foreign_id'] = rurl if rdata['url'] == url: continue if resp.find('.//{DAV:}collection') is not None: rdata['parent_foreign_id'] = rurl context.log.info("Fetching contents of folder: %s" % rurl) context.recurse(data=rdata) else: rdata['parent_foreign_id'] = url fetch(context, rdata)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block continue_statement expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block continue_statement if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end none block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier else_clause block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement call identifier argument_list identifier identifier
List files in a WebDAV directory.
def stChromaFeaturesInit(nfft, fs): freqs = numpy.array([((f + 1) * fs) / (2 * nfft) for f in range(nfft)]) Cp = 27.50 nChroma = numpy.round(12.0 * numpy.log2(freqs / Cp)).astype(int) nFreqsPerChroma = numpy.zeros((nChroma.shape[0], )) uChroma = numpy.unique(nChroma) for u in uChroma: idx = numpy.nonzero(nChroma == u) nFreqsPerChroma[idx] = idx[0].shape return nChroma, nFreqsPerChroma
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list_comprehension binary_operator parenthesized_expression binary_operator parenthesized_expression binary_operator identifier integer identifier parenthesized_expression binary_operator integer identifier for_in_clause identifier call identifier argument_list identifier expression_statement assignment identifier float expression_statement assignment identifier call attribute call attribute identifier identifier argument_list binary_operator float call attribute identifier identifier argument_list binary_operator identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list tuple subscript attribute identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list comparison_operator identifier identifier expression_statement assignment subscript identifier identifier attribute subscript identifier integer identifier return_statement expression_list identifier identifier
This function initializes the chroma matrices used in the calculation of the chroma features
def jboss_standalone_conf_file(broker): log_files = broker[JDRSpecs.jboss_standalone_server_log] if log_files: log_content = log_files[-1].content results = [] for line in log_content: if "sun.java.command =" in line and ".jdr" not in line and "-Djboss.server.base.dir" in line: results.append(line) if results: config_xml = 'standalone.xml' java_command = results[-1] if '--server-config' in java_command: config_xml = java_command.split('--server-config=')[1].split()[0] elif '-c ' in java_command: config_xml = java_command.split('-c ')[1].split()[0] return [config_xml] return []
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript identifier attribute identifier identifier if_statement identifier block expression_statement assignment identifier attribute subscript identifier unary_operator integer identifier expression_statement assignment identifier list for_statement identifier identifier block if_statement boolean_operator boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier unary_operator integer if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier subscript call attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end integer identifier argument_list integer elif_clause comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier subscript call attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end integer identifier argument_list integer return_statement list identifier return_statement list
Get which jboss standalone conf file is using from server log
def select(select, tag, namespaces=None, limit=0, flags=0, **kwargs): return compile(select, namespaces, flags, **kwargs).select(tag, limit)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier integer default_parameter identifier integer dictionary_splat_pattern identifier block return_statement call attribute call identifier argument_list identifier identifier identifier dictionary_splat identifier identifier argument_list identifier identifier
Select the specified tags.
def logger_new (self, loggername, **kwargs): args = self[loggername] args.update(kwargs) return self.loggers[loggername](**args)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call subscript attribute identifier identifier identifier argument_list dictionary_splat identifier
Instantiate new logger and return it.
def downloadThumbnail(self, outPath): url = self._url + "/info/thumbnail" params = { } return self._get(url=url, out_folder=outPath, file_name=None, param_dict=params, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier dictionary return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier none keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
downloads the items's thumbnail
def unwrap_rtx(rtx, payload_type, ssrc): packet = RtpPacket( payload_type=payload_type, marker=rtx.marker, sequence_number=unpack('!H', rtx.payload[0:2])[0], timestamp=rtx.timestamp, ssrc=ssrc, payload=rtx.payload[2:]) packet.csrc = rtx.csrc packet.extensions = rtx.extensions return packet
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier subscript call identifier argument_list string string_start string_content string_end subscript attribute identifier identifier slice integer integer integer keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier subscript attribute identifier identifier slice integer expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier return_statement identifier
Recover initial packet from a retransmission packet.
def _apply_theme(self): self.theme.apply_axs(self.axs) self.theme.apply_figure(self.figure)
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Apply theme attributes to Matplotlib objects
def oneImageNLF(img, img2=None, signal=None): x, y, weights, signal = calcNLF(img, img2, signal) _, fn, _ = _evaluate(x, y, weights) return fn, signal
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment pattern_list identifier identifier identifier identifier call identifier argument_list identifier identifier identifier expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier identifier identifier return_statement expression_list identifier identifier
Estimate the NLF from one or two images of the same kind
def from_serializable(cls, object_dict): key_class = cls._from_visible(cls.STARTS_WITH + 'class' + cls.ENDS_WITH) key_module = cls._from_visible(cls.STARTS_WITH + 'module' + cls.ENDS_WITH) obj_class = object_dict.pop(key_class) obj_module = object_dict.pop(key_module) if key_module in object_dict else None obj = cls._from_class(obj_class, obj_module) obj.modify_object(object_dict) return obj
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list identifier comparison_operator identifier identifier none expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
core class method to create visible objects from a dictionary
def wait_for_host(self, host): t = time.time() if host in self.times: due_time = self.times[host] if due_time > t: wait = due_time - t time.sleep(wait) t = time.time() wait_time = random.uniform(self.wait_time_min, self.wait_time_max) self.times[host] = t + wait_time
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier binary_operator identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier binary_operator identifier identifier
Throttle requests to one host.
def _remove_remote_data_bags(): data_bags_path = os.path.join(env.node_work_path, 'data_bags') if exists(data_bags_path): sudo("rm -rf {0}".format(data_bags_path))
module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end if_statement call identifier argument_list identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Remove remote data bags, so it won't leak any sensitive information
def split(self, tValues): if self.segmentType == "curve": on1 = self.previousOnCurve off1 = self.points[0].coordinates off2 = self.points[1].coordinates on2 = self.points[2].coordinates return bezierTools.splitCubicAtT(on1, off1, off2, on2, *tValues) elif self.segmentType == "line": segments = [] x1, y1 = self.previousOnCurve x2, y2 = self.points[0].coordinates dx = x2 - x1 dy = y2 - y1 pp = x1, y1 for t in tValues: np = (x1+dx*t, y1+dy*t) segments.append([pp, np]) pp = np segments.append([pp, (x2, y2)]) return segments elif self.segmentType == "qcurve": raise NotImplementedError else: raise NotImplementedError
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute subscript attribute identifier identifier integer identifier expression_statement assignment identifier attribute subscript attribute identifier identifier integer identifier expression_statement assignment identifier attribute subscript attribute identifier identifier integer identifier return_statement call attribute identifier identifier argument_list identifier identifier identifier identifier list_splat identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier list expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier attribute subscript attribute identifier identifier integer identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier expression_list identifier identifier for_statement identifier identifier block expression_statement assignment identifier tuple binary_operator identifier binary_operator identifier identifier binary_operator identifier binary_operator identifier identifier expression_statement call attribute identifier identifier argument_list list identifier identifier expression_statement assignment identifier identifier expression_statement call attribute identifier identifier argument_list list identifier tuple identifier identifier return_statement identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block raise_statement identifier else_clause block raise_statement identifier
Split the segment according the t values
def _flds_shape(fieldname, header): shp = list(header['nts']) shp.append(header['ntb']) if fieldname == 'Velocity': shp.insert(0, 3) header['xp'] = int(header['nts'][0] != 1) shp[1] += header['xp'] header['yp'] = int(header['nts'][1] != 1) shp[2] += header['yp'] header['zp'] = 1 header['xyp'] = 1 else: shp.insert(0, 1) header['xp'] = 0 header['yp'] = 0 header['zp'] = 0 header['xyp'] = 0 return shp
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 expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list integer integer expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list comparison_operator subscript subscript identifier string string_start string_content string_end integer integer expression_statement augmented_assignment subscript identifier integer subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list comparison_operator subscript subscript identifier string string_start string_content string_end integer integer expression_statement augmented_assignment subscript identifier integer subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end integer expression_statement assignment subscript identifier string string_start string_content string_end integer else_clause block expression_statement call attribute identifier identifier argument_list integer integer expression_statement assignment subscript identifier string string_start string_content string_end integer expression_statement assignment subscript identifier string string_start string_content string_end integer expression_statement assignment subscript identifier string string_start string_content string_end integer expression_statement assignment subscript identifier string string_start string_content string_end integer return_statement identifier
Compute shape of flds variable.
def normalAt(self, i): normals = self.polydata(True).GetPointData().GetNormals() return np.array(normals.GetTuple(i))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute call attribute identifier identifier argument_list true identifier argument_list identifier argument_list return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier
Return the normal vector at vertex point `i`.
def last(values, axis, skipna=None): if (skipna or skipna is None) and values.dtype.kind not in 'iSU': _fail_on_dask_array_input_skipna(values) return nanlast(values, axis) return take(values, -1, axis=axis)
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement boolean_operator parenthesized_expression boolean_operator identifier comparison_operator identifier none comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end block expression_statement call identifier argument_list identifier return_statement call identifier argument_list identifier identifier return_statement call identifier argument_list identifier unary_operator integer keyword_argument identifier identifier
Return the last non-NA elements in this array along the given axis
def _CronJobFromRow(self, row): (job, create_time, enabled, forced_run_requested, last_run_status, last_run_time, current_run_id, state, leased_until, leased_by) = row job = rdf_cronjobs.CronJob.FromSerializedString(job) job.current_run_id = db_utils.IntToCronJobRunID(current_run_id) job.enabled = enabled job.forced_run_requested = forced_run_requested job.last_run_status = last_run_status job.last_run_time = mysql_utils.TimestampToRDFDatetime(last_run_time) if state: job.state = rdf_protodict.AttributedDict.FromSerializedString(state) job.created_at = mysql_utils.TimestampToRDFDatetime(create_time) job.leased_until = mysql_utils.TimestampToRDFDatetime(leased_until) job.leased_by = leased_by return job
module function_definition identifier parameters identifier identifier block expression_statement assignment tuple_pattern identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier 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 identifier return_statement identifier
Creates a cronjob object from a database result row.
def add_tags(self, *tags): normed_tags = self.api.manager._normalize_tags(tags) self.api.manager.add_tags(self.archive_name, normed_tags)
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier identifier
Set tags for a given archive