Parser needed.

Skybuck Flying skybuck2000 at hotmail.com
Thu Jun 4 12:01:44 EDT 2015


Yes these string processing techniques will work very nicely and very fast:

cut and pasted an example but should work... now I developed it a bit 
further, bye ,bye.

BotDemoFolder = "C:\\Games\\Startrek Online\\Startrek Online\\Cryptic 
Studios\\Star Trek Online\\Live\\demos"
BotDemoFile = "SpaceFleetAlertEnemyExample.demo"


import time

def ProcessEntityRef():
global DemoChars
global CreatedEntsIndex

StartIndex = DemoChars.find("EntityRef", CreatedEntsIndex)
StopIndex = DemoChars.find("\n",StartIndex)

if StartIndex <> -1:
  Ref = DemoChars[StartIndex:StopIndex]
else:
  Ref = 0

return Ref

def ProcessCreatedEntities():
global DemoChars
global CreatedEntsIndex
CreatedEntsIndex = 0
while (CreatedEntsIndex <> -1): # and (CreatedEntsIndex < 100000):
  CreatedEntsIndex = DemoChars.find("createdEnts", CreatedEntsIndex)
  RefNumber = ProcessEntityRef()
  if CreatedEntsIndex <> -1:
   CreatedEntsIndex = CreatedEntsIndex + 1
  print "RefNumber: " + str(RefNumber)
return


def Main():
global DemoChars

DemoFilePath = BotDemoFolder + "\\" + BotDemoFile

FileObject = open( DemoFilePath, "r")

# DemoLines = FileObject.readlines()
# ParseDemoLines( DemoLines )

DemoChars = FileObject.read()

ProcessCreatedEntities()

# Index = DemoChars.find("createdEnts")

# print DemoChars[Index:Index+5]


# rfind

# ParseDemoChars( DemoChars )

FileObject.close()
return

print "program started"

Tick1 = time.time()
Main()
Tick2 = time.time()

Seconds = Tick2 - Tick1


print "program finished"


# Skybuck 




More information about the Python-list mailing list