idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
26,100 | def _ewp_files_set ( self , ewp_dic , project_dic ) : try : ewp_dic [ 'project' ] [ 'file' ] = [ ] except KeyError : pass ewp_dic [ 'project' ] [ 'group' ] = [ ] i = 0 for group_name , files in project_dic [ 'groups' ] . items ( ) : ewp_dic [ 'project' ] [ 'group' ] . append ( { 'name' : group_name , 'file' : [ ] } ) f... | Fills files in the ewp dictionary |
26,101 | def _clean_xmldict_single_dic ( self , dictionary ) : for k , v in dictionary . items ( ) : if v is None : dictionary [ k ] = '' | Every None replace by in the dic as xml parsers puts None in those fiels which is not valid for IAR |
26,102 | def _fix_paths ( self , data ) : data [ 'include_paths' ] = [ join ( '$PROJ_DIR$' , path ) for path in data [ 'include_paths' ] ] if data [ 'linker_file' ] : data [ 'linker_file' ] = join ( '$PROJ_DIR$' , data [ 'linker_file' ] ) data [ 'groups' ] = { } for attribute in SOURCE_KEYS : for k , v in data [ attribute ] . i... | All paths needs to be fixed - add PROJ_DIR prefix + normalize |
26,103 | def build_project ( self ) : proj_path = join ( getcwd ( ) , self . workspace [ 'files' ] [ 'ewp' ] ) if proj_path . split ( '.' ) [ - 1 ] != 'ewp' : proj_path += '.ewp' if not os . path . exists ( proj_path ) : logger . debug ( "The file: %s does not exists, exported prior building?" % proj_path ) return - 1 logger . ... | Build IAR project |
26,104 | def gen_file_jinja ( self , template_file , data , output , dest_path ) : if not os . path . exists ( dest_path ) : os . makedirs ( dest_path ) output = join ( dest_path , output ) logger . debug ( "Generating: %s" % output ) env = Environment ( ) env . loader = FileSystemLoader ( self . TEMPLATE_DIR ) template = env .... | Fills data to the project template using jinja2 . |
26,105 | def _expand_data ( self , old_data , new_data , group ) : for file in old_data : if file : extension = file . split ( "." ) [ - 1 ] . lower ( ) if extension in self . file_types . keys ( ) : new_data [ 'groups' ] [ group ] . append ( self . _expand_one_file ( normpath ( file ) , new_data , extension ) ) else : logger .... | data expansion - uvision needs filename and path separately . |
26,106 | def _get_groups ( self , data ) : groups = [ ] for attribute in SOURCE_KEYS : for k , v in data [ attribute ] . items ( ) : if k == None : k = 'Sources' if k not in groups : groups . append ( k ) for k , v in data [ 'include_files' ] . items ( ) : if k == None : k = 'Includes' if k not in groups : groups . append ( k )... | Get all groups defined |
26,107 | def _iterate ( self , data , expanded_data ) : for attribute in SOURCE_KEYS : for k , v in data [ attribute ] . items ( ) : if k == None : group = 'Sources' else : group = k if group in data [ attribute ] . keys ( ) : self . _expand_data ( data [ attribute ] [ group ] , expanded_data , group ) for k , v in data [ 'incl... | _Iterate through all data store the result expansion in extended dictionary |
26,108 | def export_project ( self ) : output = copy . deepcopy ( self . generated_project ) data_for_make = self . workspace . copy ( ) self . exporter . process_data_for_makefile ( data_for_make ) output [ 'path' ] , output [ 'files' ] [ 'makefile' ] = self . gen_file_jinja ( 'makefile_gcc.tmpl' , data_for_make , 'Makefile' ,... | Processes groups and misc options specific for eclipse and run generator |
26,109 | def generate ( self , tool , copied = False , copy = False ) : tools = [ ] if not tool : logger . info ( "Workspace supports one tool for all projects within." ) return - 1 else : tools = [ tool ] result = 0 for export_tool in tools : tool_export = ToolsSupported ( ) . get_tool ( export_tool ) if tool_export is None : ... | Generates a workspace |
26,110 | def _validate_tools ( self , tool ) : tools = [ ] if not tool : if len ( self . project [ 'common' ] [ 'tools_supported' ] ) == 0 : logger . info ( "No tool defined." ) return - 1 tools = self . project [ 'common' ] [ 'tools_supported' ] else : tools = [ tool ] return tools | Use tool_supported or tool |
26,111 | def _generate_output_dir ( settings , path ) : relpath = os . path . relpath ( settings . root , path ) count = relpath . count ( os . sep ) + 1 return relpath + os . path . sep , count | This is a separate function so that it can be more easily tested |
26,112 | def _copy_sources_to_generated_destination ( self ) : files = [ ] for key in FILES_EXTENSIONS . keys ( ) : if type ( self . project [ 'export' ] [ key ] ) is dict : for k , v in self . project [ 'export' ] [ key ] . items ( ) : files . extend ( v ) elif type ( self . project [ 'export' ] [ key ] ) is list : files . ext... | Copies all project files to specified directory - generated dir |
26,113 | def clean ( self , tool ) : tools = self . _validate_tools ( tool ) if tools == - 1 : return - 1 for current_tool in tools : self . _fill_export_dict ( current_tool ) path = self . project [ 'export' ] [ 'output_dir' ] [ 'path' ] if os . path . isdir ( path ) : logger . info ( "Cleaning directory %s" % path ) shutil . ... | Clean a project |
26,114 | def generate ( self , tool , copied = False , copy = False ) : tools = self . _validate_tools ( tool ) if tools == - 1 : return - 1 generated_files = { } result = 0 for export_tool in tools : exporter = ToolsSupported ( ) . get_tool ( export_tool ) if exporter is None : result = - 1 logger . debug ( "Tool: %s was not f... | Generates a project |
26,115 | def build ( self , tool ) : tools = self . _validate_tools ( tool ) if tools == - 1 : return - 1 result = 0 for build_tool in tools : builder = ToolsSupported ( ) . get_tool ( build_tool ) if builder is None : logger . debug ( "Tool: %s was not found" % builder ) result = - 1 continue logger . debug ( "Building for too... | build the project |
26,116 | def get_generated_project_files ( self , tool ) : exporter = ToolsSupported ( ) . get_tool ( tool ) return exporter ( self . generated_files [ tool ] , self . settings ) . get_generated_project_files ( ) | Get generated project files the content depends on a tool . Look at tool implementation |
26,117 | def export_project ( self ) : generated_projects = deepcopy ( self . generated_projects ) self . process_data_for_makefile ( self . workspace ) generated_projects [ 'path' ] , generated_projects [ 'files' ] [ 'makefile' ] = self . gen_file_jinja ( 'makefile_armcc.tmpl' , self . workspace , 'Makefile' , self . workspace... | Processes misc options specific for GCC ARM and run generator |
26,118 | def _parse_specific_options ( self , data ) : data [ 'common_flags' ] = [ ] data [ 'ld_flags' ] = [ ] data [ 'c_flags' ] = [ ] data [ 'cxx_flags' ] = [ ] data [ 'asm_flags' ] = [ ] for k , v in data [ 'misc' ] . items ( ) : if type ( v ) is list : if k not in data : data [ k ] = [ ] data [ k ] . extend ( v ) else : if ... | Parse all specific setttings . |
26,119 | def export_project ( self ) : output = copy . deepcopy ( self . generated_project ) self . process_data_for_makefile ( self . workspace ) self . _fix_sublime_paths ( self . workspace ) self . workspace [ 'linker_options' ] = [ ] output [ 'path' ] , output [ 'files' ] [ 'makefile' ] = self . gen_file_jinja ( 'makefile_g... | Processes misc options specific for GCC ARM and run generator . |
26,120 | def fix_paths ( project_data , rel_path , extensions ) : norm_func = lambda path : os . path . normpath ( os . path . join ( rel_path , path ) ) for key in extensions : if type ( project_data [ key ] ) is dict : for k , v in project_data [ key ] . items ( ) : project_data [ key ] [ k ] = [ norm_func ( i ) for i in v ] ... | Fix paths for extension list |
26,121 | def _make_cls ( self , value ) : if isinstance ( value , self . _cls ) : return value return self . _cls ( value ) | If value is not instance of self . _cls converts and returns it . Otherwise returns value . |
26,122 | def _send_request ( self , request ) : headers = { "X-Experience-API-Version" : self . version } if self . auth is not None : headers [ "Authorization" ] = self . auth headers . update ( request . headers ) params = request . query_params params = { k : unicode ( params [ k ] ) . encode ( 'utf-8' ) for k in params . ke... | Establishes connection and returns http response based off of request . |
26,123 | def about ( self ) : request = HTTPRequest ( method = "GET" , resource = "about" ) lrs_response = self . _send_request ( request ) if lrs_response . success : lrs_response . content = About . from_json ( lrs_response . data ) return lrs_response | Gets about response from LRS |
26,124 | def save_statement ( self , statement ) : if not isinstance ( statement , Statement ) : statement = Statement ( statement ) request = HTTPRequest ( method = "POST" , resource = "statements" ) if statement . id is not None : request . method = "PUT" request . query_params [ "statementId" ] = statement . id request . hea... | Save statement to LRS and update statement id if necessary |
26,125 | def save_statements ( self , statements ) : if not isinstance ( statements , StatementList ) : statements = StatementList ( statements ) request = HTTPRequest ( method = "POST" , resource = "statements" ) request . headers [ "Content-Type" ] = "application/json" request . content = statements . to_json ( ) lrs_response... | Save statements to LRS and update their statement id s |
26,126 | def retrieve_statement ( self , statement_id ) : request = HTTPRequest ( method = "GET" , resource = "statements" ) request . query_params [ "statementId" ] = statement_id lrs_response = self . _send_request ( request ) if lrs_response . success : lrs_response . content = Statement . from_json ( lrs_response . data ) r... | Retrieve a statement from the server from its id |
26,127 | def query_statements ( self , query ) : params = { } param_keys = [ "registration" , "since" , "until" , "limit" , "ascending" , "related_activities" , "related_agents" , "format" , "attachments" , ] for k , v in query . iteritems ( ) : if v is not None : if k == "agent" : params [ k ] = v . to_json ( self . version ) ... | Query the LRS for statements with specified parameters |
26,128 | def more_statements ( self , more_url ) : if isinstance ( more_url , StatementsResult ) : more_url = more_url . more more_url = self . get_endpoint_server_root ( ) + more_url request = HTTPRequest ( method = "GET" , resource = more_url ) lrs_response = self . _send_request ( request ) if lrs_response . success : lrs_re... | Query the LRS for more statements |
26,129 | def retrieve_state_ids ( self , activity , agent , registration = None , since = None ) : if not isinstance ( activity , Activity ) : activity = Activity ( activity ) if not isinstance ( agent , Agent ) : agent = Agent ( agent ) request = HTTPRequest ( method = "GET" , resource = "activities/state" ) request . query_pa... | Retrieve state id s from the LRS with the provided parameters |
26,130 | def retrieve_state ( self , activity , agent , state_id , registration = None ) : if not isinstance ( activity , Activity ) : activity = Activity ( activity ) if not isinstance ( agent , Agent ) : agent = Agent ( agent ) request = HTTPRequest ( method = "GET" , resource = "activities/state" , ignore404 = True ) request... | Retrieve state from LRS with the provided parameters |
26,131 | def save_state ( self , state ) : request = HTTPRequest ( method = "PUT" , resource = "activities/state" , content = state . content , ) if state . content_type is not None : request . headers [ "Content-Type" ] = state . content_type else : request . headers [ "Content-Type" ] = "application/octet-stream" if state . e... | Save a state doc to the LRS |
26,132 | def _delete_state ( self , activity , agent , state_id = None , registration = None , etag = None ) : if not isinstance ( activity , Activity ) : activity = Activity ( activity ) if not isinstance ( agent , Agent ) : agent = Agent ( agent ) request = HTTPRequest ( method = "DELETE" , resource = "activities/state" ) if ... | Private method to delete a specified state from the LRS |
26,133 | def delete_state ( self , state ) : return self . _delete_state ( activity = state . activity , agent = state . agent , state_id = state . id , etag = state . etag ) | Delete a specified state from the LRS |
26,134 | def retrieve_activity_profile ( self , activity , profile_id ) : if not isinstance ( activity , Activity ) : activity = Activity ( activity ) request = HTTPRequest ( method = "GET" , resource = "activities/profile" , ignore404 = True ) request . query_params = { "profileId" : profile_id , "activityId" : activity . id }... | Retrieve activity profile with the specified parameters |
26,135 | def save_activity_profile ( self , profile ) : request = HTTPRequest ( method = "PUT" , resource = "activities/profile" , content = profile . content ) if profile . content_type is not None : request . headers [ "Content-Type" ] = profile . content_type else : request . headers [ "Content-Type" ] = "application/octet-s... | Save an activity profile doc to the LRS |
26,136 | def delete_activity_profile ( self , profile ) : request = HTTPRequest ( method = "DELETE" , resource = "activities/profile" ) request . query_params = { "profileId" : profile . id , "activityId" : profile . activity . id } if profile . etag is not None : request . headers [ "If-Match" ] = profile . etag return self . ... | Delete activity profile doc from LRS |
26,137 | def retrieve_agent_profile ( self , agent , profile_id ) : if not isinstance ( agent , Agent ) : agent = Agent ( agent ) request = HTTPRequest ( method = "GET" , resource = "agents/profile" , ignore404 = True ) request . query_params = { "profileId" : profile_id , "agent" : agent . to_json ( self . version ) } lrs_resp... | Retrieve agent profile with the specified parameters |
26,138 | def save_agent_profile ( self , profile ) : request = HTTPRequest ( method = "PUT" , resource = "agents/profile" , content = profile . content , ) if profile . content_type is not None : request . headers [ "Content-Type" ] = profile . content_type else : request . headers [ "Content-Type" ] = "application/octet-stream... | Save an agent profile doc to the LRS |
26,139 | def delete_agent_profile ( self , profile ) : request = HTTPRequest ( method = "DELETE" , resource = "agents/profile" ) request . query_params = { "profileId" : profile . id , "agent" : profile . agent . to_json ( self . version ) } if profile . etag is not None : request . headers [ "If-Match" ] = profile . etag retur... | Delete agent profile doc from LRS |
26,140 | def get_endpoint_server_root ( self ) : parsed = urlparse ( self . _endpoint ) root = parsed . scheme + "://" + parsed . hostname if parsed . port is not None : root += ":" + unicode ( parsed . port ) return root | Parses RemoteLRS object s endpoint and returns its root |
26,141 | def from_json ( cls , json_data ) : data = json . loads ( json_data ) result = cls ( data ) if hasattr ( result , "_from_json" ) : result . _from_json ( ) return result | Tries to convert a JSON representation to an object of the same type as self |
26,142 | def to_json ( self , version = Version . latest ) : return json . dumps ( self . as_version ( version ) ) | Tries to convert an object into a JSON representation and return the resulting string |
26,143 | def as_version ( self , version = Version . latest ) : if not isinstance ( self , list ) : result = { } for k , v in self . iteritems ( ) if isinstance ( self , dict ) else vars ( self ) . iteritems ( ) : k = self . _props_corrected . get ( k , k ) if isinstance ( v , SerializableBase ) : result [ k ] = v . as_version ... | Returns a dict that has been modified based on versioning in order to be represented in JSON properly |
26,144 | def _filter_none ( obj ) : result = { } for k , v in obj . iteritems ( ) : if v is not None : if k . startswith ( '_' ) : k = k [ 1 : ] result [ k ] = v return result | Filters out attributes set to None prior to serialization and returns a new object without those attributes . This saves the serializer from sending empty bytes over the network . This method also fixes the keys to look as expected by ignoring a leading _ if it is present . |
26,145 | def jsonify_timedelta ( value ) : assert isinstance ( value , datetime . timedelta ) seconds = value . total_seconds ( ) minutes , seconds = divmod ( seconds , 60 ) hours , minutes = divmod ( minutes , 60 ) days , hours = divmod ( hours , 24 ) days , hours , minutes = map ( int , ( days , hours , minutes ) ) seconds = ... | Converts a datetime . timedelta to an ISO 8601 duration string for JSON - ification . |
26,146 | def zip_dicts ( left , right , prefix = ( ) ) : for key , left_value in left . items ( ) : path = prefix + ( key , ) right_value = right . get ( key ) if isinstance ( left_value , dict ) : yield from zip_dicts ( left_value , right_value or { } , path ) else : yield path , left , left_value , right , right_value | Modified zip through two dictionaries . |
26,147 | def configure ( defaults , metadata , loader ) : config = Configuration ( defaults ) config . merge ( loader ( metadata ) ) validate ( defaults , metadata , config ) return config | Build a fresh configuration . |
26,148 | def boolean ( value ) : if isinstance ( value , bool ) : return value if value == "" : return False return strtobool ( value ) | Configuration - friendly boolean type converter . |
26,149 | def _load_from_environ ( metadata , value_func = None ) : prefix = metadata . name . upper ( ) . replace ( "-" , "_" ) return expand_config ( environ , separator = "__" , skip_to = 1 , key_parts_filter = lambda key_parts : len ( key_parts ) > 1 and key_parts [ 0 ] == prefix , value_func = lambda value : value_func ( va... | Load configuration from environment variables . |
26,150 | def load_from_dict ( dct = None , ** kwargs ) : dct = dct or dict ( ) dct . update ( kwargs ) def _load_from_dict ( metadata ) : return dict ( dct ) return _load_from_dict | Load configuration from a dictionary . |
26,151 | def binding ( key , registry = None ) : if registry is None : registry = _registry def decorator ( func ) : registry . bind ( key , func ) return func return decorator | Creates a decorator that binds a factory function to a key . |
26,152 | def defaults ( ** kwargs ) : def decorator ( func ) : setattr ( func , DEFAULTS , kwargs ) return func return decorator | Creates a decorator that saves the provided kwargs as defaults for a factory function . |
26,153 | def _invoke_hook ( hook_name , target ) : try : for value in getattr ( target , hook_name ) : func , args , kwargs = value func ( target , * args , ** kwargs ) except AttributeError : pass except ( TypeError , ValueError ) : pass | Generic hook invocation . |
26,154 | def _register_hook ( hook_name , target , func , * args , ** kwargs ) : call = ( func , args , kwargs ) try : getattr ( target , hook_name ) . append ( call ) except AttributeError : setattr ( target , hook_name , [ call ] ) | Generic hook registration . |
26,155 | def on_resolve ( target , func , * args , ** kwargs ) : return _register_hook ( ON_RESOLVE , target , func , * args , ** kwargs ) | Register a resolution hook . |
26,156 | def create_cache ( name ) : caches = { subclass . name ( ) : subclass for subclass in Cache . __subclasses__ ( ) } return caches . get ( name , NaiveCache ) ( ) | Create a cache by name . |
26,157 | def get_config_filename ( metadata ) : envvar = "{}__SETTINGS" . format ( underscore ( metadata . name ) . upper ( ) ) try : return environ [ envvar ] except KeyError : return None | Derive a configuration file name from the FOO_SETTINGS environment variable . |
26,158 | def _load_from_file ( metadata , load_func ) : config_filename = get_config_filename ( metadata ) if config_filename is None : return dict ( ) with open ( config_filename , "r" ) as file_ : data = load_func ( file_ . read ( ) ) return dict ( data ) | Load configuration from a file . |
26,159 | def get_scoped_config ( self , graph ) : def loader ( metadata ) : if not self . current_scope : target = graph . config else : target = graph . config . get ( self . current_scope , { } ) return { self . key : target . get ( self . key , { } ) , } defaults = { self . key : get_defaults ( self . func ) , } return confi... | Compute a configuration using the current scope . |
26,160 | def resolve ( self , graph ) : cached = graph . get ( self . scoped_key ) if cached : return cached component = self . create ( graph ) graph . assign ( self . scoped_key , component ) return component | Resolve a scoped component respecting the graph cache . |
26,161 | def create ( self , graph ) : scoped_config = self . get_scoped_config ( graph ) scoped_graph = ScopedGraph ( graph , scoped_config ) return self . func ( scoped_graph ) | Create a new scoped component . |
26,162 | def infect ( cls , graph , key , default_scope = None ) : func = graph . factory_for ( key ) if isinstance ( func , cls ) : func = func . func factory = cls ( key , func , default_scope ) graph . _registry . factories [ key ] = factory return factory | Forcibly convert an entry - point based factory to a ScopedFactory . |
26,163 | def load_each ( * loaders ) : def _load_each ( metadata ) : return merge ( loader ( metadata ) for loader in loaders ) return _load_each | Loader factory that combines a series of loaders . |
26,164 | def all ( self ) : return { key : value for key , value in chain ( self . entry_points . items ( ) , self . factories . items ( ) ) } | Return a synthetic dictionary of all factories . |
26,165 | def defaults ( self ) : return { key : get_defaults ( value ) for key , value in self . all . items ( ) } | Return a nested dicionary of all registered factory defaults . |
26,166 | def bind ( self , key , factory ) : if key in self . factories : raise AlreadyBoundError ( key ) else : self . factories [ key ] = factory | Bind a factory to a key . |
26,167 | def resolve ( self , key ) : try : return self . _resolve_from_binding ( key ) except NotBoundError : return self . _resolve_from_entry_point ( key ) | Resolve a key to a factory . |
26,168 | def expand_config ( dct , separator = '.' , skip_to = 0 , key_func = lambda key : key . lower ( ) , key_parts_filter = lambda key_parts : True , value_func = lambda value : value ) : config = { } for key , value in dct . items ( ) : key_separator = separator ( key ) if callable ( separator ) else separator key_parts = ... | Expand a dictionary recursively by splitting keys along the separator . |
26,169 | def create_object_graph ( name , debug = False , testing = False , import_name = None , root_path = None , loader = load_from_environ , registry = _registry , profiler = None , cache = None ) : metadata = Metadata ( name = name , debug = debug , testing = testing , import_name = import_name , root_path = root_path , ) ... | Create a new object graph . |
26,170 | def _reserve ( self , key ) : self . assign ( key , RESERVED ) try : yield finally : del self . _cache [ key ] | Reserve a component s binding temporarily . |
26,171 | def _resolve_key ( self , key ) : with self . _reserve ( key ) : factory = self . factory_for ( key ) with self . _profiler ( key ) : component = factory ( self ) invoke_resolve_hook ( component ) return self . assign ( key , component ) | Attempt to lazily create a component . |
26,172 | def scoped_to ( self , scope ) : previous_scope = self . __factory__ . current_scope try : self . __factory__ . current_scope = scope yield finally : self . __factory__ . current_scope = previous_scope | Context manager to switch scopes . |
26,173 | def scoped ( self , func ) : @ wraps ( func ) def wrapper ( * args , ** kwargs ) : scope = kwargs . get ( "scope" , self . __factory__ . default_scope ) with self . scoped_to ( scope ) : return func ( * args , ** kwargs ) return wrapper | Decorator to switch scopes . |
26,174 | def merge ( self , dct = None , ** kwargs ) : if dct is None : dct = { } if kwargs : dct . update ( ** kwargs ) for key , value in dct . items ( ) : if all ( ( isinstance ( value , dict ) , isinstance ( self . get ( key ) , Configuration ) , getattr ( self . get ( key ) , "__merge__" , True ) , ) ) : self [ key ] . mer... | Recursively merge a dictionary or kwargs into the current dict . |
26,175 | def validate ( self , metadata , path , value ) : if isinstance ( value , Requirement ) : if metadata . testing and self . mock_value is not None : value = self . mock_value elif self . default_value is not None : value = self . default_value elif not value . required : return None else : raise ValidationError ( f"Miss... | Validate this requirement . |
26,176 | def decode_conjure_union_type ( cls , obj , conjure_type ) : type_of_union = obj [ "type" ] for attr , conjure_field in conjure_type . _options ( ) . items ( ) : if conjure_field . identifier == type_of_union : attribute = attr conjure_field_definition = conjure_field break else : raise ValueError ( "unknown union type... | Decodes json into a conjure union type . |
26,177 | def decode_conjure_enum_type ( cls , obj , conjure_type ) : if not ( isinstance ( obj , str ) or str ( type ( obj ) ) == "<type 'unicode'>" ) : raise Exception ( 'Expected to find str type but found {} instead' . format ( type ( obj ) ) ) if obj in conjure_type . __members__ : return conjure_type [ obj ] else : return ... | Decodes json into a conjure enum type . |
26,178 | def decode_list ( cls , obj , element_type ) : if not isinstance ( obj , list ) : raise Exception ( "expected a python list" ) return list ( map ( lambda x : cls . do_decode ( x , element_type ) , obj ) ) | Decodes json into a list handling conversion of the elements . |
26,179 | def do_decode ( cls , obj , obj_type ) : if inspect . isclass ( obj_type ) and issubclass ( obj_type , ConjureBeanType ) : return cls . decode_conjure_bean_type ( obj , obj_type ) elif inspect . isclass ( obj_type ) and issubclass ( obj_type , ConjureUnionType ) : return cls . decode_conjure_union_type ( obj , obj_type... | Decodes json into the specified type |
26,180 | def encode_conjure_bean_type ( cls , obj ) : encoded = { } for attribute_name , field_definition in obj . _fields ( ) . items ( ) : encoded [ field_definition . identifier ] = cls . do_encode ( getattr ( obj , attribute_name ) ) return encoded | Encodes a conjure bean into json |
26,181 | def encode_conjure_union_type ( cls , obj ) : encoded = { } encoded [ "type" ] = obj . type for attr , field_definition in obj . _options ( ) . items ( ) : if field_definition . identifier == obj . type : attribute = attr break else : raise ValueError ( "could not find attribute for union " + "member {0} of type {1}" .... | Encodes a conjure union into json |
26,182 | def do_encode ( cls , obj ) : if isinstance ( obj , ConjureBeanType ) : return cls . encode_conjure_bean_type ( obj ) elif isinstance ( obj , ConjureUnionType ) : return cls . encode_conjure_union_type ( obj ) elif isinstance ( obj , ConjureEnumType ) : return obj . value elif isinstance ( obj , list ) : return list ( ... | Encodes the passed object into json |
26,183 | def radians_to ( self , other ) : d2r = math . pi / 180.0 lat1rad = self . latitude * d2r long1rad = self . longitude * d2r lat2rad = other . latitude * d2r long2rad = other . longitude * d2r delta_lat = lat1rad - lat2rad delta_long = long1rad - long2rad sin_delta_lat_div2 = math . sin ( delta_lat / 2.0 ) sin_delta_lon... | Returns the distance from this GeoPoint to another in radians . |
26,184 | def append ( self , item ) : self . beginInsertRows ( QtCore . QModelIndex ( ) , self . rowCount ( ) , self . rowCount ( ) ) self . items . append ( item ) self . endInsertRows ( ) | Append item to end of model |
26,185 | def on_item_toggled ( self , index , state = None ) : if not index . data ( model . IsIdle ) : return self . info ( "Cannot toggle" ) if not index . data ( model . IsOptional ) : return self . info ( "This item is mandatory" ) if state is None : state = not index . data ( model . IsChecked ) index . model ( ) . setData... | An item is requesting to be toggled |
26,186 | def on_comment_entered ( self ) : text_edit = self . findChild ( QtWidgets . QWidget , "CommentBox" ) comment = text_edit . text ( ) context = self . controller . context context . data [ "comment" ] = comment placeholder = self . findChild ( QtWidgets . QLabel , "CommentPlaceholder" ) placeholder . setVisible ( not co... | The user has typed a comment |
26,187 | def on_finished ( self ) : self . controller . is_running = False error = self . controller . current_error if error is not None : self . info ( self . tr ( "Stopped due to error(s), see Terminal." ) ) else : self . info ( self . tr ( "Finished successfully!" ) ) | Finished signal handler |
26,188 | def reset ( self ) : self . info ( self . tr ( "About to reset.." ) ) models = self . data [ "models" ] models [ "instances" ] . store_checkstate ( ) models [ "plugins" ] . store_checkstate ( ) models [ "instances" ] . ids = [ ] for m in models . values ( ) : m . reset ( ) for b in self . data [ "buttons" ] . values ( ... | Prepare GUI for reset |
26,189 | def closeEvent ( self , event ) : self . hide ( ) if self . data [ "state" ] [ "is_closing" ] : self . info ( self . tr ( "Cleaning up models.." ) ) for v in self . data [ "views" ] . values ( ) : v . model ( ) . deleteLater ( ) v . setModel ( None ) self . info ( self . tr ( "Cleaning up terminal.." ) ) for item in se... | Perform post - flight checks before closing |
26,190 | def reject ( self ) : if self . controller . is_running : self . info ( self . tr ( "Stopping.." ) ) self . controller . is_running = False | Handle ESC key |
26,191 | def info ( self , message ) : info = self . findChild ( QtWidgets . QLabel , "Info" ) info . setText ( message ) self . data [ "models" ] [ "terminal" ] . append ( { "label" : message , "type" : "info" } ) animation = self . data [ "animation" ] [ "display_info" ] animation . stop ( ) animation . start ( ) util . u_pri... | Print user - facing information |
26,192 | def rowsInserted ( self , parent , start , end ) : super ( LogView , self ) . rowsInserted ( parent , start , end ) self . scrollToBottom ( ) | Automatically scroll to bottom on each new item added |
26,193 | def reset ( self ) : self . context = pyblish . api . Context ( ) self . plugins = pyblish . api . discover ( ) self . was_discovered . emit ( ) self . pair_generator = None self . current_pair = ( None , None ) self . current_error = None self . processing = { "nextOrder" : None , "ordersWithError" : set ( ) } self . ... | Discover plug - ins and run collection |
26,194 | def _load ( self ) : self . is_running = True self . pair_generator = self . _iterator ( self . plugins , self . context ) self . current_pair = next ( self . pair_generator , ( None , None ) ) self . current_error = None self . is_running = False | Initiate new generator and load first pair |
26,195 | def _process ( self , plugin , instance = None ) : self . processing [ "nextOrder" ] = plugin . order try : result = pyblish . plugin . process ( plugin , self . context , instance ) except Exception as e : raise Exception ( "Unknown error: %s" % e ) else : has_error = result [ "error" ] is not None if has_error : self... | Produce result from plugin and instance |
26,196 | def _run ( self , until = float ( "inf" ) , on_finished = lambda : None ) : def on_next ( ) : if self . current_pair == ( None , None ) : return util . defer ( 100 , on_finished_ ) order = self . current_pair [ 0 ] . order if order > ( until + 0.5 ) : return util . defer ( 100 , on_finished_ ) self . about_to_process .... | Process current pair and store next pair for next process |
26,197 | def _iterator ( self , plugins , context ) : test = pyblish . logic . registered_test ( ) for plug , instance in pyblish . logic . Iterator ( plugins , context ) : if not plug . active : continue if instance is not None and instance . data . get ( "publish" ) is False : continue self . processing [ "nextOrder" ] = plug... | Yield next plug - in and instance to process . |
26,198 | def cleanup ( self ) : for instance in self . context : del ( instance ) for plugin in self . plugins : del ( plugin ) | Forcefully delete objects from memory |
26,199 | def get_root_uri ( uri ) : chunks = urlsplit ( uri ) return urlunsplit ( ( chunks . scheme , chunks . netloc , chunks . path , '' , '' ) ) | Return root URI - strip query and fragment . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.