Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
387,700 | def list_networks(full_ids=False):
networks = docker_fabric().networks()
_format_output_table(networks, NETWORK_COLUMNS, full_ids) | Lists networks on the Docker remote host, similar to ``docker network ls``.
:param full_ids: Shows the full network ids. When ``False`` (default) only shows the first 12 characters.
:type full_ids: bool |
387,701 | def get_ssl_context(private_key, certificate):
if (
certificate
and os.path.isfile(certificate)
and private_key
and os.path.isfile(private_key)
):
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context.load_cert_chain(certificate, private_key)
return ... | Get ssl context from private key and certificate paths.
The return value is used when calling Flask.
i.e. app.run(ssl_context=get_ssl_context(,,,)) |
387,702 | def stop(self):
should_sleep = self._is_running
super(Sensor, self).stop()
if should_sleep:
time.sleep(max(self._select_timeout, self._retransmit_timeout) + 1)
if self._listen_socket is not None:
self._shutdown_listen_socket() | Stop the interface
:rtype: None |
387,703 | def check_frequencies(pfeed, *, as_df=False, include_warnings=False):
table =
problems = []
if pfeed.frequencies is None:
problems.append([, , table, []])
else:
f = pfeed.frequencies.copy()
problems = check_for_required_columns(problems, table, f)
if problems:
... | Check that ``pfeed.frequency`` follows the ProtoFeed spec.
Return a list of problems of the form described in
:func:`gt.check_table`;
the list will be empty if no problems are found. |
387,704 | def get_changesets(self, start=None, end=None, start_date=None,
end_date=None, branch_name=None, reverse=False):
start_raw_id = self._get_revision(start)
start_pos = self.revisions.index(start_raw_id) if start else None
end_raw_id = self._get_revision(end)
... | Returns iterator of ``MercurialChangeset`` objects from start to end
(both are inclusive)
:param start: None, str, int or mercurial lookup format
:param end: None, str, int or mercurial lookup format
:param start_date:
:param end_date:
:param branch_name:
:param... |
387,705 | def _prepare_hiveconf(d):
if not d:
return []
return as_flattened_list(
zip(["-hiveconf"] * len(d),
["{}={}".format(k, v) for k, v in d.items()])
) | This function prepares a list of hiveconf params
from a dictionary of key value pairs.
:param d:
:type d: dict
>>> hh = HiveCliHook()
>>> hive_conf = {"hive.exec.dynamic.partition": "true",
... "hive.exec.dynamic.partition.mode": "nonstrict"}
>>> hh._prepare_hiv... |
387,706 | def main():
if in sys.argv:
print(main.__doc__)
sys.exit()
if in sys.argv:
while 1:
try:
ans=input("Input Pole Latitude [positive north]: <cntrl-D to quit> ")
plat=float(ans)
ans=input("Input Pole Longitude [positive ... | NAME
vgp_di.py
DESCRIPTION
converts site latitude, longitude and pole latitude, longitude to declination, inclination
SYNTAX
vgp_di.py [-h] [-i] [-f FILE] [< filename]
OPTIONS
-h prints help message and quits
-i interactive data entry
-f FILE to specif... |
387,707 | def get_load(jid):
jid_dir = salt.utils.jid.jid_dir(jid, _job_dir(), __opts__[])
load_fn = os.path.join(jid_dir, LOAD_P)
if not os.path.exists(jid_dir) or not os.path.exists(load_fn):
return {}
serial = salt.payload.Serial(__opts__)
ret = {}
load_p = os.path.join(jid_dir, LOAD_P)
... | Return the load data that marks a specified jid |
387,708 | def get_timeout(self):
"setup a timeout for waiting for a proposal"
if self.timeout_time is not None or self.proposal:
return
now = self.cm.chainservice.now
round_timeout = ConsensusManager.round_timeout
round_timeout_factor = ConsensusManager.round_timeout_factor
... | setup a timeout for waiting for a proposal |
387,709 | def write_temp_file(self, content, filename=None, mode=):
if filename is None:
filename = str(uuid.uuid4())
fqpn = os.path.join(self.tcex.default_args.tc_temp_path, filename)
with open(fqpn, mode) as fh:
fh.write(content)
return fqpn | Write content to a temporary file.
Args:
content (bytes|str): The file content. If passing binary data the mode needs to be set
to 'wb'.
filename (str, optional): The filename to use when writing the file.
mode (str, optional): The file write mode which could... |
387,710 | def all_notebook_jobs(self):
from db.models.notebooks import NotebookJob
return NotebookJob.all.filter(project=self) | Similar to notebook_jobs,
but uses the default manager to return archived experiments as well. |
387,711 | def simxGetArrayParameter(clientID, paramIdentifier, operationMode):
paramValues = (ct.c_float*3)()
ret = c_GetArrayParameter(clientID, paramIdentifier, paramValues, operationMode)
arr = []
for i in range(3):
arr.append(paramValues[i])
return ret, arr | Please have a look at the function description/documentation in the V-REP user manual |
387,712 | def get_notifications(self, startDate, endDate, loadBalancerID, loadBalancerRuleID):
return self._call(GetLoadBalancerNotifications, startDate=startDate, endDate=endDate,
loadBalancerID=loadBalancerID, loadBalancerRuleID=loadBalancerRuleID) | Get the load balancer notifications for a specific rule within a specifying window time frame
:type startDate: datetime
:type endDate: datetime
:type loadBalancerID: int
:type loadBalancerRuleID: int
:param startDate: From Date
:param endDate: To Date
:param loadB... |
387,713 | def merge_with(self, other, multiset_op, other_op=None):
result = FeatureCollection()
for ms_name in set(self._counters()) | set(other._counters()):
c1 = self.get(ms_name, None)
c2 = other.get(ms_name, None)
if c1 is None and c2 is not None:
c... | Merge this feature collection with another.
Merges two feature collections using the given ``multiset_op``
on each corresponding multiset and returns a new
:class:`FeatureCollection`. The contents of the two original
feature collections are not modified.
For each feature name i... |
387,714 | def convergence_from_grid(self, grid):
surface_density_grid = np.zeros(grid.shape[0])
grid_eta = self.grid_to_elliptical_radii(grid)
for i in range(grid.shape[0]):
surface_density_grid[i] = self.convergence_func(grid_eta[i])
return surface_density_grid | Calculate the projected convergence at a given set of arc-second gridded coordinates.
Parameters
----------
grid : grids.RegularGrid
The grid of (y,x) arc-second coordinates the surface density is computed on. |
387,715 | def load_isd_daily_temp_data(
self, start, end, read_from_cache=True, write_to_cache=True
):
return load_isd_daily_temp_data(
self.usaf_id,
start,
end,
read_from_cache=read_from_cache,
write_to_cache=write_to_cache,
) | Load resampled daily ISD temperature data from start date to end date (inclusive).
This is the primary convenience method for loading resampled daily ISD temperature data.
Parameters
----------
start : datetime.datetime
The earliest date from which to load data.
end... |
387,716 | def export_to_dicts(table, *args, **kwargs):
field_names = table.field_names
return [{key: getattr(row, key) for key in field_names} for row in table] | Export a `rows.Table` to a list of dicts |
387,717 | def handle_selected_page(self):
if not self.selected_page:
pass
if self.selected_page.name in (, ):
self.selected_page = self.selected_page.loop()
elif self.selected_page.name in (, ):
self.active = False
else:
... | Open the subscription and submission pages subwindows, but close the
current page if any other type of page is selected. |
387,718 | def delete_ec2_nodes(
instance_id_list,
client=None
):
if not client:
client = boto3.client()
resp = client.terminate_instances(
InstanceIds=instance_id_list
)
return resp | This deletes EC2 nodes and terminates the instances.
Parameters
----------
instance_id_list : list of str
A list of EC2 instance IDs to terminate.
client : boto3.Client or None
If None, this function will instantiate a new `boto3.Client` object to
use in its operations. Altern... |
387,719 | def _make_repr_table_from_sframe(X):
assert isinstance(X, _SFrame)
column_names = X.column_names()
out_data = [ [None]*len(column_names) for i in range(X.num_rows())]
column_sizes = [len(s) for s in column_names]
for i, c in enumerate(column_names):
for j, e in enumerate(X[c]):
... | Serializes an SFrame to a list of strings, that, when printed, creates a well-formatted table. |
387,720 | def state(self):
state = self._resource.get(, self.default_state)
if state in State:
return state
else:
return getattr(State, state) | Get the Document's state |
387,721 | def _check_connection(self):
try:
super()._check_connection()
except OSError as exc:
_LOGGER.error(exc)
self.protocol.transport.close()
self.protocol.conn_lost_callback()
return
task = self.loop.call_later(
self.rec... | Check if connection is alive every reconnect_timeout seconds. |
387,722 | def __create_coordinates(self, lat, lon, elev):
lat.sort()
lon.sort()
geo_dict = {}
if len(lat) == 2 and len(lon) == 2:
if lat[0] == lat[1] and lon[0] == lon[1]:
logger_noaa_lpd.info("coordinates found: {}".format("2"))
... | GeoJSON standard:
Use to determine 2-point or 4-point coordinates
:param list lat:
:param list lon:
:return dict: |
387,723 | def predict(self):
RV = np.zeros((self.N,self.P))
for term_i in range(self.n_terms):
RV+=np.dot(self.Fstar()[term_i],np.dot(self.B()[term_i],self.Astar()[term_i]))
return RV | predict the value of the fixed effect |
387,724 | def relative_datetime(self):
now = datetime.now(timezone.utc)
tense = "from now" if self.created_at > now else "ago"
return "{0} {1}".format(humanize.naturaldelta(now - self.created_at), tense) | Return human-readable relative time string. |
387,725 | def plot_evec(fignum, Vs, symsize, title):
plt.figure(num=fignum)
plt.text(-1.1, 1.15, title)
symb, symkey = [, , ], 0
col = [, , ]
for VEC in range(3):
X, Y = [], []
for Vdirs in Vs:
XY = pmag.dimap(Vdirs[V... | plots eigenvector directions of S vectors
Paramters
________
fignum : matplotlib figure number
Vs : nested list of eigenvectors
symsize : size in pts for symbol
title : title for plot |
387,726 | def generate_ppi_network(
ppi_graph_path: str,
dge_list: List[Gene],
max_adj_p: float,
max_log2_fold_change: float,
min_log2_fold_change: float,
ppi_edge_min_confidence: Optional[float] = None,
current_disease_ids_path: Optional[str] = None,
disease_associ... | Generate the protein-protein interaction network.
:return Network: Protein-protein interaction network with information on differential expression. |
387,727 | def get_authorization_user(self, **kwargs):
if self.authorization_user is not None:
return self.authorization_user
self.authorization_user = self.request.user
return self.request.user | Gets the user the authorization object is for. |
387,728 | def load_schema(schema_path):
try:
with open(schema_path) as schema_file:
schema = json.load(schema_file)
except ValueError as e:
raise SchemaInvalidError(
% (schema_file.name, str(e)))
return schema | Load the JSON schema at the given path as a Python object.
Args:
schema_path: A filename for a JSON schema.
Returns:
A Python object representation of the schema. |
387,729 | def _gzip_open_filename(handle):
import gzip
if sys.version_info[0] > 2:
handle = gzip.open(handle, mode=, encoding="UTF-8")
else:
handle = gzip.open(handle)
return handle | Hide Python 2 vs. 3 differences in gzip.open() |
387,730 | def get_as_bytes(self, s3_path):
(bucket, key) = self._path_to_bucket_and_key(s3_path)
obj = self.s3.Object(bucket, key)
contents = obj.get()[].read()
return contents | Get the contents of an object stored in S3 as bytes
:param s3_path: URL for target S3 location
:return: File contents as pure bytes |
387,731 | def _set_url(self, url):
original_url = self._url
try:
self._update_index(url)
except:
self._url = original_url
raise | Set a new URL for the data server. If we're unable to contact
the given url, then the original url is kept. |
387,732 | def playURI(self, uri):
url: str = get_url("/remote/play.json")
params = {
"oauth": self._oauth_token,
"csrf": self._csrf_token,
"uri": uri,
"context": uri,
}
r = self._request(url=url, params=params)
return r.json() | Play a Spotify uri, for example spotify:track:5Yn8WCB4Dqm8snemB5Mu4K
:param uri: Playlist, Artist, Album, or Song Uri |
387,733 | def _op_msg_no_header(flags, command, identifier, docs, check_keys, opts):
encoded = _dict_to_bson(command, False, opts)
flags_type = _pack_op_msg_flags_type(flags, 0)
total_size = len(encoded)
max_doc_size = 0
if identifier:
type_one = _pack_byte(1)
cstring = _make_c_strin... | Get a OP_MSG message.
Note: this method handles multiple documents in a type one payload but
it does not perform batch splitting and the total message size is
only checked *after* generating the entire message. |
387,734 | def get_item_with_id(self, uid):
for item in self.get_items():
if item.id == uid:
return item
return None | Returns item for defined UID.
>>> book.get_item_with_id('image_001')
:Args:
- uid: UID for the item
:Returns:
Returns item object. Returns None if nothing was found. |
387,735 | def compare_and_set(self, expect, update):
with self._reference.get_lock():
if self._reference.value == expect:
self._reference.value = update
return True
return False | Atomically sets the value to `update` if the current value is equal to
`expect`.
:param expect: The expected current value.
:param update: The value to set if and only if `expect` equals the
current value. |
387,736 | def convert_sequence_to_motor_units(cycles, unit_converter):
return cv_cycles | Converts a move sequence to motor units.
Converts a move sequence to motor units using the provied converter.
Parameters
----------
cycles : iterable of dicts
The iterable of cycles of motion to do one after another. See
``compile_sequence`` for format.
unit_converter : UnitConvert... |
387,737 | def run_step(context):
logger.debug("started")
context.clear()
logger.info(f"Context wiped. New context size: {len(context)}")
logger.debug("done") | Wipe the entire context.
Args:
Context is a dictionary or dictionary-like.
Does not require any specific keys in context. |
387,738 | def hash(self):
return u.join([
self.alias,
self.description,
str(self.ignored),
str(self.flags),
]) | Return a value that's used to uniquely identify an entry in a date so we can regroup all entries that share the
same hash. |
387,739 | def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
ln_mean, [ln_stddev] = super().get_mean_and_stddevs(
sites, rup, dists, imt, stddev_types)
coeffs = self.COEFFS_UPPER[imt]
ln_mean += np.log(coeffs[])
return ln_mean, [ln_stddev... | See :meth:`superclass method
<.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
for specification of input and result values.
Implements the correction factor for the upper crust, equation (12) on
p. 484:
``P' = P x Correction_factor`` |
387,740 | def _truncated_power_method(self, A, x0, k, max_iter=10000, thresh=1e-8):
xts = [x0]
for t in range(max_iter):
xts.append(self._normalize(self._truncate(np.dot(A, xts[-1]), k)))
if np.linalg.norm(xts[-1] - xts[-2]) < thresh: break
return xts[-1] | given a matrix A, an initial guess x0, and a maximum cardinality k,
find the best k-sparse approximation to its dominant eigenvector
References
----------
[1] Yuan, X-T. and Zhang, T. "Truncated Power Method for Sparse Eigenvalue Problems."
Journal of Machine Learning Research. ... |
387,741 | def api_request(*args, **kwargs):
r = requests.request(*args, **kwargs)
return APIResponse(r) | Wrapper which converts a requests.Response into our custom APIResponse
object
:param args:
:param kwargs:
:return: |
387,742 | def reftrack_element_data(rt, role):
element = rt.get_element()
if element is None:
return
if role == QtCore.Qt.DisplayRole or role == QtCore.Qt.EditRole:
return element.name | Return the data for the element (e.g. the Asset or Shot)
:param rt: the :class:`jukeboxcore.reftrack.Reftrack` holds the data
:type rt: :class:`jukeboxcore.reftrack.Reftrack`
:param role: item data role
:type role: QtCore.Qt.ItemDataRole
:returns: data for the element
:rtype: depending on role
... |
387,743 | def list_tables(self):
lines = output_lines(self.exec_psql())
return [line.split() for line in lines] | Runs the ``\\dt`` command and returns a list of column values with
information about all tables in the database. |
387,744 | def fetch_next(self):
if not self._buffer_size() and self.alive:
return self._get_more()
elif self._buffer_size():
future = self._framework.get_future(self.get_io_loop())
future.set_result(True)
return future
else:
... | A Future used with `gen.coroutine`_ to asynchronously retrieve the
next document in the result set, fetching a batch of documents from the
server if necessary. Resolves to ``False`` if there are no more
documents, otherwise :meth:`next_object` is guaranteed to return a
document.
... |
387,745 | def attach_event_handler(canvas, handler=close_on_esc_or_middlemouse):
if getattr(canvas, "_py_event_dispatcher_attached", None):
return
event_dispatcher = C.TPyDispatcherProcessedEvent(handler)
canvas.Connect("ProcessedEvent(int,int,int,TObject*)",
"TPyDispatcherProcessedEv... | Attach a handler function to the ProcessedEvent slot, defaulting to
closing when middle mouse is clicked or escape is pressed
Note that escape only works if the pad has focus, which in ROOT-land means
the mouse has to be over the canvas area. |
387,746 | def visit_AsyncFunctionDef(self, node):
node = self.get_function_node(node)
if node is not None:
node._async = True | Visit an async function node. |
387,747 | def _load_isd_station_metadata(download_path):
from shapely.geometry import Point
isd_history = pd.read_csv(
os.path.join(download_path, "isd-history.csv"),
dtype=str,
parse_dates=["BEGIN", "END"],
)
hasGEO = (
isd_history.LAT.notnull() & isd_history.LON.notnu... | Collect metadata for US isd stations. |
387,748 | def QA_SU_save_stock_list(client=DATABASE, ui_log=None, ui_progress=None):
client.drop_collection()
coll = client.stock_list
coll.create_index()
try:
QA_util_log_info(
,
ui_log=ui_log,
ui_progress=ui_progress,
ui_progress_int_value=5... | save stock_list
Keyword Arguments:
client {[type]} -- [description] (default: {DATABASE}) |
387,749 | def upsert(manager, defaults=None, updates=None, **kwargs):
defaults = defaults or {}
defaults.update(updates or {})
obj, created = manager.get_or_create(defaults=defaults, **kwargs)
if updates is not None and not created and any(getattr(obj, k) != updates[k] for k in updates):
... | Performs an update on an object or an insert if the object does not exist.
:type defaults: dict
:param defaults: These values are set when the object is created, but are irrelevant
when the object already exists. This field should only be used when values only need to
be set during crea... |
387,750 | def printPre(self, *args):
if len(args):
self.b_printPre = args[0]
else:
return self.b_printPre | get/set the str_pre string. |
387,751 | def to_volume(self):
if hasattr(self.header.definitions, "Lattice"):
X, Y, Z = self.header.definitions.Lattice
else:
raise ValueError("Unable to determine data size")
volume = self.decoded_data.reshape(Z, Y, X)
return volume | Return a 3D volume of the data |
387,752 | def get(self, key, value):
for element in self.neoindex[key][value]:
if self.indexClass == "vertex":
yield Vertex(element)
elif self.indexClass == "edge":
yield Edge(element)
else:
raise TypeError(self.indexClass) | Gets an element from an index under a given
key-value pair
@params key: Index key string
@params value: Index value string
@returns A generator of Vertex or Edge objects |
387,753 | def sized_imap(func, iterable, strict=False):
try:
length = len(iterable)
except TypeError:
if strict:
raise
else:
return imap(func, iterable)
return SizedGenerator(lambda: imap(func, iterable), length=length) | Return an iterable whose elements are the result of applying the callable `func`
to each element of `iterable`. If `iterable` has a `len()`, then the iterable returned
by this function will have the same `len()`. Otherwise calling `len()` on the
returned iterable will raise `TypeError`.
:param func: Th... |
387,754 | def ingest_user(self):
if self.audit_trail and self.audit_trail.records \
and self.audit_trail.records[0].action == :
return self.audit_trail.records[0].user | Username responsible for ingesting this object into the repository,
as recorded in the :attr:`audit_trail`, if available. |
387,755 | def XYZ100_to_CIECAM02(self, XYZ100, on_negative_A="raise"):
XYZ100 = np.asarray(XYZ100, dtype=float)
if XYZ100.shape[-1] != 3:
raise ValueError("XYZ100 shape must be (..., 3)")
RGB = broadcasting_matvec(M_CAT02, XYZ100)
RGB_C = self.... | Computes CIECAM02 appearance correlates for the given tristimulus
value(s) XYZ (normalized to be on the 0-100 scale).
Example: ``vc.XYZ100_to_CIECAM02([30.0, 45.5, 21.0])``
:param XYZ100: An array-like of tristimulus values. These should be
given on the 0-100 scale, not the 0-1 scale... |
387,756 | def _iterate_uniqueness_keys(self, field):
uniqueness = getattr(field, , None)
if not uniqueness:
return
for keys in uniqueness:
composed_keys = self._compose_keys(keys)
yield composed_keys | Iterates over the keys marked as "unique"
in the specified field.
Arguments:
field:
The field of which key's to
iterate over. |
387,757 | def get_homes(self, query=None, gps_lat=None, gps_lng=None, offset=0, items_per_grid=8):
params = {
: ,
: ,
: ,
: str(offset),
: ,
: ,
: ,
: str(items_per_grid),
: ,
: ,
:... | Search listings with
* Query (e.g. query="Lisbon, Portugal") or
* Location (e.g. gps_lat=55.6123352&gps_lng=37.7117917) |
387,758 | def require_perms(view_func, required):
from horizon.exceptions import NotAuthorized
if required:
return dec
else:
return view_func | Enforces permission-based access controls.
:param list required: A tuple of permission names, all of which the request
user must possess in order access the decorated view.
Example usage::
from horizon.decorators import require_perms
@require_perms(['foo.admin', 'f... |
387,759 | def case_comments(self):
comments = (comment for comment in self.comments if
comment.variant_id is None)
return comments | Return only comments made on the case. |
387,760 | def export_olx(self, tarball, root_path):
def append_asset_to_soup_and_export(asset_):
if isinstance(asset_, Item):
try:
unique_url = asset_.export_olx(tarball, root_path)
except AttributeError:
pass
els... | if sequestered, only export the assets |
387,761 | def getDescendants(self, all_descendants=False):
children = self.getBackReferences(
"AnalysisRequestParentAnalysisRequest")
descendants = []
if all_descendants:
for child in children:
descendants.append(child... | Returns the descendant Analysis Requests
:param all_descendants: recursively include all descendants |
387,762 | def write_oplog_progress(self):
if self.oplog_checkpoint is None:
return None
with self.oplog_progress as oplog_prog:
oplog_dict = oplog_prog.get_dict()
items = [[name, util.bson_ts_to_long(oplog_dict[name])] for name in oplog_dict]
if not items:
... | Writes oplog progress to file provided by user |
387,763 | def execute(self, sources, target):
fields = self._get_fields_list_from_eps(sources)
ret_fields = fields[0]
if self.clear_feature:
ret_fields = list(self._remove_field_roles(ret_fields, set(six.iterkeys(self.field_mapping)),
... | :type sources: list[DFAdapter]
:type target: DFAdapter |
387,764 | def to_excess_returns(returns, rf, nperiods=None):
if type(rf) is float and nperiods is not None:
_rf = deannualize(rf, nperiods)
else:
_rf = rf
return returns - _rf | Given a series of returns, it will return the excess returns over rf.
Args:
* returns (Series, DataFrame): Returns
* rf (float, Series): `Risk-Free rate(s) <https://www.investopedia.com/terms/r/risk-freerate.asp>`_ expressed in annualized term or return series
* nperiods (int): Optional. If... |
387,765 | def create_environment_vip(self):
return EnvironmentVIP(
self.networkapi_url,
self.user,
self.password,
self.user_ldap) | Get an instance of environment_vip services facade. |
387,766 | def list(self, all_my_agents=False, limit=500, offset=0):
logger.info("list(all_my_agents=%s, limit=%s, offset=%s)", all_my_agents, limit, offset)
if all_my_agents:
evt = self._request_entity_list_all(limit=limit, offset=offset)
else:
evt = self._request_entity_l... | List `all` the things created by this client on this or all your agents
Returns QAPI list function payload
Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException)
if there is a communications problem between you and the infrastructure
`all_my_agents` (op... |
387,767 | def method(self, returns, **parameter_types):
@wrapt.decorator
def type_check_wrapper(method, instance, args, kwargs):
if instance is not None:
raise Exception("Instance shouldn't be set.")
parameter_names = inspect.getargspec(method).args ... | Syntactic sugar for registering a method
Example:
>>> registry = Registry()
>>> @registry.method(returns=int, x=int, y=int)
... def add(x, y):
... return x + y
:param returns: The method's return type
:type returns: type
:param param... |
387,768 | def register_callback_reassigned(self, func, serialised=True):
self.__client.register_callback_reassigned(partial(self.__callback_payload_only, func), serialised) | Register a callback for resource reassignment. This will be called when any resource
is reassigned to or from your agent.
If `serialised` is not set, the callbacks might arrive in a different order to they were requested.
The payload passed to your callback is an OrderedDict with the following... |
387,769 | def get_reset_data(self, data):
error = False
reset = None
msg = ""
user = self.database.users.find_one({"reset": data["reset"]})
if user is None:
error = True
msg = "Invalid reset hash."
else:
reset = {"hash": data["reset"], "... | Returns the user info to reset |
387,770 | def i2s_frameid(x):
try:
return PNIO_FRAME_IDS[x]
except KeyError:
pass
if 0x0100 <= x < 0x1000:
return "RT_CLASS_3 (%4x)" % x
if 0x8000 <= x < 0xC000:
return "RT_CLASS_1 (%4x)" % x
if 0xC000 <= x < 0xFC00:
return "RT_CLASS_UDP (%4x)" % x
if 0xFF80 <=... | Get representation name of a pnio frame ID
:param x: a key of the PNIO_FRAME_IDS dictionary
:returns: str |
387,771 | def do_work_spec(self, args):
work_spec_name = self._get_work_spec_name(args)
spec = self.task_master.get_work_spec(work_spec_name)
if args.json:
self.stdout.write(json.dumps(spec, indent=4, sort_keys=True) +
)
else:
yaml.saf... | dump the contents of an existing work spec |
387,772 | def start_capture(self, adapter_number, output_file):
try:
adapter = self._ethernet_adapters[adapter_number]
except KeyError:
raise VirtualBoxError("Adapter {adapter_number} doesn{name}bridge start_capture {name} "{output_file}"{name}' [{id}]: starting packet capture on... | Starts a packet capture.
:param adapter_number: adapter number
:param output_file: PCAP destination file for the capture |
387,773 | def _set_get_stp_brief_info(self, v, load=False):
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=get_stp_brief_info.get_stp_brief_info, is_leaf=True, yang_name="get-stp-brief-info", rest_name="get-stp-brief-info", parent=self, path_helper=self._path_helper, extmethods=sel... | Setter method for get_stp_brief_info, mapped from YANG variable /brocade_xstp_ext_rpc/get_stp_brief_info (rpc)
If this variable is read-only (config: false) in the
source YANG file, then _set_get_stp_brief_info is considered as a private
method. Backends looking to populate this variable should
do so vi... |
387,774 | def getScriptLocation():
location = os.path.abspath("./")
if __file__.rfind("/") != -1:
location = __file__[:__file__.rfind("/")]
return location | Helper function to get the location of a Python file. |
387,775 | def _expand_prefix_spec(self, spec, prefix = ):
if type(spec) is not dict:
raise NipapInputError()
for key in spec.keys():
if key not in _prefix_spec:
raise NipapExtraneousInputError("Key not allowed in prefix spec.")
where = ""
... | Expand prefix specification to SQL. |
387,776 | def build(self, endpoint, values=None, method=None, force_external=False,
append_unknown=True):
self.map.update()
if values:
if isinstance(values, MultiDict):
valueiter = values.iteritems(multi=True)
else:
valueiter = iterite... | Building URLs works pretty much the other way round. Instead of
`match` you call `build` and pass it the endpoint and a dict of
arguments for the placeholders.
The `build` function also accepts an argument called `force_external`
which, if you set it to `True` will force external URLs.... |
387,777 | def notify(self, msg, color=, notify=, message_format=):
self.message_dict = {
: msg,
: color,
: notify,
: message_format,
}
if not self.debug:
return requests.post(
self.notification_url,
json.d... | Send notification to specified HipChat room |
387,778 | def possible_version_evaluation(self):
only_broken = self.get_options().only_broken
ranges = self._ranges
yield
for target in sorted(filter(self._is_relevant, self.jvm_targets)):
min_version = ranges.min_allowed_version.get(target)
max_version = ranges.max_allowed_version.get(target)
... | Evaluate the possible range of versions for each target, yielding the output analysis. |
387,779 | def load_schema(schema):
with repo.Repo.db:
repo.Repo.db.executescript(schema) | Load a schema file with path +schema+ into the database. Assumes that
there exists an active database connection. |
387,780 | def dead(self):
if not self._weak:
return False
cb = self._callback()
if cb is None:
return True
return False | Whether the callback no longer exists.
If the callback is maintained via a weak reference, and that
weak reference has been collected, this will be true
instead of false. |
387,781 | async def _process_latching(self, key, latching_entry):
if latching_entry[Constants.LATCH_CALLBACK]:
if latching_entry[Constants.LATCH_CALLBACK_TYPE]:
await latching_entry[Constants.LATCH_CALLBACK] \
([key, latching_entry[Constants.LATCHED_DA... | This is a private utility method.
This method process latching events and either returns them via
callback or stores them in the latch map
:param key: Encoded pin
:param latching_entry: a latch table entry
:returns: Callback or store data in latch map |
387,782 | def compute_laplacian(self, lap_type=):
r
if lap_type != self.lap_type:
| r"""Compute a graph Laplacian.
For undirected graphs, the combinatorial Laplacian is defined as
.. math:: L = D - W,
where :math:`W` is the weighted adjacency matrix and :math:`D` the
weighted degree matrix. The normalized Laplacian is defined as
.. math:: L = I - D^{-1/2} W ... |
387,783 | def register_languages():
for language in set(SUPPORTED_LANGUAGES) - {"en"}:
language_stemmer = partial(nltk_stemmer, get_language_stemmer(language))
Pipeline.register_function(language_stemmer, "stemmer-{}".format(language)) | Register all supported languages to ensure compatibility. |
387,784 | def _process_image_msg(self, msg):
encoding = msg.encoding
try:
image = self._bridge.imgmsg_to_cv2(msg, encoding)
except CvBridgeError as e:
rospy.logerr(e)
return image | Process an image message and return a numpy array with the image data
Returns
-------
:obj:`numpy.ndarray` containing the image in the image message
Raises
------
CvBridgeError
If the bridge is not able to convert the image |
387,785 | def gen_unordered(self):
operations = [_Run(_INSERT), _Run(_UPDATE), _Run(_DELETE)]
for idx, (op_type, operation) in enumerate(self.ops):
operations[op_type].add(idx, operation)
for run in operations:
if run.ops:
yield run | Generate batches of operations, batched by type of
operation, in arbitrary order. |
387,786 | def calculate_request_digest(method, partial_digest, digest_response=None,
uri=None, nonce=None, nonce_count=None, client_nonce=None):
responsepartial_digest
if digest_response:
if uri or nonce or nonce_count or client_nonce:
raise Exception("Both digest_response... | Calculates a value for the 'response' value of the client authentication request.
Requires the 'partial_digest' calculated from the realm, username, and password.
Either call it with a digest_response to use the values from an authentication request,
or pass the individual parameters (i.e. to generate an a... |
387,787 | def load(cls, path_to_file):
import mimetypes
mimetypes.init()
mime = mimetypes.guess_type( % path_to_file)[0]
img_type = ImageTypeEnum.lookup_by_mime_type(mime)
with open(path_to_file, ) as f:
data = f.read()
return Image(data, image_type=img_type) | Loads the image data from a file on disk and tries to guess the image MIME type
:param path_to_file: path to the source file
:type path_to_file: str
:return: a `pyowm.image.Image` instance |
387,788 | def run_preassembly_related(preassembler, beliefengine, **kwargs):
logger.info( %
len(preassembler.unique_stmts))
return_toplevel = kwargs.get(, True)
poolsize = kwargs.get(, None)
size_cutoff = kwargs.get(, 100)
stmts_out = preassembler.combine_related(return_toplevel=False,
... | Run related stage of preassembly on a list of statements.
Parameters
----------
preassembler : indra.preassembler.Preassembler
A Preassembler instance which already has a set of unique statements
internally.
beliefengine : indra.belief.BeliefEngine
A BeliefEngine instance.
r... |
387,789 | def visible(self, visible):
self._visible = visible
if visible and len(self.panel.objects) == 0:
self.setup()
self.select.visible = True
self.control_panel.extend(self.controls)
self.panel.extend(self.children)
elif not visible and len(se... | When visible changed, do setup or unwatch and call visible_callback |
387,790 | def eval(self, expression, args=None, *,
timeout=-1.0, push_subscribe=False) -> _MethodRet:
return self._db.eval(expression, args,
timeout=timeout, push_subscribe=push_subscribe) | Eval request coroutine.
Examples:
.. code-block:: pycon
>>> await conn.eval('return 42')
<Response sync=3 rowcount=1 data=[42]>
>>> await conn.eval('return box.info.version')
<Response sync=3 rowcount=1 data=['2.1.1-7-gd381a45b... |
387,791 | def run(configobj, wcsmap=None):
.format(__version__, util._ptime()[0])), file=sys.stderr)
return
log.info("USER INPUT PARAMETERS common to all Processing Steps:")
util.printParams(configobj, log=log)
staticMask.create... | Initial example by Nadia ran MD with configobj EPAR using:
It can be run in one of two ways:
from stsci.tools import teal
1. Passing a config object to teal
teal.teal('drizzlepac/pars/astrodrizzle.cfg')
2. Passing a task name:
teal.teal('astrodrizzle')
The exa... |
387,792 | def _check_minions_directories(pki_dir):
minions_accepted = os.path.join(pki_dir, salt.key.Key.ACC)
minions_pre = os.path.join(pki_dir, salt.key.Key.PEND)
minions_rejected = os.path.join(pki_dir, salt.key.Key.REJ)
minions_denied = os.path.join(pki_dir, salt.key.Key.DEN)
return minions_accepted... | Return the minion keys directory paths.
This function is a copy of salt.key.Key._check_minions_directories. |
387,793 | def write(self, filename, type_=):
if os.path.exists(filename):
name, ext = filename.rsplit(,1)
try:
prefix, num = name.rsplit(,1)
n = int(num)
n += 1
filename = prefix + + str(n) + + ext
except Valu... | Write file, will not overwrite files with the same name
outputs to obo by default but can also output to ttl if
passed type_='ttl' when called. |
387,794 | def parsebool(el):
txt = text(el)
up = txt.upper()
if up == "OUI":
return True
if up == "NON":
return False
return bool(parseint(el)) | Parse a ``BeautifulSoup`` element as a bool |
387,795 | def namedb_history_save( cur, opcode, history_id, creator_address, value_hash, block_id, vtxindex, txid, accepted_rec, history_snapshot=False ):
assert in accepted_rec, "Malformed record at ({},{}): missing op".format(block_id, accepted_rec[])
op = accepted_rec[]
record_data = op_canonicaliz... | Insert data into the state engine's history.
It must be for a never-before-seen (txid,block_id,vtxindex) set.
@history_id is either the name or namespace ID
Return True on success
Raise an Exception on error |
387,796 | def record_serializer(self):
imp = current_app.config[]
if isinstance(imp, string_types):
return import_string(imp)
return imp | Github Release API class. |
387,797 | def run(self):
import salt.client
self.parse_args()
if self.config[] not in (, ):
self.setup_logfile_logger()
verify_log(self.config)
try:
if not in kwargs and not in kwargs and self.options.eauth:
... | Execute the salt command line |
387,798 | def fig16():
tpm = np.array([
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 1, 0, 0],
[1, 0, 1, 0, 0, 0, 0],
[1, 0, 0, 0, 1, 0, 0],
[1, 0, 0, 0, 0, 0, 0],
[1, 0, 1, 0, 1, 0, 0],
[1, 0, 1, 0, 0, 0, 0],
[1, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 1, 1, 0, 0],
... | The network shown in Figure 5B of the 2014 IIT 3.0 paper. |
387,799 | def sanitize_type(raw_type):
cleaned = get_printable(raw_type).strip()
for bad in [
r, r,
r,
r,
r,
r, r, r,
r
]:
cleaned = re.sub(bad, , cleaned).strip()
if cleaned in [, ]:
cleaned = cleaned.strip()
cleaned... | Sanitize the raw type string. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.