用于处理基于io的表的泛型超类
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用于处理基于io的表的泛型超类相关的知识,希望对你有一定的参考价值。
""" Name : MyIO.py Author : Jason Spadaro Description : superclass for io-based classes and objects Copyright 2009 """ class myIO: """ ******************************************** *Description : returns items from an external storage source, and * stores them again later. ******************************************* """ def __init__(self, connectDict): """ ******************************************** *Description : Initializes the connection information, rows * of data. Then it makes the connection based on the myIO * subclass. ******************************************* """ self.data_rows = [] #Empty array of items... self.item_names = connectDict["item_names"] #List of item attribute names self.connectDict = connectDict #connection information (filename, db name, etc) self.make_connect() def make_connect(self): """ ******************************************** *Description : connection method ******************************************* """ pass def getItem(self, i): """ ******************************************** *Description : get's one item's worth of data. ******************************************* """ temp_dict = {} for attribute, name in self.datarows[i], item_names: temp_dict.update({name:attribute}) return temp_dict def writeItem(self): """ ******************************************** *Description : Writes one item worth of data ******************************************* """ pass def close(self): """ ******************************************** *Description : Cleans up io when it closes. ******************************************* """ pass def dump_current_dict(self, item_dict): """ ******************************************** *Description : Generically writes all items to io ******************************************** """ for item_name, item in item_dict.iteritems(): print item_name + " is being written." self.write_item(item) def get_item_dict(self): """ ******************************************** *Description : Getter for the aggregator ******************************************** """ tempItemDict = itemDict() for i in range(self.data_rows): tempItem = getItem(i) tempItemDict.add(tempItem) return tempItemDict
以上是关于用于处理基于io的表的泛型超类的主要内容,如果未能解决你的问题,请参考以下文章