import commands def varmax(datadir='data/', phiavg=False): """ $Id: for_pencil.py,v 1.1.1.1 2009/04/20 11:19:04 dintrans Exp $ Give the maximum number of VAR files (or PHIAGV ones) >>> vmax = varmax() @param datadir: name of datadir directory @type datadir: string @type phiavg: string @return: last VAR or PHIAVG file @rtype: integer """ if (not phiavg): cmd = 'tail -1 '+datadir+'proc0/'+'varN.list' else: cmd = 'tail -1 '+datadir+'averages/'+'phiavg.files' varname = commands.getoutput(cmd) if (not phiavg): lastvar = int(varname.split('VAR')[1]) else: lastvar = int(varname.split('PHIAVG')[1]) return lastvar