Changeset 3517


Ignore:
Timestamp:
26/02/08 13:17:09 (12 years ago)
Author:
astephen
Message:

Added config file and parser for annotations.

Location:
nappy/trunk/nappy/utils
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • nappy/trunk/nappy/utils/common_utils.py

    r3515 r3517  
    155155            } 
    156156 
     157    dict = nappy.utils.parse_config.getAnnotationsConfigDict() 
    157158    if annotation: return dict[item] + delimiter 
    158159    else: return '' 
  • nappy/trunk/nappy/utils/parse_config.py

    r3406 r3517  
    1515config_file = os.path.join(base_dir, "nappy.ini") 
    1616config_dict = None 
     17annotations_config_file = os.path.join(base_dir, "annotations.ini") 
     18annotations_config_dict = None 
     19 
    1720 
    1821class MyCasePreservingConfigParser(ConfigParser.ConfigParser): 
     
    4952    return config_dict 
    5053 
     54def makeAnnotationsConfigDict(af=annotations_config_file): 
     55    """ 
     56    Parses annotations config file and returns dictionary of annotations. 
     57    """ 
     58    ad = {} 
     59    conf = MyCasePreservingConfigParser() 
     60    conf.read(af) 
     61 
     62    # Load up dict 
     63    for item in conf.options("annotations"): 
     64        value = conf.get("annotations", item) 
     65        ad[item] = value 
     66 
     67    return ad 
     68 
     69def getAnnotationsConfigDict(af=annotations_config_file): 
     70    "Checks if already made and only makes if required." 
     71    global annotations_config_dict 
     72    if annotations_config_dict == None: 
     73        annotations_config_dict = makeAnnotationsConfigDict(af) 
     74    return annotations_config_dict 
    5175 
    5276if __name__=="__main__": 
    5377    print getConfigDict() 
     78    print getAnnotationsConfigDict() 
Note: See TracChangeset for help on using the changeset viewer.