casa
$Rev:20696$
|
00001 import os 00002 from taskinit import * 00003 from tasksinfo import * 00004 00005 def find(matchstring=None): 00006 """ Find string in tasks, task names, parameter names: 00007 00008 Lists the following: 00009 1) All of the task names that have the string 00010 2) All of the tasks whose contents (e.g., documentation, 00011 parameters, etc) have the string 00012 3) All of the parameter names that have the string 00013 00014 Keyword arguments: 00015 matchstring -- String to match in the documentation 00016 default: ''; example: matchstring='vis' 00017 00018 """ 00019 import IPython.ipapi 00020 _ip = IPython.ipapi.get() 00021 00022 00023 casalog.origin('find') 00024 00025 #Python script 00026 #parameter_printvalues(arg_names,arg_values,arg_types) 00027 if ((type(matchstring)==str) & (matchstring!='')): 00028 pathname=os.environ.get('CASAPATH').split()[0] 00029 arch=os.environ.get('CASAPATH').split()[1] 00030 test=pathname.find('lib') 00031 if (test != -1): 00032 filepath=pathname+'/lib/python2.5/' 00033 else: 00034 filepath=pathname+'/'+arch+'/python/2.5/' 00035 if not os.path.exists(filepath) : 00036 filepath=pathname+'/Resources/python/' 00037 00038 # taskfiles = ['accum.py','simdata.py','applycal.py','bandpass.py','blcal.py','browsetable.py','clean.py','clearcal.py','clearplot.py','clearstat.py','concat.py','deconvolve.py','exportfits.py','exportuvfits.py','feather.py','filecatalog.py','flagdata.py','flagmanager.py','fluxscale.py','ft.py','gaincal.py','imhead.py','immoments.py','importasdm.py','importfits.py','importgmrt.py','importuvfits.py','importvla.py','invert.py','listcal.py','listhistory.py','listobs.py','makemask.py','mosaic.py','plotants.py','plotcal.py','plotms.py','plotxy.py','regridimage.py','setjy.py','smoothcal.py','split.py','uvcontsub.py','uvmodelfit.py','viewer.py'] 00039 00040 taskfiles = [] 00041 for key in tasksum.keys() : 00042 taskfiles.append(key+'.py') 00043 mydir = _ip.magic("sc -l = pwd")[0] 00044 os.chdir(filepath) 00045 00046 print 'Found in:' 00047 print '-----------' 00048 print '' 00049 00050 print 'Task Names:' 00051 for i in taskfiles: 00052 found=i.find(matchstring) 00053 if (found>=0): 00054 print '\t ',i.rstrip('.py') 00055 00056 print 'Parameter Names:' 00057 00058 paramstring='grep "def " parameter_dictionary.py | grep '+matchstring 00059 parameternames=_ip.magic("sc -l ="+paramstring) 00060 for i in parameternames: 00061 temp1=i.lstrip('\tdef ') 00062 temp2=temp1.rstrip('():') 00063 print '\t ',temp2 00064 00065 print 'Tasks (documentation, parameters)' 00066 00067 for i in taskfiles: 00068 #for i in ['accum.py','applycal.py','bandpass.py','blcal.py']: 00069 mystring='grep -l '+matchstring+' '+i 00070 grepfile = _ip.magic("sc -l ="+mystring)[0] 00071 task = grepfile.rstrip('.py') 00072 if (task!=''): print '\t ',task 00073 00074 os.chdir(mydir) 00075 00076 else: 00077 raise Exception, 'Bad input string - try again' 00078