_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q255300 | _f_gene | validation | def _f_gene(sid, prefix="G_"):
"""Clips gene prefix from id."""
sid = sid.replace(SBML_DOT, ".")
return _clip(sid, prefix) | python | {
"resource": ""
} |
q255301 | read_sbml_model | validation | def read_sbml_model(filename, number=float, f_replace=F_REPLACE,
set_missing_bounds=False, **kwargs):
"""Reads SBML model from given filename.
If the given filename ends with the suffix ''.gz'' (for example,
''myfile.xml.gz'),' the file is assumed to be compressed in gzip
format and... | python | {
"resource": ""
} |
q255302 | _get_doc_from_filename | validation | def _get_doc_from_filename(filename):
"""Get SBMLDocument from given filename.
Parameters
----------
filename : path to SBML, or SBML string, or filehandle
Returns
-------
libsbml.SBMLDocument
"""
if isinstance(filename, string_types):
if ("win" in platform) and (len(filena... | python | {
"resource": ""
} |
q255303 | write_sbml_model | validation | def write_sbml_model(cobra_model, filename, f_replace=F_REPLACE, **kwargs):
"""Writes cobra model to filename.
The created model is SBML level 3 version 1 (L1V3) with
fbc package v2 (fbc-v2).
If the given filename ends with the suffix ".gz" (for example,
"myfile.xml.gz"), libSBML assumes the calle... | python | {
"resource": ""
} |
q255304 | _create_bound | validation | def _create_bound(model, reaction, bound_type, f_replace, units=None,
flux_udef=None):
"""Creates bound in model for given reaction.
Adds the parameters for the bounds to the SBML model.
Parameters
----------
model : libsbml.Model
SBML model instance
reaction : cobra.... | python | {
"resource": ""
} |
q255305 | _create_parameter | validation | def _create_parameter(model, pid, value, sbo=None, constant=True, units=None,
flux_udef=None):
"""Create parameter in SBML model."""
parameter = model.createParameter() # type: libsbml.Parameter
parameter.setId(pid)
parameter.setValue(value)
parameter.setConstant(constant)
... | python | {
"resource": ""
} |
q255306 | _check_required | validation | def _check_required(sbase, value, attribute):
"""Get required attribute from SBase.
Parameters
----------
sbase : libsbml.SBase
value : existing value
attribute: name of attribute
Returns
-------
attribute value (or value if already set)
"""
if (value is None) or (value ==... | python | {
"resource": ""
} |
q255307 | _check | validation | def _check(value, message):
"""
Checks the libsbml return value and logs error messages.
If 'value' is None, logs an error message constructed using
'message' and then exits with status code 1. If 'value' is an integer,
it assumes it is a libSBML return status code. If the code value is
L... | python | {
"resource": ""
} |
q255308 | _parse_notes_dict | validation | def _parse_notes_dict(sbase):
""" Creates dictionary of COBRA notes.
Parameters
----------
sbase : libsbml.SBase
Returns
-------
dict of notes
"""
notes = sbase.getNotesString()
if notes and len(notes) > 0:
pattern = r"<p>\s*(\w+\s*\w*)\s*:\s*([\w|\s]+)<"
matche... | python | {
"resource": ""
} |
q255309 | _sbase_notes_dict | validation | def _sbase_notes_dict(sbase, notes):
"""Set SBase notes based on dictionary.
Parameters
----------
sbase : libsbml.SBase
SBML object to set notes on
notes : notes object
notes information from cobra object
"""
if notes and len(notes) > 0:
tokens = ['<html xmlns = "ht... | python | {
"resource": ""
} |
q255310 | _parse_annotations | validation | def _parse_annotations(sbase):
"""Parses cobra annotations from a given SBase object.
Annotations are dictionaries with the providers as keys.
Parameters
----------
sbase : libsbml.SBase
SBase from which the SBML annotations are read
Returns
-------
dict (annotation dictionary... | python | {
"resource": ""
} |
q255311 | _sbase_annotations | validation | def _sbase_annotations(sbase, annotation):
"""Set SBase annotations based on cobra annotations.
Parameters
----------
sbase : libsbml.SBase
SBML object to annotate
annotation : cobra annotation structure
cobra object with annotation information
FIXME: annotation format must be ... | python | {
"resource": ""
} |
q255312 | _error_string | validation | def _error_string(error, k=None):
"""String representation of SBMLError.
Parameters
----------
error : libsbml.SBMLError
k : index of error
Returns
-------
string representation of error
"""
package = error.getPackage()
if package == '':
package = 'core'
templa... | python | {
"resource": ""
} |
q255313 | production_envelope | validation | def production_envelope(model, reactions, objective=None, carbon_sources=None,
points=20, threshold=None):
"""Calculate the objective value conditioned on all combinations of
fluxes for a set of chosen reactions
The production envelope can be used to analyze a model's ability to
... | python | {
"resource": ""
} |
q255314 | total_yield | validation | def total_yield(input_fluxes, input_elements, output_flux, output_elements):
"""
Compute total output per input unit.
Units are typically mol carbon atoms or gram of source and product.
Parameters
----------
input_fluxes : list
A list of input reaction fluxes in the same order as the
... | python | {
"resource": ""
} |
q255315 | reaction_elements | validation | def reaction_elements(reaction):
"""
Split metabolites into the atoms times their stoichiometric coefficients.
Parameters
----------
reaction : Reaction
The metabolic reaction whose components are desired.
Returns
-------
list
Each of the reaction's metabolites' desired... | python | {
"resource": ""
} |
q255316 | reaction_weight | validation | def reaction_weight(reaction):
"""Return the metabolite weight times its stoichiometric coefficient."""
if len(reaction.metabolites) != 1:
raise ValueError('Reaction weight is only defined for single '
'metabolite products or educts.')
met, coeff = next(iteritems(reaction.... | python | {
"resource": ""
} |
q255317 | total_components_flux | validation | def total_components_flux(flux, components, consumption=True):
"""
Compute the total components consumption or production flux.
Parameters
----------
flux : float
The reaction flux for the components.
components : list
List of stoichiometrically weighted components.
consumpt... | python | {
"resource": ""
} |
q255318 | find_carbon_sources | validation | def find_carbon_sources(model):
"""
Find all active carbon source reactions.
Parameters
----------
model : Model
A genome-scale metabolic model.
Returns
-------
list
The medium reactions with carbon input flux.
"""
try:
model.slim_optimize(error_value=N... | python | {
"resource": ""
} |
q255319 | assess | validation | def assess(model, reaction, flux_coefficient_cutoff=0.001, solver=None):
"""Assesses production capacity.
Assesses the capacity of the model to produce the precursors for the
reaction and absorb the production of the reaction while the reaction is
operating at, or above, the specified cutoff.
Para... | python | {
"resource": ""
} |
q255320 | assess_component | validation | def assess_component(model, reaction, side, flux_coefficient_cutoff=0.001,
solver=None):
"""Assesses the ability of the model to provide sufficient precursors,
or absorb products, for a reaction operating at, or beyond,
the specified cutoff.
Parameters
----------
model : co... | python | {
"resource": ""
} |
q255321 | assess_precursors | validation | def assess_precursors(model, reaction, flux_coefficient_cutoff=0.001,
solver=None):
"""Assesses the ability of the model to provide sufficient precursors for
a reaction operating at, or beyond, the specified cutoff.
Deprecated: use assess_component instead
Parameters
--------... | python | {
"resource": ""
} |
q255322 | assess_products | validation | def assess_products(model, reaction, flux_coefficient_cutoff=0.001,
solver=None):
"""Assesses whether the model has the capacity to absorb the products of
a reaction at a given flux rate.
Useful for identifying which components might be blocking a reaction
from achieving a specific ... | python | {
"resource": ""
} |
q255323 | add_loopless | validation | def add_loopless(model, zero_cutoff=None):
"""Modify a model so all feasible flux distributions are loopless.
In most cases you probably want to use the much faster `loopless_solution`.
May be used in cases where you want to add complex constraints and
objecives (for instance quadratic objectives) to t... | python | {
"resource": ""
} |
q255324 | _add_cycle_free | validation | def _add_cycle_free(model, fluxes):
"""Add constraints for CycleFreeFlux."""
model.objective = model.solver.interface.Objective(
Zero, direction="min", sloppy=True)
objective_vars = []
for rxn in model.reactions:
flux = fluxes[rxn.id]
if rxn.boundary:
rxn.bounds = (fl... | python | {
"resource": ""
} |
q255325 | loopless_solution | validation | def loopless_solution(model, fluxes=None):
"""Convert an existing solution to a loopless one.
Removes as many loops as possible (see Notes).
Uses the method from CycleFreeFlux [1]_ and is much faster than
`add_loopless` and should therefore be the preferred option to get loopless
flux distributions... | python | {
"resource": ""
} |
q255326 | loopless_fva_iter | validation | def loopless_fva_iter(model, reaction, solution=False, zero_cutoff=None):
"""Plugin to get a loopless FVA solution from single FVA iteration.
Assumes the following about `model` and `reaction`:
1. the model objective is set to be `reaction`
2. the model has been optimized and contains the minimum/maxim... | python | {
"resource": ""
} |
q255327 | create_stoichiometric_matrix | validation | def create_stoichiometric_matrix(model, array_type='dense', dtype=None):
"""Return a stoichiometric array representation of the given model.
The the columns represent the reactions and rows represent
metabolites. S[i,j] therefore contains the quantity of metabolite `i`
produced (negative for consumed) ... | python | {
"resource": ""
} |
q255328 | nullspace | validation | def nullspace(A, atol=1e-13, rtol=0):
"""Compute an approximate basis for the nullspace of A.
The algorithm used by this function is based on the singular value
decomposition of `A`.
Parameters
----------
A : numpy.ndarray
A should be at most 2-D. A 1-D array with length k will be trea... | python | {
"resource": ""
} |
q255329 | constraint_matrices | validation | def constraint_matrices(model, array_type='dense', include_vars=False,
zero_tol=1e-6):
"""Create a matrix representation of the problem.
This is used for alternative solution approaches that do not use optlang.
The function will construct the equality matrix, inequality matrix and
... | python | {
"resource": ""
} |
q255330 | add_room | validation | def add_room(model, solution=None, linear=False, delta=0.03, epsilon=1E-03):
r"""
Add constraints and objective for ROOM.
This function adds variables and constraints for applying regulatory
on/off minimization (ROOM) to the model.
Parameters
----------
model : cobra.Model
The mode... | python | {
"resource": ""
} |
q255331 | sample | validation | def sample(model, n, method="optgp", thinning=100, processes=1, seed=None):
"""Sample valid flux distributions from a cobra model.
The function samples valid flux distributions from a cobra model.
Currently we support two methods:
1. 'optgp' (default) which uses the OptGPSampler that supports parallel... | python | {
"resource": ""
} |
q255332 | optimizely | validation | def optimizely(parser, token):
"""
Optimizely template tag.
Renders Javascript code to set-up A/B testing. You must supply
your Optimizely account number in the ``OPTIMIZELY_ACCOUNT_NUMBER``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError(... | python | {
"resource": ""
} |
q255333 | clicky | validation | def clicky(parser, token):
"""
Clicky tracking template tag.
Renders Javascript code to track page visits. You must supply
your Clicky Site ID (as a string) in the ``CLICKY_SITE_ID``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' ta... | python | {
"resource": ""
} |
q255334 | chartbeat_top | validation | def chartbeat_top(parser, token):
"""
Top Chartbeat template tag.
Render the top Javascript code for Chartbeat.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no arguments" % bits[0])
return ChartbeatTopNode() | python | {
"resource": ""
} |
q255335 | chartbeat_bottom | validation | def chartbeat_bottom(parser, token):
"""
Bottom Chartbeat template tag.
Render the bottom Javascript code for Chartbeat. You must supply
your Chartbeat User ID (as a string) in the ``CHARTBEAT_USER_ID``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise Template... | python | {
"resource": ""
} |
q255336 | woopra | validation | def woopra(parser, token):
"""
Woopra tracking template tag.
Renders Javascript code to track page visits. You must supply
your Woopra domain in the ``WOOPRA_DOMAIN`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no arguments" % ... | python | {
"resource": ""
} |
q255337 | spring_metrics | validation | def spring_metrics(parser, token):
"""
Spring Metrics tracking template tag.
Renders Javascript code to track page visits. You must supply
your Spring Metrics Tracking ID in the
``SPRING_METRICS_TRACKING_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise Te... | python | {
"resource": ""
} |
q255338 | kiss_insights | validation | def kiss_insights(parser, token):
"""
KISSinsights set-up template tag.
Renders Javascript code to set-up surveys. You must supply
your account number and site code in the
``KISS_INSIGHTS_ACCOUNT_NUMBER`` and ``KISS_INSIGHTS_SITE_CODE``
settings.
"""
bits = token.split_contents()
i... | python | {
"resource": ""
} |
q255339 | matomo | validation | def matomo(parser, token):
"""
Matomo tracking template tag.
Renders Javascript code to track page visits. You must supply
your Matomo domain (plus optional URI path), and tracked site ID
in the ``MATOMO_DOMAIN_PATH`` and the ``MATOMO_SITE_ID`` setting.
Custom variables can be passed in the `... | python | {
"resource": ""
} |
q255340 | snapengage | validation | def snapengage(parser, token):
"""
SnapEngage set-up template tag.
Renders Javascript code to set-up SnapEngage chat. You must supply
your widget ID in the ``SNAPENGAGE_WIDGET_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no... | python | {
"resource": ""
} |
q255341 | performable | validation | def performable(parser, token):
"""
Performable template tag.
Renders Javascript code to set-up Performable tracking. You must
supply your Performable API key in the ``PERFORMABLE_API_KEY``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("... | python | {
"resource": ""
} |
q255342 | _hashable_bytes | validation | def _hashable_bytes(data):
"""
Coerce strings to hashable bytes.
"""
if isinstance(data, bytes):
return data
elif isinstance(data, str):
return data.encode('ascii') # Fail on anything non-ASCII.
else:
raise TypeError(data) | python | {
"resource": ""
} |
q255343 | intercom_user_hash | validation | def intercom_user_hash(data):
"""
Return a SHA-256 HMAC `user_hash` as expected by Intercom, if configured.
Return None if the `INTERCOM_HMAC_SECRET_KEY` setting is not configured.
"""
if getattr(settings, 'INTERCOM_HMAC_SECRET_KEY', None):
return hmac.new(
key=_hashable_bytes(s... | python | {
"resource": ""
} |
q255344 | intercom | validation | def intercom(parser, token):
"""
Intercom.io template tag.
Renders Javascript code to intercom.io testing. You must supply
your APP ID account number in the ``INTERCOM_APP_ID``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no... | python | {
"resource": ""
} |
q255345 | uservoice | validation | def uservoice(parser, token):
"""
UserVoice tracking template tag.
Renders Javascript code to track page visits. You must supply
your UserVoice Widget Key in the ``USERVOICE_WIDGET_KEY``
setting or the ``uservoice_widget_key`` template context variable.
"""
bits = token.split_contents()
... | python | {
"resource": ""
} |
q255346 | kiss_metrics | validation | def kiss_metrics(parser, token):
"""
KISSinsights tracking template tag.
Renders Javascript code to track page visits. You must supply
your KISSmetrics API key in the ``KISS_METRICS_API_KEY``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError... | python | {
"resource": ""
} |
q255347 | piwik | validation | def piwik(parser, token):
"""
Piwik tracking template tag.
Renders Javascript code to track page visits. You must supply
your Piwik domain (plus optional URI path), and tracked site ID
in the ``PIWIK_DOMAIN_PATH`` and the ``PIWIK_SITE_ID`` setting.
Custom variables can be passed in the ``piwi... | python | {
"resource": ""
} |
q255348 | get_required_setting | validation | def get_required_setting(setting, value_re, invalid_msg):
"""
Return a constant from ``django.conf.settings``. The `setting`
argument is the constant name, the `value_re` argument is a regular
expression used to validate the setting value and the `invalid_msg`
argument is used as exception message ... | python | {
"resource": ""
} |
q255349 | get_user_from_context | validation | def get_user_from_context(context):
"""
Get the user instance from the template context, if possible.
If the context does not contain a `request` or `user` attribute,
`None` is returned.
"""
try:
return context['user']
except KeyError:
pass
try:
request = context... | python | {
"resource": ""
} |
q255350 | get_identity | validation | def get_identity(context, prefix=None, identity_func=None, user=None):
"""
Get the identity of a logged in user from a template context.
The `prefix` argument is used to provide different identities to
different analytics services. The `identity_func` argument is a
function that returns the identi... | python | {
"resource": ""
} |
q255351 | is_internal_ip | validation | def is_internal_ip(context, prefix=None):
"""
Return whether the visitor is coming from an internal IP address,
based on information from the template context.
The prefix is used to allow different analytics services to have
different notions of internal addresses.
"""
try:
request ... | python | {
"resource": ""
} |
q255352 | mixpanel | validation | def mixpanel(parser, token):
"""
Mixpanel tracking template tag.
Renders Javascript code to track page visits. You must supply
your Mixpanel token in the ``MIXPANEL_API_TOKEN`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no arg... | python | {
"resource": ""
} |
q255353 | gosquared | validation | def gosquared(parser, token):
"""
GoSquared tracking template tag.
Renders Javascript code to track page visits. You must supply
your GoSquared site token in the ``GOSQUARED_SITE_TOKEN`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' ta... | python | {
"resource": ""
} |
q255354 | olark | validation | def olark(parser, token):
"""
Olark set-up template tag.
Renders Javascript code to set-up Olark chat. You must supply
your site ID in the ``OLARK_SITE_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no arguments" % bits[0])
... | python | {
"resource": ""
} |
q255355 | clickmap | validation | def clickmap(parser, token):
"""
Clickmap tracker template tag.
Renders Javascript code to track page visits. You must supply
your clickmap tracker ID (as a string) in the ``CLICKMAP_TRACKER_ID``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxE... | python | {
"resource": ""
} |
q255356 | gauges | validation | def gauges(parser, token):
"""
Gaug.es template tag.
Renders Javascript code to gaug.es testing. You must supply
your Site ID account number in the ``GAUGES_SITE_ID``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no arguments... | python | {
"resource": ""
} |
q255357 | crazy_egg | validation | def crazy_egg(parser, token):
"""
Crazy Egg tracking template tag.
Renders Javascript code to track page clicks. You must supply
your Crazy Egg account number (as a string) in the
``CRAZY_EGG_ACCOUNT_NUMBER`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise Te... | python | {
"resource": ""
} |
q255358 | yandex_metrica | validation | def yandex_metrica(parser, token):
"""
Yandex.Metrica counter template tag.
Renders Javascript code to track page visits. You must supply
your website counter ID (as a string) in the
``YANDEX_METRICA_COUNTER_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise... | python | {
"resource": ""
} |
q255359 | hubspot | validation | def hubspot(parser, token):
"""
HubSpot tracking template tag.
Renders Javascript code to track page visits. You must supply
your portal ID (as a string) in the ``HUBSPOT_PORTAL_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes ... | python | {
"resource": ""
} |
q255360 | status_printer | validation | def status_printer():
"""Manage the printing and in-place updating of a line of characters
.. note::
If the string is longer than a line, then in-place updating may not
work (it will print a new line at each refresh).
"""
last_len = [0]
def p(s):
s = next(spinner) + ' ' + s... | python | {
"resource": ""
} |
q255361 | do_apply | validation | def do_apply(mutation_pk, dict_synonyms, backup):
"""Apply a specified mutant to the source code
:param mutation_pk: mutmut cache primary key of the mutant to apply
:type mutation_pk: str
:param dict_synonyms: list of synonym keywords for a python dictionary
:type dict_synonyms: list[str]
:pa... | python | {
"resource": ""
} |
q255362 | popen_streaming_output | validation | def popen_streaming_output(cmd, callback, timeout=None):
"""Open a subprocess and stream its output without hard-blocking.
:param cmd: the command to execute within the subprocess
:type cmd: str
:param callback: function that intakes the subprocess' stdout line by line.
It is called for each l... | python | {
"resource": ""
} |
q255363 | python_source_files | validation | def python_source_files(path, tests_dirs):
"""Attempt to guess where the python source files to mutate are and yield
their paths
:param path: path to a python source file or package directory
:type path: str
:param tests_dirs: list of directory paths containing test files
(we do not want t... | python | {
"resource": ""
} |
q255364 | compute_exit_code | validation | def compute_exit_code(config, exception=None):
"""Compute an exit code for mutmut mutation testing
The following exit codes are available for mutmut:
* 0 if all mutants were killed (OK_KILLED)
* 1 if a fatal error occurred
* 2 if one or more mutants survived (BAD_SURVIVED)
* 4 if one or mor... | python | {
"resource": ""
} |
q255365 | CoreBluetoothDevice._update_advertised | validation | def _update_advertised(self, advertised):
"""Called when advertisement data is received."""
# Advertisement data was received, pull out advertised service UUIDs and
# name from advertisement data.
if 'kCBAdvDataServiceUUIDs' in advertised:
self._advertised = self._advertised ... | python | {
"resource": ""
} |
q255366 | CoreBluetoothDevice._characteristics_discovered | validation | def _characteristics_discovered(self, service):
"""Called when GATT characteristics have been discovered."""
# Characteristics for the specified service were discovered. Update
# set of discovered services and signal when all have been discovered.
self._discovered_services.add(service)
... | python | {
"resource": ""
} |
q255367 | CoreBluetoothDevice._characteristic_changed | validation | def _characteristic_changed(self, characteristic):
"""Called when the specified characteristic has changed its value."""
# Called when a characteristic is changed. Get the on_changed handler
# for this characteristic (if it exists) and call it.
on_changed = self._char_on_changed.get(cha... | python | {
"resource": ""
} |
q255368 | CoreBluetoothDevice._descriptor_changed | validation | def _descriptor_changed(self, descriptor):
"""Called when the specified descriptor has changed its value."""
# Tell the descriptor it has a new value to read.
desc = descriptor_list().get(descriptor)
if desc is not None:
desc._value_read.set() | python | {
"resource": ""
} |
q255369 | CoreBluetoothDevice.rssi | validation | def rssi(self, timeout_sec=TIMEOUT_SEC):
"""Return the RSSI signal strength in decibels."""
# Kick off query to get RSSI, then wait for it to return asyncronously
# when the _rssi_changed() function is called.
self._rssi_read.clear()
self._peripheral.readRSSI()
if not sel... | python | {
"resource": ""
} |
q255370 | BluezGattService.list_characteristics | validation | def list_characteristics(self):
"""Return list of GATT characteristics that have been discovered for this
service.
"""
paths = self._props.Get(_SERVICE_INTERFACE, 'Characteristics')
return map(BluezGattCharacteristic,
get_provider()._get_objects_by_path(paths)) | python | {
"resource": ""
} |
q255371 | BluezGattCharacteristic.list_descriptors | validation | def list_descriptors(self):
"""Return list of GATT descriptors that have been discovered for this
characteristic.
"""
paths = self._props.Get(_CHARACTERISTIC_INTERFACE, 'Descriptors')
return map(BluezGattDescriptor,
get_provider()._get_objects_by_path(paths)) | python | {
"resource": ""
} |
q255372 | CoreBluetoothAdapter._state_changed | validation | def _state_changed(self, state):
"""Called when the power state changes."""
logger.debug('Adapter state change: {0}'.format(state))
# Handle when powered on.
if state == 5:
self._powered_off.clear()
self._powered_on.set()
# Handle when powered off.
... | python | {
"resource": ""
} |
q255373 | CoreBluetoothAdapter.start_scan | validation | def start_scan(self, timeout_sec=TIMEOUT_SEC):
"""Start scanning for BLE devices."""
get_provider()._central_manager.scanForPeripheralsWithServices_options_(None, None)
self._is_scanning = True | python | {
"resource": ""
} |
q255374 | CoreBluetoothAdapter.stop_scan | validation | def stop_scan(self, timeout_sec=TIMEOUT_SEC):
"""Stop scanning for BLE devices."""
get_provider()._central_manager.stopScan()
self._is_scanning = False | python | {
"resource": ""
} |
q255375 | CoreBluetoothAdapter.power_on | validation | def power_on(self, timeout_sec=TIMEOUT_SEC):
"""Power on Bluetooth."""
# Turn on bluetooth and wait for powered on event to be set.
self._powered_on.clear()
IOBluetoothPreferenceSetControllerPowerState(1)
if not self._powered_on.wait(timeout_sec):
raise RuntimeError('... | python | {
"resource": ""
} |
q255376 | CoreBluetoothAdapter.power_off | validation | def power_off(self, timeout_sec=TIMEOUT_SEC):
"""Power off Bluetooth."""
# Turn off bluetooth.
self._powered_off.clear()
IOBluetoothPreferenceSetControllerPowerState(0)
if not self._powered_off.wait(timeout_sec):
raise RuntimeError('Exceeded timeout waiting for adapte... | python | {
"resource": ""
} |
q255377 | ServiceBase.find_device | validation | def find_device(cls, timeout_sec=TIMEOUT_SEC):
"""Find the first available device that supports this service and return
it, or None if no device is found. Will wait for up to timeout_sec
seconds to find the device.
"""
return get_provider().find_device(service_uuids=cls.ADVERTIS... | python | {
"resource": ""
} |
q255378 | ServiceBase.discover | validation | def discover(cls, device, timeout_sec=TIMEOUT_SEC):
"""Wait until the specified device has discovered the expected services
and characteristics for this service. Should be called once before other
calls are made on the service. Returns true if the service has been
discovered in the spe... | python | {
"resource": ""
} |
q255379 | Device.find_service | validation | def find_service(self, uuid):
"""Return the first child service found that has the specified
UUID. Will return None if no service that matches is found.
"""
for service in self.list_services():
if service.uuid == uuid:
return service
return None | python | {
"resource": ""
} |
q255380 | BluezDevice.list_services | validation | def list_services(self):
"""Return a list of GattService objects that have been discovered for
this device.
"""
return map(BluezGattService,
get_provider()._get_objects(_SERVICE_INTERFACE,
self._device.object_path)) | python | {
"resource": ""
} |
q255381 | BluezDevice.advertised | validation | def advertised(self):
"""Return a list of UUIDs for services that are advertised by this
device.
"""
uuids = []
# Get UUIDs property but wrap it in a try/except to catch if the property
# doesn't exist as it is optional.
try:
uuids = self._props.Get(_I... | python | {
"resource": ""
} |
q255382 | GattService.find_characteristic | validation | def find_characteristic(self, uuid):
"""Return the first child characteristic found that has the specified
UUID. Will return None if no characteristic that matches is found.
"""
for char in self.list_characteristics():
if char.uuid == uuid:
return char
... | python | {
"resource": ""
} |
q255383 | GattCharacteristic.find_descriptor | validation | def find_descriptor(self, uuid):
"""Return the first child descriptor found that has the specified
UUID. Will return None if no descriptor that matches is found.
"""
for desc in self.list_descriptors():
if desc.uuid == uuid:
return desc
return None | python | {
"resource": ""
} |
q255384 | CoreBluetoothGattCharacteristic.read_value | validation | def read_value(self, timeout_sec=TIMEOUT_SEC):
"""Read the value of this characteristic."""
# Kick off a query to read the value of the characteristic, then wait
# for the result to return asyncronously.
self._value_read.clear()
self._device._peripheral.readValueForCharacteristic... | python | {
"resource": ""
} |
q255385 | CoreBluetoothGattCharacteristic.write_value | validation | def write_value(self, value, write_type=0):
"""Write the specified value to this characteristic."""
data = NSData.dataWithBytes_length_(value, len(value))
self._device._peripheral.writeValue_forCharacteristic_type_(data,
self._characteristic,
write_type) | python | {
"resource": ""
} |
q255386 | CoreBluetoothGattDescriptor.read_value | validation | def read_value(self):
"""Read the value of this descriptor."""
pass
# Kick off a query to read the value of the descriptor, then wait
# for the result to return asyncronously.
self._value_read.clear()
self._device._peripheral.readValueForDescriptor(self._descriptor)
... | python | {
"resource": ""
} |
q255387 | BluezAdapter.start_scan | validation | def start_scan(self, timeout_sec=TIMEOUT_SEC):
"""Start scanning for BLE devices with this adapter."""
self._scan_started.clear()
self._adapter.StartDiscovery()
if not self._scan_started.wait(timeout_sec):
raise RuntimeError('Exceeded timeout waiting for adapter to start scan... | python | {
"resource": ""
} |
q255388 | BluezAdapter.stop_scan | validation | def stop_scan(self, timeout_sec=TIMEOUT_SEC):
"""Stop scanning for BLE devices with this adapter."""
self._scan_stopped.clear()
self._adapter.StopDiscovery()
if not self._scan_stopped.wait(timeout_sec):
raise RuntimeError('Exceeded timeout waiting for adapter to stop scanning... | python | {
"resource": ""
} |
q255389 | CentralDelegate.centralManager_didDiscoverPeripheral_advertisementData_RSSI_ | validation | def centralManager_didDiscoverPeripheral_advertisementData_RSSI_(self, manager, peripheral, data, rssi):
"""Called when the BLE adapter found a device while scanning, or has
new advertisement data for a device.
"""
logger.debug('centralManager_didDiscoverPeripheral_advertisementData_RSSI... | python | {
"resource": ""
} |
q255390 | CentralDelegate.centralManager_didConnectPeripheral_ | validation | def centralManager_didConnectPeripheral_(self, manager, peripheral):
"""Called when a device is connected."""
logger.debug('centralManager_didConnectPeripheral called')
# Setup peripheral delegate and kick off service discovery. For now just
# assume all services need to be discovered.
... | python | {
"resource": ""
} |
q255391 | CentralDelegate.centralManager_didDisconnectPeripheral_error_ | validation | def centralManager_didDisconnectPeripheral_error_(self, manager, peripheral, error):
"""Called when a device is disconnected."""
logger.debug('centralManager_didDisconnectPeripheral called')
# Get the device and remove it from the device list, then fire its
# disconnected event.
... | python | {
"resource": ""
} |
q255392 | CentralDelegate.peripheral_didDiscoverServices_ | validation | def peripheral_didDiscoverServices_(self, peripheral, services):
"""Called when services are discovered for a device."""
logger.debug('peripheral_didDiscoverServices called')
# Make sure the discovered services are added to the list of known
# services, and kick off characteristic discov... | python | {
"resource": ""
} |
q255393 | CentralDelegate.peripheral_didUpdateValueForCharacteristic_error_ | validation | def peripheral_didUpdateValueForCharacteristic_error_(self, peripheral, characteristic, error):
"""Called when characteristic value was read or updated."""
logger.debug('peripheral_didUpdateValueForCharacteristic_error called')
# Stop if there was some kind of error.
if error is not None... | python | {
"resource": ""
} |
q255394 | CentralDelegate.peripheral_didUpdateValueForDescriptor_error_ | validation | def peripheral_didUpdateValueForDescriptor_error_(self, peripheral, descriptor, error):
"""Called when descriptor value was read or updated."""
logger.debug('peripheral_didUpdateValueForDescriptor_error called')
# Stop if there was some kind of error.
if error is not None:
re... | python | {
"resource": ""
} |
q255395 | CentralDelegate.peripheral_didReadRSSI_error_ | validation | def peripheral_didReadRSSI_error_(self, peripheral, rssi, error):
"""Called when a new RSSI value for the peripheral is available."""
logger.debug('peripheral_didReadRSSI_error called')
# Note this appears to be completely undocumented at the time of this
# writing. Can see more details... | python | {
"resource": ""
} |
q255396 | CoreBluetoothProvider.initialize | validation | def initialize(self):
"""Initialize the BLE provider. Must be called once before any other
calls are made to the provider.
"""
# Setup the central manager and its delegate.
self._central_manager = CBCentralManager.alloc()
self._central_manager.initWithDelegate_queue_opti... | python | {
"resource": ""
} |
q255397 | CoreBluetoothProvider.disconnect_devices | validation | def disconnect_devices(self, service_uuids):
"""Disconnect any connected devices that have any of the specified
service UUIDs.
"""
# Get list of connected devices with specified services.
cbuuids = map(uuid_to_cbuuid, service_uuids)
for device in self._central_manager.ret... | python | {
"resource": ""
} |
q255398 | BluezProvider.initialize | validation | def initialize(self):
"""Initialize bluez DBus communication. Must be called before any other
calls are made!
"""
# Ensure GLib's threading is initialized to support python threads, and
# make a default mainloop that all DBus objects will inherit. These
# commands MUST ... | python | {
"resource": ""
} |
q255399 | BluezProvider.clear_cached_data | validation | def clear_cached_data(self):
"""Clear any internally cached BLE device data. Necessary in some cases
to prevent issues with stale device data getting cached by the OS.
"""
# Go through and remove any device that isn't currently connected.
for device in self.list_devices():
... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.