Ho già dato, se per 1 [una, one, ein] volta in nove anni sono io a chiedere qualcosa causa vuoto mentale / mancanza di tempo / whatever non muore nessuno.

Per un'esigenza così specifica dubito servirà mai a qualcun altro, comunque ecco qua:

Codice PHP:
import sys
class router:
    
attributi={"IAD":""}
print 
"log parser"
if(len(sys.argv)<2):
    print 
"missing input file"
    
exit()
else:
    print 
len(sys.argv)
fInput=open(sys.argv[1],"r")
if(
len(sys.argv)==2):
    
fOutput=sys.stdout
else:
    
fOutput=open(sys.argv[2],"w")


routers =[]
def printToFile(r):
    if 
r.attributi["IAD"]=="":
        return
    
str=r.attributi["IAD"]+"\t"+r.attributi["IP"]+"\t";
    if 
r.attributi.has_key("MODELLO"):
        
str+= r.attributi["MODELLO"]
    else:
        
str+= "DOWN"
    
str+="\t"
    
if r.attributi.has_key("FIRMWARE"):
        
str+= r.attributi["FIRMWARE"]
    else:
        
str+= "DOWN"
    
str+="\t"
    
fOutput.write(str+"\n")
def load():
    
rrouter()
    while 
True:
        
testo=fInput.readline()
        if 
testo =="":
            
printToFile(r)
            break
        
index=testo.find(":");
        
intestazione=testo[:index]
        
dato=testo[index+1:len(testo)-1]
        
#print intestazione,"-->",dato
        
if intestazione=="IAD":
            
printToFile(r);
            
r=router()
            
r.attributi={}
            
#print "\n---\n"    
        
r.attributi[intestazione]=dato
load
()