Back to index

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

List of all members.

Public Member Functions

def __init__
def read
def write
def copy

Public Attributes

 request
 fname
 data
 renames

Detailed Description

Definition at line 123 of file _conv160.py.


Constructor & Destructor Documentation

def MoinMoin.script.migration._conv160.EditLog.__init__ (   self,
  request,
  fname 
)

Definition at line 124 of file _conv160.py.

00124 
00125     def __init__(self, request, fname):
00126         self.request = request
00127         self.fname = fname
00128         self.data = None
00129         self.renames = {}


Member Function Documentation

def MoinMoin.script.migration._conv160.EditLog.copy (   self,
  destfname,
  renames,
  deleted = False 
)

Definition at line 199 of file _conv160.py.

00199 
00200     def copy(self, destfname, renames, deleted=False):
00201         self.renames = renames
00202         self.read()
00203         self.write(destfname, deleted)
00204 

Here is the caller graph for this function:

read complete edit-log from disk 

Definition at line 130 of file _conv160.py.

00130 
00131     def read(self):
00132         """ read complete edit-log from disk """
00133         data = {}
00134         try:
00135             lineno = 0
00136             f = file(self.fname, 'r')
00137             for line in f:
00138                 lineno += 1
00139                 line = line.replace('\r', '').replace('\n', '')
00140                 if not line.strip(): # skip empty lines
00141                     continue
00142                 fields = line.split('\t') + [''] * 9
00143                 timestamp, rev, action, pagename, ip, hostname, userid, extra, comment = fields[:9]
00144                 try:
00145                     timestamp = int(timestamp)
00146                     rev = int(rev)
00147                 except ValueError, err:
00148                     print "Error: %r has a damaged timestamp or revision number in log line %d [%s] - skipping this entry" % (
00149                         self.fname, lineno, str(err))
00150                     continue # ignore this line, do not terminate - to find all those errors in one go
00151                 pagename = wikiutil.unquoteWikiname(pagename)
00152                 data[(timestamp, rev, pagename)] = (timestamp, rev, action, pagename, ip, hostname, userid, extra, comment)
00153             f.close()
00154         except IOError, err:
00155             # no edit-log
00156             pass
00157         self.data = data

Here is the caller graph for this function:

def MoinMoin.script.migration._conv160.EditLog.write (   self,
  fname,
  deleted = False 
)
write complete edit-log to disk 

Definition at line 158 of file _conv160.py.

00158 
00159     def write(self, fname, deleted=False):
00160         """ write complete edit-log to disk """
00161         if self.data:
00162             editlog = self.data.items()
00163             editlog.sort()
00164             f = file(fname, "w")
00165             max_rev = 0
00166             for key, fields in editlog:
00167                 timestamp, rev, action, pagename, ip, hostname, userid, extra, comment = fields
00168                 if action.startswith('ATT'):
00169                     try:
00170                         fname = urllib.unquote(extra).decode('utf-8')
00171                     except UnicodeDecodeError:
00172                         fname = urllib.unquote(extra).decode('iso-8859-1')
00173                     if ('FILE', pagename, fname) in self.renames:
00174                         fname = self.renames[('FILE', pagename, fname)]
00175                     extra = urllib.quote(fname.encode('utf-8'))
00176                 if ('PAGE', pagename) in self.renames:
00177                     pagename = self.renames[('PAGE', pagename)]
00178                 timestamp = str(timestamp)
00179                 if rev != 99999999:
00180                     max_rev = max(rev, max_rev)
00181                 revstr = '%08d' % rev
00182                 pagename = wikiutil.quoteWikinameFS(pagename)
00183                 fields = timestamp, revstr, action, pagename, ip, hostname, userid, extra, comment
00184                 log_str = '\t'.join(fields) + '\n'
00185                 f.write(log_str)
00186             if create_rev and not deleted:
00187                 timestamp = str(wikiutil.timestamp2version(time.time()))
00188                 revstr = '%08d' % (max_rev + 1)
00189                 action = 'SAVE'
00190                 ip = '127.0.0.1'
00191                 hostname = 'localhost'
00192                 userid = ''
00193                 extra = ''
00194                 comment = "converted to 1.6 markup"
00195                 fields = timestamp, revstr, action, pagename, ip, hostname, userid, extra, comment
00196                 log_str = '\t'.join(fields) + '\n'
00197                 f.write(log_str)
00198             f.close()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 127 of file _conv160.py.

Definition at line 126 of file _conv160.py.

Definition at line 128 of file _conv160.py.

Definition at line 125 of file _conv160.py.


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