from string import join ##---------------------------------------------------------- class FigObject: ##---------------------------------------------------------- def __init__(self,lines): self.content=lines self.ana() def ana(self): self.type=self.content[0].rstrip().split()[1] self.layer=self.content[1].rstrip().split()[6] self.color=self.content[1].rstrip().split()[4] ## and/or 5? def set_color(self,c): ll=self.content[1].split() ll[4]=c ll[5]=c newline=join(ll,' ').lstrip().rstrip()+'\n' self.content[1]=newline ##---------------------------------------------------------- class FigFile: ##---------------------------------------------------------- def __init__(self,fname): self.fname=fname self.objects=[] self.read() self.ana() def read(self): f=file(self.fname,'r') self.content=f.readlines() self.nlines=len(self.content) i=1 while not self.content[i].startswith('#'): i+=1 self.header=self.content[:i] def write(self,fname): f=open(fname,'w') for l in self.header: f.write(l) for o in self.objects: f.write(join(o.content)) f.close() def ana(self): i=1 try: while i