342
341
# and move them to the new place if there's not already
343
342
# a new one there
345
tmpl_dir = os.path.join(mm_cfg.PREFIX, "templates")
346
list_dir = os.path.join(mm_cfg.PREFIX, "lists")
347
b4_tmpl_dir = os.path.join(tmpl_dir, mlist._internal_name)
348
new_tmpl_dir = os.path.join(list_dir, mlist._internal_name)
349
if os.path.exists(b4_tmpl_dir):
344
# There is a problem with the following if the list name is equal
345
# to a language code. All the templates get moved from templates/xx
346
# to lists/xx. To avoid this, test the list name, and if it is 'en'
347
# or matches a name in the messages directory, just skip this step.
348
if (mlist._internal_name <> 'en' and
349
mlist._internal_name not in os.listdir(mm_cfg.MESSAGES_DIR)):
350
# It's okay to move the templates.
351
tmpl_dir = os.path.join(mm_cfg.PREFIX, "templates")
352
list_dir = mm_cfg.LIST_DATA_DIR
353
b4_tmpl_dir = os.path.join(tmpl_dir, mlist._internal_name)
354
new_tmpl_dir = os.path.join(list_dir, mlist._internal_name)
355
if os.path.exists(b4_tmpl_dir):
351
357
- This list looks like it might have <= b4 list templates around""")
352
for f in os.listdir(b4_tmpl_dir):
353
o_tmpl = os.path.join(b4_tmpl_dir, f)
354
n_tmpl = os.path.join(new_tmpl_dir, f)
355
if os.path.exists(o_tmpl):
356
if not os.path.exists(n_tmpl):
357
os.rename(o_tmpl, n_tmpl)
358
print _('- moved %(o_tmpl)s to %(n_tmpl)s')
358
for f in os.listdir(b4_tmpl_dir):
359
o_tmpl = os.path.join(b4_tmpl_dir, f)
360
n_tmpl = os.path.join(new_tmpl_dir, f)
361
if os.path.exists(o_tmpl):
362
if not os.path.exists(n_tmpl):
363
os.rename(o_tmpl, n_tmpl)
364
print _('- moved %(o_tmpl)s to %(n_tmpl)s')
367
- both %(o_tmpl)s and %(n_tmpl)s exist, leaving untouched""")
361
- both %(o_tmpl)s and %(n_tmpl)s exist, leaving untouched""")
364
370
- %(o_tmpl)s doesn't exist, leaving untouched""")
366
372
# Move all the templates to the en language subdirectory as required for
435
441
for filename in os.listdir(dirpath):
436
442
filepath = os.path.join(dirpath, filename)
437
443
filebase, ext = os.path.splitext(filepath)
444
# A bug in Mailman 2.1.9 left .bak files behind in some
445
# circumstances. It should be safe to remove them.
438
448
# Handle the .db metadata files as part of the handling of the
439
449
# .pck or .msg message files.
440
450
if ext not in ('.pck', '.msg'):