Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.script.migration._conv160a.EventLog 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 70 of file _conv160a.py.


Constructor & Destructor Documentation

def MoinMoin.script.migration._conv160a.EventLog.__init__ (   self,
  request,
  fname 
)

Definition at line 71 of file _conv160a.py.

00071 
00072     def __init__(self, request, fname):
00073         self.request = request
00074         self.fname = fname
00075         self.data = None
00076         self.renames = {}


Member Function Documentation

def MoinMoin.script.migration._conv160a.EventLog.copy (   self,
  destfname,
  renames 
)

Definition at line 117 of file _conv160a.py.

00117 
00118     def copy(self, destfname, renames):
00119         self.renames = renames
00120         self.read()
00121         self.write(destfname)
00122 

Here is the caller graph for this function:

read complete event-log from disk 

Definition at line 77 of file _conv160a.py.

00077 
00078     def read(self):
00079         """ read complete event-log from disk """
00080         data = []
00081         try:
00082             lineno = 0
00083             f = file(self.fname, 'r')
00084             for line in f:
00085                 lineno += 1
00086                 line = line.replace('\r', '').replace('\n', '')
00087                 if not line.strip(): # skip empty lines
00088                     continue
00089                 fields = line.split('\t')
00090                 try:
00091                     timestamp, action, kvpairs = fields[:3]
00092                     timestamp = int(timestamp)
00093                     kvdict = wikiutil.parseQueryString(kvpairs)
00094                     data.append((timestamp, action, kvdict))
00095                 except ValueError, err:
00096                     # corrupt event log line, log error and skip it
00097                     print "Error: invalid event log (%s) line %d, err: %s, SKIPPING THIS LINE!" % (self.fname, lineno, str(err))
00098             f.close()
00099         except IOError, err:
00100             # no event-log
00101             pass
00102         self.data = data

Here is the caller graph for this function:

write complete event-log to disk 

Definition at line 103 of file _conv160a.py.

00103 
00104     def write(self, fname):
00105         """ write complete event-log to disk """
00106         if self.data:
00107             f = file(fname, 'w')
00108             for timestamp, action, kvdict in self.data:
00109                 pagename = kvdict.get('pagename')
00110                 if pagename and ('PAGE', pagename) in self.renames:
00111                     kvdict['pagename'] = self.renames[('PAGE', pagename)]
00112                 kvpairs = wikiutil.makeQueryString(kvdict)
00113                 fields = str(timestamp), action, kvpairs
00114                 line = '\t'.join(fields) + '\n'
00115                 f.write(line)
00116             f.close()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 74 of file _conv160a.py.

Definition at line 73 of file _conv160a.py.

Definition at line 75 of file _conv160a.py.

Definition at line 72 of file _conv160a.py.


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