Changeset 3393 for nappy


Ignore:
Timestamp:
12/02/08 18:43:54 (12 years ago)
Author:
astephen
Message:
 
File:
1 edited

Legend:

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

    r3349 r3393  
    44 
    55""" 
    6 general.py 
    7 ========= 
     6common_utils.py 
     7=============== 
    88 
    99Functions and classes commonly used in nappy. 
     
    7777     
    7878 
    79  
    8079def modifyNADictCopy(indict, v_new, start, end, ivol, nvol): 
    8180    """ 
     
    104103    version = nappy.utils.parse_config.getConfigDict()["DEFAULT"]["version"] 
    105104    return version 
     105 
     106 
     107def makeDictFromCommaSepString(s): 
     108    """ 
     109    Reads in comma-separated list and converts to dictionary of successive 
     110    keyword,value pairs. 
     111    """ 
     112    if s.count(",") % 2 == 0: 
     113        raise Exception("Must provide even number of items in argument of commas-separated pairs of values: " + s) 
     114 
     115    d = {} 
     116    items = value.split(",") 
     117    while len(items) > 0: 
     118        d[items[0]] = items[1] 
     119        items = items[2:]  
     120    return d 
Note: See TracChangeset for help on using the changeset viewer.