Unnamed: 0
int64
0
389k
code
stringlengths
26
79.6k
docstring
stringlengths
1
46.9k
378,600
def __readimzmlmeta(self): d = {} scan_settings_list_elem = self.root.find( % self.sl) instrument_config_list_elem = self.root.find( % self.sl) supportedparams1 = [("max count of pixels x", int), ("max count of pixels y", int), ("max dimension x", int...
This method should only be called by __init__. Initializes the imzmldict with frequently used metadata from the .imzML file. This method reads only a subset of the available meta information and may be extended in the future. The keys are named similarly to the imzML names. Currently supported ...
378,601
def extract_tree(self, labels, without, suppress_unifurcations=True): if not isinstance(suppress_unifurcations, bool): raise TypeError("suppress_unifurcations must be a bool") if labels is not None and not isinstance(labels, set): try: labels = set(labels...
Helper function for ``extract_tree_*`` functions
378,602
def rehearse(self, docs, sgd=None, losses=None, config=None): if len(docs) == 0: return if sgd is None: if self._optimizer is None: self._optimizer = create_default_optimizer(Model.ops) sgd = self._optimizer docs = list(docs) ...
Make a "rehearsal" update to the models in the pipeline, to prevent forgetting. Rehearsal updates run an initial copy of the model over some data, and update the model so its current predictions are more like the initial ones. This is useful for keeping a pre-trained model on-track, even...
378,603
def results(cls, function, group=None): return numpy.array(cls._results[group][function])
Returns a numpy nparray representing the benchmark results of a function in a group.
378,604
def van_dec_2d(x, skip_connections, output_shape, first_depth, hparams=None): with tf.variable_scope(): dec = tf.layers.conv2d_transpose( x, first_depth * 4, 3, padding=, activation=tf.nn.relu, strides=2) dec = tf.nn.dropout(dec, hparams.van_keep_prob) dec = tf.contrib.layers.layer_norm(dec) ...
The VAN decoder. Args: x: The analogy information to decode. skip_connections: The encoder layers which can be used as skip connections. output_shape: The shape of the desired output image. first_depth: The depth of the first layer of the van image encoder. hparams: The python hparams. Returns...
378,605
def process_request(self, request): if not self.is_resource_protected(request): return if self.deny_access_condition(request): return self.deny_access(request)
The actual middleware method, called on all incoming requests. This default implementation will ignore the middleware (return None) if the conditions specified in is_resource_protected aren't met. If they are, it then tests to see if the user should be denied access via the denied_access_condit...
378,606
def critical_angle(pressure, u, v, heights, stormu, stormv): r u = u.to() v = v.to() stormu = stormu.to() stormv = stormv.to() sort_inds = np.argsort(pressure[::-1]) pressure = pressure[sort_inds] heights = heights[sort_inds] u = u[sort_inds] v = v[sort_inds] shr5...
r"""Calculate the critical angle. The critical angle is the angle between the 10m storm-relative inflow vector and the 10m-500m shear vector. A critical angle near 90 degrees indicates that a storm in this environment on the indicated storm motion vector is likely ingesting purely streamwise vorticity ...
378,607
def ccmod_setcoef(k): mp_Zf[k] = sl.rfftn(mp_Z_Y[k], mp_cri.Nv, mp_cri.axisN) mp_ZSf[k] = np.conj(mp_Zf[k]) * mp_Sf[k]
Set the coefficient maps for the ccmod stage. The only parameter is the slice index `k` and there are no return values; all inputs and outputs are from and to global variables.
378,608
def usage(asked_for=0): exit = fsq.const() if asked_for else\ fsq.const() f = sys.stdout if asked_for else sys.stderr shout(.format( os.path.basename(_PROG)), f) if asked_for: shout(\ \ .format(os.path.basename(_PROG)), f) shout...
Exit with a usage string, used for bad argument or with -h
378,609
def ack(self, message, subscription_id=None, **kwargs): if isinstance(message, dict): message_id = message.get("message-id") if not subscription_id: subscription_id = message.get("subscription") else: message_id = message if not messag...
Acknowledge receipt of a message. This only makes sense when the 'acknowledgement' flag was set for the relevant subscription. :param message: ID of the message to be acknowledged, OR a dictionary containing a field 'message-id'. :param subscription_id: ID of the associat...
378,610
def get_md5(string): try: hasher = hashlib.md5() except BaseException: hasher = hashlib.new(, usedForSecurity=False) hasher.update(string) return hasher.hexdigest()
Get a string's MD5
378,611
def copy_images(images, source, target): image_err = False if len(images) > 0: images_dir = os.path.join(target, ) os.makedirs(images_dir) for image in images: if os.path.isabs(image): old_image_file = image else: old_image_fil...
Copy images to converted topology :param images: Images to copy :param source: Old Topology Directory :param target: Target topology files directory :return: True when an image cannot be found, otherwise false :rtype: bool
378,612
def refresh(self, item): client = self._clients[item].get_client() self[item] = val = self.item_class(client) return val
Forces a refresh of a cached item. :param item: Client name. :type item: unicode | str :return: Items in the cache. :rtype: DockerHostItemCache.item_class
378,613
def on_resize(width, height): glViewport(0, 0, width, height) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(30, 1.0*width/height, 0.1, 1000.0) glMatrixMode(GL_MODELVIEW) glLoadIdentity()
Setup 3D projection
378,614
def _get_arguments_for_execution(self, function_name, serialized_args): arguments = [] for (i, arg) in enumerate(serialized_args): if isinstance(arg, ObjectID): argument = self.get_object([arg])[0] if isinstance(argument, RayError): ...
Retrieve the arguments for the remote function. This retrieves the values for the arguments to the remote function that were passed in as object IDs. Arguments that were passed by value are not changed. This is called by the worker that is executing the remote function. Args: ...
378,615
def spline_base1d(length, nr_knots = 20, spline_order = 5, marginal = None): if marginal is None: knots = augknt(np.linspace(0,length+1, nr_knots), spline_order) else: knots = knots_from_marginal(marginal, nr_knots, spline_order) x_eval = np.arange(1,length+1).astype(float) ...
Computes a 1D spline basis Input: length: int length of each basis nr_knots: int Number of knots, i.e. number of basis functions. spline_order: int Order of the splines. marginal: array, optional Estimate of the marginal distribut...
378,616
def add(self, url: str, anything: Any) -> None: url = normalize_url(url) parts = url.split() curr_partial_routes = self._routes curr_key_parts = [] for part in parts: if part.startswith(): curr_key_parts.append(part[2:]) part ...
Register a URL pattern into\ the routes for later matching. It's possible to attach any kind of\ object to the pattern for later\ retrieving. A dict with methods and callbacks,\ for example. Anything really. Registration order does not matter.\ Adding a URL firs...
378,617
def write_stream (stream, holders, defaultsection=None): anybefore = False for h in holders: if anybefore: print (, file=stream) s = h.get (, defaultsection) if s is None: raise ValueError ( % h) print ( % s, file=stream) for k in sorted (x...
Very simple writing in ini format. The simple stringification of each value in each Holder is printed, and no escaping is performed. (This is most relevant for multiline values or ones containing pound signs.) `None` values are skipped. Arguments: stream A text stream to write to. holder...
378,618
def precess_coordinates(ra, dec, epoch_one, epoch_two, jd=None, mu_ra=0.0, mu_dec=0.0, outscalar=False): s VARTOOLS/converttime.c [coordprecess]. Parameters ---------- ra,dec : f...
Precesses target coordinates `ra`, `dec` from `epoch_one` to `epoch_two`. This takes into account the jd of the observations, as well as the proper motion of the target mu_ra, mu_dec. Adapted from J. D. Hartman's VARTOOLS/converttime.c [coordprecess]. Parameters ---------- ra,dec : float ...
378,619
def rr_history(self, ips): api_name = fmt_url_path = u return self._multi_get(api_name, fmt_url_path, ips)
Get the domains related to input ips. Args: ips: an enumerable of strings as ips Returns: An enumerable of resource records and features
378,620
def install(zone, nodataset=False, brand_opts=None): ** ret = {: True} res = __salt__[](.format( zone=zone, nodataset= if nodataset else , brand_opts=.format(brand_opts) if brand_opts else , )) ret[] = res[] == 0 ret[] = res[] if ret[] else res[] ret[] = ret[].r...
Install the specified zone from the system. zone : string name of the zone nodataset : boolean do not create a ZFS file system brand_opts : string brand specific options to pass CLI Example: .. code-block:: bash salt '*' zoneadm.install dolores salt '*' zo...
378,621
def user_choice(prompt, choices=("yes", "no"), default=None): assert default is None or default in choices choice_list = .join((choice.title() if choice == default else choice for choice in choices)) response = None while response not in choices: response = input(prompt + + choice_list + )...
Prompts the user for confirmation. The default value, if any, is capitalized. :param prompt: Information to display to the user. :param choices: an iterable of possible choices. :param default: default choice :return: the user's choice
378,622
def execute_migrations(self, show_traceback=True): all_migrations = get_pending_migrations(self.path, self.databases) if not len(all_migrations): sys.stdout.write("There are no migrations to apply.\n") for db, migrations in all_migrations.iteritems(): ...
Executes all pending migrations across all capable databases
378,623
def import_module(path): mod = __import__(path, locals={}, globals={}) for item in path.split()[1:]: try: mod = getattr(mod, item) except AttributeError: raise ImportError( % path) return mod
Import a module given a dotted *path* in the form of ``.name(.name)*``, and returns the last module (unlike ``__import__`` which just returns the first module). :param path: The dotted path to the module.
378,624
def all_cities(): cities = [] fname = pkg_resources.resource_filename(__name__, ) with open(fname, ) as csvfile: reader = csv.reader(csvfile, delimiter = ) for row in reader: cities.append(row[0]) cities.sort() return cities
Get a list of all Backpage city names. Returns: list of city names as Strings
378,625
def sector_shift(self): header = self.source.header return header.mini_sector_shift if self._is_mini \ else header.sector_shift
Property with current sector size shift. Actually sector size is 2 ** sector shift
378,626
def _extend_str(class_node, rvalue): code = dedent( ) code = code.format(rvalue=rvalue) fake = AstroidBuilder(MANAGER).string_build(code)["whatever"] for method in fake.mymethods(): method.parent = class_node method.lineno = None method.col_offset = None ...
function to extend builtin str/unicode class
378,627
def addcomment(accountable, body): r = accountable.issue_add_comment(body) headers = sorted([, , ]) rows = [[v for k, v in sorted(r.items()) if k in headers]] rows.insert(0, headers) print_table(SingleTable(rows))
Add a comment to the given issue key. Accepts a body argument to be used as the comment's body.
378,628
def insert_child(self, child_pid, index=-1): self._check_child_limits(child_pid) if index is None: index = -1 try: with db.session.begin_nested(): if not isinstance(child_pid, PersistentIdentifier): child_pid = resolve_pid(chil...
Insert a new child into a PID concept. Argument 'index' can take the following values: 0,1,2,... - insert child PID at the specified position -1 - insert the child PID at the last position None - insert child without order (no re-ordering is done) NOTE: If 'inde...
378,629
def uri(self): if self._uds_path: uri = % (quote_plus(self._uds_path),) else: uri = % (format_addr(self._address),) return uri + if self._ssl else uri
Connection string to pass to `~pymongo.mongo_client.MongoClient`.
378,630
def get_authors(self, language): return self.gettext(language, self._author) if self._author else ""
Return the list of this task's authors
378,631
def get_last_scene_id(self, refresh=False): if refresh: self.refresh_complex_value() self.refresh_complex_value() val = self.get_complex_value() or self.get_complex_value() return val
Get last scene id. Refresh data from Vera if refresh is True, otherwise use local cache. Refresh is only needed if you're not using subscriptions.
378,632
def copyVarStatesFrom(self, particleState, varNames): self.permuteVars[varName].resetVelocity(self._rng)
Copy specific variables from particleState into this particle. Parameters: -------------------------------------------------------------- particleState: dict produced by a particle's getState() method varNames: which variables to copy
378,633
def byte_to_channels(self, byte): assert isinstance(byte, int) assert byte >= 0 assert byte < 256 result = [] for offset in range(0, 8): if byte & (1 << offset): result.append(offset + 1) return result
:return: list(int)
378,634
def index(path=None): payload = { "username": "soandso", "message": "Hello bot", "vars": { "name": "Soandso", } } return Response(r.format(json.dumps(payload)), mimetype="text/plain")
On all other routes, just return an example `curl` command.
378,635
def result_to_dict(raw_result): result = {} for channel_index, channel in enumerate(raw_result): channel_id, channel_name = channel[0], channel[1] channel_result = { : channel_id, : channel_name, : [] } for movie in channel[2]: ...
Parse raw result from fetcher into readable dictionary Args: raw_result (dict) - raw data from `fetcher` Returns: dict - readable dictionary
378,636
def run(self) -> None: if self.loop is None: return create_server = asyncio.ensure_future(self._run(), loop=self.loop) try: self.loop.run_until_complete(create_server) self.loop.run_until_complete(self._check_alive()) finally: se...
创建了 sock 的运行回调
378,637
def sbar(Ss): if type(Ss) == list: Ss = np.array(Ss) npts = Ss.shape[0] Ss = Ss.transpose() avd, avs = [], [] D = np.array([Ss[0], Ss[1], Ss[2], Ss[3] + 0.5 * (Ss[0] + Ss[1]), Ss[4] + 0.5 * (Ss[1] + Ss[2]), Ss[5] + 0.5 * (Ss[0] + Ss[2])]) for j in range(6): ...
calculate average s,sigma from list of "s"s.
378,638
def error_asymptotes(pca,**kwargs): ax = kwargs.pop("ax",current_axes()) lon,lat = pca.plane_errors(, n=1000) ax.plot(lon,lat,) lon,lat = pca.plane_errors(, n=1000) ax.plot(lon,lat,) ax.plane(*pca.strike_dip())
Plots asymptotic error bounds for hyperbola on a stereonet.
378,639
def __get_constants(self): helper = ConstantClass(self._constants_class_name, self._io) helper.reload() constants = helper.constants() for name, value in constants.items(): self._add_replace_pair(name, value, True) self._io.text(. form...
Gets the constants from the class that acts like a namespace for constants and adds them to the replace pairs.
378,640
def console_print(con: tcod.console.Console, x: int, y: int, fmt: str) -> None: lib.TCOD_console_printf(_console(con), x, y, _fmt(fmt))
Print a color formatted string on a console. Args: con (Console): Any Console instance. x (int): Character x position from the left. y (int): Character y position from the top. fmt (AnyStr): A unicode or bytes string optionaly using color codes. .. deprecated:: 8.5 Use ...
378,641
def _show_or_dump(self, dump=False, indent=3, lvl="", label_lvl="", first_call=True): if dump: from scapy.themes import AnsiColorTheme ct = AnsiColorTheme() else: ct = conf.color_theme s = "%s%s %s %s \n" % (label_lvl, ...
Internal method that shows or dumps a hierarchical view of a packet. Called by show. :param dump: determine if it prints or returns the string value :param int indent: the size of indentation for each layer :param str lvl: additional information about the layer lvl :param str la...
378,642
def view_include(view_module, namespace=None, app_name=None): view_dict = defaultdict(list) if isinstance(view_module, six.string_types): view_module = importlib.import_module(view_module) for member_name, member in inspect.getmembers(view_module): is_class_view = insp...
Includes view in the url, works similar to django include function. Auto imports all class based views that are subclass of ``URLView`` and all functional views that have been decorated with ``url_view``. :param view_module: object of the module or string with importable path :param namespace: name of ...
378,643
def ParseOptions(cls, options, config_object, category=None, names=None): for helper_name, helper_class in cls._helper_classes.items(): if ((category and helper_class.CATEGORY != category) or (names and helper_name not in names)): continue try: helper_class.ParseOptions(o...
Parses and validates arguments using the appropriate helpers. Args: options (argparse.Namespace): parser options. config_object (object): object to be configured by an argument helper. category (Optional[str]): category of helpers to apply to the group, such as storage, output, where No...
378,644
def update_check(self, entity, check, label=None, name=None, disabled=None, metadata=None, monitoring_zones_poll=None, timeout=None, period=None, target_alias=None, target_hostname=None, target_receiver=None): entity.update_check(check, label=label, name=name, disabl...
Updates an existing check with any of the parameters.
378,645
def ucas_download_playlist(url, output_dir = , merge = False, info_only = False, **kwargs): html = get_content(url) parts = re.findall( r, html) assert parts, for part_path in parts: ucas_download( + part_path, output_dir=output_dir, merge=merge, info_only=info_only)
course page
378,646
def memoized_method(method=None, cache_factory=None): if method is None: return lambda f: memoized_method(f, cache_factory=cache_factory) cache_factory = cache_factory or dict @wraps(method) def memoized_method_property(self): cache = cache_factory() cache_attr = "_%s_cac...
Memoize a class's method. Arguments are similar to to `memoized`, except that the cache container is specified with `cache_factory`: a function called with no arguments to create the caching container for the instance. Note that, unlike `memoized`, the result cache will be stored on the instance, ...
378,647
def _handle_log_rotations(self): s log file if necessary ' for h in self.capture_handlers: if self._should_rotate_log(h): self._rotate_log(h)
Rotate each handler's log file if necessary
378,648
def get(session, api_key, **kwargs): args, kwargs = validate_args(api_key, **kwargs) resp = session.get(*args, **kwargs) return WeatherAnswer.validate(resp.json())
Выполняет доступ к API. session - модуль requests или сессия из него api_key - строка ключа доступа к API rate - тариф, может быть `informers` или `forecast` lat, lon - широта и долгота ``` import yandex_weather_api import requests as req yandex_weather_api.get(req, "ЗАМЕНИ_МЕНЯ_КЛЮЧО...
378,649
def _check_conflict(cls, dirPath, name): old_sys_path = sys.path try: sys.path = [d for d in old_sys_path if os.path.realpath(d) != os.path.realpath(dirPath)] try: colliding_module = importlib.import_module(name) except ImportError: ...
Check whether the module of the given name conflicts with another module on the sys.path. :param dirPath: the directory from which the module was originally loaded :param name: the mpdule name
378,650
def get_netloc_and_auth(self, netloc, scheme): if scheme == : return super(Subversion, self).get_netloc_and_auth( netloc, scheme) return split_auth_from_netloc(netloc)
This override allows the auth information to be passed to svn via the --username and --password options instead of via the URL.
378,651
def encode(i, *, width=-1): if i < 0: raise ValueError("value is negative") assert width != 0 data = bytearray() while i: data.append(i & 127) i >>= 7 if width > 0 and len(data) > width: raise ValueError("Integer too large"...
Encodes a nonnegative integer into syncsafe format When width > 0, then len(result) == width When width < 0, then len(result) >= abs(width)
378,652
def readline(self, size=-1): if size == 0: return self.string_type() index = self.expect([self.crlf, self.delimiter]) if index == 0: return self.before + self.crlf else: return self.before
This reads and returns one entire line. The newline at the end of line is returned as part of the string, unless the file ends without a newline. An empty string is returned if EOF is encountered immediately. This looks for a newline as a CR/LF pair (\\r\\n) even on UNIX because this is ...
378,653
def verify_chunks(self, chunks): err = [] for chunk in chunks: err.extend(self.verify_data(chunk)) return err
Verify the chunks in a list of low data structures
378,654
def load_config(self, argv=None, aliases=None, flags=None): self.clear() if argv is None: argv = self.argv if aliases is None: aliases = self.aliases if flags is None: flags = self.flags self._create_parser(aliases, flags) self...
Parse command line arguments and return as a Config object. Parameters ---------- args : optional, list If given, a list with the structure of sys.argv[1:] to parse arguments from. If not given, the instance's self.argv attribute (given at construction time) is us...
378,655
def p_rst(p): val = p[2].eval() if val not in (0, 8, 16, 24, 32, 40, 48, 56): error(p.lineno(1), % val) p[0] = None return p[0] = Asm(p.lineno(1), % val)
asm : RST expr
378,656
def del_calc(db, job_id, user): job_id = int(job_id) dependent = db( , job_id) if dependent: return {"error": % (job_id, [j.id for j in dependent])} try: owner, path = db(, job_id, one=True) except NotFound: ...
Delete a calculation and all associated outputs, if possible. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: job ID, can be an integer or a string :param user: username :returns: None if everything went fine or an error message
378,657
def _build(self, inputs): shape_inputs = inputs.get_shape().as_list() rank = len(shape_inputs) full_multiples = [1] * rank for dim, multiple in zip(self._dims, self._multiples): full_multiples[dim] = multiple return tf.tile(inputs, multiples=full_multiples)
Connects the `TileByDim` module into the graph. Args: inputs: `Tensor` to tile. Returns: The tiled tensor.
378,658
def combine_action_handlers(*handlers): for handler in handlers: if not (iscoroutinefunction(handler) or iscoroutine(handler)): raise ValueError("Provided handler is not a coroutine: %s" % handler) async def combined_handler(*args, **kwds): ...
This function combines the given action handlers into a single function which will call all of them.
378,659
def unpack_binary(self, offset, length=False): if not length: return bytes("".encode("ascii")) o = self._offset + offset try: return bytes(struct.unpack_from("<{}s".format(length), self._buf, o)[0]) except struct.error: raise OverrunBufferExce...
Returns raw binary data from the relative offset with the given length. Arguments: - `offset`: The relative offset from the start of the block. - `length`: The length of the binary blob. If zero, the empty string zero length is returned. Throws: - `OverrunBufferExcept...
378,660
def get_deffacts(self): return sorted(self._get_by_type(DefFacts), key=lambda d: d.order)
Return the existing deffacts sorted by the internal order
378,661
def finish(self): if self.finished: return self.exit_code checkpoint_status = self.checkpoint() self.exit_code = self._exit_code() if self.exit_code != 0: raise TeradataPTError("BulkLoad job finished with return code ".format(self.exit_code)) ...
Finishes the load job. Called automatically when the connection closes. :return: The exit code returned when applying rows to the table
378,662
def defer_sync(self, func): latch = Latch() def wrapper(): try: latch.put(func()) except Exception: latch.put(sys.exc_info()[1]) self.defer(wrapper) res = latch.get() if isinstance(res, Exception): raise...
Arrange for `func()` to execute on :class:`Broker` thread, blocking the current thread until a result or exception is available. :returns: Return value of `func()`.
378,663
def master_callback(self, m, master): sysid = m.get_srcSystem() mtype = m.get_type() if sysid in self.mpstate.sysid_outputs: self.mpstate.sysid_outputs[sysid].write(m.get_msgbuf()) if mtype == "GLOBAL_POSITION_INT": for modname in , , , ...
process mavlink message m on master, sending any messages to recipients
378,664
def _templated(fn): @functools.wraps(fn) def inner(ctl): return [i.format(**ctl) for i in fn(ctl)] return inner
Return a function which applies ``str.format(**ctl)`` to all results of ``fn(ctl)``.
378,665
def get_snippet(self, snippet_id, timeout=None): return self._api_request( self.SNIPPET_ENDPOINT % (snippet_id), self.HTTP_GET, timeout=timeout )
API call to get a specific Snippet
378,666
def getlist(self, name: str, default: Any = None) -> List[Any]: return super().get(name, default)
Return the entire list
378,667
def accuracy(conf_matrix): total, correct = 0.0, 0.0 for true_response, guess_dict in conf_matrix.items(): for guess, count in guess_dict.items(): if true_response == guess: correct += count total += count return correct/total
Given a confusion matrix, returns the accuracy. Accuracy Definition: http://research.ics.aalto.fi/events/eyechallenge2005/evaluation.shtml
378,668
def writeln(self, string=, *args, **kwargs): self.write(string + , *args, **kwargs) self.on_new_line = True self.current_indent += 1 self.auto_added_line = False
Writes a string into the source code _and_ appends a new line, applying indentation if required
378,669
def get_rms(self): return np.sqrt(np.mean(np.square(self._entry_scores)))
Gets the root mean square of the score. If this system is based on grades, the RMS of the output score is returned. return: (decimal) - the median score *compliance: mandatory -- This method must be implemented.*
378,670
def result_pretty(self, number_of_runs=0, time_str=None, fbestever=None): if fbestever is None: fbestever = self.best.f s = ( + ( if number_of_runs > 1 else )) \ % number_of_runs if number_of_runs else for k, v in self.stop().items(): ...
pretty print result. Returns ``self.result()``
378,671
def save(self, *args, **kwargs): self._pre_save(*args, **kwargs) response = self._save(*args, **kwargs) response = self._post_save(response, *args, **kwargs) return response
saves creates or updates current resource returns new resource
378,672
def String(self, str): ret = libxml2mod.xmlTextReaderConstString(self._o, str) return ret
Get an interned string from the reader, allows for example to speedup string name comparisons
378,673
def delete_instance(self, instance_id, project_id=None): instance = self._get_client(project_id=project_id).instance(instance_id) try: instance.delete() return except GoogleAPICallError as e: self.log.error(, e.message) raise e
Deletes an existing Cloud Spanner instance. :param instance_id: The ID of the Cloud Spanner instance. :type instance_id: str :param project_id: Optional, the ID of the GCP project that owns the Cloud Spanner database. If set to None or missing, the default project_id from the GCP co...
378,674
def unpack_shards(shards, stream_arn, session): if not shards: return {} if "ShardId" in shards[0]: shards = _translate_shards(shards) by_id = {shard_token["shard_id"]: Shard(stream_arn=stream_arn, shard_id=shard_token["shard_id"], iterator_ty...
List[Dict] -> Dict[shard_id, Shard]. Each Shards' parent/children are hooked up with the other Shards in the list.
378,675
def extract(self, destination, format=, csv_delimiter=None, csv_header=True, compress=False): job = self.extract_async(destination, format=format, csv_delimiter=csv_delimiter, csv_header=csv_header, compress=compress) if job is not None: job.wait() return job
Exports the table to GCS; blocks until complete. Args: destination: the destination URI(s). Can be a single URI or a list. format: the format to use for the exported data; one of 'csv', 'json', or 'avro' (default 'csv'). csv_delimiter: for CSV exports, the field delimiter to use. Defaul...
378,676
def delete(event, saltenv=, test=None): salt/cloud/*/destroyed sevent = salt.utils.event.get_event( , __opts__[], __opts__[], opts=__opts__, listen=True) master_key = salt.utils.master.get_master_key(, __opts__) __jid_event__.fire_event({: ev...
Delete a reactor CLI Example: .. code-block:: bash salt-run reactor.delete 'salt/cloud/*/destroyed'
378,677
def auth_recv(self): id_r = auth_data = None for p in self.packets[-1].payloads: if p._type == payloads.Type.IDr: id_r = p logger.debug(.format(dump(bytes(p)))) if p._type == payloads.Type.AUTH: auth_data = p._data ...
Handle peer's IKE_AUTH response.
378,678
def connect_array(self, address, connection_key, connection_type, **kwargs): data = {"management_address": address, "connection_key": connection_key, "type": connection_type} data.update(kwargs) return self._request("POST", "array/connection", data)
Connect this array with another one. :param address: IP address or DNS name of other array. :type address: str :param connection_key: Connection key of other array. :type connection_key: str :param connection_type: Type(s) of connection desired. :type connection_type: li...
378,679
def write_sources_list(url, codename, filename=, mode=0o644): repo_path = os.path.join(, filename) content = .format( url=url, codename=codename, ) write_file(repo_path, content.encode(), mode)
add deb repo to /etc/apt/sources.list.d/
378,680
def update_context(self, context, update_mask=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): if not in self...
Updates the specified context. Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.ContextsClient() >>> >>> # TODO: Initialize ``context``: >>> context = {} >>> >>> response = client.update_context(cont...
378,681
def comunicar_certificado_icpbrasil(self, certificado): resp = self._http_post(, certificado=certificado) conteudo = resp.json() return RespostaSAT.comunicar_certificado_icpbrasil( conteudo.get())
Sobrepõe :meth:`~satcfe.base.FuncoesSAT.comunicar_certificado_icpbrasil`. :return: Uma resposta SAT padrão. :rtype: satcfe.resposta.padrao.RespostaSAT
378,682
def get_driver(self): driver = self.__get_driver_for_channel(self.__get_channel()) if driver is None: driver = self.new_driver() return driver
Get an already running instance of Webdriver. If there is none, it will create one. Returns: Webdriver - Selenium Webdriver instance. Usage:: driver = WTF_WEBDRIVER_MANAGER.new_driver() driver.get("http://the-internet.herokuapp.com") same_driver = WTF_W...
378,683
def _child(details): if isinstance(details, list): return OptionsNode(details) elif isinstance(details, dict): if in details: return ArrayNode(details) elif in details: return HashNode(details) elif in details: if isinstance(details[], (dict,list)): return _child(d...
Child A private function to figure out the child node type Arguments: details {dict} -- A dictionary describing a data point Returns: _NodeInterface
378,684
def _get_type(self, policy): if isinstance(policy, string_types) or is_instrinsic(policy): return PolicyTypes.MANAGED_POLICY if isinstance(policy, dict) and "Statement" in policy: return PolicyTypes.POLICY_STATEMENT if self...
Returns the type of the given policy :param string or dict policy: Policy data :return PolicyTypes: Type of the given policy. None, if type could not be inferred
378,685
def _do_read_config(self, config_file, pommanipext): parser = InterpolationConfigParser() dataset = parser.read(config_file) if config_file not in dataset: raise IOError("Config file %s not found." % config_file) if parser.has_option(,): include = parser....
Reads config for a single job defined by section.
378,686
def list_(bank): redis_server = _get_redis_server() bank_redis_key = _get_bank_redis_key(bank) try: banks = redis_server.smembers(bank_redis_key) except (RedisConnectionError, RedisResponseError) as rerr: mesg = .format(rkey=bank_redis_key, ...
Lists entries stored in the specified bank.
378,687
def iterator_cycle(variables: VarType, parent: str) -> Iterable[VarMatrix]: if isinstance(variables, dict): if variables.get("times"): times = int(variables["times"]) del variables["times"] yield list(variable_matrix(variables, parent, "product")) * times e...
Cycle through a list of values a specified number of times Args: variables: The input variables for the creation of the range parent: The variable for which the values are being generated. Returns: A list of dictionaries mapping the parent to each value.
378,688
async def debug_create_unit(self, unit_spawn_commands: List[List[Union[UnitTypeId, int, Point2, Point3]]]): assert isinstance(unit_spawn_commands, list) assert unit_spawn_commands assert isinstance(unit_spawn_commands[0], list) assert len(unit_spawn_commands[0]) == 4 ass...
Usage example (will spawn 1 marine in the center of the map for player ID 1): await self._client.debug_create_unit([[UnitTypeId.MARINE, 1, self._game_info.map_center, 1]])
378,689
def get_xml_type(val): if type(val).__name__ in (, ): return if type(val).__name__ in (, ): return if type(val).__name__ == : return if type(val).__name__ == : return if isinstance(val, numbers.Number): return if type(val).__name__ == : r...
Returns the data type for the xml type attribute
378,690
def partition(pred, iterable): pos, neg = [], [] pos_append, neg_append = pos.append, neg.append for elem in iterable: if pred(elem): pos_append(elem) else: neg_append(elem) return neg, pos
Partition an iterable. Arguments --------- pred : function A function that takes an element of the iterable and returns a boolen indicating to which partition it belongs iterable : iterable Returns ------- A two-tuple of lists with the first list containin...
378,691
def _push_tag_buffer(self, data): if data.context & data.CX_QUOTED: self._emit_first(tokens.TagAttrQuote(char=data.quoter)) self._emit_all(self._pop()) buf = data.padding_buffer self._emit_first(tokens.TagAttrStart( pad_first=buf["first"], pad_before_...
Write a pending tag attribute from *data* to the stack.
378,692
def calcinds(data, threshold, ignoret=None): inds = [] for i in range(len(data[])): snr = data[][i] time = data[][i] if (threshold >= 0 and snr > threshold): if ignoret: incl = [t0 for (t0, t1) in ignoret if np.round(time).astype(int) in range(t0,t1)] ...
Find indexes for data above (or below) given threshold.
378,693
def activities(self, name=None, pk=None, scope=None, **kwargs): request_params = { : pk, : name, : scope } if self.match_app_version(label=, version=, default=False): request_params.update(API_EXTRA_PARAMS[]) ...
Search for activities with optional name, pk and scope filter. If additional `keyword=value` arguments are provided, these are added to the request parameters. Please refer to the documentation of the KE-chain API for additional query parameters. :param pk: id (primary key) of the activity to ...
378,694
def drop(self, index=None, columns=None): if self._is_transposed: return self.transpose().drop(index=columns, columns=index).transpose() if index is None: new_data = self.data new_index = self.index else: def delitem(df, internal_indices=...
Remove row data for target index and columns. Args: index: Target index to drop. columns: Target columns to drop. Returns: A new QueryCompiler.
378,695
def decrypt(self, ciphertext, encoder=encoding.RawEncoder): ciphertext = encoder.decode(ciphertext) plaintext = nacl.bindings.crypto_box_seal_open( ciphertext, self._public_key, self._private_key, ) return plaintext
Decrypts the ciphertext using the ephemeral public key enclosed in the ciphertext and the SealedBox private key, returning the plaintext message. :param ciphertext: [:class:`bytes`] The encrypted message to decrypt :param encoder: The encoder used to decode the ciphertext. :retu...
378,696
def _save(self): collection = JSONClientValidated(, collection=, runtime=self._runtime) if in self._my_map: collection.save(self._my_map) else: insert_result = collection.insert_...
Saves the current state of this AssessmentSection to database. Should be called every time the question map changes.
378,697
def init_instance(self, key): with self._mor_lock: if key not in self._mor: self._mor[key] = {}
Create an empty instance if it doesn't exist. If the instance already exists, this is a noop.
378,698
def _find_longest_parent_path(path_set, path): while path not in path_set: if not path: return None path = os.path.dirname(path) return path
Finds the longest "parent-path" of 'path' in 'path_set'. This function takes and returns "path-like" strings which are strings made of strings separated by os.sep. No file access is performed here, so these strings need not correspond to actual files in some file-system.. This function returns the longest ance...
378,699
def load(self, value): self.reset( value, validator=self.__dict__.get(), env=self.__dict__.get(), )
enforce env > value when loading from file