#-*- coding: GBK -*-
|
#¶ÁÈ¡Óû§ÅäÖÃÎļþ
|
#×÷Õߣºifo
|
|
import DataFileReader
|
import logging
|
import traceback
|
|
class tagPetSkill( DataFileReader.DataFileReader ):
|
_SKIP_LINES = 1
|
_SKIP_COLUMNS = 0
|
|
def __init__(self,filename):
|
DataFileReader.DataFileReader.__init__( self )
|
self.configList = []
|
# Óû§ÅäÖÃÎļþµÄËùÔÚ·¾¶
|
try:
|
if not self.Open(filename): # ´ò¿ªÎļþ
|
logging.fatal( "tagPetSkill File[%s] no found" % filename )
|
return
|
except Exception, e:
|
print str(e)
|
print traceback.print_exc()
|
logging.error( str(e) )
|
logging.error( traceback.print_exc() )
|
logging.info( "tagPetSkill File[%s] open successfully" % filename )
|
|
def _ProcessData( self, datalist):
|
import tagPetSkillParam
|
self.configList.append( tagPetSkillParam.tagPetSkillParam(datalist,self.commentline) )
|
|
#·µ»ØÓÐЧÄÚÈÝÌõÊý
|
def GetRecordCount(self):
|
return len(self.configList)
|
|
#ͨ¹ýË÷Òý·µ»ØÄÚÈÝ
|
def GetRecordByIndex(self,index):
|
return self.configList[index]
|
|
def GetCommentLine(self):
|
commentlinelist = self.commentline.replace( "\n", "\t" ).split( "\t" )
|
commentlinelist.pop()
|
return commentlinelist
|
|
def __str__(self):
|
strRet = ""
|
for param in self.configList:
|
strRet += str(param) + "\n"
|
return strRet
|
|
|
__gtagPetSkill = None
|
|
def ReadConfig( filename ):
|
global __gtagPetSkill
|
if not __gtagPetSkill:
|
__gtagPetSkill = tagPetSkill( filename )
|
|
|
def GetConfig():
|
global __gtagPetSkill
|
return __gtagPetSkill
|
|
|
if __name__ == '__main__':
|
ReadConfig("tagPetSkill.txt")
|
newConfig = GetConfig()
|
print newConfig.GetRecordCount()
|
record1 = newConfig.GetRecordByIndex( 2 )
|
# record2 = newConfig.GetRecordByIndex( 100 )
|
# print record2.GetAccID()
|
# print record2.Adult
|
# print record1.Sex,record1.Job
|
print newConfig.GetCommentLine()
|
print newConfig.__str__()
|
|