summaryrefslogtreecommitdiff
path: root/Mailman/HTMLFormatter.py
diff options
context:
space:
mode:
authorbwarsaw2001-02-16 06:11:40 +0000
committerbwarsaw2001-02-16 06:11:40 +0000
commit2d9c60fdf13139fd85f41a483390dd2d546a41a5 (patch)
treed42f78d197d535858edac09a4601a85eed100e23 /Mailman/HTMLFormatter.py
parenta13da91647209d76c13ff06f5bccefa5a4c08f21 (diff)
downloadmailman-2d9c60fdf13139fd85f41a483390dd2d546a41a5.tar.gz
mailman-2d9c60fdf13139fd85f41a483390dd2d546a41a5.tar.zst
mailman-2d9c60fdf13139fd85f41a483390dd2d546a41a5.zip
Diffstat (limited to 'Mailman/HTMLFormatter.py')
-rw-r--r--Mailman/HTMLFormatter.py40
1 files changed, 22 insertions, 18 deletions
diff --git a/Mailman/HTMLFormatter.py b/Mailman/HTMLFormatter.py
index 5eb04fb5e..77a5970d8 100644
--- a/Mailman/HTMLFormatter.py
+++ b/Mailman/HTMLFormatter.py
@@ -20,9 +20,13 @@
import os
import errno
-# XXX: should be converted to use re module
+# BAW: should be converted to use re module
import regsub
+# BAW: this should be de-string-module-ified
import string
+import shutil
+
+# BAW: these should import from Mailman
import mm_cfg
import Utils
from htmlformat import *
@@ -412,22 +416,22 @@ class HTMLFormatter:
return d
def InitTemplates(self, langs=None):
- def ExtensionFilter(item):
- return item[-5:] == '.html'
-
- if not langs:
+ if langs is None:
langs = [mm_cfg.DEFAULT_SERVER_LANGUAGE]
-
for L in langs:
- files = filter(ExtensionFilter,
- os.listdir(os.path.join(mm_cfg.TEMPLATE_DIR, L)))
- Utils.MakeDirTree(os.path.join(self._template_dir, L))
-
- for filename in files:
- file1 = open(os.path.join(mm_cfg.TEMPLATE_DIR, L, filename))
- text = file1.read()
- file1.close()
- file2 = open(os.path.join(self._template_dir, L, filename),
- 'w+')
- file2.write(text)
- file2.close()
+ # srcdir is where the language template .html files will come
+ # from. Usually $MAILMAN/templates/<lang> but if that doesn't
+ # exist, default to $MAILMAN/templates for the English templates.
+ srcdir = os.path.join(mm_cfg.TEMPLATE_DIR, L)
+ if not os.path.isdir(srcdir):
+ srcdir = mm_cfg.TEMPLATE_DIR
+ # dstdir is where to copy the language templates to.
+ dstdir = os.path.join(self._template_dir, L)
+ omask = os.umask(0)
+ try:
+ os.makedirs(dstdir, 02775)
+ finally:
+ os.umask(omask)
+ # Now copy all the .html files over
+ for file in [f for f in os.listdir(srcdir) if f.endswith('.html')]:
+ shutil.copy(os.path.join(srcdir, file), dstdir)