Guest User

Untitled

a guest
Jun 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. # ...PremiumMod/libs/database.py
  2.  
  3. # =============================================================================
  4. # >> IMPORT
  5. # =============================================================================
  6. from PremiumMod.libs.constant import DATA_PATH
  7. from cPickle import load, dump
  8. from path import path
  9.  
  10. # =============================================================================
  11. # >> LOAD & UNLOAD
  12. # =============================================================================
  13.  
  14.  
  15. class database(dict):
  16.     def __init__(self):
  17.         dict.__init__(self)
  18.         self.path = DATA_PATH
  19.         self.load()
  20.  
  21.     def load(self):
  22.         self.clear()
  23.         if self.path.isfile():
  24.             v = open(self.path, 'rb')
  25.             try:
  26.                 self.update(load(v))
  27.             except:
  28.                 pass
  29.             v.close()
  30.  
  31.     def save(self):
  32.         if self.path.isfile():
  33.             v = open(self.path, 'wb')
  34.             dump(self, v, 'wb')
  35.             v.close()
  36.        
  37. setup_dict = database()
  38.  
  39.  
  40. '''
  41. TypeError: argument must have 'write' attribute
  42.  
  43. '''
Add Comment
Please, Sign In to add comment