用于处理基于io的表的泛型超类

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用于处理基于io的表的泛型超类相关的知识,希望对你有一定的参考价值。

  1. """
  2. Name : MyIO.py
  3. Author : Jason Spadaro
  4. Description : superclass for io-based classes and objects
  5. Copyright 2009
  6. """
  7.  
  8. class myIO:
  9. """
  10. ********************************************
  11. *Description : returns items from an external storage source, and
  12. * stores them again later.
  13. *******************************************
  14. """
  15.  
  16. def __init__(self, connectDict):
  17. """
  18. ********************************************
  19. *Description : Initializes the connection information, rows
  20. * of data. Then it makes the connection based on the myIO
  21. * subclass.
  22. *******************************************
  23. """
  24.  
  25. self.data_rows = [] #Empty array of items...
  26. self.item_names = connectDict["item_names"] #List of item attribute names
  27. self.connectDict = connectDict #connection information (filename, db name, etc)
  28. self.make_connect()
  29.  
  30. def make_connect(self):
  31. """
  32. ********************************************
  33. *Description : connection method
  34. *******************************************
  35. """
  36.  
  37. pass
  38.  
  39. def getItem(self, i):
  40. """
  41. ********************************************
  42. *Description : get's one item's worth of data.
  43. *******************************************
  44. """
  45. temp_dict = {}
  46. for attribute, name in self.datarows[i], item_names:
  47. temp_dict.update({name:attribute})
  48. return temp_dict
  49.  
  50. def writeItem(self):
  51. """
  52. ********************************************
  53. *Description : Writes one item worth of data
  54. *******************************************
  55. """
  56.  
  57. pass
  58.  
  59. def close(self):
  60. """
  61. ********************************************
  62. *Description : Cleans up io when it closes.
  63. *******************************************
  64. """
  65.  
  66. pass
  67.  
  68. def dump_current_dict(self, item_dict):
  69. """
  70. ********************************************
  71. *Description : Generically writes all items to io
  72. ********************************************
  73. """
  74.  
  75. for item_name, item in item_dict.iteritems():
  76. print item_name + " is being written."
  77. self.write_item(item)
  78.  
  79. def get_item_dict(self):
  80. """
  81. ********************************************
  82. *Description : Getter for the aggregator
  83. ********************************************
  84. """
  85.  
  86. tempItemDict = itemDict()
  87. for i in range(self.data_rows):
  88. tempItem = getItem(i)
  89. tempItemDict.add(tempItem)
  90. return tempItemDict

以上是关于用于处理基于io的表的泛型超类的主要内容,如果未能解决你的问题,请参考以下文章

Unity3D 基于预设(Prefab)的泛型对象池实现

Dagger 和 Kotlin - 将类绑定到其泛型超类型的问题

java学习笔记9.22(泛型)

JPA的泛型DAO设计及使用

Java中的泛型 (上) - 基本概念和原理

201671010129 2016—2017—2 《Java程序设计》学习Java的泛型程序设计的小结