home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 56 / CDPowerplay56Disc2.iso / demos / blade / data1.cab / Program_Executable_Files / Lib / ReadGSFile.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-10-27  |  3.4 KB  |  93 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import re
  5. import sys
  6. import string
  7. GSPattern = '[^a-zA-Z0-9.:\\\\\\-_]*'
  8.  
  9. def __ReadGSLine(fileobject):
  10.     Line = fileobject.readline()
  11.     if Line == '':
  12.         raise EOFError
  13.     
  14.     return string.strip(Line)
  15.  
  16.  
  17. def __ReadGhostSector(fileobject):
  18.     Line = __ReadGSLine(fileobject)
  19.     GSDesc = { }
  20.     GSDesc['Vertex'] = []
  21.     BeginNotFound = 1
  22.     while BeginNotFound:
  23.         Line = __ReadGSLine(fileobject)
  24.         res = re.split(GSPattern, Line)
  25.         if res[0] == 'BeginGhostSector':
  26.             break
  27.         
  28.     Line = __ReadGSLine(fileobject)
  29.     res = re.split(GSPattern, Line)
  30.     while res[0] != 'EndGhostSector':
  31.         Tag = res[0]
  32.         if Tag == 'Name':
  33.             GSDesc['Name'] = res[1]
  34.         elif Tag == 'FloorHeight':
  35.             GSDesc['FloorHeight'] = -1000 * string.atof(res[1])
  36.         elif Tag == 'RoofHeight':
  37.             GSDesc['RoofHeight'] = -1000 * string.atof(res[1])
  38.         elif Tag == 'Vertex':
  39.             GSDesc['Vertex'].append((1000 * string.atof(res[1]), -1000 * string.atof(res[2])))
  40.         elif Tag == 'Grupo':
  41.             GSDesc['Grupo'] = res[1]
  42.         elif Tag == 'Sonido':
  43.             GSDesc['Sonido'] = res[1]
  44.         elif Tag == 'Volumen':
  45.             GSDesc['Volumen'] = string.atof(res[1])
  46.         elif Tag == 'VolumenBase':
  47.             GSDesc['VolumenBase'] = string.atof(res[1])
  48.         elif Tag == 'DistanciaMinima':
  49.             GSDesc['DistanciaMinima'] = string.atof(res[1])
  50.         elif Tag == 'DistanciaMaxima':
  51.             GSDesc['DistanciaMaxima'] = string.atof(res[1])
  52.         elif Tag == 'DistMaximaVertical':
  53.             GSDesc['DistMaximaVertical'] = string.atof(res[1])
  54.         elif Tag == 'Escala':
  55.             GSDesc['Escala'] = string.atof(res[1])
  56.         
  57.         Line = __ReadGSLine(fileobject)
  58.         res = re.split(GSPattern, Line)
  59.     return GSDesc
  60.  
  61.  
  62. def ReadGhostSectorFile(filename):
  63.     print filename
  64.     f = open(filename, 'rt')
  65.     ret = []
  66.     CurrLine = __ReadGSLine(f)
  67.     while CurrLine != '':
  68.         res = re.split(GSPattern, CurrLine)
  69.         CurrLine = __ReadGSLine(f)
  70.         continue
  71.         None if res[0] == 'NumGhostSectors' else range(int(res[1]))
  72.     return ret
  73.  
  74.  
  75. def ProcessGhostSectorFile(filename):
  76.     
  77.     try:
  78.         import Bladex
  79.         res = ReadGhostSectorFile(filename)
  80.         for igs in res:
  81.             Bladex.AddGhostSector(igs['Name'], igs['Grupo'], igs['FloorHeight'], igs['RoofHeight'], igs['Vertex'])
  82.             Bladex.SetGhostSectorSound(igs['Name'], igs['Sonido'], igs['Volumen'], igs['VolumenBase'], igs['DistanciaMinima'], igs['DistanciaMaxima'], igs['DistMaximaVertical'], igs['Escala'])
  83.     except KeyError:
  84.         print 'Error processing', filename, 'Unknown attribute'
  85.     except:
  86.         print 'Error processing', filename
  87.  
  88.  
  89. if __name__ == '__main__':
  90.     res = ReadGhostSectorFile('DesPrb2.sf')
  91.     print res
  92.  
  93.