_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q238300 | EmulationLoop.verify_calling_thread | train | def verify_calling_thread(self, should_be_emulation, message=None):
"""Verify if the calling thread is or is not the emulation thread.
This method can be called to make sure that an action is being taken
in the appropriate context such as not blocking the event loop thread
or modifying ... | python | {
"resource": ""
} |
q238301 | EmulationLoop.add_task | train | def add_task(self, tile_address, coroutine):
"""Add a task into the event loop.
This is the main entry point for registering background tasks that are
associated with a tile. The tasks are added to the EmulationLoop and
the tile they are a part of is recorded. When the tile is reset, a... | python | {
"resource": ""
} |
q238302 | EmulationLoop.stop_tasks | train | async def stop_tasks(self, address):
"""Clear all tasks pertaining to a tile.
This coroutine will synchronously cancel all running tasks that were
attached to the given tile and wait for them to stop before returning.
Args:
address (int): The address of the tile we should s... | python | {
"resource": ""
} |
q238303 | EmulationLoop._clean_shutdown | train | async def _clean_shutdown(self):
"""Cleanly shutdown the emulation loop."""
# Cleanly stop any other outstanding tasks not associated with tiles
remaining_tasks = []
for task in self._tasks.get(None, []):
self._logger.debug("Cancelling task at shutdown %s", task)
... | python | {
"resource": ""
} |
q238304 | EmulationLoop._add_task | train | def _add_task(self, tile_address, coroutine):
"""Add a task from within the event loop.
All tasks are associated with a tile so that they can be cleanly
stopped when that tile is reset.
"""
self.verify_calling_thread(True, "_add_task is not thread safe")
if tile_addres... | python | {
"resource": ""
} |
q238305 | DictionaryVerifier.key_rule | train | def key_rule(self, regex, verifier):
"""Add a rule with a pattern that should apply to all keys.
Any key not explicitly listed in an add_required or add_optional rule
must match ONE OF the rules given in a call to key_rule().
So these rules are all OR'ed together.
In this case ... | python | {
"resource": ""
} |
q238306 | VirtualAdapterAsyncChannel.stream | train | def stream(self, report, callback=None):
"""Queue data for streaming
Args:
report (IOTileReport): A report object to stream to a client
callback (callable): An optional callback that will be called with
a bool value of True when this report actually gets streamed... | python | {
"resource": ""
} |
q238307 | VirtualAdapterAsyncChannel.trace | train | def trace(self, data, callback=None):
"""Queue data for tracing
Args:
data (bytearray, string): Unstructured data to trace to any
connected client.
callback (callable): An optional callback that will be called with
a bool value of True when this d... | python | {
"resource": ""
} |
q238308 | VirtualDeviceAdapter._load_device | train | def _load_device(self, name, config):
"""Load a device either from a script or from an installed module"""
if config is None:
config_dict = {}
elif isinstance(config, dict):
config_dict = config
elif config[0] == '#':
# Allow passing base64 encoded js... | python | {
"resource": ""
} |
q238309 | VirtualDeviceAdapter.disconnect | train | async def disconnect(self, conn_id):
"""Asynchronously disconnect from a connected device
Args:
conn_id (int): A unique identifier that will refer to this connection
callback (callback): A callback that will be called as
callback(conn_id, adapter_id, success, fai... | python | {
"resource": ""
} |
q238310 | VirtualDeviceAdapter._send_scan_event | train | async def _send_scan_event(self, device):
"""Send a scan event from a device."""
conn_string = str(device.iotile_id)
info = {
'connection_string': conn_string,
'uuid': device.iotile_id,
'signal_strength': 100,
'validity_period': self.ExpirationTim... | python | {
"resource": ""
} |
q238311 | rpc_name | train | def rpc_name(rpc_id):
"""Map an RPC id to a string name.
This function looks the RPC up in a map of all globally declared RPCs,
and returns a nice name string. if the RPC is not found in the global
name map, returns a generic name string such as 'rpc 0x%04X'.
Args:
rpc_id (int): The id of... | python | {
"resource": ""
} |
q238312 | stream_name | train | def stream_name(stream_id):
"""Map a stream id to a human readable name.
The mapping process is as follows:
If the stream id is globally known, its global name is used as <name>
otherwise a string representation of the stream is used as <name>.
In both cases the hex representation of the stream i... | python | {
"resource": ""
} |
q238313 | SConsValues.set_option | train | def set_option(self, name, value):
"""
Sets an option from an SConscript file.
"""
if not name in self.settable:
raise SCons.Errors.UserError("This option is not settable from a SConscript file: %s"%name)
if name == 'num_jobs':
try:
value ... | python | {
"resource": ""
} |
q238314 | SConsOptionGroup.format_help | train | def format_help(self, formatter):
"""
Format an option group's help text, outdenting the title so it's
flush with the "SCons Options" title we print at the top.
"""
formatter.dedent()
result = formatter.format_heading(self.title)
formatter.indent()
result ... | python | {
"resource": ""
} |
q238315 | SConsOptionParser._process_long_opt | train | def _process_long_opt(self, rargs, values):
"""
SCons-specific processing of long options.
This is copied directly from the normal
optparse._process_long_opt() method, except that, if configured
to do so, we catch the exception thrown when an unknown option
is encountere... | python | {
"resource": ""
} |
q238316 | SConsOptionParser.add_local_option | train | def add_local_option(self, *args, **kw):
"""
Adds a local option to the parser.
This is initiated by a SetOption() call to add a user-defined
command-line option. We add the option to a separate option
group for the local options, creating the group if necessary.
"""
... | python | {
"resource": ""
} |
q238317 | SConsIndentedHelpFormatter.format_heading | train | def format_heading(self, heading):
"""
This translates any heading of "options" or "Options" into
"SCons Options." Unfortunately, we have to do this here,
because those titles are hard-coded in the optparse calls.
"""
if heading == 'Options':
heading = "SCons... | python | {
"resource": ""
} |
q238318 | TBBlock.to_dict | train | def to_dict(self):
"""Convert this object into a dictionary.
Returns:
dict: A dict with the same information as this object.
"""
out_dict = {}
out_dict['commands'] = self.commands
out_dict['configs'] = self.configs
out_dict['short_name'] = self.name... | python | {
"resource": ""
} |
q238319 | TBBlock.set_api_version | train | def set_api_version(self, major, minor):
"""Set the API version this module was designed for.
Each module must declare the mib12 API version it was compiled with as a
2 byte major.minor number. This information is used by the pic12_executive
to decide whether the application is compati... | python | {
"resource": ""
} |
q238320 | TBBlock.set_module_version | train | def set_module_version(self, major, minor, patch):
"""Set the module version for this module.
Each module must declare a semantic version number in the form:
major.minor.patch
where each component is a 1 byte number between 0 and 255.
"""
if not (self._is_byte(major) a... | python | {
"resource": ""
} |
q238321 | TBBlock.set_name | train | def set_name(self, name):
"""Set the module name to a 6 byte string
If the string is too short it is appended with space characters.
"""
if len(name) > 6:
raise ArgumentError("Name must be at most 6 characters long", name=name)
if len(name) < 6:
name +=... | python | {
"resource": ""
} |
q238322 | TBBlock.add_command | train | def add_command(self, cmd_id, handler):
"""Add a command to the TBBlock.
The cmd_id must be a non-negative 2 byte number.
handler should be the command handler
"""
if cmd_id < 0 or cmd_id >= 2**16:
raise ArgumentError("Command ID in mib block is not a non-negative 2... | python | {
"resource": ""
} |
q238323 | TBBlock.add_config | train | def add_config(self, config_id, config_data):
"""Add a configuration variable to the MIB block"""
if config_id < 0 or config_id >= 2**16:
raise ArgumentError("Config ID in mib block is not a non-negative 2-byte number",
config_data=config_id, data=config_data... | python | {
"resource": ""
} |
q238324 | TBBlock._parse_hwtype | train | def _parse_hwtype(self):
"""Convert the numerical hardware id to a chip name."""
self.chip_name = KNOWN_HARDWARE_TYPES.get(self.hw_type, "Unknown Chip (type=%d)" % self.hw_type) | python | {
"resource": ""
} |
q238325 | TBBlock.render_template | train | def render_template(self, template_name, out_path=None):
"""Render a template based on this TileBus Block.
The template has access to all of the attributes of this block as a
dictionary (the result of calling self.to_dict()).
You can optionally render to a file by passing out_path.
... | python | {
"resource": ""
} |
q238326 | Tag | train | def Tag(env, target, source, *more_tags, **kw_tags):
""" Tag a file with the given arguments, just sets the accordingly named
attribute on the file object.
TODO: FIXME
"""
if not target:
target=source
first_tag=None
else:
first_tag=source
if first_tag:
kw_ta... | python | {
"resource": ""
} |
q238327 | copy_attr | train | def copy_attr(f1, f2):
""" copies the special packaging file attributes from f1 to f2.
"""
copyit = lambda x: not hasattr(f2, x) and x[:10] == 'PACKAGING_'
if f1._tags:
pattrs = [tag for tag in f1._tags if copyit(tag)]
for attr in pattrs:
f2.Tag(attr, f1.GetTag(attr)) | python | {
"resource": ""
} |
q238328 | putintopackageroot | train | def putintopackageroot(target, source, env, pkgroot, honor_install_location=1):
""" Uses the CopyAs builder to copy all source files to the directory given
in pkgroot.
If honor_install_location is set and the copied source file has an
PACKAGING_INSTALL_LOCATION attribute, the PACKAGING_INSTALL_LOCATION... | python | {
"resource": ""
} |
q238329 | stripinstallbuilder | train | def stripinstallbuilder(target, source, env):
""" Strips the install builder action from the source list and stores
the final installation location as the "PACKAGING_INSTALL_LOCATION" of
the source of the source file. This effectively removes the final installed
files from the source list while remember... | python | {
"resource": ""
} |
q238330 | BufferedStreamWalker.restore | train | def restore(self, state):
"""Restore a previous state of this stream walker.
Raises:
ArgumentError: If the state refers to a different selector or the
offset is invalid.
"""
selector = DataStreamSelector.FromString(state.get(u'selector'))
if selector... | python | {
"resource": ""
} |
q238331 | BufferedStreamWalker.pop | train | def pop(self):
"""Pop a reading off of this stream and return it."""
if self._count == 0:
raise StreamEmptyError("Pop called on buffered stream walker without any data", selector=self.selector)
while True:
curr = self.engine.get(self.storage_type, self.offset)
... | python | {
"resource": ""
} |
q238332 | BufferedStreamWalker.seek | train | def seek(self, value, target="offset"):
"""Seek this stream to a specific offset or reading id.
There are two modes of use. You can seek to a specific reading id,
which means the walker will be positioned exactly at the reading
pointed to by the reading ID. If the reading id cannot be... | python | {
"resource": ""
} |
q238333 | BufferedStreamWalker.skip_all | train | def skip_all(self):
"""Skip all readings in this walker."""
storage, streaming = self.engine.count()
if self.selector.output:
self.offset = streaming
else:
self.offset = storage
self._count = 0 | python | {
"resource": ""
} |
q238334 | BufferedStreamWalker.notify_rollover | train | def notify_rollover(self, stream):
"""Notify that a reading in the given stream was overwritten.
Args:
stream (DataStream): The stream that had overwritten data.
"""
self.offset -= 1
if not self.matches(stream):
return
if self._count == 0:
... | python | {
"resource": ""
} |
q238335 | VirtualStreamWalker.dump | train | def dump(self):
"""Serialize the state of this stream walker.
Returns:
dict: The serialized state.
"""
reading = self.reading
if reading is not None:
reading = reading.asdict()
return {
u'selector': str(self.selector),
u'... | python | {
"resource": ""
} |
q238336 | CounterStreamWalker.peek | train | def peek(self):
"""Peek at the oldest reading in this virtual stream."""
if self.reading is None:
raise StreamEmptyError("peek called on virtual stream walker without any data", selector=self.selector)
return self.reading | python | {
"resource": ""
} |
q238337 | LinebufferUI.run | train | def run(self, refresh_interval=0.05):
"""Set up the loop, check that the tool is installed"""
try:
from asciimatics.screen import Screen
except ImportError:
raise ExternalError("You must have asciimatics installed to use LinebufferUI",
sugg... | python | {
"resource": ""
} |
q238338 | find_vc_pdir | train | def find_vc_pdir(msvc_version):
"""Try to find the product directory for the given
version.
Note
----
If for some reason the requested version could not be found, an
exception which inherits from VisualCException will be raised."""
root = 'Software\\'
try:
hkeys = _VCVER_TO_PROD... | python | {
"resource": ""
} |
q238339 | compile_sgf | train | def compile_sgf(in_path, optimize=True, model=None):
"""Compile and optionally optimize an SGF file.
Args:
in_path (str): The input path to the sgf file to compile.
optimize (bool): Whether to optimize the compiled result,
defaults to True if not passed.
model (DeviceModel):... | python | {
"resource": ""
} |
q238340 | generate | train | def generate(env):
"""Add Builders and construction variables for g77 to an Environment."""
add_all_to_env(env)
add_f77_to_env(env)
fcomp = env.Detect(compilers) or 'g77'
if env['PLATFORM'] in ['cygwin', 'win32']:
env['SHFORTRANFLAGS'] = SCons.Util.CLVar('$FORTRANFLAGS')
env['SHF77F... | python | {
"resource": ""
} |
q238341 | get_language | train | def get_language():
"""Create or retrieve the parse tree for defining a sensor graph."""
global sensor_graph, statement
if sensor_graph is not None:
return sensor_graph
_create_primitives()
_create_simple_statements()
_create_block_bnf()
sensor_graph = ZeroOrMore(statement) + Str... | python | {
"resource": ""
} |
q238342 | _create_mo_file_builder | train | def _create_mo_file_builder(env, **kw):
""" Create builder object for `MOFiles` builder """
import SCons.Action
# FIXME: What factory use for source? Ours or their?
kw['action'] = SCons.Action.Action('$MSGFMTCOM','$MSGFMTCOMSTR')
kw['suffix'] = '$MOSUFFIX'
kw['src_suffix'] = '$POSUFFIX'
kw['src_builder'] ... | python | {
"resource": ""
} |
q238343 | generate | train | def generate(env,**kw):
""" Generate `msgfmt` tool """
import SCons.Util
from SCons.Tool.GettextCommon import _detect_msgfmt
try:
env['MSGFMT'] = _detect_msgfmt(env)
except:
env['MSGFMT'] = 'msgfmt'
env.SetDefault(
MSGFMTFLAGS = [ SCons.Util.CLVar('-c') ],
MSGFMTCOM = '$MSGFMT $MSGFMTFLAGS -... | python | {
"resource": ""
} |
q238344 | RCScan | train | def RCScan():
"""Return a prototype Scanner instance for scanning RC source files"""
res_re= r'^(?:\s*#\s*(?:include)|' \
'.*?\s+(?:ICON|BITMAP|CURSOR|HTML|FONT|MESSAGETABLE|TYPELIB|REGISTRY|D3DFX)' \
'\s*.*?)' \
'\s*(<|"| )([^>"\s]+)(?:[>"\s])*$'
resScanner = SCons.Scan... | python | {
"resource": ""
} |
q238345 | _read_linguas_from_files | train | def _read_linguas_from_files(env, linguas_files=None):
""" Parse `LINGUAS` file and return list of extracted languages """
import SCons.Util
import SCons.Environment
global _re_comment
global _re_lang
if not SCons.Util.is_List(linguas_files) \
and not SCons.Util.is_String(linguas_fil... | python | {
"resource": ""
} |
q238346 | _init_po_files | train | def _init_po_files(target, source, env):
""" Action function for `POInit` builder. """
nop = lambda target, source, env: 0
if 'POAUTOINIT' in env:
autoinit = env['POAUTOINIT']
else:
autoinit = False
# Well, if everything outside works well, this loop should do single
# iteration.... | python | {
"resource": ""
} |
q238347 | _POTargetFactory._create_node | train | def _create_node(self, name, factory, directory=None, create=1):
""" Create node, and set it up to factory settings. """
import SCons.Util
node = factory(name, directory, create)
node.set_noclean(self.noclean)
node.set_precious(self.precious)
if self.nodefault:
... | python | {
"resource": ""
} |
q238348 | _POTargetFactory.Entry | train | def Entry(self, name, directory=None, create=1):
""" Create `SCons.Node.FS.Entry` """
return self._create_node(name, self.env.fs.Entry, directory, create) | python | {
"resource": ""
} |
q238349 | _POTargetFactory.File | train | def File(self, name, directory=None, create=1):
""" Create `SCons.Node.FS.File` """
return self._create_node(name, self.env.fs.File, directory, create) | python | {
"resource": ""
} |
q238350 | StreamAllocator.allocate_stream | train | def allocate_stream(self, stream_type, stream_id=None, previous=None, attach=False):
"""Allocate a new stream of the given type.
The stream is allocated with an incremental ID starting at
StreamAllocator.StartingID. The returned data stream can always
be used to to attach a NodeInput t... | python | {
"resource": ""
} |
q238351 | StreamAllocator.attach_stream | train | def attach_stream(self, stream):
"""Notify that we would like to attach a node input to this stream.
The return value from this function is the DataStream that should be attached
to since this function may internally allocate a new SGNode that copies the
stream if there is no space in t... | python | {
"resource": ""
} |
q238352 | IOTile._find_v1_settings | train | def _find_v1_settings(self, settings):
"""Parse a v1 module_settings.json file.
V1 is the older file format that requires a modules dictionary with a
module_name and modules key that could in theory hold information on
multiple modules in a single directory.
"""
if 'mod... | python | {
"resource": ""
} |
q238353 | IOTile._ensure_product_string | train | def _ensure_product_string(cls, product):
"""Ensure that all product locations are strings.
Older components specify paths as lists of path components. Join
those paths into a normal path string.
"""
if isinstance(product, str):
return product
if isinstanc... | python | {
"resource": ""
} |
q238354 | IOTile.find_products | train | def find_products(self, product_type):
"""Search for products of a given type.
Search through the products declared by this IOTile component and
return only those matching the given type. If the product is described
by the path to a file, a complete normalized path will be returned.
... | python | {
"resource": ""
} |
q238355 | IOTile.library_directories | train | def library_directories(self):
"""Return a list of directories containing any static libraries built by this IOTile."""
libs = self.find_products('library')
if len(libs) > 0:
return [os.path.join(self.output_folder)]
return [] | python | {
"resource": ""
} |
q238356 | IOTile.filter_products | train | def filter_products(self, desired_prods):
"""When asked for a product, filter only those on this list."""
self.filter_prods = True
self.desired_prods = set(desired_prods) | python | {
"resource": ""
} |
q238357 | format_ascii | train | def format_ascii(sensor_graph):
"""Format this sensor graph as a loadable ascii file format.
This includes commands to reset and clear previously stored
sensor graphs.
NB. This format does not include any required configuration
variables that were specified in this sensor graph, so you
should ... | python | {
"resource": ""
} |
q238358 | SensorGraph.clear | train | def clear(self):
"""Clear all nodes from this sensor_graph.
This function is equivalent to just creating a new SensorGraph() object
from scratch. It does not clear any data from the SensorLog, however.
"""
self.roots = []
self.nodes = []
self.streamers = []
... | python | {
"resource": ""
} |
q238359 | SensorGraph.add_node | train | def add_node(self, node_descriptor):
"""Add a node to the sensor graph based on the description given.
The node_descriptor must follow the sensor graph DSL and describe
a node whose input nodes already exist.
Args:
node_descriptor (str): A description of the node to be adde... | python | {
"resource": ""
} |
q238360 | SensorGraph.add_config | train | def add_config(self, slot, config_id, config_type, value):
"""Add a config variable assignment to this sensor graph.
Args:
slot (SlotIdentifier): The slot identifier that this config
variable is assigned to.
config_id (int): The 16-bit id of this config_id
... | python | {
"resource": ""
} |
q238361 | SensorGraph.add_streamer | train | def add_streamer(self, streamer):
"""Add a streamer to this sensor graph.
Args:
streamer (DataStreamer): The streamer we want to add
"""
if self._max_streamers is not None and len(self.streamers) >= self._max_streamers:
raise ResourceUsageError("Maximum number o... | python | {
"resource": ""
} |
q238362 | SensorGraph.add_constant | train | def add_constant(self, stream, value):
"""Store a constant value for use in this sensor graph.
Constant assignments occur after all sensor graph nodes have been
allocated since they must be propogated to all appropriate virtual
stream walkers.
Args:
stream (DataStre... | python | {
"resource": ""
} |
q238363 | SensorGraph.add_metadata | train | def add_metadata(self, name, value):
"""Attach a piece of metadata to this sensorgraph.
Metadata is not used during the simulation of a sensorgraph but allows
it to convey additional context that may be used during code
generation. For example, associating an `app_tag` with a sensorgra... | python | {
"resource": ""
} |
q238364 | SensorGraph.initialize_remaining_constants | train | def initialize_remaining_constants(self, value=0):
"""Ensure that all constant streams referenced in the sensor graph have a value.
Constant streams that are automatically created by the compiler are initialized
as part of the compilation process but it's possible that the user references
... | python | {
"resource": ""
} |
q238365 | SensorGraph.load_constants | train | def load_constants(self):
"""Load all constants into their respective streams.
All previous calls to add_constant stored a constant value that
should be associated with virtual stream walkers. This function
actually calls push_stream in order to push all of the constant
values ... | python | {
"resource": ""
} |
q238366 | SensorGraph.get_config | train | def get_config(self, slot, config_id):
"""Get a config variable assignment previously set on this sensor graph.
Args:
slot (SlotIdentifier): The slot that we are setting this config variable
on.
config_id (int): The 16-bit config variable identifier.
Ret... | python | {
"resource": ""
} |
q238367 | SensorGraph.is_output | train | def is_output(self, stream):
"""Check if a stream is a sensor graph output.
Return:
bool
"""
for streamer in self.streamers:
if streamer.selector.matches(stream):
return True
return False | python | {
"resource": ""
} |
q238368 | SensorGraph.get_tick | train | def get_tick(self, name):
"""Check the config variables to see if there is a configurable tick.
Sensor Graph has a built-in 10 second tick that is sent every 10
seconds to allow for triggering timed events. There is a second
'user' tick that is generated internally by the sensorgraph c... | python | {
"resource": ""
} |
q238369 | SensorGraph.mark_streamer | train | def mark_streamer(self, index):
"""Manually mark a streamer that should trigger.
The next time check_streamers is called, the given streamer will be
manually marked that it should trigger, which will cause it to trigger
unless it has no data.
Args:
index (int): The ... | python | {
"resource": ""
} |
q238370 | SensorGraph.check_streamers | train | def check_streamers(self, blacklist=None):
"""Check if any streamers are ready to produce a report.
You can limit what streamers are checked by passing a set-like
object into blacklist.
This method is the primary way to see when you should poll a given
streamer for its next rep... | python | {
"resource": ""
} |
q238371 | SensorGraph.sort_nodes | train | def sort_nodes(self):
"""Topologically sort all of our nodes.
Topologically sorting our nodes makes nodes that are inputs to other
nodes come first in the list of nodes. This is important to do before
programming a sensorgraph into an embedded device whose engine assumes
a topo... | python | {
"resource": ""
} |
q238372 | generate | train | def generate(env):
"""Add Builders and construction variables for ipkg to an Environment."""
try:
bld = env['BUILDERS']['Ipkg']
except KeyError:
bld = SCons.Builder.Builder(action='$IPKGCOM',
suffix='$IPKGSUFFIX',
source... | python | {
"resource": ""
} |
q238373 | InputTrigger.triggered | train | def triggered(self, walker):
"""Check if this input is triggered on the given stream walker.
Args:
walker (StreamWalker): The walker to check
Returns:
bool: Whether this trigger is triggered or not
"""
if self.use_count:
comp_value = walker.... | python | {
"resource": ""
} |
q238374 | SGNode.connect_input | train | def connect_input(self, index, walker, trigger=None):
"""Connect an input to a stream walker.
If the input is already connected to something an exception is thrown.
Otherwise the walker is used to read inputs for that input.
A triggering condition can optionally be passed that will det... | python | {
"resource": ""
} |
q238375 | SGNode.input_streams | train | def input_streams(self):
"""Return a list of DataStream objects for all singular input streams.
This function only returns individual streams, not the streams that would
be selected from a selector like 'all outputs' for example.
Returns:
list(DataStream): A list of all of ... | python | {
"resource": ""
} |
q238376 | SGNode.find_input | train | def find_input(self, stream):
"""Find the input that responds to this stream.
Args:
stream (DataStream): The stream to find
Returns:
(index, None): The index if found or None
"""
for i, input_x in enumerate(self.inputs):
if input_x[0].matche... | python | {
"resource": ""
} |
q238377 | SGNode.num_inputs | train | def num_inputs(self):
"""Return the number of connected inputs.
Returns:
int: The number of connected inputs
"""
num = 0
for walker, _ in self.inputs:
if not isinstance(walker, InvalidStreamWalker):
num += 1
return num | python | {
"resource": ""
} |
q238378 | SGNode.connect_output | train | def connect_output(self, node):
"""Connect another node to our output.
This downstream node will automatically be triggered when we update
our output.
Args:
node (SGNode): The node that should receive our output
"""
if len(self.outputs) == self.max_outputs:... | python | {
"resource": ""
} |
q238379 | SGNode.triggered | train | def triggered(self):
"""Test if we should trigger our operation.
We test the trigger condition on each of our inputs and then
combine those triggers using our configured trigger combiner
to get an overall result for whether this node is triggered.
Returns:
bool: Tru... | python | {
"resource": ""
} |
q238380 | SGNode.set_func | train | def set_func(self, name, func):
"""Set the processing function to use for this node.
Args:
name (str): The name of the function to use. This is
just stored for reference in case we need to serialize
the node later.
func (callable): A function tha... | python | {
"resource": ""
} |
q238381 | SGNode.process | train | def process(self, rpc_executor, mark_streamer=None):
"""Run this node's processing function.
Args:
rpc_executor (RPCExecutor): An object capable of executing RPCs
in case we need to do that.
mark_streamer (callable): Function that can be called to manually
... | python | {
"resource": ""
} |
q238382 | FortranScan | train | def FortranScan(path_variable="FORTRANPATH"):
"""Return a prototype Scanner instance for scanning source files
for Fortran USE & INCLUDE statements"""
# The USE statement regex matches the following:
#
# USE module_name
# USE :: module_name
# USE, INTRINSIC :: module_name
# USE, NON_INTRINSIC :: modu... | python | {
"resource": ""
} |
q238383 | generate | train | def generate(env):
"""Add Builders and construction variables for compaq visual fortran to an Environment."""
fortran.generate(env)
env['FORTRAN'] = 'f90'
env['FORTRANCOM'] = '$FORTRAN $FORTRANFLAGS $_FORTRANMODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.windows} /object:${TARGET.windows... | python | {
"resource": ""
} |
q238384 | Value.read | train | def read(self):
"""Return the value. If necessary, the value is built."""
self.build()
if not hasattr(self, 'built_value'):
self.built_value = self.value
return self.built_value | python | {
"resource": ""
} |
q238385 | Value.get_csig | train | def get_csig(self, calc=None):
"""Because we're a Python value node and don't have a real
timestamp, we get to ignore the calculator and just use the
value contents."""
try:
return self.ninfo.csig
except AttributeError:
pass
contents = self.get_con... | python | {
"resource": ""
} |
q238386 | SerializableState.mark_complex | train | def mark_complex(self, name, serializer, deserializer):
"""Mark a property as complex with serializer and deserializer functions.
Args:
name (str): The name of the complex property.
serializer (callable): The function to call to serialize the property's
value to ... | python | {
"resource": ""
} |
q238387 | SerializableState.mark_typed_list | train | def mark_typed_list(self, name, type_object):
"""Mark a property as containing serializable objects of a given type.
This convenience method allows you to avoid having to call
``mark_complex()`` whenever you need to serialize a list of objects.
This method requires that all members of t... | python | {
"resource": ""
} |
q238388 | SerializableState.mark_typed_map | train | def mark_typed_map(self, name, type_object):
"""Mark a property as containing a map str to serializable object.
This convenience method allows you to avoid having to call
``mark_complex()`` whenever you need to serialize a dict of objects.
This method requires that all members of the gi... | python | {
"resource": ""
} |
q238389 | SerializableState.mark_typed_object | train | def mark_typed_object(self, name, type_object):
"""Mark a property as containing a serializable object.
This convenience method allows you to avoid having to call
``mark_complex()`` whenever you need to serialize a complex object.
This method requires that property ``name`` be a single ... | python | {
"resource": ""
} |
q238390 | SerializableState.dump_property | train | def dump_property(self, name):
"""Serialize a property of this class by name.
Args:
name (str): The name of the property to dump.
Returns:
object: The serialized value of the property.
"""
if not hasattr(self, name):
raise ArgumentError("Unk... | python | {
"resource": ""
} |
q238391 | SerializableState.get_properties | train | def get_properties(self):
"""Get a list of all of the public data properties of this class.
Returns:
list of str: A list of all of the public properties in this class.
"""
names = inspect.getmembers(self, predicate=lambda x: not inspect.ismethod(x))
return [x[0] for... | python | {
"resource": ""
} |
q238392 | get_default_version | train | def get_default_version(env):
"""Returns the default version string to use for MSVS.
If no version was requested by the user through the MSVS environment
variable, query all the available visual studios through
get_installed_visual_studios, and take the highest one.
Return
------
version: ... | python | {
"resource": ""
} |
q238393 | get_default_arch | train | def get_default_arch(env):
"""Return the default arch to use for MSVS
if no version was requested by the user through the MSVS_ARCH environment
variable, select x86
Return
------
arch: str
"""
arch = env.get('MSVS_ARCH', 'x86')
msvs = InstalledVSMap.get(env['MSVS_VERSION'])
i... | python | {
"resource": ""
} |
q238394 | ControlStructure.format_rpc | train | def format_rpc(self, address, rpc_id, payload):
"""Create a formated word list that encodes this rpc."""
addr_word = (rpc_id | (address << 16) | ((1 << 1) << 24))
send_length = len(payload)
if len(payload) < 20:
payload = payload + b'\0'*(20 - len(payload))
payload... | python | {
"resource": ""
} |
q238395 | ControlStructure.format_response | train | def format_response(self, response_data):
"""Format an RPC response."""
_addr, length = self.response_info()
if len(response_data) != length:
raise HardwareError("Invalid response read length, should be the same as what response_info() returns", expected=length, actual=len(response_... | python | {
"resource": ""
} |
q238396 | ProgramScanner | train | def ProgramScanner(**kw):
"""Return a prototype Scanner instance for scanning executable
files for static-lib dependencies"""
kw['path_function'] = SCons.Scanner.FindPathDirs('LIBPATH')
ps = SCons.Scanner.Base(scan, "ProgramScanner", **kw)
return ps | python | {
"resource": ""
} |
q238397 | _subst_libs | train | def _subst_libs(env, libs):
"""
Substitute environment variables and split into list.
"""
if SCons.Util.is_String(libs):
libs = env.subst(libs)
if SCons.Util.is_String(libs):
libs = libs.split()
elif SCons.Util.is_Sequence(libs):
_libs = []
for l in libs:
... | python | {
"resource": ""
} |
q238398 | scan | train | def scan(node, env, libpath = ()):
"""
This scanner scans program files for static-library
dependencies. It will search the LIBPATH environment variable
for libraries specified in the LIBS variable, returning any
files it finds as dependencies.
"""
try:
libs = env['LIBS']
except... | python | {
"resource": ""
} |
q238399 | RemoteBridgeState.clear_to_reset | train | def clear_to_reset(self, config_vars):
"""Clear the RemoteBridge subsystem to its reset state."""
super(RemoteBridgeState, self).clear_to_reset(config_vars)
self.status = BRIDGE_STATUS.IDLE
self.error = 0 | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.