Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.script.migration._conv160.User Class Reference

List of all members.

Public Member Functions

def __init__
def read
def write
def copy

Public Attributes

 request
 uid
 users_dir
 profile
 bookmarks
 renames

Detailed Description

represents a user with all related data 

Definition at line 364 of file _conv160.py.


Constructor & Destructor Documentation

def MoinMoin.script.migration._conv160.User.__init__ (   self,
  request,
  users_dir,
  uid 
)

Definition at line 366 of file _conv160.py.

00366 
00367     def __init__(self, request, users_dir, uid):
00368         self.request = request
00369         self.uid = uid
00370         self.users_dir = users_dir
00371         self.profile = None
00372         self.bookmarks = None


Member Function Documentation

def MoinMoin.script.migration._conv160.User.copy (   self,
  users_dir,
  renames 
)

Definition at line 430 of file _conv160.py.

00430 
00431     def copy(self, users_dir, renames):
00432         self.renames = renames
00433         self.read()
00434         self.write(users_dir)
00435 

Here is the caller graph for this function:

read profile and bookmarks data from disk 

Definition at line 373 of file _conv160.py.

00373 
00374     def read(self):
00375         """ read profile and bookmarks data from disk """
00376         self.profile = {}
00377         fname = opj(self.users_dir, self.uid)
00378         # read user profile
00379         f = codecs.open(fname, 'r', config.charset)
00380         for line in f:
00381             line = line.replace(u'\r', '').replace(u'\n', '')
00382             if not line.strip() or line.startswith(u'#'): # skip empty or comment lines
00383                 continue
00384             try:
00385                 key, value = line.split(u'=', 1)
00386             except Exception, err:
00387                 print "Error: User reader can not parse line %r from profile %r (%s)" % (line, fname, str(err))
00388                 continue
00389             self.profile[key] = value
00390         f.close()
00391         # read bookmarks
00392         self.bookmarks = {}
00393         fname_pattern = opj(self.users_dir, "%s.*.bookmark" % self.uid)
00394         for fname in glob.glob(fname_pattern):
00395             f = file(fname, "r")
00396             bookmark = f.read()
00397             f.close()
00398             wiki = fname.replace('.bookmark', '').replace(opj(self.users_dir, self.uid+'.'), '')
00399             self.bookmarks[wiki] = int(bookmark)
00400         # don't care about trail

Here is the caller graph for this function:

def MoinMoin.script.migration._conv160.User.write (   self,
  users_dir 
)
write profile and bookmarks data to disk 

Definition at line 401 of file _conv160.py.

00401 
00402     def write(self, users_dir):
00403         """ write profile and bookmarks data to disk """
00404         fname = opj(users_dir, self.uid)
00405         f = codecs.open(fname, 'w', config.charset)
00406         for key, value in self.profile.items():
00407             if key in (u'subscribed_pages', u'quicklinks'):
00408                 pages = value.split(u'\t')
00409                 for i in range(len(pages)):
00410                     pagename = pages[i]
00411                     try:
00412                         interwiki, pagename = pagename.split(u':', 1)
00413                     except:
00414                         interwiki, pagename = u'Self', pagename
00415                     if interwiki == u'Self' or interwiki == self.request.cfg.interwikiname:
00416                         if ('PAGE', pagename) in self.renames:
00417                             pagename = self.renames[('PAGE', pagename)]
00418                             pages[i] = u'%s:%s' % (interwiki, pagename)
00419                 key += '[]' # we have lists here
00420                 value = u'\t'.join(pages)
00421                 f.write(u"%s=%s\n" % (key, value))
00422             else:
00423                 f.write(u"%s=%s\n" % (key, value))
00424         bookmark_entries = [u'%s:%s' % item for item in self.bookmarks.items()]
00425         key = u"bookmarks{}"
00426         value = u'\t'.join(bookmark_entries)
00427         f.write(u"%s=%s\n" % (key, value))
00428         f.close()
00429         # don't care about trail

Here is the caller graph for this function:


Member Data Documentation

Definition at line 371 of file _conv160.py.

Definition at line 370 of file _conv160.py.

Definition at line 431 of file _conv160.py.

Definition at line 367 of file _conv160.py.

Definition at line 368 of file _conv160.py.

Definition at line 369 of file _conv160.py.


The documentation for this class was generated from the following file: