iode.Database.get_names

Note

Below, Database represents either:

  • Comments

  • Equations

  • Identities

  • Lists

  • Scalars

  • Tables

  • Variables

Database.get_names(self, pattern: str | List[str] = '') List[str]

Returns the list of objects names given a pattern.

Parameters:
pattern: str or list(str), optional

pattern to select a subset of objects. For example, ‘A*;*_’ will select all objects for which the name starts with ‘A’ or ends with ‘_’. Return all names contained in the database by default.

Returns:
list(str)

Examples

>>> from iode import SAMPLE_DATA_DIR
>>> from iode import comments
>>> comments.load(f"{SAMPLE_DATA_DIR}/fun.cmt")
>>> comments.get_names("A*;*_")         
['ACAF', 'ACAG', 'AOUC', 'AQC', 'BENEF_', 'GOSH_', 
'IDH_', 'PAFF_', 'PC_', 'PFI_', 'QAFF_', 'QAF_', 
'QAI_', 'QAT_', 'QBBPPOT_', 'QC_', 'QQMAB_', 'QS_', 
'Q_', 'TFPHP_', 'VAFF_', 'VAI_', 'VAT_', 'VC_', 'VS_', 
'WBF_', 'WBU_', 'WCF_', 'WCR1_', 'WCR2_', 'WIND_', 
'WNF_', 'YDH_', 'ZZ_']
>>> # or equivalently
>>> comments.get_names(["A*", "*_"])    
['ACAF', 'ACAG', 'AOUC', 'AQC', 'BENEF_', 'GOSH_', 
'IDH_', 'PAFF_', 'PC_', 'PFI_', 'QAFF_', 'QAF_', 
'QAI_', 'QAT_', 'QBBPPOT_', 'QC_', 'QQMAB_', 'QS_', 
'Q_', 'TFPHP_', 'VAFF_', 'VAI_', 'VAT_', 'VC_', 'VS_', 
'WBF_', 'WBU_', 'WCF_', 'WCR1_', 'WCR2_', 'WIND_', 
'WNF_', 'YDH_', 'ZZ_']
>>> # get the list of all names
>>> comments.names                
['ACAF', 'ACAG', 'AOUC', ..., 'ZKF', 'ZX', 'ZZ_']