aboutsummaryrefslogtreecommitdiffstats
path: root/admin/bin/faq2ht.py
diff options
context:
space:
mode:
authorbwarsaw <>2006-09-17 18:16:07 +0000
committerbwarsaw <>2006-09-17 18:16:07 +0000
commit34d6ece8a454e5d1d027ed106ba039a0a88db36d (patch)
tree6dc6f8711b20124ce38491300d5fb95e1c022206 /admin/bin/faq2ht.py
parentb7f0fb3c888c1d331c2239fba0b8332a3bf240f2 (diff)
downloadmailman2-34d6ece8a454e5d1d027ed106ba039a0a88db36d.tar.gz
mailman2-34d6ece8a454e5d1d027ed106ba039a0a88db36d.tar.xz
mailman2-34d6ece8a454e5d1d027ed106ba039a0a88db36d.zip
Copy the mm21 admin directory out of the mm21 branch. We'll svn
external the latter to get that back into the release, but I really don't want to maintain multiple copies of the web pages.
Diffstat (limited to 'admin/bin/faq2ht.py')
-rwxr-xr-xadmin/bin/faq2ht.py102
1 files changed, 0 insertions, 102 deletions
diff --git a/admin/bin/faq2ht.py b/admin/bin/faq2ht.py
deleted file mode 100755
index 29db9ea7..00000000
--- a/admin/bin/faq2ht.py
+++ /dev/null
@@ -1,102 +0,0 @@
-#! /usr/bin/env python
-
-"""Convert the plain text FAQ file to its .ht template.
-"""
-
-import sys
-import os
-import re
-
-
-
-def main():
- faqfile = sys.argv[1]
- fp = open(faqfile)
- lines = fp.readlines()
- fp.close()
-
- outfile = sys.argv[2]
- if outfile == '-':
- closep = 0
- out = sys.stdout
- else:
- closep = 1
- out = open(outfile, 'w')
-
- # skip over cruft in FAQ file
- lineno = 0
- while not lines[lineno].startswith('FREQUENTLY'):
- lineno += 1
- lineno += 1
-
- # skip blanks
- while not lines[lineno].strip():
- lineno += 1
-
- # first print out standard .ht boilerplate
- print >> out, '''\
-Title: Mailman Frequently Asked Questions
-
-See also the <a href="http://www.python.org/cgi-bin/faqw-mm.py">Mailman
-FAQ Wizard</a> for more information.
-
- <h3>Mailman Frequently Asked Questions</h3>
-'''
- first = 1
- question = []
- answer = []
- faq = []
- while 1:
- line = lines[lineno][:-1]
-
- if line.startswith('Q.'):
- inquestion = 1
- if not first:
- faq.append((question, answer))
- question = []
- answer = []
- else:
- first = 0
- elif line.startswith('A.'):
- inquestion = 0
- elif line.startswith('\f'):
- break
-
- if inquestion:
- question.append(line)
- else:
- # watch for lists
- if line.lstrip().startswith('*'):
- answer.append('<li>')
- line = line.replace('*', '', 1)
- # substitute <...>
- line = re.sub(r'<(?P<var>[^>]+)>',
- '<em>\g<var></em>',
- line)
- # make links active
- line = re.sub(r'(?P<url>http://\S+)',
- '<a href="\g<url>">\g<url></a>',
- line)
- answer.append(line)
-
- lineno += 1
- faq.append((question, answer))
-
- for question, answer in faq:
- print >> out, '<b>',
- for line in question:
- print >> out, line
- print >> out, '</b><br>',
- for line in answer:
- if not line:
- print >> out, '<p>',
- else:
- print >> out, line
-
- if closep:
- out.close()
-
-
-
-if __name__ == '__main__':
- main()