File:  [Repository] / cdli / splitatf.py
Revision 1.2: download - view: text, annotated - select for diffs - revision graph
Mon Nov 28 12:31:56 2005 UTC (18 years, 6 months ago) by dwinter
Branches: MAIN
CVS tags: zcat_only_1, Root_zcat_only_1, HEAD
basked, locking upload

    1: """split atf file, get an atf file"""
    2: 
    3: import sys
    4: import os.path
    5: 
    6: def splitatf(filename,dir=None):
    7:     """split it"""
    8:     try:
    9:         fh=open(filename,"r")
   10:     except:
   11:         print """Can't open file: %s (%s %s)"""%(filename,sys.exc_info()[0],sys.exc_info()[0])
   12:     
   13:     nf=None
   14:     for line in fh.readlines():
   15:         print line
   16:         if (len(line.lstrip())>0) and (line.lstrip()[0]=="&"): #newfile
   17:             if nf:
   18:                 nf.close() #close last file
   19:         
   20:             
   21:             filename=line[1:].split("=")[0].rstrip()+".atf"
   22:             if dir:
   23:                 filename=os.path.join(dir,filename)
   24:             nf=file(filename,"w")
   25:             
   26:         nf.write(line)
   27:     
   28:     nf.close()
   29:     fh.close()
   30:     
   31: 
   32: splitatf(sys.argv[1])

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>