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, 5 months ago) by dwinter
Branches: MAIN
CVS tags: zcat_only_1, Root_zcat_only_1, HEAD
basked, locking upload

"""split atf file, get an atf file"""

import sys
import os.path

def splitatf(filename,dir=None):
    """split it"""
    try:
        fh=open(filename,"r")
    except:
        print """Can't open file: %s (%s %s)"""%(filename,sys.exc_info()[0],sys.exc_info()[0])
    
    nf=None
    for line in fh.readlines():
        print line
        if (len(line.lstrip())>0) and (line.lstrip()[0]=="&"): #newfile
            if nf:
                nf.close() #close last file
        
            
            filename=line[1:].split("=")[0].rstrip()+".atf"
            if dir:
                filename=os.path.join(dir,filename)
            nf=file(filename,"w")
            
        nf.write(line)
    
    nf.close()
    fh.close()
    

splitatf(sys.argv[1])

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