idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
21,600 | def DeriveReportKey ( cls , root_key , report_id , sent_timestamp ) : signed_data = struct . pack ( "<LLL" , AuthProvider . ReportKeyMagic , report_id , sent_timestamp ) hmac_calc = hmac . new ( root_key , signed_data , hashlib . sha256 ) return bytearray ( hmac_calc . digest ( ) ) | Derive a standard one time use report signing key . |
21,601 | def declare ( self , name ) : if name in self . _data : raise KeyError ( "Declared name {} that already existed" . format ( name ) ) self . _data [ name ] = self . _loop . create_future ( ) | Declare that a key will be set in the future . |
21,602 | async def get ( self , name , timeout = None , autoremove = True ) : self . _ensure_declared ( name ) try : await asyncio . wait_for ( self . _data [ name ] , timeout , loop = self . _loop . get_loop ( ) ) return self . _data [ name ] . result ( ) finally : if autoremove : self . _data [ name ] . cancel ( ) del self . ... | Wait for a value to be set for a key . |
21,603 | def get_nowait ( self , name , default = _MISSING , autoremove = False ) : self . _ensure_declared ( name ) try : future = self . _data [ name ] if future . done ( ) : return future . result ( ) if default is _MISSING : raise KeyError ( "Key {} has not been assigned a value and no default given" . format ( name ) ) ret... | Get the value of a key if it is already set . |
21,604 | def set ( self , name , value , autodeclare = False ) : if not autodeclare and name not in self . _data : raise KeyError ( "Key {} has not been declared and autodeclare=False" . format ( name ) ) self . _ensure_declared ( name ) self . _data [ name ] . set_result ( value ) | Set the value of a key . |
21,605 | def dump_tree ( self , statement = None , indent_level = 0 ) : out = u"" indent = u" " * indent_level if statement is None : for root_statement in self . statements : out += self . dump_tree ( root_statement , indent_level ) else : out += indent + str ( statement ) + u'\n' if len ( statement . children ) > 0 : for chil... | Dump the AST for this parsed file . |
21,606 | def parse_file ( self , sg_file = None , data = None ) : if sg_file is not None and data is not None : raise ArgumentError ( "You must pass either a path to an sgf file or the sgf contents but not both" ) if sg_file is None and data is None : raise ArgumentError ( "You must pass either a path to an sgf file or the sgf ... | Parse a sensor graph file into an AST describing the file . |
21,607 | def compile ( self , model ) : log = SensorLog ( InMemoryStorageEngine ( model ) , model ) self . sensor_graph = SensorGraph ( log , model ) allocator = StreamAllocator ( self . sensor_graph , model ) self . _scope_stack = [ ] root = RootScope ( self . sensor_graph , allocator ) self . _scope_stack . append ( root ) fo... | Compile this file into a SensorGraph . |
21,608 | def parse_statement ( self , statement , orig_contents ) : children = [ ] is_block = False name = statement . getName ( ) if name == 'block' : children_statements = statement [ 1 ] for child in children_statements : parsed = self . parse_statement ( child , orig_contents = orig_contents ) children . append ( parsed ) l... | Parse a statement possibly called recursively . |
21,609 | def stream ( self , report , callback = None ) : if self . _push_channel is None : return self . _push_channel . stream ( report , callback = callback ) | Stream a report asynchronously . |
21,610 | def stream_realtime ( self , stream , value ) : if not self . stream_iface_open : return reading = IOTileReading ( 0 , stream , value ) report = IndividualReadingReport . FromReadings ( self . iotile_id , [ reading ] ) self . stream ( report ) | Stream a realtime value as an IndividualReadingReport . |
21,611 | def trace ( self , data , callback = None ) : if self . _push_channel is None : return self . _push_channel . trace ( data , callback = callback ) | Trace data asynchronously . |
21,612 | def register_rpc ( self , address , rpc_id , func ) : if rpc_id < 0 or rpc_id > 0xFFFF : raise RPCInvalidIDError ( "Invalid RPC ID: {}" . format ( rpc_id ) ) if address not in self . _rpc_overlays : self . _rpc_overlays [ address ] = RPCDispatcher ( ) self . _rpc_overlays [ address ] . add_rpc ( rpc_id , func ) | Register a single RPC handler with the given info . |
21,613 | def add_tile ( self , address , tile ) : if address in self . _tiles : raise ArgumentError ( "Tried to add two tiles at the same address" , address = address ) self . _tiles [ address ] = tile | Add a tile to handle all RPCs at a given address . |
21,614 | def iter_tiles ( self , include_controller = True ) : for address , tile in sorted ( self . _tiles . items ( ) ) : if address == 8 and not include_controller : continue yield address , tile | Iterate over all tiles in this device in order . |
21,615 | def open_streaming_interface ( self ) : super ( ReferenceDevice , self ) . open_streaming_interface ( ) self . rpc ( 8 , rpcs . SG_GRAPH_INPUT , 8 , streams . COMM_TILE_OPEN ) return [ ] | Called when someone opens a streaming interface to the device . |
21,616 | def close_streaming_interface ( self ) : super ( ReferenceDevice , self ) . close_streaming_interface ( ) self . rpc ( 8 , rpcs . SG_GRAPH_INPUT , 8 , streams . COMM_TILE_CLOSED ) | Called when someone closes the streaming interface to the device . |
21,617 | def build_parser ( ) : parser = argparse . ArgumentParser ( description = "The IOTile task supervisor" ) parser . add_argument ( '-c' , '--config' , help = "config json with options" ) parser . add_argument ( '-v' , '--verbose' , action = "count" , default = 0 , help = "Increase logging verbosity" ) return parser | Build the script s argument parser . |
21,618 | def configure_logging ( verbosity ) : root = logging . getLogger ( ) formatter = logging . Formatter ( '%(asctime)s.%(msecs)03d %(levelname).3s %(name)s %(message)s' , '%y-%m-%d %H:%M:%S' ) handler = logging . StreamHandler ( ) handler . setFormatter ( formatter ) loglevels = [ logging . CRITICAL , logging . ERROR , lo... | Set up the global logging level . |
21,619 | def createProgBuilder ( env ) : try : program = env [ 'BUILDERS' ] [ 'Program' ] except KeyError : import SCons . Defaults program = SCons . Builder . Builder ( action = SCons . Defaults . LinkAction , emitter = '$PROGEMITTER' , prefix = '$PROGPREFIX' , suffix = '$PROGSUFFIX' , src_suffix = '$OBJSUFFIX' , src_builder =... | This is a utility function that creates the Program Builder in an Environment if it is not there already . |
21,620 | def createStaticLibBuilder ( env ) : try : static_lib = env [ 'BUILDERS' ] [ 'StaticLibrary' ] except KeyError : action_list = [ SCons . Action . Action ( "$ARCOM" , "$ARCOMSTR" ) ] if env . get ( 'RANLIB' , False ) or env . Detect ( 'ranlib' ) : ranlib_action = SCons . Action . Action ( "$RANLIBCOM" , "$RANLIBCOMSTR" ... | This is a utility function that creates the StaticLibrary Builder in an Environment if it is not there already . |
21,621 | def createSharedLibBuilder ( env ) : try : shared_lib = env [ 'BUILDERS' ] [ 'SharedLibrary' ] except KeyError : import SCons . Defaults action_list = [ SCons . Defaults . SharedCheck , SCons . Defaults . ShLinkAction , LibSymlinksAction ] shared_lib = SCons . Builder . Builder ( action = action_list , emitter = "$SHLI... | This is a utility function that creates the SharedLibrary Builder in an Environment if it is not there already . |
21,622 | def createLoadableModuleBuilder ( env ) : try : ld_module = env [ 'BUILDERS' ] [ 'LoadableModule' ] except KeyError : import SCons . Defaults action_list = [ SCons . Defaults . SharedCheck , SCons . Defaults . LdModuleLinkAction , LibSymlinksAction ] ld_module = SCons . Builder . Builder ( action = action_list , emitte... | This is a utility function that creates the LoadableModule Builder in an Environment if it is not there already . |
21,623 | def createObjBuilders ( env ) : try : static_obj = env [ 'BUILDERS' ] [ 'StaticObject' ] except KeyError : static_obj = SCons . Builder . Builder ( action = { } , emitter = { } , prefix = '$OBJPREFIX' , suffix = '$OBJSUFFIX' , src_builder = [ 'CFile' , 'CXXFile' ] , source_scanner = SourceFileScanner , single_source = ... | This is a utility function that creates the StaticObject and SharedObject Builders in an Environment if they are not there already . |
21,624 | def CreateJarBuilder ( env ) : try : java_jar = env [ 'BUILDERS' ] [ 'JarFile' ] except KeyError : fs = SCons . Node . FS . get_default_fs ( ) jar_com = SCons . Action . Action ( '$JARCOM' , '$JARCOMSTR' ) java_jar = SCons . Builder . Builder ( action = jar_com , suffix = '$JARSUFFIX' , src_suffix = '$JAVACLASSSUFFIX' ... | The Jar builder expects a list of class files which it can package into a jar file . |
21,625 | def get_builder ( self , env ) : builder = getattr ( env , self . __name__ ) self . initializer . apply_tools ( env ) builder = getattr ( env , self . __name__ ) if builder is self : return None self . initializer . remove_methods ( env ) return builder | Returns the appropriate real Builder for this method name after having the associated ToolInitializer object apply the appropriate Tool module . |
21,626 | def remove_methods ( self , env ) : for method in list ( self . methods . values ( ) ) : env . RemoveMethod ( method ) | Removes the methods that were added by the tool initialization so we no longer copy and re - bind them when the construction environment gets cloned . |
21,627 | def apply_tools ( self , env ) : for t in self . tools : tool = SCons . Tool . Tool ( t ) if tool . exists ( env ) : env . Tool ( tool ) return | Searches the list of associated Tool modules for one that exists and applies that to the construction environment . |
21,628 | def get_contents_entry ( node ) : try : node = node . disambiguate ( must_exist = 1 ) except SCons . Errors . UserError : return '' else : return _get_contents_map [ node . _func_get_contents ] ( node ) | Fetch the contents of the entry . Returns the exact binary contents of the file . |
21,629 | def get_contents_dir ( node ) : contents = [ ] for n in sorted ( node . children ( ) , key = lambda t : t . name ) : contents . append ( '%s %s\n' % ( n . get_csig ( ) , n . name ) ) return '' . join ( contents ) | Return content signatures and names of all our children separated by new - lines . Ensure that the nodes are sorted . |
21,630 | def get_build_env ( self ) : try : return self . _memo [ 'get_build_env' ] except KeyError : pass result = self . get_executor ( ) . get_build_env ( ) self . _memo [ 'get_build_env' ] = result return result | Fetch the appropriate Environment to build this node . |
21,631 | def get_executor ( self , create = 1 ) : try : executor = self . executor except AttributeError : if not create : raise try : act = self . builder . action except AttributeError : executor = SCons . Executor . Null ( targets = [ self ] ) else : executor = SCons . Executor . Executor ( act , self . env or self . builder... | Fetch the action executor for this node . Create one if there isn t already one and requested to do so . |
21,632 | def executor_cleanup ( self ) : try : executor = self . get_executor ( create = None ) except AttributeError : pass else : if executor is not None : executor . cleanup ( ) | Let the executor clean up any cached information . |
21,633 | def prepare ( self ) : if self . depends is not None : for d in self . depends : if d . missing ( ) : msg = "Explicit dependency `%s' not found, needed by target `%s'." raise SCons . Errors . StopError ( msg % ( d , self ) ) if self . implicit is not None : for i in self . implicit : if i . missing ( ) : msg = "Implici... | Prepare for this Node to be built . |
21,634 | def build ( self , ** kw ) : try : self . get_executor ( ) ( self , ** kw ) except SCons . Errors . BuildError as e : e . node = self raise | Actually build the node . |
21,635 | def built ( self ) : for parent in self . waiting_parents : parent . implicit = None self . clear ( ) if self . pseudo : if self . exists ( ) : raise SCons . Errors . UserError ( "Pseudo target " + str ( self ) + " must not exist" ) else : if not self . exists ( ) and do_store_info : SCons . Warnings . warn ( SCons . W... | Called just after this node is successfully built . |
21,636 | def has_builder ( self ) : try : b = self . builder except AttributeError : b = self . builder = None return b is not None | Return whether this Node has a builder or not . |
21,637 | def get_implicit_deps ( self , env , initial_scanner , path_func , kw = { } ) : nodes = [ self ] seen = set ( nodes ) dependencies = [ ] path_memo = { } root_node_scanner = self . _get_scanner ( env , initial_scanner , None , kw ) while nodes : node = nodes . pop ( 0 ) scanner = node . _get_scanner ( env , initial_scan... | Return a list of implicit dependencies for this node . |
21,638 | def get_source_scanner ( self , node ) : scanner = None try : scanner = self . builder . source_scanner except AttributeError : pass if not scanner : scanner = self . get_env_scanner ( self . get_build_env ( ) ) if scanner : scanner = scanner . select ( node ) return scanner | Fetch the source scanner for the specified node |
21,639 | def scan ( self ) : if self . implicit is not None : return self . implicit = [ ] self . implicit_set = set ( ) self . _children_reset ( ) if not self . has_builder ( ) : return build_env = self . get_build_env ( ) executor = self . get_executor ( ) if implicit_cache and not implicit_deps_changed : implicit = self . ge... | Scan this node s dependents for implicit dependencies . |
21,640 | def get_binfo ( self ) : try : return self . binfo except AttributeError : pass binfo = self . new_binfo ( ) self . binfo = binfo executor = self . get_executor ( ) ignore_set = self . ignore_set if self . has_builder ( ) : binfo . bact = str ( executor ) binfo . bactsig = SCons . Util . MD5signature ( executor . get_c... | Fetch a node s build information . |
21,641 | def add_dependency ( self , depend ) : try : self . _add_child ( self . depends , self . depends_set , depend ) except TypeError as e : e = e . args [ 0 ] if SCons . Util . is_List ( e ) : s = list ( map ( str , e ) ) else : s = str ( e ) raise SCons . Errors . UserError ( "attempted to add a non-Node dependency to %s:... | Adds dependencies . |
21,642 | def add_ignore ( self , depend ) : try : self . _add_child ( self . ignore , self . ignore_set , depend ) except TypeError as e : e = e . args [ 0 ] if SCons . Util . is_List ( e ) : s = list ( map ( str , e ) ) else : s = str ( e ) raise SCons . Errors . UserError ( "attempted to ignore a non-Node dependency of %s:\n\... | Adds dependencies to ignore . |
21,643 | def add_source ( self , source ) : if self . _specific_sources : return try : self . _add_child ( self . sources , self . sources_set , source ) except TypeError as e : e = e . args [ 0 ] if SCons . Util . is_List ( e ) : s = list ( map ( str , e ) ) else : s = str ( e ) raise SCons . Errors . UserError ( "attempted to... | Adds sources . |
21,644 | def _add_child ( self , collection , set , child ) : added = None for c in child : if c not in set : set . add ( c ) collection . append ( c ) added = 1 if added : self . _children_reset ( ) | Adds child to collection first checking set to see if it s already present . |
21,645 | def all_children ( self , scan = 1 ) : if scan : self . scan ( ) return list ( chain . from_iterable ( [ _f for _f in [ self . sources , self . depends , self . implicit ] if _f ] ) ) | Return a list of all the node s direct children . |
21,646 | def Tag ( self , key , value ) : if not self . _tags : self . _tags = { } self . _tags [ key ] = value | Add a user - defined tag . |
21,647 | def render_include_tree ( self ) : if self . is_derived ( ) : env = self . get_build_env ( ) if env : for s in self . sources : scanner = self . get_source_scanner ( s ) if scanner : path = self . get_build_scanner_path ( scanner ) else : path = None def f ( node , env = env , scanner = scanner , path = path ) : return... | Return a text representation suitable for displaying to the user of the include tree for the sources of this node . |
21,648 | def get_next ( self ) : while self . stack : if self . stack [ - 1 ] . wkids : node = self . stack [ - 1 ] . wkids . pop ( 0 ) if not self . stack [ - 1 ] . wkids : self . stack [ - 1 ] . wkids = None if node in self . history : self . cycle_func ( node , self . stack ) else : node . wkids = copy . copy ( self . kids_f... | Return the next node for this walk of the tree . |
21,649 | def timeout_thread_handler ( timeout , stop_event ) : stop_happened = stop_event . wait ( timeout ) if stop_happened is False : print ( "Killing program due to %f second timeout" % timeout ) os . _exit ( 2 ) | A background thread to kill the process if it takes too long . |
21,650 | def create_parser ( ) : parser = argparse . ArgumentParser ( description = DESCRIPTION , formatter_class = argparse . RawDescriptionHelpFormatter ) parser . add_argument ( '-v' , '--verbose' , action = "count" , default = 0 , help = "Increase logging level (goes error, warn, info, debug)" ) parser . add_argument ( '-l'... | Create the argument parser for iotile . |
21,651 | def parse_global_args ( argv ) : parser = create_parser ( ) args = parser . parse_args ( argv ) should_log = args . include or args . exclude or ( args . verbose > 0 ) verbosity = args . verbose root = logging . getLogger ( ) if should_log : formatter = logging . Formatter ( '%(asctime)s.%(msecs)03d %(levelname).3s %(n... | Parse all global iotile tool arguments . |
21,652 | def setup_completion ( shell ) : import glob try : import readline except ImportError : import pyreadline as readline def _complete ( text , state ) : buf = readline . get_line_buffer ( ) if buf . startswith ( 'help ' ) or " " not in buf : return [ x for x in shell . valid_identifiers ( ) if x . startswith ( text ) ] [... | Setup readline to tab complete in a cross platform way . |
21,653 | def main ( argv = None ) : if argv is None : argv = sys . argv [ 1 : ] args = parse_global_args ( argv ) type_system . interactive = True line = args . commands timeout_thread = None timeout_stop_event = threading . Event ( ) if args . timeout : timeout_thread = threading . Thread ( target = timeout_thread_handler , ar... | Run the iotile shell tool . |
21,654 | def build ( args ) : scons_path = "Error" try : scons_path = resource_path ( 'scons-local-{}' . format ( SCONS_VERSION ) , expect = 'folder' ) sys . path . insert ( 0 , scons_path ) import SCons . Script except ImportError : raise BuildError ( "Couldn't find internal scons packaged w/ iotile-build. This is a bug that s... | Invoke the scons build system from the current directory exactly as if the scons tool had been invoked . |
21,655 | def archs ( self , as_list = False ) : archs = self . arch_list ( ) . split ( '/' ) if as_list : return archs return set ( archs ) | Return all of the architectures for this target . |
21,656 | def retarget ( self , remove = [ ] , add = [ ] ) : archs = self . arch_list ( ) . split ( '/' ) for r in remove : if r in archs : archs . remove ( r ) archs . extend ( add ) archstr = "/" . join ( archs ) return self . family . find ( archstr , self . module_name ( ) ) | Return a TargetSettings object for the same module but with some of the architectures removed and others added . |
21,657 | def property ( self , name , default = MISSING ) : if name in self . settings : return self . settings [ name ] if default is not MISSING : return default raise ArgumentError ( "property %s not found for target '%s' and no default given" % ( name , self . name ) ) | Get the value of the given property for this chip using the default value if not found and one is provided . If not found and default is None raise an Exception . |
21,658 | def combined_properties ( self , suffix ) : props = [ y for x , y in self . settings . items ( ) if x . endswith ( suffix ) ] properties = itertools . chain ( * props ) processed_props = [ x for x in properties ] return processed_props | Get the value of all properties whose name ends with suffix and join them together into a list . |
21,659 | def includes ( self ) : incs = self . combined_properties ( 'includes' ) processed_incs = [ ] for prop in incs : if isinstance ( prop , str ) : processed_incs . append ( prop ) else : processed_incs . append ( os . path . join ( * prop ) ) fullpaths = [ os . path . normpath ( os . path . join ( '.' , x ) ) for x in pro... | Return all of the include directories for this chip as a list . |
21,660 | def arch_prefixes ( self ) : archs = self . archs ( as_list = True ) prefixes = [ ] for i in range ( 1 , len ( archs ) + 1 ) : prefixes . append ( archs [ : i ] ) return prefixes | Return the initial 1 2 ... N architectures as a prefix list |
21,661 | def targets ( self , module ) : if module not in self . module_targets : raise BuildError ( "Could not find module in targets()" , module = module ) return [ self . find ( x , module ) for x in self . module_targets [ module ] ] | Find the targets for a given module . |
21,662 | def for_all_targets ( self , module , func , filter_func = None ) : for target in self . targets ( module ) : if filter_func is None or filter_func ( target ) : func ( target ) | Call func once for all of the targets of this module . |
21,663 | def validate_target ( self , target ) : archs = target . split ( '/' ) for arch in archs : if not arch in self . archs : return False return True | Make sure that the specified target only contains architectures that we know about . |
21,664 | def _load_architectures ( self , family ) : if "architectures" not in family : raise InternalError ( "required architectures key not in build_settings.json for desired family" ) for key , val in family [ 'architectures' ] . items ( ) : if not isinstance ( val , dict ) : raise InternalError ( "All entries under chip_set... | Load in all of the architectural overlays for this family . An architecture adds configuration information that is used to build a common set of source code for a particular hardware and situation . They are stackable so that you can specify a chip and a configuration for that chip for example . |
21,665 | def generate ( env ) : c_file , cxx_file = SCons . Tool . createCFileBuilders ( env ) c_file . add_action ( ".l" , LexAction ) c_file . add_emitter ( ".l" , lexEmitter ) c_file . add_action ( ".lex" , LexAction ) c_file . add_emitter ( ".lex" , lexEmitter ) cxx_file . add_action ( ".lm" , LexAction ) cxx_file . add_emi... | Add Builders and construction variables for lex to an Environment . |
21,666 | def handle_tick ( self ) : self . uptime += 1 for name , interval in self . ticks . items ( ) : if interval == 0 : continue self . tick_counters [ name ] += 1 if self . tick_counters [ name ] == interval : self . graph_input ( self . TICK_STREAMS [ name ] , self . uptime ) self . tick_counters [ name ] = 0 | Internal callback every time 1 second has passed . |
21,667 | def set_tick ( self , index , interval ) : name = self . tick_name ( index ) if name is None : return pack_error ( ControllerSubsystem . SENSOR_GRAPH , Error . INVALID_ARRAY_KEY ) self . ticks [ name ] = interval return Error . NO_ERROR | Update the a tick s interval . |
21,668 | def get_tick ( self , index ) : name = self . tick_name ( index ) if name is None : return [ pack_error ( ControllerSubsystem . SENSOR_GRAPH , Error . INVALID_ARRAY_KEY ) , 0 ] return [ Error . NO_ERROR , self . ticks [ name ] ] | Get a tick s interval . |
21,669 | def get_time ( self , force_uptime = False ) : if force_uptime : return self . uptime time = self . uptime + self . time_offset if self . is_utc : time |= ( 1 << 31 ) return time | Get the current UTC time or uptime . |
21,670 | def synchronize_clock ( self , offset ) : self . time_offset = offset - self . uptime self . is_utc = True if self . has_rtc : self . stored_offset = self . time_offset | Persistently synchronize the clock to UTC time . |
21,671 | def get_user_timer ( self , index ) : err , tick = self . clock_manager . get_tick ( index ) return [ err , tick ] | Get the current value of a user timer . |
21,672 | def set_user_timer ( self , value , index ) : err = self . clock_manager . set_tick ( index , value ) return [ err ] | Set the current value of a user timer . |
21,673 | def set_time_offset ( self , offset , is_utc ) : is_utc = bool ( is_utc ) self . clock_manager . time_offset = offset self . clock_manager . is_utc = is_utc return [ Error . NO_ERROR ] | Temporarily set the current time offset . |
21,674 | def device_id_to_slug ( did ) : try : device_slug = IOTileDeviceSlug ( did , allow_64bits = False ) except ValueError : raise ArgumentError ( "Unable to recognize {} as a device id" . format ( did ) ) return str ( device_slug ) | Converts a device id into a correct device slug . |
21,675 | def fleet_id_to_slug ( did ) : try : fleet_slug = IOTileFleetSlug ( did ) except ValueError : raise ArgumentError ( "Unable to recognize {} as a fleet id" . format ( did ) ) return str ( fleet_slug ) | Converts a fleet id into a correct fleet slug . |
21,676 | def get_architecture ( arch = None ) : if arch is None : arch = os . environ . get ( 'PROCESSOR_ARCHITEW6432' ) if not arch : arch = os . environ . get ( 'PROCESSOR_ARCHITECTURE' ) return SupportedArchitectureMap . get ( arch , ArchDefinition ( '' , [ '' ] ) ) | Returns the definition for the specified architecture string . |
21,677 | def generate ( env ) : try : bld = env [ 'BUILDERS' ] [ 'Rpm' ] except KeyError : bld = RpmBuilder env [ 'BUILDERS' ] [ 'Rpm' ] = bld env . SetDefault ( RPM = 'LC_ALL=C rpmbuild' ) env . SetDefault ( RPMFLAGS = SCons . Util . CLVar ( '-ta' ) ) env . SetDefault ( RPMCOM = rpmAction ) env . SetDefault ( RPMSUFFIX = '.rpm... | Add Builders and construction variables for rpm to an Environment . |
21,678 | def next_id ( self , channel ) : if channel not in self . topics : self . topics [ channel ] = 0 return 0 self . topics [ channel ] += 1 return self . topics [ channel ] | Get the next sequence number for a named channel or topic |
21,679 | def escape ( arg ) : "escape shell special characters" slash = '\\' special = '"$' arg = arg . replace ( slash , slash + slash ) for c in special : arg = arg . replace ( c , slash + c ) return '"' + arg + '"' | escape shell special characters |
21,680 | def process_streamer ( self , streamer , callback = None ) : index = streamer . index if index in self . _in_progress_streamers : raise InternalError ( "You cannot add a streamer again until it has finished streaming." ) queue_item = QueuedStreamer ( streamer , callback ) self . _in_progress_streamers . add ( index ) s... | Start streaming a streamer . |
21,681 | def pack_rpc_response ( response = None , exception = None ) : if response is None : response = bytes ( ) if exception is None : status = ( 1 << 6 ) if len ( response ) > 0 : status |= ( 1 << 7 ) elif isinstance ( exception , ( RPCInvalidIDError , RPCNotFoundError ) ) : status = 2 elif isinstance ( exception , BusyRPCR... | Convert a response payload or exception to a status code and payload . |
21,682 | def unpack_rpc_response ( status , response = None , rpc_id = 0 , address = 0 ) : status_code = status & ( ( 1 << 6 ) - 1 ) if address == 8 : status_code &= ~ ( 1 << 7 ) if status == 0 : raise BusyRPCResponse ( ) elif status == 2 : raise RPCNotFoundError ( "rpc %d:%04X not found" % ( address , rpc_id ) ) elif status ==... | Unpack an RPC status back in to payload or exception . |
21,683 | def pack_rpc_payload ( arg_format , args ) : code = _create_respcode ( arg_format , args ) packed_result = struct . pack ( code , * args ) unpacked_validation = struct . unpack ( code , packed_result ) if tuple ( args ) != unpacked_validation : raise RPCInvalidArgumentsError ( "Passed values would be truncated, please ... | Pack an RPC payload according to arg_format . |
21,684 | def unpack_rpc_payload ( resp_format , payload ) : code = _create_argcode ( resp_format , payload ) return struct . unpack ( code , payload ) | Unpack an RPC payload according to resp_format . |
21,685 | def isfortran ( env , source ) : try : fsuffixes = env [ 'FORTRANSUFFIXES' ] except KeyError : return 0 if not source : return 0 for s in source : if s . sources : ext = os . path . splitext ( str ( s . sources [ 0 ] ) ) [ 1 ] if ext in fsuffixes : return 1 return 0 | Return 1 if any of code in source has fortran files in it 0 otherwise . |
21,686 | def ComputeFortranSuffixes ( suffixes , ppsuffixes ) : assert len ( suffixes ) > 0 s = suffixes [ 0 ] sup = s . upper ( ) upper_suffixes = [ _ . upper ( ) for _ in suffixes ] if SCons . Util . case_sensitive_suffixes ( s , sup ) : ppsuffixes . extend ( upper_suffixes ) else : suffixes . extend ( upper_suffixes ) | suffixes are fortran source files and ppsuffixes the ones to be pre - processed . Both should be sequences not strings . |
21,687 | def CreateDialectActions ( dialect ) : CompAction = SCons . Action . Action ( '$%sCOM ' % dialect , '$%sCOMSTR' % dialect ) CompPPAction = SCons . Action . Action ( '$%sPPCOM ' % dialect , '$%sPPCOMSTR' % dialect ) ShCompAction = SCons . Action . Action ( '$SH%sCOM ' % dialect , '$SH%sCOMSTR' % dialect ) ShCompPPAction... | Create dialect specific actions . |
21,688 | def DialectAddToEnv ( env , dialect , suffixes , ppsuffixes , support_module = 0 ) : ComputeFortranSuffixes ( suffixes , ppsuffixes ) fscan = SCons . Scanner . Fortran . FortranScan ( "%sPATH" % dialect ) for suffix in suffixes + ppsuffixes : SCons . Tool . SourceFileScanner . add_scanner ( suffix , fscan ) env . Appen... | Add dialect specific construction variables . |
21,689 | def add_fortran_to_env ( env ) : try : FortranSuffixes = env [ 'FORTRANFILESUFFIXES' ] except KeyError : FortranSuffixes = [ '.f' , '.for' , '.ftn' ] try : FortranPPSuffixes = env [ 'FORTRANPPFILESUFFIXES' ] except KeyError : FortranPPSuffixes = [ '.fpp' , '.FPP' ] DialectAddToEnv ( env , "FORTRAN" , FortranSuffixes , ... | Add Builders and construction variables for Fortran to an Environment . |
21,690 | def add_f77_to_env ( env ) : try : F77Suffixes = env [ 'F77FILESUFFIXES' ] except KeyError : F77Suffixes = [ '.f77' ] try : F77PPSuffixes = env [ 'F77PPFILESUFFIXES' ] except KeyError : F77PPSuffixes = [ ] DialectAddToEnv ( env , "F77" , F77Suffixes , F77PPSuffixes ) | Add Builders and construction variables for f77 to an Environment . |
21,691 | def add_f90_to_env ( env ) : try : F90Suffixes = env [ 'F90FILESUFFIXES' ] except KeyError : F90Suffixes = [ '.f90' ] try : F90PPSuffixes = env [ 'F90PPFILESUFFIXES' ] except KeyError : F90PPSuffixes = [ ] DialectAddToEnv ( env , "F90" , F90Suffixes , F90PPSuffixes , support_module = 1 ) | Add Builders and construction variables for f90 to an Environment . |
21,692 | def add_f95_to_env ( env ) : try : F95Suffixes = env [ 'F95FILESUFFIXES' ] except KeyError : F95Suffixes = [ '.f95' ] try : F95PPSuffixes = env [ 'F95PPFILESUFFIXES' ] except KeyError : F95PPSuffixes = [ ] DialectAddToEnv ( env , "F95" , F95Suffixes , F95PPSuffixes , support_module = 1 ) | Add Builders and construction variables for f95 to an Environment . |
21,693 | def add_f03_to_env ( env ) : try : F03Suffixes = env [ 'F03FILESUFFIXES' ] except KeyError : F03Suffixes = [ '.f03' ] try : F03PPSuffixes = env [ 'F03PPFILESUFFIXES' ] except KeyError : F03PPSuffixes = [ ] DialectAddToEnv ( env , "F03" , F03Suffixes , F03PPSuffixes , support_module = 1 ) | Add Builders and construction variables for f03 to an Environment . |
21,694 | def add_f08_to_env ( env ) : try : F08Suffixes = env [ 'F08FILESUFFIXES' ] except KeyError : F08Suffixes = [ '.f08' ] try : F08PPSuffixes = env [ 'F08PPFILESUFFIXES' ] except KeyError : F08PPSuffixes = [ ] DialectAddToEnv ( env , "F08" , F08Suffixes , F08PPSuffixes , support_module = 1 ) | Add Builders and construction variables for f08 to an Environment . |
21,695 | def add_all_to_env ( env ) : add_fortran_to_env ( env ) add_f77_to_env ( env ) add_f90_to_env ( env ) add_f95_to_env ( env ) add_f03_to_env ( env ) add_f08_to_env ( env ) | Add builders and construction variables for all supported fortran dialects . |
21,696 | def _delete_duplicates ( l , keep_last ) : seen = set ( ) result = [ ] if keep_last : l . reverse ( ) for i in l : try : if i not in seen : result . append ( i ) seen . add ( i ) except TypeError : result . append ( i ) if keep_last : result . reverse ( ) return result | Delete duplicates from a sequence keeping the first or last . |
21,697 | def clone ( self , new_object ) : return self . __class__ ( new_object , self . method , self . name ) | Returns an object that re - binds the underlying method to the specified new object . |
21,698 | def _init_special ( self ) : self . _special_del = { } self . _special_del [ 'SCANNERS' ] = _del_SCANNERS self . _special_set = { } for key in reserved_construction_var_names : self . _special_set [ key ] = _set_reserved for key in future_reserved_construction_var_names : self . _special_set [ key ] = _set_future_reser... | Initial the dispatch tables for special handling of special construction variables . |
21,699 | def AddMethod ( self , function , name = None ) : method = MethodWrapper ( self , function , name ) self . added_methods . append ( method ) | Adds the specified function as a method of this construction environment with the specified name . If the name is omitted the default name is the name of the function itself . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.