Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def run(self, refresh_interval=0.05): try: from asciimatics.screen import Screen except ImportError: raise ExternalError("You must have asciimatics installed to use LinebufferUI", suggestion="pi...
[ "Set up the loop, check that the tool is installed" ]
Please provide a description of the function:def is_host_target_supported(host_target, msvc_version): # We assume that any Visual Studio version supports x86 as a target if host_target[1] != "x86": maj, min = msvc_version_to_maj_min(msvc_version) if maj < 8: return False re...
[ "Return True if the given (host, target) tuple is supported given the\n msvc version.\n\n Parameters\n ----------\n host_target: tuple\n tuple of (canonalized) host-target, e.g. (\"x86\", \"amd64\") for cross\n compilation from 32 bits windows to 64 bits.\n msvc_version: str\n ms...
Please provide a description of the function:def find_vc_pdir_vswhere(msvc_version): vswhere_path = os.path.join( 'C:\\', 'Program Files (x86)', 'Microsoft Visual Studio', 'Installer', 'vswhere.exe' ) vswhere_cmd = [vswhere_path, '-version', msvc_version, '-prope...
[ "\n Find the MSVC product directory using vswhere.exe .\n Run it asking for specified version and get MSVS install location\n :param msvc_version:\n :return: MSVC install dir\n " ]
Please provide a description of the function:def find_vc_pdir(msvc_version): root = 'Software\\' try: hkeys = _VCVER_TO_PRODUCT_DIR[msvc_version] except KeyError: debug("Unknown version of MSVC: %s" % msvc_version) raise UnsupportedVersion("Unknown version %s" % msvc_version) ...
[ "Try to find the product directory for the given\n version.\n\n Note\n ----\n If for some reason the requested version could not be found, an\n exception which inherits from VisualCException will be raised." ]
Please provide a description of the function:def find_batch_file(env,msvc_version,host_arch,target_arch): pdir = find_vc_pdir(msvc_version) if pdir is None: raise NoVersionFound("No version of Visual Studio found") debug('vc.py: find_batch_file() pdir:{}'.format(pdir)) # filter out e.g. "...
[ "\n Find the location of the batch script which should set up the compiler\n for any TARGET_ARCH whose compilers were installed by Visual Studio/VCExpress\n " ]
Please provide a description of the function:def compile_sgf(in_path, optimize=True, model=None): if model is None: model = DeviceModel() parser = SensorGraphFileParser() parser.parse_file(in_path) parser.compile(model) if optimize: opt = SensorGraphOptimizer() opt.op...
[ "Compile and optionally optimize an SGF file.\n\n Args:\n in_path (str): The input path to the sgf file to compile.\n optimize (bool): Whether to optimize the compiled result,\n defaults to True if not passed.\n model (DeviceModel): Optional device model if we are\n com...
Please provide a description of the function:def generate(env): 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['SHF77FLAGS'] = SCons.Util.CLVar('...
[ "Add Builders and construction variables for g77 to an Environment." ]
Please provide a description of the function:def execute(self, sensor_graph, scope_stack): parent = scope_stack[-1] alloc = parent.allocator # The output is unused output = alloc.allocate_stream(DataStream.UnbufferedType, attach=True) trigger_stream, trigger_cond = pa...
[ "Execute this statement on the sensor_graph given the current scope tree.\n\n This adds a single node to the sensor graph with the trigger_streamer function\n as is processing function.\n\n Args:\n sensor_graph (SensorGraph): The sensor graph that we are building or\n ...
Please provide a description of the function:def get_language(): 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) + StringEnd() sensor_gra...
[ "Create or retrieve the parse tree for defining a sensor graph." ]
Please provide a description of the function:def _create_mo_file_builder(env, **kw): 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'] = '_PO...
[ " Create builder object for `MOFiles` builder " ]
Please provide a description of the function:def generate(env,**kw): 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...
[ " Generate `msgfmt` tool " ]
Please provide a description of the function:def RCScan(): res_re= r'^(?:\s*#\s*(?:include)|' \ '.*?\s+(?:ICON|BITMAP|CURSOR|HTML|FONT|MESSAGETABLE|TYPELIB|REGISTRY|D3DFX)' \ '\s*.*?)' \ '\s*(<|"| )([^>"\s]+)(?:[>"\s])*$' resScanner = SCons.Scanner.ClassicCPP("ResourceS...
[ "Return a prototype Scanner instance for scanning RC source files" ]
Please provide a description of the function:def _read_linguas_from_files(env, linguas_files=None): 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_files) \ and ...
[ " Parse `LINGUAS` file and return list of extracted languages " ]
Please provide a description of the function:def _translate(env, target=None, source=SCons.Environment._null, *args, **kw): if target is None: target = [] pot = env.POTUpdate(None, source, *args, **kw) po = env.POUpdate(target, pot, *args, **kw) return po
[ " Function for `Translate()` pseudo-builder " ]
Please provide a description of the function:def _init_po_files(target, source, env): 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....
[ " Action function for `POInit` builder. " ]
Please provide a description of the function:def _detect_xgettext(env): if 'XGETTEXT' in env: return env['XGETTEXT'] xgettext = env.Detect('xgettext'); if xgettext: return xgettext raise SCons.Errors.StopError(XgettextNotFound, "Could not detect xgettext") return None
[ " Detects *xgettext(1)* binary " ]
Please provide a description of the function:def _detect_msginit(env): if 'MSGINIT' in env: return env['MSGINIT'] msginit = env.Detect('msginit'); if msginit: return msginit raise SCons.Errors.StopError(MsginitNotFound, "Could not detect msginit") return None
[ " Detects *msginit(1)* program. " ]
Please provide a description of the function:def _detect_msgmerge(env): if 'MSGMERGE' in env: return env['MSGMERGE'] msgmerge = env.Detect('msgmerge'); if msgmerge: return msgmerge raise SCons.Errors.StopError(MsgmergeNotFound, "Could not detect msgmerge") return None
[ " Detects *msgmerge(1)* program. " ]
Please provide a description of the function:def _detect_msgfmt(env): if 'MSGFMT' in env: return env['MSGFMT'] msgfmt = env.Detect('msgfmt'); if msgfmt: return msgfmt raise SCons.Errors.StopError(MsgfmtNotFound, "Could not detect msgfmt") return None
[ " Detects *msgmfmt(1)* program. " ]
Please provide a description of the function:def _create_node(self, name, factory, directory=None, create=1): import SCons.Util node = factory(name, directory, create) node.set_noclean(self.noclean) node.set_precious(self.precious) if self.nodefault: self.env...
[ " Create node, and set it up to factory settings. " ]
Please provide a description of the function:def Entry(self, name, directory=None, create=1): return self._create_node(name, self.env.fs.Entry, directory, create)
[ " Create `SCons.Node.FS.Entry` " ]
Please provide a description of the function:def File(self, name, directory=None, create=1): return self._create_node(name, self.env.fs.File, directory, create)
[ " Create `SCons.Node.FS.File` " ]
Please provide a description of the function:def _execute(self, env, target, source, *args, **kw): import SCons.Util import SCons.Node linguas_files = None if 'LINGUAS_FILE' in env and env['LINGUAS_FILE']: linguas_files = env['LINGUAS_FILE'] # This preven...
[ " Execute builder's actions.\n \n Here we append to `target` the languages read from `$LINGUAS_FILE` and \n apply `SCons.Builder.BuilderBase._execute()` separatelly to each target.\n The arguments and return value are same as for\n `SCons.Builder.BuilderBase._execute()`. \n ...
Please provide a description of the function:def allocate_stream(self, stream_type, stream_id=None, previous=None, attach=False): if stream_type not in DataStream.TypeToString: raise ArgumentError("Unknown stream type in allocate_stream", stream_type=stream_type) if stream_id is n...
[ "Allocate a new stream of the given type.\n\n The stream is allocated with an incremental ID starting at\n StreamAllocator.StartingID. The returned data stream can always\n be used to to attach a NodeInput to this stream, however the\n attach_stream() function should always be called fi...
Please provide a description of the function:def attach_stream(self, stream): curr_stream, count, prev = self._allocated_streams[stream] # Check if we need to split this stream and allocate a new one if count == (self.model.get(u'max_node_outputs') - 1): new_stream = self....
[ "Notify that we would like to attach a node input to this stream.\n\n The return value from this function is the DataStream that should be attached\n to since this function may internally allocate a new SGNode that copies the\n stream if there is no space in the output list to hold another inpu...
Please provide a description of the function:def _find_v1_settings(self, settings): if 'module_name' in settings: modname = settings['module_name'] if 'modules' not in settings or len(settings['modules']) == 0: raise DataError("No modules defined in module_settings.json...
[ "Parse a v1 module_settings.json file.\n\n V1 is the older file format that requires a modules dictionary with a\n module_name and modules key that could in theory hold information on\n multiple modules in a single directory.\n " ]
Please provide a description of the function:def _load_settings(self, info): modname, modsettings, architectures, targets, release_info = info self.settings = modsettings # Name is converted to all lowercase to canonicalize it prepend = '' if 'domain' in modsettings: ...
[ "Load settings for a module." ]
Please provide a description of the function:def _ensure_product_string(cls, product): if isinstance(product, str): return product if isinstance(product, list): return os.path.join(*product) raise DataError("Unknown object (not str or list) specified as a comp...
[ "Ensure that all product locations are strings.\n\n Older components specify paths as lists of path components. Join\n those paths into a normal path string.\n " ]
Please provide a description of the function:def find_products(self, product_type): if self.filter_prods and product_type in self.LIST_PRODUCTS and product_type not in self.desired_prods: return [] if product_type in self.LIST_PRODUCTS: found_products = self.products.g...
[ "Search for products of a given type.\n\n Search through the products declared by this IOTile component and\n return only those matching the given type. If the product is described\n by the path to a file, a complete normalized path will be returned.\n The path could be different depend...
Please provide a description of the function:def library_directories(self): libs = self.find_products('library') if len(libs) > 0: return [os.path.join(self.output_folder)] return []
[ "Return a list of directories containing any static libraries built by this IOTile." ]
Please provide a description of the function:def filter_products(self, desired_prods): self.filter_prods = True self.desired_prods = set(desired_prods)
[ "When asked for a product, filter only those on this list." ]
Please provide a description of the function:def format_ascii(sensor_graph): cmdfile = CommandFile("Sensor Graph", "1.0") # Clear any old sensor graph cmdfile.add("set_online", False) cmdfile.add("clear") cmdfile.add("reset") # Load in the nodes for node in sensor_graph.dump_nodes():...
[ "Format this sensor graph as a loadable ascii file format.\n\n This includes commands to reset and clear previously stored\n sensor graphs.\n\n NB. This format does not include any required configuration\n variables that were specified in this sensor graph, so you\n should also output tha information...
Please provide a description of the function:def clear(self): self.roots = [] self.nodes = [] self.streamers = [] self.constant_database = {} self.metadata_database = {} self.config_database = {}
[ "Clear all nodes from this sensor_graph.\n\n This function is equivalent to just creating a new SensorGraph() object\n from scratch. It does not clear any data from the SensorLog, however.\n " ]
Please provide a description of the function:def add_node(self, node_descriptor): if self._max_nodes is not None and len(self.nodes) >= self._max_nodes: raise ResourceUsageError("Maximum number of nodes exceeded", max_nodes=self._max_nodes) node, inputs, processor = parse_node_des...
[ "Add a node to the sensor graph based on the description given.\n\n The node_descriptor must follow the sensor graph DSL and describe\n a node whose input nodes already exist.\n\n Args:\n node_descriptor (str): A description of the node to be added\n including its inpu...
Please provide a description of the function:def add_config(self, slot, config_id, config_type, value): if slot not in self.config_database: self.config_database[slot] = {} self.config_database[slot][config_id] = (config_type, value)
[ "Add a config variable assignment to this sensor graph.\n\n Args:\n slot (SlotIdentifier): The slot identifier that this config\n variable is assigned to.\n config_id (int): The 16-bit id of this config_id\n config_type (str): The type of the config variable, c...
Please provide a description of the function:def add_streamer(self, streamer): if self._max_streamers is not None and len(self.streamers) >= self._max_streamers: raise ResourceUsageError("Maximum number of streamers exceeded", max_streamers=self._max_streamers) streamer.link_to_st...
[ "Add a streamer to this sensor graph.\n\n Args:\n streamer (DataStreamer): The streamer we want to add\n " ]
Please provide a description of the function:def add_constant(self, stream, value): if stream in self.constant_database: raise ArgumentError("Attempted to set the same constant twice", stream=stream, old_value=self.constant_database[stream], new_value=value) self.constant_database...
[ "Store a constant value for use in this sensor graph.\n\n Constant assignments occur after all sensor graph nodes have been\n allocated since they must be propogated to all appropriate virtual\n stream walkers.\n\n Args:\n stream (DataStream): The constant stream to assign the...
Please provide a description of the function:def add_metadata(self, name, value): if name in self.metadata_database: raise ArgumentError("Attempted to set the same metadata value twice", name=name, old_value=self.metadata_database[name], new_value=value) self.metadata_database[nam...
[ "Attach a piece of metadata to this sensorgraph.\n\n Metadata is not used during the simulation of a sensorgraph but allows\n it to convey additional context that may be used during code\n generation. For example, associating an `app_tag` with a sensorgraph\n allows the snippet code gen...
Please provide a description of the function:def initialize_remaining_constants(self, value=0): remaining = [] for node, _inputs, _outputs in self.iterate_bfs(): streams = node.input_streams() + [node.stream] for stream in streams: if stream.stream_typ...
[ "Ensure that all constant streams referenced in the sensor graph have a value.\n\n Constant streams that are automatically created by the compiler are initialized\n as part of the compilation process but it's possible that the user references\n other constant streams but never assigns them an e...
Please provide a description of the function:def load_constants(self): for stream, value in self.constant_database.items(): self.sensor_log.push(stream, IOTileReading(0, stream.encode(), value))
[ "Load all constants into their respective streams.\n\n All previous calls to add_constant stored a constant value that\n should be associated with virtual stream walkers. This function\n actually calls push_stream in order to push all of the constant\n values to their walkers.\n ...
Please provide a description of the function:def get_config(self, slot, config_id): if slot not in self.config_database: raise ArgumentError("No config variables have been set on specified slot", slot=slot) if config_id not in self.config_database[slot]: raise Argument...
[ "Get a config variable assignment previously set on this sensor graph.\n\n Args:\n slot (SlotIdentifier): The slot that we are setting this config variable\n on.\n config_id (int): The 16-bit config variable identifier.\n\n Returns:\n (str, str|int): Ret...
Please provide a description of the function:def is_output(self, stream): for streamer in self.streamers: if streamer.selector.matches(stream): return True return False
[ "Check if a stream is a sensor graph output.\n\n Return:\n bool\n " ]
Please provide a description of the function:def get_tick(self, name): name_map = { 'fast': config_fast_tick_secs, 'user1': config_tick1_secs, 'user2': config_tick2_secs } config = name_map.get(name) if config is None: raise Argu...
[ "Check the config variables to see if there is a configurable tick.\n\n Sensor Graph has a built-in 10 second tick that is sent every 10\n seconds to allow for triggering timed events. There is a second\n 'user' tick that is generated internally by the sensorgraph compiler\n and used fo...
Please provide a description of the function:def process_input(self, stream, value, rpc_executor): self.sensor_log.push(stream, value) # FIXME: This should be specified in our device model if stream.important: associated_output = stream.associated_stream() self...
[ "Process an input through this sensor graph.\n\n The tick information in value should be correct and is transfered\n to all results produced by nodes acting on this tick.\n\n Args:\n stream (DataStream): The stream the input is part of\n value (IOTileReading): The value to...
Please provide a description of the function:def mark_streamer(self, index): self._logger.debug("Marking streamer %d manually", index) if index >= len(self.streamers): raise ArgumentError("Invalid streamer index", index=index, num_streamers=len(self.streamers)) self._manua...
[ "Manually mark a streamer that should trigger.\n\n The next time check_streamers is called, the given streamer will be\n manually marked that it should trigger, which will cause it to trigger\n unless it has no data.\n\n Args:\n index (int): The index of the streamer that we s...
Please provide a description of the function:def check_streamers(self, blacklist=None): ready = [] selected = set() for i, streamer in enumerate(self.streamers): if blacklist is not None and i in blacklist: continue if i in selected: ...
[ "Check if any streamers are ready to produce a report.\n\n You can limit what streamers are checked by passing a set-like\n object into blacklist.\n\n This method is the primary way to see when you should poll a given\n streamer for its next report.\n\n Note, this function is not ...
Please provide a description of the function:def iterate_bfs(self): working_set = deque(self.roots) seen = [] while len(working_set) > 0: curr = working_set.popleft() # Now build input and output node lists for this node inputs = [] for...
[ "Generator that yields node, [inputs], [outputs] in breadth first order.\n\n This generator will iterate over all nodes in the sensor graph, yielding\n a 3 tuple for each node with a list of all of the nodes connected to its\n inputs and all of the nodes connected to its output.\n\n Retu...
Please provide a description of the function:def sort_nodes(self): node_map = {id(node): i for i, node in enumerate(self.nodes)} node_deps = {} for node, inputs, _outputs in self.iterate_bfs(): node_index = node_map[id(node)] deps = {node_map[id(x)] for x in i...
[ "Topologically sort all of our nodes.\n\n Topologically sorting our nodes makes nodes that are inputs to other\n nodes come first in the list of nodes. This is important to do before\n programming a sensorgraph into an embedded device whose engine assumes\n a topologically sorted graph....
Please provide a description of the function:def generate(env): try: bld = env['BUILDERS']['Ipkg'] except KeyError: bld = SCons.Builder.Builder(action='$IPKGCOM', suffix='$IPKGSUFFIX', source_scanner=None, ...
[ "Add Builders and construction variables for ipkg to an Environment." ]
Please provide a description of the function:def format_trigger(self, stream): src = u'value' if self.use_count: src = u'count' return u"{}({}) {} {}".format(src, stream, self.comp_string, self.reference)
[ "Create a user understandable string like count(stream) >= X.\n\n Args:\n stream (DataStream): The stream to use to format ourselves.\n\n Returns:\n str: The formatted string\n " ]
Please provide a description of the function:def triggered(self, walker): if self.use_count: comp_value = walker.count() else: if walker.count() == 0: return False comp_value = walker.peek().value return self.comp_function(comp_valu...
[ "Check if this input is triggered on the given stream walker.\n\n Args:\n walker (StreamWalker): The walker to check\n\n Returns:\n bool: Whether this trigger is triggered or not\n " ]
Please provide a description of the function:def connect_input(self, index, walker, trigger=None): if trigger is None: trigger = TrueTrigger() if index >= len(self.inputs): raise TooManyInputsError("Input index exceeded max number of inputs", index=index, max_inputs=le...
[ "Connect an input to a stream walker.\n\n If the input is already connected to something an exception is thrown.\n Otherwise the walker is used to read inputs for that input.\n\n A triggering condition can optionally be passed that will determine\n when this input will be considered as t...
Please provide a description of the function:def input_streams(self): streams = [] for walker, _trigger in self.inputs: if walker.selector is None or not walker.selector.singular: continue streams.append(walker.selector.as_stream()) return str...
[ "Return a list of DataStream objects for all singular input streams.\n\n This function only returns individual streams, not the streams that would\n be selected from a selector like 'all outputs' for example.\n\n Returns:\n list(DataStream): A list of all of the individual DataStream...
Please provide a description of the function:def find_input(self, stream): for i, input_x in enumerate(self.inputs): if input_x[0].matches(stream): return i
[ "Find the input that responds to this stream.\n\n Args:\n stream (DataStream): The stream to find\n\n Returns:\n (index, None): The index if found or None\n " ]
Please provide a description of the function:def num_inputs(self): num = 0 for walker, _ in self.inputs: if not isinstance(walker, InvalidStreamWalker): num += 1 return num
[ "Return the number of connected inputs.\n\n Returns:\n int: The number of connected inputs\n " ]
Please provide a description of the function:def connect_output(self, node): if len(self.outputs) == self.max_outputs: raise TooManyOutputsError("Attempted to connect too many nodes to the output of a node", max_outputs=self.max_outputs, stream=self.stream) self.outputs.append(nod...
[ "Connect another node to our output.\n\n This downstream node will automatically be triggered when we update\n our output.\n\n Args:\n node (SGNode): The node that should receive our output\n " ]
Please provide a description of the function:def triggered(self): trigs = [x[1].triggered(x[0]) for x in self.inputs] if self.trigger_combiner == self.OrTriggerCombiner: return True in trigs return False not in trigs
[ "Test if we should trigger our operation.\n\n We test the trigger condition on each of our inputs and then\n combine those triggers using our configured trigger combiner\n to get an overall result for whether this node is triggered.\n\n Returns:\n bool: True if we should trigg...
Please provide a description of the function:def set_func(self, name, func): self.func_name = name self.func = func
[ "Set the processing function to use for this node.\n\n Args:\n name (str): The name of the function to use. This is\n just stored for reference in case we need to serialize\n the node later.\n func (callable): A function that is called to process inputs\n ...
Please provide a description of the function:def process(self, rpc_executor, mark_streamer=None): if self.func is None: raise ProcessingFunctionError('No processing function set for node', stream=self.stream) results = self.func(*[x[0] for x in self.inputs], rpc_executor=rpc_execu...
[ "Run this node's processing function.\n\n Args:\n rpc_executor (RPCExecutor): An object capable of executing RPCs\n in case we need to do that.\n mark_streamer (callable): Function that can be called to manually\n mark a streamer as triggered by index.\n\n ...
Please provide a description of the function:def main(argv=None): if argv is None: argv = sys.argv[1:] parser = build_args() args = parser.parse_args(args=argv) verbosity = args.verbose root = logging.getLogger() formatter = logging.Formatter('%(levelname).6s %(name)s %(message)...
[ "Main script entry point.\n\n Args:\n argv (list): The command line arguments, defaults to sys.argv if not passed.\n\n Returns:\n int: The return value of the script.\n " ]
Please provide a description of the function:def FortranScan(path_variable="FORTRANPATH"): # The USE statement regex matches the following: # # USE module_name # USE :: module_name # USE, INTRINSIC :: module_name # USE, NON_INTRINSIC :: module_name # # Limitations # # -- While the regex can handle ...
[ "Return a prototype Scanner instance for scanning source files\n for Fortran USE & INCLUDE statements", "(?i)(?:^|['\">]\\s*;)\\s*INCLUDE\\s+(?:\\w+_)?[<\"'](.+?)(?=[\"'>])", "(?i)^\\s*MODULE\\s+(?!PROCEDURE)(\\w+)" ]
Please provide a description of the function:def generate(env): fortran.generate(env) env['FORTRAN'] = 'f90' env['FORTRANCOM'] = '$FORTRAN $FORTRANFLAGS $_FORTRANMODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.windows} /object:${TARGET.windows}' env['FORTRANPPCOM'] = '$FORTRAN $FOR...
[ "Add Builders and construction variables for compaq visual fortran to an Environment." ]
Please provide a description of the function:def read(self): self.build() if not hasattr(self, 'built_value'): self.built_value = self.value return self.built_value
[ "Return the value. If necessary, the value is built." ]
Please provide a description of the function:def get_text_contents(self): ###TODO: something reasonable about universal newlines contents = str(self.value) for kid in self.children(None): contents = contents + kid.get_contents().decode() return contents
[ "By the assumption that the node.built_value is a\n deterministic product of the sources, the contents of a Value\n are the concatenation of all the contents of its sources. As\n the value need not be built when get_contents() is called, we\n cannot use the actual node.built_value." ]
Please provide a description of the function:def get_csig(self, calc=None): try: return self.ninfo.csig except AttributeError: pass contents = self.get_contents() self.get_ninfo().csig = contents return contents
[ "Because we're a Python value node and don't have a real\n timestamp, we get to ignore the calculator and just use the\n value contents." ]
Please provide a description of the function:def restore(self, state): own_properties = set(self.get_properties()) state_properties = set(state) to_restore = own_properties.intersection(state_properties) for name in to_restore: value = state.get(name) ...
[ "Restore this state from the output of a previous call to dump().\n\n Only those properties in this object and listed in state will be\n updated. Other properties will not be modified and state may contain\n keys that do not correspond with properties in this object.\n\n Args:\n ...
Please provide a description of the function:def mark_complex(self, name, serializer, deserializer): self._complex_properties[name] = (serializer, deserializer)
[ "Mark a property as complex with serializer and deserializer functions.\n\n Args:\n name (str): The name of the complex property.\n serializer (callable): The function to call to serialize the property's\n value to something that can be saved in a json.\n deser...
Please provide a description of the function:def mark_typed_list(self, name, type_object): if not hasattr(type_object, 'dump'): raise ArgumentError("The passed type object %s is missing required method: dump()" % type_object) if not hasattr(type_object, 'Restore'): rais...
[ "Mark a property as containing serializable objects of a given type.\n\n This convenience method allows you to avoid having to call\n ``mark_complex()`` whenever you need to serialize a list of objects.\n This method requires that all members of the given list be of a single\n class that...
Please provide a description of the function:def mark_typed_map(self, name, type_object): if not hasattr(type_object, 'dump'): raise ArgumentError("The passed type object %s is missing required method: dump()" % type_object) if not hasattr(type_object, 'Restore'): raise...
[ "Mark a property as containing a map str to serializable object.\n\n This convenience method allows you to avoid having to call\n ``mark_complex()`` whenever you need to serialize a dict of objects.\n This method requires that all members of the given dict be of a single\n class that con...
Please provide a description of the function:def mark_typed_object(self, name, type_object): if not hasattr(type_object, 'dump'): raise ArgumentError("The passed type object %s is missing required method: dump()" % type_object) if not hasattr(type_object, 'Restore'): ra...
[ "Mark a property as containing a serializable object.\n\n This convenience method allows you to avoid having to call\n ``mark_complex()`` whenever you need to serialize a complex object.\n This method requires that property ``name`` be a single class that\n contains a dump() method and a...
Please provide a description of the function:def dump_property(self, name): if not hasattr(self, name): raise ArgumentError("Unknown property %s" % name) value = getattr(self, name) if name in self._complex_properties: value = self._complex_properties[name][0](...
[ "Serialize a property of this class by name.\n\n Args:\n name (str): The name of the property to dump.\n\n Returns:\n object: The serialized value of the property.\n " ]
Please provide a description of the function:def get_properties(self): names = inspect.getmembers(self, predicate=lambda x: not inspect.ismethod(x)) return [x[0] for x in names if not x[0].startswith("_") and x[0] not in self._ignored_properties]
[ "Get a list of all of the public data properties of this class.\n\n Returns:\n list of str: A list of all of the public properties in this class.\n " ]
Please provide a description of the function:def get_default_version(env): if 'MSVS' not in env or not SCons.Util.is_Dict(env['MSVS']): # get all versions, and remember them for speed later versions = [vs.version for vs in get_installed_visual_studios()] env['MSVS'] = {'VERSIONS' : vers...
[ "Returns the default version string to use for MSVS.\n\n If no version was requested by the user through the MSVS environment\n variable, query all the available visual studios through\n get_installed_visual_studios, and take the highest one.\n\n Return\n ------\n version: str\n the default...
Please provide a description of the function:def get_default_arch(env): arch = env.get('MSVS_ARCH', 'x86') msvs = InstalledVSMap.get(env['MSVS_VERSION']) if not msvs: arch = 'x86' elif not arch in msvs.get_supported_arch(): fmt = "Visual Studio version %s does not support architec...
[ "Return the default arch to use for MSVS\n\n if no version was requested by the user through the MSVS_ARCH environment\n variable, select x86\n\n Return\n ------\n arch: str\n " ]
Please provide a description of the function:def encrypt_report(self, device_id, root, data, **kwargs): for _priority, provider in self.providers: try: return provider.encrypt_report(device_id, root, data, **kwargs) except NotFoundError: pass ...
[ "Encrypt a buffer of report data on behalf of a device.\n\n Args:\n device_id (int): The id of the device that we should encrypt for\n root (int): The root key type that should be used to generate the report\n data (bytearray): The data that we should encrypt.\n **...
Please provide a description of the function:def verify_report(self, device_id, root, data, signature, **kwargs): for _priority, provider in self.providers: try: return provider.verify_report(device_id, root, data, signature, **kwargs) except NotFoundError: ...
[ "Verify a buffer of report data on behalf of a device.\n\n Args:\n device_id (int): The id of the device that we should encrypt for\n root (int): The root key type that should be used to generate the report\n data (bytearray): The data that we should verify\n signa...
Please provide a description of the function:def format_rpc(self, address, rpc_id, payload): 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_words = st...
[ "Create a formated word list that encodes this rpc." ]
Please provide a description of the function:def format_response(self, response_data): _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, actu...
[ "Format an RPC response." ]
Please provide a description of the function:def ProgramScanner(**kw): kw['path_function'] = SCons.Scanner.FindPathDirs('LIBPATH') ps = SCons.Scanner.Base(scan, "ProgramScanner", **kw) return ps
[ "Return a prototype Scanner instance for scanning executable\n files for static-lib dependencies" ]
Please provide a description of the function:def _subst_libs(env, libs): 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: _libs += _su...
[ "\n Substitute environment variables and split into list.\n " ]
Please provide a description of the function:def scan(node, env, libpath = ()): try: libs = env['LIBS'] except KeyError: # There are no LIBS in this environment, so just return a null list: return [] libs = _subst_libs(env, libs) try: prefix = env['LIBPREFIXES'] ...
[ "\n This scanner scans program files for static-library\n dependencies. It will search the LIBPATH environment variable\n for libraries specified in the LIBS variable, returning any\n files it finds as dependencies.\n " ]
Please provide a description of the function:def ListVariable(key, help, default, names, map={}): names_str = 'allowed names: %s' % ' '.join(names) if SCons.Util.is_List(default): default = ','.join(default) help = '\n '.join( (help, '(all|none|comma-separated list of names)', names_...
[ "\n The input parameters describe a 'package list' option, thus they\n are returned with the correct converter and validator appended. The\n result is usable for input to opts.Add() .\n\n A 'package list' option may either be 'all', 'none' or a list of\n package names (separated by space).\n " ]
Please provide a description of the function:def clear_to_reset(self, config_vars): super(RemoteBridgeState, self).clear_to_reset(config_vars) self.status = BRIDGE_STATUS.IDLE self.error = 0
[ "Clear the RemoteBridge subsystem to its reset state." ]
Please provide a description of the function:def begin_script(self): if self.remote_bridge.status in (BRIDGE_STATUS.RECEIVED, BRIDGE_STATUS.VALIDATED, BRIDGE_STATUS.EXECUTING): return [1] #FIXME: Return correct error here self.remote_bridge.status = BRIDGE_STATUS.WAITING ...
[ "Indicate we are going to start loading a script." ]
Please provide a description of the function:def end_script(self): if self.remote_bridge.status not in (BRIDGE_STATUS.RECEIVED, BRIDGE_STATUS.WAITING): return [1] #FIXME: State change self.remote_bridge.status = BRIDGE_STATUS.RECEIVED return [0]
[ "Indicate that we have finished receiving a script." ]
Please provide a description of the function:def trigger_script(self): if self.remote_bridge.status not in (BRIDGE_STATUS.RECEIVED,): return [1] #FIXME: State change # This is asynchronous in real life so just cache the error try: self.remote_bridge.parsed_scri...
[ "Actually process a script." ]
Please provide a description of the function:def reset_script(self): self.remote_bridge.status = BRIDGE_STATUS.IDLE self.remote_bridge.error = 0 self.remote_bridge.parsed_script = None self._device.script = bytearray() return [0]
[ "Clear any partially received script." ]
Please provide a description of the function:def render_template_inplace(template_path, info, dry_run=False, extra_filters=None, resolver=None): filters = {} if resolver is not None: filters['find_product'] = _create_resolver_filter(resolver) if extra_filters is not None: filters.upda...
[ "Render a template file in place.\n\n This function expects template path to be a path to a file\n that ends in .tpl. It will be rendered to a file in the\n same directory with the .tpl suffix removed.\n\n Args:\n template_path (str): The path to the template file\n that we want to re...
Please provide a description of the function:def render_template(template_name, info, out_path=None): env = Environment(loader=PackageLoader('iotile.build', 'config/templates'), trim_blocks=True, lstrip_blocks=True) template = env.get_template(template_name) result = template.re...
[ "Render a template using the variables in info.\n\n You can optionally render to a file by passing out_path.\n\n Args:\n template_name (str): The name of the template to load. This must\n be a file in config/templates inside this package\n out_path (str): An optional path of where to...
Please provide a description of the function:def render_recursive_template(template_folder, info, out_folder, preserve=None, dry_run=False): if isinstance(preserve, str): raise ArgumentError("You must pass a list of strings to preserve, not a string", preserve=preserve) if preserve is None: ...
[ "Copy a directory tree rendering all templates found within.\n\n This function inspects all of the files in template_folder recursively. If\n any file ends .tpl, it is rendered using render_template and the .tpl\n suffix is removed. All other files are copied without modification.\n\n out_folder is not...
Please provide a description of the function:def generate(env): cplusplus.generate(env) if acc: env['CXX'] = acc or 'aCC' env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS +Z') # determine version of aCC line = os.popen(acc + ' -V 2>&1').readline().rstrip() if ...
[ "Add Builders and construction variables for g++ to an Environment." ]
Please provide a description of the function:def _find_monitor(monitors, handle): found_devs = set() found_events = set() for conn_string, device in monitors.items(): for event, handles in device.items(): if handle in handles: found_events.add(event) ...
[ "Find all devices and events with a given monitor installed." ]
Please provide a description of the function:def _add_monitor(monitors, handle, callback, devices, events): for conn_string in devices: data = monitors.get(conn_string) if data is None: data = dict() monitors[conn_string] = data for event in events: ...
[ "Add the given monitor to the listed devices and events." ]
Please provide a description of the function:def _remove_monitor(monitors, handle, devices, events): empty_devices = [] for conn_string in devices: data = monitors.get(conn_string) if data is None: continue for event in events: event_dict = data.get(event)...
[ "Remove the given monitor from the listed devices and events." ]
Please provide a description of the function:def register_monitor(self, devices, events, callback): # Ensure we don't exhaust any iterables events = list(events) devices = list(devices) for event in events: if event not in self.SUPPORTED_EVENTS: rai...
[ "Register a callback when events happen.\n\n If this method is called, it is guaranteed to take effect before the\n next call to ``_notify_event`` after this method returns. This method\n is safe to call from within a callback that is itself called by\n ``notify_event``.\n\n See ...
Please provide a description of the function:def iter_monitors(self): for conn_string, events in self._monitors.items(): for event, handlers in events.items(): for handler in handlers: yield (conn_string, event, handler)
[ "Iterate over all defined (conn_string, event, monitor) tuples." ]
Please provide a description of the function:def adjust_monitor(self, handle, action, devices, events): events = list(events) devices = list(devices) for event in events: if event not in self.SUPPORTED_EVENTS: raise ArgumentError("Unknown event type {} spec...
[ "Adjust a previously registered callback.\n\n See :meth:`AbstractDeviceAdapter.adjust_monitor`.\n " ]
Please provide a description of the function:def remove_monitor(self, handle): action = (handle, "delete", None, None) if self._currently_notifying: self._deferred_adjustments.append(action) else: self._adjust_monitor_internal(*action)
[ "Remove a previously registered monitor.\n\n See :meth:`AbstractDeviceAdapter.adjust_monitor`.\n " ]
Please provide a description of the function:async def _notify_event_internal(self, conn_string, name, event): try: self._currently_notifying = True conn_id = self._get_conn_id(conn_string) event_maps = self._monitors.get(conn_string, {}) wildcard_maps ...
[ "Notify that an event has occured.\n\n This method will send a notification and ensure that all callbacks\n registered for it have completed by the time it returns. In\n particular, if the callbacks are awaitable, this method will await\n them before returning. The order in which the c...
Please provide a description of the function:def notify_event(self, conn_string, name, event): return self._loop.launch_coroutine(self._notify_event_internal, conn_string, name, event)
[ "Notify an event.\n\n This method will launch a coroutine that runs all callbacks (and\n awaits all coroutines) attached to the given event that was just\n raised. Internally it uses\n :meth:`BackgroundEventLoop.launch_coroutine` which retains an\n awaitable object when called fr...