idx
int64
0
252k
question
stringlengths
48
5.28k
target
stringlengths
5
1.23k
236,000
def coerce ( self , value , ** kwargs ) : result = [ ] for v in value : result . append ( self . _coercion . coerce ( v , ** kwargs ) ) return result
Coerces array items with proper coercion .
236,001
def coerce ( self , value , includes = None , errors = None , resources = None , default_locale = 'en-US' , locale = None ) : if includes is None : includes = [ ] if errors is None : errors = [ ] return self . _coerce_block ( value , includes = includes , errors = errors , resources = resources , default_locale = defau...
Coerces Rich Text properly .
236,002
def coerce ( self , value , ** kwargs ) : if value is None : return None return self . _coercion . coerce ( value , ** kwargs )
Coerces the value to the proper type .
236,003
def content_type ( self , content_type_id , query = None ) : return self . _get ( self . environment_url ( '/content_types/{0}' . format ( content_type_id ) ) , query )
Fetches a Content Type by ID .
236,004
def entry ( self , entry_id , query = None ) : if query is None : query = { } self . _normalize_select ( query ) try : query . update ( { 'sys.id' : entry_id } ) return self . _get ( self . environment_url ( '/entries' ) , query ) [ 0 ] except IndexError : raise EntryNotFoundError ( "Entry not found for ID: '{0}'" . fo...
Fetches an Entry by ID .
236,005
def asset ( self , asset_id , query = None ) : return self . _get ( self . environment_url ( '/assets/{0}' . format ( asset_id ) ) , query )
Fetches an Asset by ID .
236,006
def sync ( self , query = None ) : if query is None : query = { } self . _normalize_sync ( query ) return self . _get ( self . environment_url ( '/sync' ) , query )
Fetches content from the Sync API .
236,007
def _request_headers ( self ) : headers = { 'X-Contentful-User-Agent' : self . _contentful_user_agent ( ) , 'Content-Type' : 'application/vnd.contentful.delivery.v{0}+json' . format ( self . api_version ) } if self . authorization_as_header : headers [ 'Authorization' ] = 'Bearer {0}' . format ( self . access_token ) h...
Sets the default Request Headers .
236,008
def _url ( self , url ) : protocol = 'https' if self . https else 'http' return '{0}://{1}/spaces/{2}{3}' . format ( protocol , self . api_url , self . space_id , url )
Creates the Request URL .
236,009
def _normalize_query ( self , query ) : for k , v in query . items ( ) : if isinstance ( v , list ) : query [ k ] = ',' . join ( [ str ( e ) for e in v ] )
Converts Arrays in the query to comma separaters lists for proper API handling .
236,010
def _http_get ( self , url , query ) : if not self . authorization_as_header : query . update ( { 'access_token' : self . access_token } ) response = None self . _normalize_query ( query ) kwargs = { 'params' : query , 'headers' : self . _request_headers ( ) } if self . _has_proxy ( ) : kwargs [ 'proxies' ] = self . _p...
Performs the HTTP GET Request .
236,011
def _get ( self , url , query = None ) : if query is None : query = { } response = retry_request ( self ) ( self . _http_get ) ( url , query = query ) if self . raw_mode : return response if response . status_code != 200 : error = get_error ( response ) if self . raise_errors : raise error return error localized = quer...
Wrapper for the HTTP Request Rate Limit Backoff is handled here Responses are Processed with ResourceBuilder .
236,012
def _proxy_parameters ( self ) : proxy_protocol = '' if self . proxy_host . startswith ( 'https' ) : proxy_protocol = 'https' else : proxy_protocol = 'http' proxy = '{0}://' . format ( proxy_protocol ) if self . proxy_username and self . proxy_password : proxy += '{0}:{1}@' . format ( self . proxy_username , self . pro...
Builds Proxy parameters Dict from client options .
236,013
def url ( self , ** kwargs ) : url = self . file [ 'url' ] args = [ '{0}={1}' . format ( k , v ) for k , v in kwargs . items ( ) ] if args : url += '?{0}' . format ( '&' . join ( args ) ) return url
Returns a formatted URL for the Asset s File with serialized parameters .
236,014
def fields ( self , locale = None ) : if locale is None : locale = self . _locale ( ) return self . _fields . get ( locale , { } )
Get fields for a specific locale
236,015
def resolve ( self , client ) : resolve_method = getattr ( client , snake_case ( self . link_type ) ) if self . link_type == 'Space' : return resolve_method ( ) else : return resolve_method ( self . id )
Resolves Link to a specific Resource
236,016
def snake_case ( a_string ) : partial = re . sub ( '(.)([A-Z][a-z]+)' , r'\1_\2' , a_string ) return re . sub ( '([a-z0-9])([A-Z])' , r'\1_\2' , partial ) . lower ( )
Returns a snake cased version of a string .
236,017
def is_link_array ( value ) : if isinstance ( value , list ) and len ( value ) > 0 : return is_link ( value [ 0 ] ) return False
Checks if value is an array of links .
236,018
def resource_for_link ( link , includes , resources = None , locale = None ) : if resources is not None : cache_key = "{0}:{1}:{2}" . format ( link [ 'sys' ] [ 'linkType' ] , link [ 'sys' ] [ 'id' ] , locale ) if cache_key in resources : return resources [ cache_key ] for i in includes : if ( i [ 'sys' ] [ 'id' ] == li...
Returns the resource that matches the link
236,019
def all_resource_urls ( query ) : urls = [ ] next = True while next : response = requests . get ( query ) json_data = json . loads ( response . content ) for resource in json_data [ 'results' ] : urls . append ( resource [ 'url' ] ) if bool ( json_data [ 'next' ] ) : query = json_data [ 'next' ] else : next = False ret...
Get all the URLs for every resource
236,020
def get_all ( resource ) : QUERYSETS = { settings . PEOPLE : PeopleQuerySet , settings . PLANETS : PlanetQuerySet , settings . STARSHIPS : StarshipQuerySet , settings . VEHICLES : VehicleQuerySet , settings . SPECIES : SpeciesQuerySet , settings . FILMS : FilmQuerySet } urls = all_resource_urls ( "{0}/{1}/" . format ( ...
Return all of a single resource
236,021
def get_planet ( planet_id ) : result = _get ( planet_id , settings . PLANETS ) return Planet ( result . content )
Return a single planet
236,022
def get_starship ( starship_id ) : result = _get ( starship_id , settings . STARSHIPS ) return Starship ( result . content )
Return a single starship
236,023
def get_vehicle ( vehicle_id ) : result = _get ( vehicle_id , settings . VEHICLES ) return Vehicle ( result . content )
Return a single vehicle
236,024
def get_species ( species_id ) : result = _get ( species_id , settings . SPECIES ) return Species ( result . content )
Return a single species
236,025
def get_film ( film_id ) : result = _get ( film_id , settings . FILMS ) return Film ( result . content )
Return a single film
236,026
def order_by ( self , order_attribute ) : to_return = [ ] for f in sorted ( self . items , key = lambda i : getattr ( i , order_attribute ) ) : to_return . append ( f ) return to_return
Return the list of items in a certain order
236,027
def print_crawl ( self ) : print ( "Star Wars" ) time . sleep ( .5 ) print ( "Episode {0}" . format ( self . episode_id ) ) time . sleep ( .5 ) print ( "" ) time . sleep ( .5 ) print ( "{0}" . format ( self . title ) ) for line in self . gen_opening_crawl ( ) : time . sleep ( .5 ) print ( line )
Print the opening crawl one line at a time
236,028
def is_str ( string ) : if sys . version_info [ : 2 ] >= ( 3 , 0 ) : return isinstance ( string , str ) return isinstance ( string , basestring )
Python 2 and 3 compatible string checker .
236,029
def _create_logger_ ( name ) : logger = logging . getLogger ( name ) handler = logging . StreamHandler ( ) handler . setFormatter ( logging . Formatter ( '%(levelname)s %(message)s' ) ) logger . addHandler ( handler ) logger . setLevel ( logging . INFO ) return logger
Implementation detail creates a logger .
236,030
def remove_file_no_raise ( file_name , config ) : if config . keep_xml : return True try : if os . path . exists ( file_name ) : os . remove ( file_name ) except IOError as error : loggers . root . error ( "Error occurred while removing temporary created file('%s'): %s" , file_name , str ( error ) )
Removes file from disk if exception is raised .
236,031
def create_temp_file_name ( suffix , prefix = None , dir = None , directory = None ) : if dir is not None : warnings . warn ( "The dir argument is deprecated.\n" + "Please use the directory argument instead." , DeprecationWarning ) directory = dir if not prefix : prefix = tempfile . gettempprefix ( ) fd , name = tempfi...
Small convenience function that creates temporary files .
236,032
def contains_parent_dir ( fpath , dirs ) : return bool ( [ x for x in dirs if _f ( fpath , x ) ] )
Returns true if paths in dirs start with fpath .
236,033
def create_decl_string ( return_type , arguments_types , with_defaults = True ) : return free_function_type_t . NAME_TEMPLATE % { 'return_type' : return_type . build_decl_string ( with_defaults ) , 'arguments' : ',' . join ( [ _f ( x , with_defaults ) for x in arguments_types ] ) }
Returns free function type
236,034
def create_typedef ( self , typedef_name , unused = None , with_defaults = True ) : return free_function_type_t . TYPEDEF_NAME_TEMPLATE % { 'typedef_name' : typedef_name , 'return_type' : self . return_type . build_decl_string ( with_defaults ) , 'arguments' : ',' . join ( [ _f ( x , with_defaults ) for x in self . arg...
returns string that contains valid C ++ code that defines typedef to function type
236,035
def create_typedef ( self , typedef_name , class_alias = None , with_defaults = True ) : has_const_str = '' if self . has_const : has_const_str = 'const' if None is class_alias : if with_defaults : class_alias = self . class_inst . decl_string else : class_alias = self . class_inst . partial_decl_string return member_f...
creates typedef to the function type
236,036
def parse ( files , config = None , compilation_mode = COMPILATION_MODE . FILE_BY_FILE , cache = None ) : if not config : config = xml_generator_configuration_t ( ) parser = project_reader_t ( config = config , cache = cache ) declarations = parser . read_files ( files , compilation_mode ) config . xml_generator_from_x...
Parse header files .
236,037
def remove_alias ( type_ ) : if isinstance ( type_ , cpptypes . type_t ) : type_ref = type_ elif isinstance ( type_ , typedef . typedef_t ) : type_ref = type_ . decl_type else : return type_ if type_ref . cache . remove_alias : return type_ref . cache . remove_alias no_alias = __remove_alias ( type_ref . clone ( ) ) ty...
Returns type_t without typedef
236,038
def is_pointer ( type_ ) : return does_match_definition ( type_ , cpptypes . pointer_t , ( cpptypes . const_t , cpptypes . volatile_t ) ) or does_match_definition ( type_ , cpptypes . pointer_t , ( cpptypes . volatile_t , cpptypes . const_t ) )
returns True if type represents C ++ pointer type False otherwise
236,039
def remove_pointer ( type_ ) : nake_type = remove_alias ( type_ ) if not is_pointer ( nake_type ) : return type_ elif isinstance ( nake_type , cpptypes . volatile_t ) and isinstance ( nake_type . base , cpptypes . pointer_t ) : return cpptypes . volatile_t ( nake_type . base . base ) elif isinstance ( nake_type , cppty...
removes pointer from the type definition
236,040
def is_array ( type_ ) : nake_type = remove_alias ( type_ ) nake_type = remove_reference ( nake_type ) nake_type = remove_cv ( nake_type ) return isinstance ( nake_type , cpptypes . array_t )
returns True if type represents C ++ array type False otherwise
236,041
def array_size ( type_ ) : nake_type = remove_alias ( type_ ) nake_type = remove_reference ( nake_type ) nake_type = remove_cv ( nake_type ) assert isinstance ( nake_type , cpptypes . array_t ) return nake_type . size
returns array size
236,042
def array_item_type ( type_ ) : if is_array ( type_ ) : type_ = remove_alias ( type_ ) type_ = remove_cv ( type_ ) return type_ . base elif is_pointer ( type_ ) : return remove_pointer ( type_ ) else : raise RuntimeError ( "array_item_type functions takes as argument array or pointer " + "types" )
returns array item type
236,043
def remove_reference ( type_ ) : nake_type = remove_alias ( type_ ) if not is_reference ( nake_type ) : return type_ return nake_type . base
removes reference from the type definition
236,044
def remove_const ( type_ ) : nake_type = remove_alias ( type_ ) if not is_const ( nake_type ) : return type_ else : if isinstance ( nake_type , cpptypes . array_t ) : is_v = is_volatile ( nake_type ) if is_v : result_type = nake_type . base . base . base else : result_type = nake_type . base . base if is_v : result_typ...
removes const from the type definition
236,045
def is_same ( type1 , type2 ) : nake_type1 = remove_declarated ( type1 ) nake_type2 = remove_declarated ( type2 ) return nake_type1 == nake_type2
returns True if type1 and type2 are same types
236,046
def is_elaborated ( type_ ) : nake_type = remove_alias ( type_ ) if isinstance ( nake_type , cpptypes . elaborated_t ) : return True elif isinstance ( nake_type , cpptypes . reference_t ) : return is_elaborated ( nake_type . base ) elif isinstance ( nake_type , cpptypes . pointer_t ) : return is_elaborated ( nake_type ...
returns True if type represents C ++ elaborated type False otherwise
236,047
def is_volatile ( type_ ) : nake_type = remove_alias ( type_ ) if isinstance ( nake_type , cpptypes . volatile_t ) : return True elif isinstance ( nake_type , cpptypes . const_t ) : return is_volatile ( nake_type . base ) elif isinstance ( nake_type , cpptypes . array_t ) : return is_volatile ( nake_type . base ) retur...
returns True if type represents C ++ volatile type False otherwise
236,048
def remove_volatile ( type_ ) : nake_type = remove_alias ( type_ ) if not is_volatile ( nake_type ) : return type_ else : if isinstance ( nake_type , cpptypes . array_t ) : is_c = is_const ( nake_type ) if is_c : base_type_ = nake_type . base . base . base else : base_type_ = nake_type . base . base result_type = base_...
removes volatile from the type definition
236,049
def remove_cv ( type_ ) : nake_type = remove_alias ( type_ ) if not is_const ( nake_type ) and not is_volatile ( nake_type ) : return type_ result = nake_type if is_const ( result ) : result = remove_const ( result ) if is_volatile ( result ) : result = remove_volatile ( result ) if is_const ( result ) : result = remov...
removes const and volatile from the type definition
236,050
def is_fundamental ( type_ ) : return does_match_definition ( type_ , cpptypes . fundamental_t , ( cpptypes . const_t , cpptypes . volatile_t ) ) or does_match_definition ( type_ , cpptypes . fundamental_t , ( cpptypes . volatile_t , cpptypes . const_t ) )
returns True if type represents C ++ fundamental type
236,051
def args ( self , decl_string ) : args_begin = decl_string . find ( self . __begin ) args_end = decl_string . rfind ( self . __end ) if - 1 in ( args_begin , args_end ) or args_begin == args_end : raise RuntimeError ( "%s doesn't validate template instantiation string" % decl_string ) args_only = decl_string [ args_beg...
Extracts a list of arguments from the provided declaration string .
236,052
def has_public_binary_operator ( type_ , operator_symbol ) : type_ = type_traits . remove_alias ( type_ ) type_ = type_traits . remove_cv ( type_ ) type_ = type_traits . remove_declarated ( type_ ) assert isinstance ( type_ , class_declaration . class_t ) if type_traits . is_std_string ( type_ ) or type_traits . is_std...
returns True if type_ has public binary operator otherwise False
236,053
def update ( self , source_file , configuration , declarations , included_files ) : source_file = os . path . normpath ( source_file ) included_files = [ os . path . normpath ( p ) for p in included_files ] dependent_files = { } for name in [ source_file ] + included_files : dependent_files [ name ] = 1 key = self . _c...
Replace a cache entry by a new value .
236,054
def cached_value ( self , source_file , configuration ) : key = self . _create_cache_key ( source_file ) entry = self . __index . get ( key ) if entry is None : return None configsig = self . _create_config_signature ( configuration ) if configsig != entry . configsig : return None for id_ , sig in entry . filesigs : i...
Return the cached declarations or None .
236,055
def _load ( self ) : indexfilename = os . path . join ( self . __dir , "index.dat" ) if os . path . exists ( indexfilename ) : data = self . _read_file ( indexfilename ) self . __index = data [ 0 ] self . __filename_rep = data [ 1 ] if self . __filename_rep . _sha1_sigs != self . __sha1_sigs : print ( ( "CACHE: Warning...
Load the cache .
236,056
def _save ( self ) : if self . __modified_flag : self . __filename_rep . update_id_counter ( ) indexfilename = os . path . join ( self . __dir , "index.dat" ) self . _write_file ( indexfilename , ( self . __index , self . __filename_rep ) ) self . __modified_flag = False
save the cache index in case it was modified .
236,057
def _read_file ( self , filename ) : if self . __compression : f = gzip . GzipFile ( filename , "rb" ) else : f = open ( filename , "rb" ) res = pickle . load ( f ) f . close ( ) return res
read a Python object from a cache file .
236,058
def _write_file ( self , filename , data ) : if self . __compression : f = gzip . GzipFile ( filename , "wb" ) else : f = open ( filename , "wb" ) pickle . dump ( data , f , pickle . HIGHEST_PROTOCOL ) f . close ( )
Write a data item into a file .
236,059
def _remove_entry ( self , source_file , key ) : entry = self . __index . get ( key ) if entry is None : return for id_ , _ in entry . filesigs : self . __filename_rep . release_filename ( id_ ) del self . __index [ key ] self . __modified_flag = True cachefilename = self . _create_cache_filename ( source_file ) try : ...
Remove an entry from the cache .
236,060
def _create_cache_key ( source_file ) : path , name = os . path . split ( source_file ) return name + str ( hash ( path ) )
return the cache key for a header file .
236,061
def _create_cache_filename ( self , source_file ) : res = self . _create_cache_key ( source_file ) + ".cache" return os . path . join ( self . __dir , res )
return the cache file name for a header file .
236,062
def _create_config_signature ( config ) : m = hashlib . sha1 ( ) m . update ( config . working_directory . encode ( "utf-8" ) ) for p in config . include_paths : m . update ( p . encode ( "utf-8" ) ) for p in config . define_symbols : m . update ( p . encode ( "utf-8" ) ) for p in config . undefine_symbols : m . update...
return the signature for a config object .
236,063
def acquire_filename ( self , name ) : id_ = self . __id_lut . get ( name ) if id_ is None : id_ = self . __next_id self . __next_id += 1 self . __id_lut [ name ] = id_ entry = filename_entry_t ( name ) self . __entries [ id_ ] = entry else : entry = self . __entries [ id_ ] entry . inc_ref_count ( ) return id_ , self ...
Acquire a file name and return its id and its signature .
236,064
def release_filename ( self , id_ ) : entry = self . __entries . get ( id_ ) if entry is None : raise ValueError ( "Invalid filename id (%d)" % id_ ) if entry . dec_ref_count ( ) == 0 : del self . __entries [ id_ ] del self . __id_lut [ entry . filename ]
Release a file name .
236,065
def is_file_modified ( self , id_ , signature ) : entry = self . __entries . get ( id_ ) if entry is None : raise ValueError ( "Invalid filename id_ (%d)" % id_ ) if entry . sig_valid : filesig = entry . signature else : filesig = self . _get_signature ( entry ) entry . signature = filesig entry . sig_valid = True retu...
Check if the file referred to by id_ has been modified .
236,066
def update_id_counter ( self ) : if not self . __entries : self . __next_id = 1 else : self . __next_id = max ( self . __entries . keys ( ) ) + 1
Update the id_ counter so that it doesn t grow forever .
236,067
def _get_signature ( self , entry ) : if self . _sha1_sigs : if not os . path . exists ( entry . filename ) : return None try : with open ( entry . filename , "r" ) as f : data = f . read ( ) return hashlib . sha1 ( data . encode ( "utf-8" ) ) . digest ( ) except IOError as e : print ( "Cannot determine sha1 digest:" ,...
Return the signature of the file stored in entry .
236,068
def is_union ( declaration ) : if not is_class ( declaration ) : return False decl = class_traits . get_declaration ( declaration ) return decl . class_type == class_declaration . CLASS_TYPES . UNION
Returns True if declaration represents a C ++ union
236,069
def is_struct ( declaration ) : if not is_class ( declaration ) : return False decl = class_traits . get_declaration ( declaration ) return decl . class_type == class_declaration . CLASS_TYPES . STRUCT
Returns True if declaration represents a C ++ struct
236,070
def find_trivial_constructor ( type_ ) : assert isinstance ( type_ , class_declaration . class_t ) trivial = type_ . constructors ( lambda x : is_trivial_constructor ( x ) , recursive = False , allow_empty = True ) if trivial : return trivial [ 0 ] return None
Returns reference to trivial constructor .
236,071
def find_copy_constructor ( type_ ) : copy_ = type_ . constructors ( lambda x : is_copy_constructor ( x ) , recursive = False , allow_empty = True ) if copy_ : return copy_ [ 0 ] return None
Returns reference to copy constructor .
236,072
def find_noncopyable_vars ( class_type , already_visited_cls_vars = None ) : assert isinstance ( class_type , class_declaration . class_t ) logger = utils . loggers . cxx_parser mvars = class_type . variables ( lambda v : not v . type_qualifiers . has_static , recursive = False , allow_empty = True ) noncopyable_vars =...
Returns list of all noncopyable variables .
236,073
def has_trivial_constructor ( class_ ) : class_ = class_traits . get_declaration ( class_ ) trivial = find_trivial_constructor ( class_ ) if trivial and trivial . access_type == 'public' : return trivial
if class has public trivial constructor this function will return reference to it None otherwise
236,074
def has_copy_constructor ( class_ ) : class_ = class_traits . get_declaration ( class_ ) copy_constructor = find_copy_constructor ( class_ ) if copy_constructor and copy_constructor . access_type == 'public' : return copy_constructor
if class has public copy constructor this function will return reference to it None otherwise
236,075
def has_destructor ( class_ ) : class_ = class_traits . get_declaration ( class_ ) destructor = class_ . decls ( decl_type = calldef_members . destructor_t , recursive = False , allow_empty = True ) if destructor : return destructor [ 0 ]
if class has destructor this function will return reference to it None otherwise
236,076
def has_public_constructor ( class_ ) : class_ = class_traits . get_declaration ( class_ ) decls = class_ . constructors ( lambda c : not is_copy_constructor ( c ) and c . access_type == 'public' , recursive = False , allow_empty = True ) if decls : return decls
if class has any public constructor this function will return list of them otherwise None
236,077
def has_public_assign ( class_ ) : class_ = class_traits . get_declaration ( class_ ) decls = class_ . member_operators ( lambda o : o . symbol == '=' and o . access_type == 'public' , recursive = False , allow_empty = True ) return bool ( decls )
returns True if class has public assign operator False otherwise
236,078
def has_vtable ( decl_type ) : assert isinstance ( decl_type , class_declaration . class_t ) return bool ( decl_type . calldefs ( lambda f : isinstance ( f , calldef_members . member_function_t ) and f . virtuality != calldef_types . VIRTUALITY_TYPES . NOT_VIRTUAL , recursive = False , allow_empty = True ) )
True if class has virtual table False otherwise
236,079
def is_base_and_derived ( based , derived ) : assert isinstance ( based , class_declaration . class_t ) assert isinstance ( derived , ( class_declaration . class_t , tuple ) ) if isinstance ( derived , class_declaration . class_t ) : all_derived = ( [ derived ] ) else : all_derived = derived for derived_cls in all_deri...
returns True if there is base and derived relationship between classes False otherwise
236,080
def is_noncopyable ( class_ , already_visited_cls_vars = None ) : logger = utils . loggers . cxx_parser class_decl = class_traits . get_declaration ( class_ ) true_header = "is_noncopyable(TRUE) - %s - " % class_ . decl_string if is_union ( class_ ) : return False if class_decl . is_abstract : logger . debug ( true_hea...
Checks if class is non copyable
236,081
def is_unary_operator ( oper ) : symbols = [ '!' , '&' , '~' , '*' , '+' , '++' , '-' , '--' ] if not isinstance ( oper , calldef_members . operator_t ) : return False if oper . symbol not in symbols : return False if isinstance ( oper , calldef_members . member_operator_t ) : if len ( oper . arguments ) == 0 : return ...
returns True if operator is unary operator otherwise False
236,082
def is_binary_operator ( oper ) : symbols = [ ',' , '()' , '[]' , '!=' , '%' , '%=' , '&' , '&&' , '&=' , '*' , '*=' , '+' , '+=' , '-' , '-=' , '->' , '->*' , '/' , '/=' , '<' , '<<' , '<<=' , '<=' , '=' , '==' , '>' , '>=' , '>>' , '>>=' , '^' , '^=' , '|' , '|=' , '||' ] if not isinstance ( oper , calldef_members . ...
returns True if operator is binary operator otherwise False
236,083
def is_copy_constructor ( constructor ) : assert isinstance ( constructor , calldef_members . constructor_t ) args = constructor . arguments parent = constructor . parent if len ( args ) != 1 : return False arg = args [ 0 ] if not isinstance ( arg . decl_type , cpptypes . compound_t ) : return False if not type_traits ...
Check if the declaration is a copy constructor
236,084
def get_members ( self , access = None ) : if access == ACCESS_TYPES . PUBLIC : return self . public_members elif access == ACCESS_TYPES . PROTECTED : return self . protected_members elif access == ACCESS_TYPES . PRIVATE : return self . private_members all_members = [ ] all_members . extend ( self . public_members ) al...
returns list of members according to access type
236,085
def adopt_declaration ( self , decl , access ) : if access == ACCESS_TYPES . PUBLIC : self . public_members . append ( decl ) elif access == ACCESS_TYPES . PROTECTED : self . protected_members . append ( decl ) elif access == ACCESS_TYPES . PRIVATE : self . private_members . append ( decl ) else : raise RuntimeError ( ...
adds new declaration to the class
236,086
def remove_declaration ( self , decl ) : access_type = self . find_out_member_access_type ( decl ) if access_type == ACCESS_TYPES . PUBLIC : container = self . public_members elif access_type == ACCESS_TYPES . PROTECTED : container = self . protected_members else : container = self . private_members del container [ con...
removes decl from members list
236,087
def find_out_member_access_type ( self , member ) : assert member . parent is self if not member . cache . access_type : if member in self . public_members : access_type = ACCESS_TYPES . PUBLIC elif member in self . protected_members : access_type = ACCESS_TYPES . PROTECTED elif member in self . private_members : acces...
returns member access type
236,088
def top_class ( self ) : curr = self parent = self . parent while isinstance ( parent , class_t ) : curr = parent parent = parent . parent return curr
reference to a parent class which contains this class and defined within a namespace
236,089
def append_value ( self , valuename , valuenum = None ) : if valuenum is None : if not self . _values : valuenum = 0 else : valuenum = self . _values [ - 1 ] [ 1 ] + 1 self . _values . append ( ( valuename , int ( valuenum ) ) )
Append another enumeration value to the enum .
236,090
def has_value_name ( self , name ) : for val , _ in self . _values : if val == name : return True return False
Check if this enum has a particular name among its values .
236,091
def update_unnamed_class ( decls ) : for decl in decls : if isinstance ( decl , declarations . typedef_t ) : referent = decl . decl_type if isinstance ( referent , declarations . elaborated_t ) : referent = referent . base if not isinstance ( referent , declarations . declarated_t ) : continue referent = referent . dec...
Adds name to class_t declarations .
236,092
def get_os_file_names ( files ) : fnames = [ ] for f in files : if utils . is_str ( f ) : fnames . append ( f ) elif isinstance ( f , file_configuration_t ) : if f . content_type in ( file_configuration_t . CONTENT_TYPE . STANDARD_SOURCE_FILE , file_configuration_t . CONTENT_TYPE . CACHED_SOURCE_FILE ) : fnames . appen...
returns file names
236,093
def read_files ( self , files , compilation_mode = COMPILATION_MODE . FILE_BY_FILE ) : if compilation_mode == COMPILATION_MODE . ALL_AT_ONCE and len ( files ) == len ( self . get_os_file_names ( files ) ) : return self . __parse_all_at_once ( files ) else : if compilation_mode == COMPILATION_MODE . ALL_AT_ONCE : msg = ...
parses a set of files
236,094
def read_xml ( self , file_configuration ) : xml_file_path = None delete_xml_file = True fc = file_configuration reader = source_reader . source_reader_t ( self . __config , None , self . __decl_factory ) try : if fc . content_type == fc . CONTENT_TYPE . STANDARD_SOURCE_FILE : self . logger . info ( 'Parsing source fil...
parses C ++ code defined on the file_configurations and returns GCCXML generated file content
236,095
def get_dependencies_from_decl ( decl , recursive = True ) : result = [ ] if isinstance ( decl , typedef . typedef_t ) or isinstance ( decl , variable . variable_t ) : return [ dependency_info_t ( decl , decl . decl_type ) ] if isinstance ( decl , namespace . namespace_t ) : if recursive : for d in decl . declarations ...
Returns the list of all types and declarations the declaration depends on .
236,096
def find_container_traits ( cls_or_string ) : if utils . is_str ( cls_or_string ) : if not templates . is_instantiation ( cls_or_string ) : return None name = templates . name ( cls_or_string ) if name . startswith ( 'std::' ) : name = name [ len ( 'std::' ) : ] if name . startswith ( 'std::tr1::' ) : name = name [ len...
Find the container traits type of a declaration .
236,097
def get_container_or_none ( self , type_ ) : type_ = type_traits . remove_alias ( type_ ) type_ = type_traits . remove_cv ( type_ ) utils . loggers . queries_engine . debug ( "Container traits: cleaned up search %s" , type_ ) if isinstance ( type_ , cpptypes . declarated_t ) : cls_declaration = type_traits . remove_ali...
Returns reference to the class declaration or None .
236,098
def class_declaration ( self , type_ ) : utils . loggers . queries_engine . debug ( "Container traits: searching class declaration for %s" , type_ ) cls_declaration = self . get_container_or_none ( type_ ) if not cls_declaration : raise TypeError ( 'Type "%s" is not instantiation of std::%s' % ( type_ . decl_string , s...
Returns reference to the class declaration .
236,099
def element_type ( self , type_ ) : return self . __find_xxx_type ( type_ , self . element_type_index , self . element_type_typedef , 'container_element_type' )
returns reference to the class value \\ mapped type declaration