Changeset 4586


Ignore:
Timestamp:
Jul 4, 2007, 4:36:57 PM (17 years ago)
Author:
nick
Message:

add "get_all_swwfiles"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r4567 r4586  
    16501650    #print "basename_in",basename_in
    16511651    #print "base",base
     1652
     1653    iterate_over = get_all_swwfiles(dir,base,verbose)
    16521654   
    16531655    if dir == "":
    16541656        dir = "." # Unix compatibility
    1655     dir_ls = os.listdir(dir)
    1656     iterate_over = [x[:-4] for x in dir_ls if base in x and x[-4:] == '.sww']
    1657 
    1658     if len(iterate_over) == 0:
    1659         msg = 'No files of the base name %s.'\
    1660               %(basename_in)
    1661         raise IOError, msg
    16621657   
    16631658    files_out = []
    1664 #    print 'sww_file',sww_file
     1659    #print 'sww_file',iterate_over
    16651660    for sww_file in iterate_over:
    16661661        for quantity in quantities:
     
    56145609    return maximal_runup, maximal_runup_location
    56155610
     5611def get_all_swwfiles(look_in_dir='',base_name='',verbose=False):
     5612    '''
     5613    Finds all the sww files in a "look_in_dir" which contains a "base_name"
     5614   
     5615    Returns: a list of strings
     5616    '''
     5617       
     5618    if look_in_dir == "":
     5619        look_in_dir = "." # Unix compatibility
     5620   
     5621    dir_ls = os.listdir(look_in_dir)
     5622    #print 'dir_ls',dir_ls, base
     5623    iterate_over = [x[:-4] for x in dir_ls if base_name in x and x[-4:] == '.sww']
     5624    if len(iterate_over) == 0:
     5625        msg = 'No files of the base name %s'\
     5626              %(base_name)
     5627        raise IOError, msg
     5628    if verbose: print 'iterate over %s' %(iterate_over)
     5629
     5630    #print 'iter',iterate_over
     5631#    files_out = []
     5632    #print 'sww_file',sww_file
     5633#    for sww_file in iterate_over:
     5634    return iterate_over
     5635
    56165636
    56175637#-------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.