Back to index

moin  1.9.0~rc2
Functions
MoinMoin.script.migration.1089999 Namespace Reference

Functions

def execute

Function Documentation

def MoinMoin.script.migration.1089999.execute (   script,
  data_dir,
  rev 
)

Definition at line 22 of file 1089999.py.

00022 
00023 def execute(script, data_dir, rev):
00024     pagenames = script.request.rootpage.getPageList(user='', include_underlay=False)
00025 
00026     for pagename in pagenames:
00027         attachdir = getAttachDir(script.request, pagename)
00028         try:
00029             drawings = [fn for fn in os.listdir(attachdir) if fn.endswith('.draw')]
00030         except OSError:
00031             # silenced. attachment directory does not exist. proceed with next page
00032             continue
00033         for drawing in drawings:
00034             basename = os.path.splitext(drawing)[0]
00035             tar_filename = os.path.join(attachdir, basename + '.tdraw')
00036             tar = tarfile.open(tar_filename, 'w:')
00037             for ext in ['.draw', '.map', '.png', '.gif', ]:
00038                 filename = os.path.join(attachdir, basename + ext)
00039                 try:
00040                     if ext != '.gif':
00041                         # get rid of the gif (TWikiDraw will (re)create
00042                         # a .png when someone edits the drawing)
00043                         # we use drawing.* as tar member filenames EVER, so the
00044                         # member filenames do not need to be changed when the
00045                         # tar container file gets renamed:
00046                         tar.add(filename, 'drawing' + ext)
00047                     os.remove(filename)
00048                 except OSError, err:
00049                     if err.errno != errno.ENOENT:
00050                         # .map and .png are optional, .draw should be there
00051                         raise
00052             tar.close()
00053 
00054     return 1090000
00055 

Here is the call graph for this function: