_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q238500
UTCAssigner.ensure_prepared
train
def ensure_prepared(self): """Calculate and cache UTC values for all exactly known anchor points.""" if self._prepared: return exact_count = 0 fixed_count = 0 inexact_count = 0 self._logger.debug("Preparing UTCAssigner (%d total anchors)", len(self._anchor_...
python
{ "resource": "" }
q238501
UTCAssigner.fix_report
train
def fix_report(self, report, errors="drop", prefer="before"): """Perform utc assignment on all readings in a report. The returned report will have all reading timestamps in UTC. This only works on SignedListReport objects. Note that the report should typically have previously been adde...
python
{ "resource": "" }
q238502
UTCAssigner._fix_left
train
def _fix_left(self, reading_id, last, start, found_id): """Fix a reading by looking for the nearest anchor point before it.""" accum_delta = 0 exact = True crossed_break = False if start == 0: return None for curr in self._anchor_points.islice(None, start -...
python
{ "resource": "" }
q238503
sconsign_dir
train
def sconsign_dir(node): """Return the .sconsign file info for this directory, creating it first if necessary.""" if not node._sconsign: import SCons.SConsign node._sconsign = SCons.SConsign.ForDirectory(node) return node._sconsign
python
{ "resource": "" }
q238504
EntryProxy.__get_base_path
train
def __get_base_path(self): """Return the file's directory and file name, with the suffix stripped.""" entry = self.get() return SCons.Subst.SpecialAttrWrapper(SCons.Util.splitext(entry.get_path())[0], entry.name + "_base")
python
{ "resource": "" }
q238505
EntryProxy.__get_windows_path
train
def __get_windows_path(self): """Return the path with \ as the path separator, regardless of platform.""" if OS_SEP == '\\': return self else: entry = self.get() r = entry.get_path().replace(OS_SEP, '\\') return SCons.Subst.SpecialAttrWrapp...
python
{ "resource": "" }
q238506
Base.must_be_same
train
def must_be_same(self, klass): """ This node, which already existed, is being looked up as the specified klass. Raise an exception if it isn't. """ if isinstance(self, klass) or klass is Entry: return raise TypeError("Tried to lookup %s '%s' as a %s." %\ ...
python
{ "resource": "" }
q238507
Base.srcnode
train
def srcnode(self): """If this node is in a build path, return the node corresponding to its source file. Otherwise, return ourself. """ srcdir_list = self.dir.srcdir_list() if srcdir_list: srcnode = srcdir_list[0].Entry(self.name) srcnode.must_be_...
python
{ "resource": "" }
q238508
Base.get_path
train
def get_path(self, dir=None): """Return path relative to the current working directory of the Node.FS.Base object that owns us.""" if not dir: dir = self.fs.getcwd() if self == dir: return '.' path_elems = self.get_path_elements() pathname = '' ...
python
{ "resource": "" }
q238509
Base.set_src_builder
train
def set_src_builder(self, builder): """Set the source code builder for this node.""" self.sbuilder = builder if not self.has_builder(): self.builder_set(builder)
python
{ "resource": "" }
q238510
Base.src_builder
train
def src_builder(self): """Fetch the source code builder for this node. If there isn't one, we cache the source code builder specified for the directory (which in turn will cache the value from its parent directory, and so on up to the file system root). """ try: ...
python
{ "resource": "" }
q238511
Base.Rfindalldirs
train
def Rfindalldirs(self, pathlist): """ Return all of the directories for a given path list, including corresponding "backing" directories in any repositories. The Node lookups are relative to this Node (typically a directory), so memoizing result saves cycles from looking ...
python
{ "resource": "" }
q238512
Base.RDirs
train
def RDirs(self, pathlist): """Search for a list of directories in the Repository list.""" cwd = self.cwd or self.fs._cwd return cwd.Rfindalldirs(pathlist)
python
{ "resource": "" }
q238513
Entry.rfile
train
def rfile(self): """We're a generic Entry, but the caller is actually looking for a File at this point, so morph into one.""" self.__class__ = File self._morph() self.clear() return File.rfile(self)
python
{ "resource": "" }
q238514
Entry.get_text_contents
train
def get_text_contents(self): """Fetch the decoded text contents of a Unicode encoded Entry. Since this should return the text contents from the file system, we check to see into what sort of subclass we should morph this Entry.""" try: self = self.disambiguate(must_e...
python
{ "resource": "" }
q238515
Entry.must_be_same
train
def must_be_same(self, klass): """Called to make sure a Node is a Dir. Since we're an Entry, we can morph into one.""" if self.__class__ is not klass: self.__class__ = klass self._morph() self.clear()
python
{ "resource": "" }
q238516
FS.chdir
train
def chdir(self, dir, change_os_dir=0): """Change the current working directory for lookups. If change_os_dir is true, we will also change the "real" cwd to match. """ curr=self._cwd try: if dir is not None: self._cwd = dir if ch...
python
{ "resource": "" }
q238517
FS.get_root
train
def get_root(self, drive): """ Returns the root directory for the specified drive, creating it if necessary. """ drive = _my_normcase(drive) try: return self.Root[drive] except KeyError: root = RootDir(drive, self) self.Root[dri...
python
{ "resource": "" }
q238518
FS._lookup
train
def _lookup(self, p, directory, fsclass, create=1): """ The generic entry point for Node lookup with user-supplied data. This translates arbitrary input into a canonical Node.FS object of the specified fsclass. The general approach for strings is to turn it into a fully normali...
python
{ "resource": "" }
q238519
FS.VariantDir
train
def VariantDir(self, variant_dir, src_dir, duplicate=1): """Link the supplied variant directory to the source directory for purposes of building files.""" if not isinstance(src_dir, SCons.Node.Node): src_dir = self.Dir(src_dir) if not isinstance(variant_dir, SCons.Node.Node)...
python
{ "resource": "" }
q238520
FS.Repository
train
def Repository(self, *dirs): """Specify Repository directories to search.""" for d in dirs: if not isinstance(d, SCons.Node.Node): d = self.Dir(d) self.Top.addRepository(d)
python
{ "resource": "" }
q238521
FS.variant_dir_target_climb
train
def variant_dir_target_climb(self, orig, dir, tail): """Create targets in corresponding variant directories Climb the directory tree, and look up path names relative to any linked variant directories we find. Even though this loops and walks up the tree, we don't memoize the re...
python
{ "resource": "" }
q238522
Dir.Dir
train
def Dir(self, name, create=True): """ Looks up or creates a directory node named 'name' relative to this directory. """ return self.fs.Dir(name, self, create)
python
{ "resource": "" }
q238523
Dir.link
train
def link(self, srcdir, duplicate): """Set this directory as the variant directory for the supplied source directory.""" self.srcdir = srcdir self.duplicate = duplicate self.__clearRepositoryCache(duplicate) srcdir.variant_dirs.append(self)
python
{ "resource": "" }
q238524
Dir.getRepositories
train
def getRepositories(self): """Returns a list of repositories for this directory. """ if self.srcdir and not self.duplicate: return self.srcdir.get_all_rdirs() + self.repositories return self.repositories
python
{ "resource": "" }
q238525
Dir.rel_path
train
def rel_path(self, other): """Return a path to "other" relative to this directory. """ # This complicated and expensive method, which constructs relative # paths between arbitrary Node.FS objects, is no longer used # by SCons itself. It was introduced to store dependency paths ...
python
{ "resource": "" }
q238526
Dir.get_found_includes
train
def get_found_includes(self, env, scanner, path): """Return this directory's implicit dependencies. We don't bother caching the results because the scan typically shouldn't be requested more than once (as opposed to scanning .h file contents, which can be requested as many times as the ...
python
{ "resource": "" }
q238527
Dir.build
train
def build(self, **kw): """A null "builder" for directories.""" global MkdirBuilder if self.builder is not MkdirBuilder: SCons.Node.Node.build(self, **kw)
python
{ "resource": "" }
q238528
Dir._create
train
def _create(self): """Create this directory, silently and without worrying about whether the builder is the default or not.""" listDirs = [] parent = self while parent: if parent.exists(): break listDirs.append(parent) p = paren...
python
{ "resource": "" }
q238529
Dir.is_up_to_date
train
def is_up_to_date(self): """If any child is not up-to-date, then this directory isn't, either.""" if self.builder is not MkdirBuilder and not self.exists(): return 0 up_to_date = SCons.Node.up_to_date for kid in self.children(): if kid.get_state() > up_to_...
python
{ "resource": "" }
q238530
Dir.get_timestamp
train
def get_timestamp(self): """Return the latest timestamp from among our children""" stamp = 0 for kid in self.children(): if kid.get_timestamp() > stamp: stamp = kid.get_timestamp() return stamp
python
{ "resource": "" }
q238531
Dir.walk
train
def walk(self, func, arg): """ Walk this directory tree by calling the specified function for each directory in the tree. This behaves like the os.path.walk() function, but for in-memory Node.FS.Dir objects. The function takes the same arguments as the functions passed ...
python
{ "resource": "" }
q238532
Dir._glob1
train
def _glob1(self, pattern, ondisk=True, source=False, strings=False): """ Globs for and returns a list of entry names matching a single pattern in this directory. This searches any repositories and source directories for corresponding entries and returns a Node (or string) relati...
python
{ "resource": "" }
q238533
FileBuildInfo.convert_to_sconsign
train
def convert_to_sconsign(self): """ Converts this FileBuildInfo object for writing to a .sconsign file This replaces each Node in our various dependency lists with its usual string representation: relative to the top-level SConstruct directory, or an absolute path if it's outside...
python
{ "resource": "" }
q238534
FileBuildInfo.prepare_dependencies
train
def prepare_dependencies(self): """ Prepares a FileBuildInfo object for explaining what changed The bsources, bdepends and bimplicit lists have all been stored on disk as paths relative to the top-level SConstruct directory. Convert the strings to actual Nodes (for use by the ...
python
{ "resource": "" }
q238535
File.Dir
train
def Dir(self, name, create=True): """Create a directory node named 'name' relative to the directory of this file.""" return self.dir.Dir(name, create=create)
python
{ "resource": "" }
q238536
File._morph
train
def _morph(self): """Turn a file system node into a File object.""" self.scanner_paths = {} if not hasattr(self, '_local'): self._local = 0 if not hasattr(self, 'released_target_info'): self.released_target_info = False self.store_info = 1 self._f...
python
{ "resource": "" }
q238537
File.get_text_contents
train
def get_text_contents(self): """ This attempts to figure out what the encoding of the text is based upon the BOM bytes, and then decodes the contents so that it's a valid python string. """ contents = self.get_contents() # The behavior of various decode() methods ...
python
{ "resource": "" }
q238538
File.get_content_hash
train
def get_content_hash(self): """ Compute and return the MD5 hash for this file. """ if not self.rexists(): return SCons.Util.MD5signature('') fname = self.rfile().get_abspath() try: cs = SCons.Util.MD5filesignature(fname, chunksize=S...
python
{ "resource": "" }
q238539
File.get_found_includes
train
def get_found_includes(self, env, scanner, path): """Return the included implicit dependencies in this file. Cache results so we only scan the file once per path regardless of how many times this information is requested. """ memo_key = (id(env), id(scanner), path) try: ...
python
{ "resource": "" }
q238540
File.push_to_cache
train
def push_to_cache(self): """Try to push the node into a cache """ # This should get called before the Nodes' .built() method is # called, which would clear the build signature if the file has # a source scanner. # # We have to clear the local memoized values *befo...
python
{ "resource": "" }
q238541
File.retrieve_from_cache
train
def retrieve_from_cache(self): """Try to retrieve the node's content from a cache This method is called from multiple threads in a parallel build, so only do thread safe stuff here. Do thread unsafe stuff in built(). Returns true if the node was successfully retrieved. ...
python
{ "resource": "" }
q238542
File.release_target_info
train
def release_target_info(self): """Called just after this node has been marked up-to-date or was built completely. This is where we try to release as many target node infos as possible for clean builds and update runs, in order to minimize the overall memory consumption. ...
python
{ "resource": "" }
q238543
File.has_src_builder
train
def has_src_builder(self): """Return whether this Node has a source builder or not. If this Node doesn't have an explicit source code builder, this is where we figure out, on the fly, if there's a transparent source code builder for it. Note that if we found a source builder, w...
python
{ "resource": "" }
q238544
File.alter_targets
train
def alter_targets(self): """Return any corresponding targets in a variant directory. """ if self.is_derived(): return [], None return self.fs.variant_dir_target_climb(self, self.dir, [self.name])
python
{ "resource": "" }
q238545
File.prepare
train
def prepare(self): """Prepare for this file to be created.""" SCons.Node.Node.prepare(self) if self.get_state() != SCons.Node.up_to_date: if self.exists(): if self.is_derived() and not self.precious: self._rmv_existing() else: ...
python
{ "resource": "" }
q238546
File.remove
train
def remove(self): """Remove this file.""" if self.exists() or self.islink(): self.fs.unlink(self.get_internal_path()) return 1 return None
python
{ "resource": "" }
q238547
File.get_max_drift_csig
train
def get_max_drift_csig(self): """ Returns the content signature currently stored for this node if it's been unmodified longer than the max_drift value, or the max_drift value is 0. Returns None otherwise. """ old = self.get_stored_info() mtime = self.get_timestam...
python
{ "resource": "" }
q238548
File.built
train
def built(self): """Called just after this File node is successfully built. Just like for 'release_target_info' we try to release some more target node attributes in order to minimize the overall memory consumption. @see: release_target_info """ SCons.Node....
python
{ "resource": "" }
q238549
File.changed
train
def changed(self, node=None, allowcache=False): """ Returns if the node is up-to-date with respect to the BuildInfo stored last time it was built. For File nodes this is basically a wrapper around Node.changed(), but we allow the return value to get cached after the reference ...
python
{ "resource": "" }
q238550
File.get_cachedir_csig
train
def get_cachedir_csig(self): """ Fetch a Node's content signature for purposes of computing another Node's cachesig. This is a wrapper around the normal get_csig() method that handles the somewhat obscure case of using CacheDir with the -n option. Any files that don't ex...
python
{ "resource": "" }
q238551
File.get_contents_sig
train
def get_contents_sig(self): """ A helper method for get_cachedir_bsig. It computes and returns the signature for this node's contents. """ try: return self.contentsig except AttributeError: pass executor = self.get_executor() ...
python
{ "resource": "" }
q238552
File.get_cachedir_bsig
train
def get_cachedir_bsig(self): """ Return the signature for a cached file, including its children. It adds the path of the cached file to the cache signature, because multiple targets built by the same action will all have the same build signature, and we have to different...
python
{ "resource": "" }
q238553
FileFinder.find_file
train
def find_file(self, filename, paths, verbose=None): """ Find a node corresponding to either a derived file or a file that exists already. Only the first file found is returned, and none is returned if no file is found. filename: A filename to find paths: A list of directory pat...
python
{ "resource": "" }
q238554
SendOTAScriptStep.run
train
def run(self, resources): """Actually send the trub script. Args: resources (dict): A dictionary containing the required resources that we needed access to in order to perform this step. """ hwman = resources['connection'] updater = hwman.hwman.app(...
python
{ "resource": "" }
q238555
process_gatt_service
train
def process_gatt_service(services, event): """Process a BGAPI event containing a GATT service description and add it to a dictionary Args: services (dict): A dictionary of discovered services that is updated with this event event (BGAPIPacket): An event containing a GATT service """ l...
python
{ "resource": "" }
q238556
handle_to_uuid
train
def handle_to_uuid(handle, services): """Find the corresponding UUID for an attribute handle""" for service in services.values(): for char_uuid, char_def in service['characteristics'].items(): if char_def['handle'] == handle: return char_uuid raise ValueError("Handle no...
python
{ "resource": "" }
q238557
_validator
train
def _validator(key, val, env): """ Validates the given value to be either '0' or '1'. This is usable as 'validator' for SCons' Variables. """ if not env[key] in (True, False): raise SCons.Errors.UserError( 'Invalid value for boolean option %s: %s' % (key, env[key]))
python
{ "resource": "" }
q238558
ServiceMessage.FromDictionary
train
def FromDictionary(cls, msg_dict): """Create from a dictionary with kv pairs. Args: msg_dict (dict): A dictionary with information as created by to_dict() Returns: ServiceMessage: the converted message """ level = msg_dict.get('level') msg = msg...
python
{ "resource": "" }
q238559
ServiceMessage.to_dict
train
def to_dict(self): """Create a dictionary with the information in this message. Returns: dict: The dictionary with information """ msg_dict = {} msg_dict['level'] = self.level msg_dict['message'] = self.message msg_dict['now_time'] = monotonic() ...
python
{ "resource": "" }
q238560
ServiceState.get_message
train
def get_message(self, message_id): """Get a message by its persistent id. Args: message_id (int): The id of the message that we're looking for """ for message in self.messages: if message.id == message_id: return message raise ArgumentEr...
python
{ "resource": "" }
q238561
ServiceState.post_message
train
def post_message(self, level, message, count=1, timestamp=None, now_reference=None): """Post a new message for service. Args: level (int): The level of the message (info, warning, error) message (string): The message contents count (int): The number of times the mess...
python
{ "resource": "" }
q238562
ServiceState.set_headline
train
def set_headline(self, level, message, timestamp=None, now_reference=None): """Set the persistent headline message for this service. Args: level (int): The level of the message (info, warning, error) message (string): The message contents timestamp (float): An option...
python
{ "resource": "" }
q238563
generate_doxygen_file
train
def generate_doxygen_file(output_path, iotile): """Fill in our default doxygen template file with info from an IOTile This populates things like name, version, etc. Arguments: output_path (str): a string path for where the filled template should go iotile (IOTile): An IOTile object that c...
python
{ "resource": "" }
q238564
pull
train
def pull(name, version, force=False): """Pull a released IOTile component into the current working directory The component is found using whatever DependencyResolvers are installed and registered as part of the default DependencyResolverChain. This is the same mechanism used in iotile depends update, ...
python
{ "resource": "" }
q238565
SynchronousLegacyWrapper.add_callback
train
def add_callback(self, name, func): """Add a callback when device events happen. Args: name (str): currently support 'on_scan' and 'on_disconnect' func (callable): the function that should be called """ if name == 'on_scan': events = ['device_seen'] ...
python
{ "resource": "" }
q238566
SynchronousLegacyWrapper.disconnect_async
train
def disconnect_async(self, conn_id, callback): """Asynchronously disconnect from a device.""" future = self._loop.launch_coroutine(self._adapter.disconnect(conn_id)) future.add_done_callback(lambda x: self._callback_future(conn_id, x, callback))
python
{ "resource": "" }
q238567
SynchronousLegacyWrapper.send_script_async
train
def send_script_async(self, conn_id, data, progress_callback, callback): """Asynchronously send a script to the device.""" def monitor_callback(_conn_string, _conn_id, _event_name, event): if event.get('operation') != 'script': return progress_callback(event.get...
python
{ "resource": "" }
q238568
MQTTTopicValidator.lock
train
def lock(self, key, client): """Set the key that will be used to ensure messages come from one party Args: key (string): The key used to validate future messages client (string): A string that will be returned to indicate who locked this device. """ ...
python
{ "resource": "" }
q238569
EmulationStateLog.track_change
train
def track_change(self, tile, property_name, value, formatter=None): """Record that a change happened on a given tile's property. This will as a StateChange object to our list of changes if we are recording changes, otherwise, it will drop the change. Args: tile (int): The a...
python
{ "resource": "" }
q238570
EmulationStateLog.dump
train
def dump(self, out_path, header=True): """Save this list of changes as a csv file at out_path. The format of the output file will be a CSV with 4 columns: timestamp, tile address, property, string_value There will be a single header row starting the CSV output unless header=Fal...
python
{ "resource": "" }
q238571
generate
train
def generate(env): """Add Builders and construction variables for pdftex to an Environment.""" global PDFTeXAction if PDFTeXAction is None: PDFTeXAction = SCons.Action.Action('$PDFTEXCOM', '$PDFTEXCOMSTR') global PDFLaTeXAction if PDFLaTeXAction is None: PDFLaTeXAction = SCons.Actio...
python
{ "resource": "" }
q238572
TileBasedVirtualDevice.stop
train
def stop(self): """Stop running this virtual device including any worker threads.""" for tile in self._tiles.values(): tile.signal_stop() for tile in self._tiles.values(): tile.wait_stopped() super(TileBasedVirtualDevice, self).stop()
python
{ "resource": "" }
q238573
SetCacheMode
train
def SetCacheMode(mode): """Set the Configure cache mode. mode must be one of "auto", "force", or "cache".""" global cache_mode if mode == "auto": cache_mode = AUTO elif mode == "force": cache_mode = FORCE elif mode == "cache": cache_mode = CACHE else: raise Va...
python
{ "resource": "" }
q238574
CreateConfigHBuilder
train
def CreateConfigHBuilder(env): """Called if necessary just before the building targets phase begins.""" action = SCons.Action.Action(_createConfigH, _stringConfigH) sconfigHBld = SCons.Builder.Builder(action=action) env.Append( BUILDERS={'SConfigHBuilder':sconfigHBld} ) ...
python
{ "resource": "" }
q238575
CheckHeader
train
def CheckHeader(context, header, include_quotes = '<>', language = None): """ A test for a C or C++ header file. """ prog_prefix, hdr_to_check = \ createIncludesFromHeaders(header, 1, include_quotes) res = SCons.Conftest.CheckHeader(context, hdr_to_check, prog_prefix, ...
python
{ "resource": "" }
q238576
CheckLib
train
def CheckLib(context, library = None, symbol = "main", header = None, language = None, autoadd = 1): """ A test for a library. See also CheckLibWithHeader. Note that library may also be None to test whether the given symbol compiles without flags. """ if library == []: libr...
python
{ "resource": "" }
q238577
CheckProg
train
def CheckProg(context, prog_name): """Simple check if a program exists in the path. Returns the path for the application, or None if not found. """ res = SCons.Conftest.CheckProg(context, prog_name) context.did_show_result = 1 return res
python
{ "resource": "" }
q238578
SConfBuildTask.display_cached_string
train
def display_cached_string(self, bi): """ Logs the original builder messages, given the SConfBuildInfo instance bi. """ if not isinstance(bi, SConfBuildInfo): SCons.Warnings.warn(SConfWarning, "The stored build information has an unexpected class: %s" % b...
python
{ "resource": "" }
q238579
SConfBase.Define
train
def Define(self, name, value = None, comment = None): """ Define a pre processor symbol name, with the optional given value in the current config header. If value is None (default), then #define name is written. If value is not none, then #define name value is written. ...
python
{ "resource": "" }
q238580
SConfBase.BuildNodes
train
def BuildNodes(self, nodes): """ Tries to build the given nodes immediately. Returns 1 on success, 0 on error. """ if self.logstream is not None: # override stdout / stderr to write in log file oldStdout = sys.stdout sys.stdout = self.logstream...
python
{ "resource": "" }
q238581
SConfBase.pspawn_wrapper
train
def pspawn_wrapper(self, sh, escape, cmd, args, env): """Wrapper function for handling piped spawns. This looks to the calling interface (in Action.py) like a "normal" spawn, but associates the call with the PSPAWN variable from the construction environment and with the streams to which...
python
{ "resource": "" }
q238582
SConfBase._startup
train
def _startup(self): """Private method. Set up logstream, and set the environment variables necessary for a piped build """ global _ac_config_logs global sconf_global global SConfFS self.lastEnvFs = self.env.fs self.env.fs = SConfFS self._createDir...
python
{ "resource": "" }
q238583
SConfBase._shutdown
train
def _shutdown(self): """Private method. Reset to non-piped spawn""" global sconf_global, _ac_config_hs if not self.active: raise SCons.Errors.UserError("Finish may be called only once!") if self.logstream is not None and not dryrun: self.logstream.write("\n") ...
python
{ "resource": "" }
q238584
CheckContext.Result
train
def Result(self, res): """Inform about the result of the test. If res is not a string, displays 'yes' or 'no' depending on whether res is evaluated as true or false. The result is only displayed when self.did_show_result is not set. """ if isinstance(res, str): text =...
python
{ "resource": "" }
q238585
linux_ver_normalize
train
def linux_ver_normalize(vstr): """Normalize a Linux compiler version number. Intel changed from "80" to "9.0" in 2005, so we assume if the number is greater than 60 it's an old-style number and otherwise new-style. Always returns an old-style float like 80 or 90 for compatibility with Windows. Shade...
python
{ "resource": "" }
q238586
parse_node_descriptor
train
def parse_node_descriptor(desc, model): """Parse a string node descriptor. The function creates an SGNode object without connecting its inputs and outputs and returns a 3-tuple: SGNode, [(input X, trigger X)], <processing function name> Args: desc (str): A description of the node to be cr...
python
{ "resource": "" }
q238587
create_binary_descriptor
train
def create_binary_descriptor(descriptor): """Convert a string node descriptor into a 20-byte binary descriptor. This is the inverse operation of parse_binary_descriptor and composing the two operations is a noop. Args: descriptor (str): A string node descriptor Returns: bytes: A 2...
python
{ "resource": "" }
q238588
parse_binary_descriptor
train
def parse_binary_descriptor(bindata): """Convert a binary node descriptor into a string descriptor. Binary node descriptor are 20-byte binary structures that encode all information needed to create a graph node. They are used to communicate that information to an embedded device in an efficent format....
python
{ "resource": "" }
q238589
_process_binary_trigger
train
def _process_binary_trigger(trigger_value, condition): """Create an InputTrigger object.""" ops = { 0: ">", 1: "<", 2: ">=", 3: "<=", 4: "==", 5: 'always' } sources = { 0: 'value', 1: 'count' } encoded_source = condition & 0b1 ...
python
{ "resource": "" }
q238590
_create_binary_trigger
train
def _create_binary_trigger(trigger): """Create an 8-bit binary trigger from an InputTrigger, TrueTrigger, FalseTrigger.""" ops = { 0: ">", 1: "<", 2: ">=", 3: "<=", 4: "==", 5: 'always' } op_codes = {y: x for x, y in ops.items()} source = 0 if i...
python
{ "resource": "" }
q238591
IOTileReading._try_assign_utc_time
train
def _try_assign_utc_time(self, raw_time, time_base): """Try to assign a UTC time to this reading.""" # Check if the raw time is encoded UTC since y2k or just uptime if raw_time != IOTileEvent.InvalidRawTime and (raw_time & (1 << 31)): y2k_offset = self.raw_time ^ (1 << 31) ...
python
{ "resource": "" }
q238592
IOTileReading.asdict
train
def asdict(self): """Encode the data in this reading into a dictionary. Returns: dict: A dictionary containing the information from this reading. """ timestamp_str = None if self.reading_time is not None: timestamp_str = self.reading_time.isoformat() ...
python
{ "resource": "" }
q238593
IOTileEvent.asdict
train
def asdict(self): """Encode the data in this event into a dictionary. The dictionary returned from this method is a reference to the data stored in the IOTileEvent, not a copy. It should be treated as read only. Returns: dict: A dictionary containing the informatio...
python
{ "resource": "" }
q238594
IOTileReport.save
train
def save(self, path): """Save a binary copy of this report Args: path (string): The path where we should save the binary copy of the report """ data = self.encode() with open(path, "wb") as out: out.write(data)
python
{ "resource": "" }
q238595
IOTileReport.serialize
train
def serialize(self): """Turn this report into a dictionary that encodes all information including received timestamp""" info = {} info['received_time'] = self.received_time info['encoded_report'] = bytes(self.encode()) # Handle python 2 / python 3 differences report_for...
python
{ "resource": "" }
q238596
Alias.get_contents
train
def get_contents(self): """The contents of an alias is the concatenation of the content signatures of all its sources.""" childsigs = [n.get_csig() for n in self.children()] return ''.join(childsigs)
python
{ "resource": "" }
q238597
generate
train
def generate(env): """ Add Builders and construction variables for Visual Age C++ compilers to an Environment. """ import SCons.Tool import SCons.Tool.cc static_obj, shared_obj = SCons.Tool.createObjBuilders(env) for suffix in CXXSuffixes: static_obj.add_action(suffix, SCons.Def...
python
{ "resource": "" }
q238598
DataStreamer.link_to_storage
train
def link_to_storage(self, sensor_log): """Attach this DataStreamer to an underlying SensorLog. Calling this method is required if you want to use this DataStreamer to generate reports from the underlying data in the SensorLog. You can call it multiple times and it will unlink itself fr...
python
{ "resource": "" }
q238599
DataStreamer.triggered
train
def triggered(self, manual=False): """Check if this streamer should generate a report. Streamers can be triggered automatically whenever they have data or they can be triggered manually. This method returns True if the streamer is currented triggered. A streamer is triggered if...
python
{ "resource": "" }