def getautosizeddcts(idfname, tablename, commdct): """get values of autosized as a dictionary""" data = readidf.readidf(idfname) keys = [] autosizeds = getautosizeds(data, commdct) for obj, autos in autosizeds: for vert, horiz in autos: for header in horiz: akey = [unicode(obj.upper()), unicode(vert.upper()), unicode(header.upper())] # all keys are caps in above line keys.append(tuple(akey)) txt = open(tablename, 'r').read() soup = BeautifulSoup(txt) head, body = table.getheadbody(soup) btabledct = table.gettitletabledct(body) flatbtable = table.flattenkey(btabledct) nflatbtable = flatbtable autos = {} for key in keys: try: # pass autos[key] = nflatbtable[key] except KeyError, e: pass
# puts all the autosized key:values in autos as a list of auto # puts all key:values in flattables as a list of flattable autos = [] flattables = [] for i, name in enumerate(names): print name fname = '%s/%s.idf' % (path, name, ) tablename = '%s/%sTable.html' % (path, name, ) auto = autosized.getautosizeddcts(fname, tablename, commdct) autos.append(auto) #------ txt = open(tablename, 'r').read() soup = BeautifulSoup(txt) head, body = table.getheadbody(soup) btabledct = table.gettitletabledct(body) flatbtable = table.flattenkey(btabledct) flattables.append(flatbtable) # make master key list of autosized values from all files allautos = {} for auto in autos: for key in auto.keys(): allautos[key] = [] for key in allautos: for auto, flattable in zip(autos, flattables): if auto.has_key(key): allautos[key].append("AUTO")