Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.script.maint.cleanpage.PluginScript Class Reference
Inheritance diagram for MoinMoin.script.maint.cleanpage.PluginScript:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.script.maint.cleanpage.PluginScript:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def qualify
def mainloop
def init_request
def run
def logRuntime

Public Attributes

 request
 argv
 def_values
 parser
 args

Detailed Description

\
Purpose:
========
This tool outputs a shell script which upon execution will remove unused or
trashed pages from the wiki.

Detailed Instructions:
======================
General syntax: moin [options] maint cleanpage [cleanpage-options]

[options] usually should be:
--config-dir=/path/to/my/cfg/ --wiki-url=wiki.example.org/

[cleanpage-options] see below:
0. Verify the outputted shell script before running it.

1. This script takes no command line arguments.

Definition at line 13 of file cleanpage.py.


Constructor & Destructor Documentation

def MoinMoin.script.maint.cleanpage.PluginScript.__init__ (   self,
  argv,
  def_values 
)

Reimplemented from MoinMoin.script.MoinScript.

Definition at line 33 of file cleanpage.py.

00033 
00034     def __init__(self, argv, def_values):
00035         MoinScript.__init__(self, argv, def_values)


Member Function Documentation

def MoinMoin.script.MoinScript.init_request (   self) [inherited]
create request 

Definition at line 174 of file __init__.py.

00174 
00175     def init_request(self):
00176         """ create request """
00177         from MoinMoin.web.contexts import ScriptContext
00178         url = self.options.wiki_url or None
00179         self.request = ScriptContext(url, self.options.page)

Here is the caller graph for this function:

def MoinMoin.script.Script.logRuntime (   self) [inherited]
Print the total command run time. 

Definition at line 148 of file __init__.py.

00148 
00149     def logRuntime(self):
00150         """ Print the total command run time. """
00151         if self.options.show_timing:
00152             log("Needed %.3f secs." % (time.clock() - _start_time, ))
00153 

Here is the call graph for this function:

Reimplemented from MoinMoin.script.MoinScript.

Definition at line 68 of file cleanpage.py.

00068 
00069     def mainloop(self):
00070         self.init_request()
00071         base = self.request.cfg.data_dir
00072         pagesdir = os.path.join(base, 'pages')
00073         for p in os.listdir(pagesdir):
00074             pagedir = os.path.join(pagesdir, p)
00075             status = self.qualify(pagedir)
00076             if status in ['trash', 'empty', ]:
00077                 print "mv '%s' trash # %s" % (pagedir, status)
00078             elif status in ['deleted', ]:
00079                 print "mv '%s' deleted # %s" % (pagedir, status)
00080             else:
00081                 print "# %s: '%s'" % (status, pagedir)
00082 

Here is the call graph for this function:

look at page directory p and return its state 

Definition at line 36 of file cleanpage.py.

00036 
00037     def qualify(self, p):
00038         """ look at page directory p and return its state """
00039         dir = os.listdir(p)
00040         if not dir:
00041             return 'empty'
00042 
00043         # check if we have something of potential value
00044         revs = []
00045         if 'revisions' in dir:
00046             revs = os.listdir(os.path.join(p, 'revisions'))
00047         atts = []
00048         if 'attachments' in dir:
00049             atts = os.listdir(os.path.join(p, 'attachments'))
00050 
00051         if not revs and not atts:
00052             return 'trash'
00053 
00054         if 'current-locked' in dir:
00055             return 'current-locked'
00056         elif 'current' in dir:
00057             try:
00058                 current = open(os.path.join(p, 'current')).read().strip()
00059                 int(current)
00060             except:
00061                 return 'current damaged'
00062             if current not in revs:
00063                 return 'deleted'
00064         else:
00065             return 'no current'
00066 
00067         return 'ok'

Here is the caller graph for this function:

def MoinMoin.script.Script.run (   self,
  showtime = 1 
) [inherited]
Run the main function of a command. 

Definition at line 130 of file __init__.py.

00130 
00131     def run(self, showtime=1):
00132         """ Run the main function of a command. """
00133         global flag_quiet
00134         try:
00135             try:
00136                 self.options, self.args = self.parser.parse_args(self.argv)
00137                 flag_quiet = self.options.quiet
00138                 # ToDo check if we need to initialize request (self.init_request())
00139                 self.mainloop()
00140             except KeyboardInterrupt:
00141                 log("*** Interrupted by user!")
00142             except SystemExit:
00143                 showtime = 0
00144                 raise
00145         finally:
00146             if showtime:
00147                 self.logRuntime()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 135 of file __init__.py.

Definition at line 102 of file __init__.py.

Definition at line 113 of file __init__.py.

Definition at line 178 of file __init__.py.


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