Back to index

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

List of all members.

Public Member Functions

def __init__
def copypage
def mainloop
def init_request
def run
def logRuntime

Public Attributes

 request
 argv
 def_values
 parser
 args

Detailed Description

\
Purpose:
========
This tool allows you to reduce a data/ directory to just the latest page
revision of each non-deleted page (plus all attachments).

This is used to make the distributed underlay directory, but can also be
used for other purposes.

So we change like this:
* data/pages/PageName/revisions/{1,2,3,4}
    -> data/pages/revisions/1  (with content of 4)
* data/pages/PageName/current (pointing to e.g. 4)
    -> same (pointing to 1)
* data/pages/PageName/edit-log and data/edit-log
    -> do not copy
* data/pages/PageName/attachments/*
    -> just copy

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

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

[reducewiki-options] see below:
0. To create a wiki data/ directory with just the latest revisions in the
   directory '/mywiki'
   moin ... maint reducewiki --target-dir=/mywiki

Definition at line 17 of file reducewiki.py.


Constructor & Destructor Documentation

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

Reimplemented from MoinMoin.script.MoinScript.

Definition at line 50 of file reducewiki.py.

00050 
00051     def __init__(self, argv, def_values):
00052         MoinScript.__init__(self, argv, def_values)
00053         self.parser.add_option(
00054             "-t", "--target-dir", dest="target_dir",
00055             help="Write reduced wiki data to DIRECTORY."
00056         )


Member Function Documentation

def MoinMoin.script.maint.reducewiki.PluginScript.copypage (   self,
  request,
  rootdir,
  pagename 
)
quick and dirty! 

Definition at line 57 of file reducewiki.py.

00057 
00058     def copypage(self, request, rootdir, pagename):
00059         """ quick and dirty! """
00060         pagedir = os.path.join(rootdir, 'pages', wikiutil.quoteWikinameFS(pagename))
00061         os.makedirs(pagedir)
00062 
00063         # write a "current" file with content "00000001"
00064         revstr = '%08d' % 1
00065         cf = os.path.join(pagedir, 'current')
00066         file(cf, 'w').write(revstr+'\n')
00067 
00068         # create a single revision 00000001
00069         revdir = os.path.join(pagedir, 'revisions')
00070         os.makedirs(revdir)
00071         tf = os.path.join(revdir, revstr)
00072         p = Page(request, pagename)
00073         text = p.get_raw_body().replace("\n", "\r\n")
00074         codecs.open(tf, 'wb', config.charset).write(text)
00075 
00076         source_dir = AttachFile.getAttachDir(request, pagename)
00077         if os.path.exists(source_dir):
00078             dest_dir = os.path.join(pagedir, "attachments")
00079             os.makedirs(dest_dir)
00080             for filename in os.listdir(source_dir):
00081                 source_file = os.path.join(source_dir, filename)
00082                 dest_file = os.path.join(dest_dir, filename)
00083                 shutil.copyfile(source_file, dest_file)

Here is the caller graph for this function:

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 84 of file reducewiki.py.

00084 
00085     def mainloop(self):
00086         self.init_request()
00087         request = self.request
00088         destdir = self.options.target_dir
00089         pagelist = list(request.rootpage.getPageList(user=''))
00090         for pagename in pagelist:
00091             self.copypage(request, destdir, pagename)
00092 

Here is the call 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: