- Timestamp:
- Aug 15, 2016, 11:01:55 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r1006 r1018 40 40 # dictionary_key_list: Function to provide the first key in a dictionay of lists with a given value 41 41 # dictKeysVals_stringList: Function to provide strings from a dictionary with keys which contain values of lists 42 # dictvar_listS: Function to provide a Dc string separated list of DVs separated [key] [value] couples following a list of keys 42 43 # files_folder_HMT: Function to retrieve a list of files from a folder [fold] and files with [head]*[middle]*[tail] 43 44 # get_configuration: Function to get the configuration from an ASCII external file … … 8307 8308 return matches, locs 8308 8309 8310 def dictvar_listS(listv, dictv, Dc, DVs): 8311 """ Function to provide a Dc string separated list of DVs separated [key] [value] couples following a list of keys 8312 listv: list of keys from dictionary to use 8313 dictv= dictionary with values to build the string 8314 Sc: character to separate key values 8315 DVs: character to separate key-value couples 8316 >>> romdict = {'i': 1, 'ii': 2, 'iii': 3, 'iv': 4, 'v':5, 'vi':6, 'vii':7, 'viii':8, 'ix': 9, 'x':10} 8317 >>> dictvar_listS(['i', 'iv', 'vii'],romdict,',',':') 8318 i:1,iv:4,vii:7 8319 """ 8320 fname = 'dictvar_listS' 8321 ik = 0 8322 for key in listv: 8323 if not dictv.has_key(key): 8324 print errormsg 8325 print ' ' + fname + ": dictionary does not have key '" + key + "' !!" 8326 print ' available keys:', dictv.keys() 8327 quit(-1) 8328 else: 8329 if ik == 0: 8330 stringv = str(key) + DVs + str(dictv[key]) 8331 else: 8332 stringv = stringv + Dc + str(key) + DVs + str(dictv[key]) 8333 8334 ik = ik + 1 8335 8336 return stringv 8337 8309 8338 #quit() 8310 8339
Note: See TracChangeset
for help on using the changeset viewer.