#-*- coding: GBK -*-
|
#¶ÁÈ¡Óû§ÅäÖÃÎļþ
|
#×÷Õߣºifo
|
|
import DataFileReader
|
import logging
|
import traceback
|
|
class tagDSAccount( 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( "tagDSAccount 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( "tagDSAccount File[%s] open successfully" % filename )
|
|
def _ProcessData( self, datalist):
|
import tagDSAccountParam
|
self.configList.append( tagDSAccountParam.tagDSAccountParam(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
|
|
|
__gtagDSAccount = None
|
|
def ReadConfig( filename ):
|
global __gtagDSAccount
|
if not __gtagDSAccount:
|
__gtagDSAccount = tagDSAccount( filename )
|
|
|
def GetConfig():
|
global __gtagDSAccount
|
return __gtagDSAccount
|
|
|
if __name__ == '__main__':
|
ReadConfig("tagDSAccount.txt")
|
newConfig = GetConfig()
|
print newConfig.GetRecordCount()
|
record1 = newConfig.GetRecordByIndex( 2 )
|
record2 = newConfig.GetRecordByIndex( 10 )
|
print record2.Adult
|
print newConfig.GetCommentLine()
|
print newConfig.__str__()
|
|