Revision: 14641
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 8, 2009 12:35 by cthulhupunk0
Initial Code
"""
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
Initial URL
Initial Description
Initial Title
Generic superclass for dealing with io based tables
Initial Tags
database, csv
Initial Language
Python