Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. # -*- coding: UTF-8 -*-
  2. '''
  3. Created on 2011.06.26.
  4.  
  5. @author: julius
  6. '''
  7.  
  8. from user import cUserRepo
  9. from pickle import dump, load
  10.  
  11. class UserRepoWrapper(object):
  12.     '''
  13.    classdocs
  14.    '''
  15.     dumpFilePath = 'users.dump'
  16.  
  17.     def __init__(self, usernames, comment_dict):
  18.         '''
  19.        Constructor
  20.        '''
  21.         try:
  22.             dumpfile = open(self.dumpFilePath, 'rb')
  23.             self.usrepo = load(dumpfile)
  24.             dumpfile.close()
  25.         except IOError:
  26.             self.usrepo = cUserRepo(usernames, comment_dict)
  27.             dumpfile = open(self.dumpFilePath, 'wb')
  28.             dump(self.usrepo, dumpfile)
  29.             dumpfile.close()
  30.        
  31.     def getResponses(self, tags):
  32.         return self.usrepo.getResponses(tags)
  33.    
  34.     def __str__(self):
  35.         return str(self.usrepo)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement