Hello, your usemod2trac tool has been very useful to migrate several usemods to a single DrProject instance. DrProject (http://www.drproject.org/) is a trac derivative that handles multiple projects in a single installation. The current production version (1.2) still keeps the trac wiki formatting rules (development ones use textile, I think), and so I'm confident that my patches should be useful for trac users.
I'm sending you my patches hoping that they will be useful for more people. Thanks again, Ferran
Index: usemod2trac/convert_usemod_to_trac.py =================================================================== --- usemod2trac.orig/convert_usemod_to_trac.py 2008-01-17 15:42:42.000000000 +0100 +++ usemod2trac/convert_usemod_to_trac.py 2008-01-17 15:43:15.000000000 +0100 @@ -26,7 +26,8 @@ from optparse import OptionParser # field separator -FS = '\xb3' +FS = '\xb3' # Comment out one: old style +FS = "\x1e\xff\xfe\x1e" # or New style (UTF-8 compatible) text_stash = [] Index: usemod2trac/extract_pages_from_usemod.py =================================================================== --- usemod2trac.orig/extract_pages_from_usemod.py 2008-01-17 15:42:42.000000000 +0100 +++ usemod2trac/extract_pages_from_usemod.py 2008-01-17 15:43:47.000000000 +0100 @@ -29,8 +29,9 @@ page_dir = os.path.join(data_dir, 'page') # field separators +FS = '\xb3' # Comment out one: old style +FS = "\x1e\xff\xfe\x1e" # or New style (UTF-8 compatible) -FS = '\xb3' FS1 = FS + '1' FS2 = FS + '2' FS3 = FS + '3'
Index: usemod2trac/convert_usemod_to_trac.py =================================================================== --- usemod2trac.orig/convert_usemod_to_trac.py 2008-05-26 11:03:26.000000000 +0200 +++ usemod2trac/convert_usemod_to_trac.py 2008-05-26 11:13:58.000000000 +0200 @@ -113,6 +113,8 @@ s=re.sub(r'^\*\*\* *', _sr(' * '), s) s=re.sub(r'^\*\* *', _sr(' * '), s) s=re.sub(r'^\* *', _sr(' * '), s) + + s=re.sub(r'^# *', _sr(' 1. '), s) return s
Index: usemod2trac/convert_usemod_to_trac.py =================================================================== --- usemod2trac.orig/convert_usemod_to_trac.py 2008-01-17 16:50:20.000000000 +0100 +++ usemod2trac/convert_usemod_to_trac.py 2008-01-17 16:52:29.000000000 +0100 @@ -65,6 +65,7 @@ nowiki_re = re.compile(r'<nowiki>(.*?)</nowiki>', re.IGNORECASE | re.DOTALL) code_re = re.compile(r'<code>(.*?)</code>', re.IGNORECASE | re.DOTALL) pre_re = re.compile(r'<pre>(.*?)</pre>', re.IGNORECASE | re.DOTALL) +spaces_re = re.compile(r'^ +(.*?)', re.IGNORECASE | re.DOTALL) def handle_multiline_markup(s): # The <nowiki> tag stores text with no markup @@ -73,6 +74,8 @@ s = code_re.sub(mo_group(1, store_pre), s) # The <pre> tag stores text with no {{{ markup }}} s = pre_re.sub(mo_group(1, store_pre), s) + # Beginning with spaces behaves like a <pre>, with no {{{ markup }}} + s = spaces_re.sub(mo_group(1, store_pre), s) s = re.sub(r'(?i)<b>(.*?)</b>', "'''\\1'''", s) s = re.sub(r'(?i)<i>(.*?)</i>', "''\\1''", s)
Index: usemod2trac/convert_usemod_to_trac.py =================================================================== --- usemod2trac.orig/convert_usemod_to_trac.py 2008-05-26 11:21:17.000000000 +0200 +++ usemod2trac/convert_usemod_to_trac.py 2008-05-26 11:21:43.000000000 +0200 @@ -81,6 +81,7 @@ s = re.sub(r'(?i)<i>(.*?)</i>', "''\\1''", s) s = re.sub(r'(?i)<strong>(.*?)</strong>', "'''\\1'''", s) s = re.sub(r'(?i)<em>(.*?)</em>', "''\\1''", s) + s = re.sub(r'(?i)<tt>(.*?)</tt>', "``\\1``", s) s = re.sub(r'(?i)<br>', lambda mo: store_raw('[[BR]]'), s) return s
Index: usemod2trac/extract_pages_from_usemod.py =================================================================== --- usemod2trac.orig/extract_pages_from_usemod.py 2008-01-17 15:47:19.000000000 +0100 +++ usemod2trac/extract_pages_from_usemod.py 2008-01-17 15:47:50.000000000 +0100 @@ -19,12 +19,13 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # +import sys import os import os.path from pprint import pprint # FIXME set data_dir to the path to your usemod database -data_dir = '/home/eb/build/wiki-snapshot/gnuradio_wikidb' +data_dir = sys.argv[1] page_dir = os.path.join(data_dir, 'page')
Usemod accepts a unnumbered list whithout an space after the asterisk, but trac doesn't. This patch takes care of it. Index: usemod2trac/convert_usemod_to_trac.py =================================================================== --- usemod2trac.orig/convert_usemod_to_trac.py 2008-01-17 15:43:15.000000000 +0100 +++ usemod2trac/convert_usemod_to_trac.py 2008-01-17 15:47:57.000000000 +0100 @@ -103,13 +103,13 @@ # tag = mo.group(2) s=re.sub('^:', '[[BR]] ', s) - s=re.sub(r'^\*\*\*\*\*\*\*', _sr(' *'), s) - s=re.sub(r'^\*\*\*\*\*\*', _sr(' *'), s) - s=re.sub(r'^\*\*\*\*\*', _sr(' *'), s) - s=re.sub(r'^\*\*\*\*', _sr(' *'), s) - s=re.sub(r'^\*\*\*', _sr(' *'), s) - s=re.sub(r'^\*\*', _sr(' *'), s) - s=re.sub(r'^\*', _sr(' *'), s) + s=re.sub(r'^\*\*\*\*\*\*\* *', _sr(' * '), s) + s=re.sub(r'^\*\*\*\*\*\* *', _sr(' * '), s) + s=re.sub(r'^\*\*\*\*\* *', _sr(' * '), s) + s=re.sub(r'^\*\*\*\* *', _sr(' * '), s) + s=re.sub(r'^\*\*\* *', _sr(' * '), s) + s=re.sub(r'^\*\* *', _sr(' * '), s) + s=re.sub(r'^\* *', _sr(' * '), s) return s
Index: usemod2trac/usemod2trac.sh =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ usemod2trac/usemod2trac.sh 2008-01-21 11:34:00.000000000 +0100 @@ -0,0 +1,41 @@ +#!/bin/sh + +# Silly wrapper for usemod2trac to automate exporting of several +# usemod wikis and display some (hopefully) helpful hints. + +indir=$1 +outdir=$2 +converterdir=~/download/usemod2trac + +if [ ! $# -eq 2 ]; then + echo "Usage: $0 usemod_dir empty_trac_output_dir" + exit 1 +fi +if [ ! -d $indir/page ]; then + echo "$1: Not a usemod directory" + exit 1 +fi +if [ ! -d $outdir ]; then + echo "$2: Not a directory" + exit 1 +fi +if [ $(echo $outdir/* | wc -w) -ne 1 ]; then + echo "$2: Output directory not empty" + exit 1 +fi + +cd $2 +echo Exporting usemod pages from $1 to $2... +$converterdir/extract_pages_from_usemod.py $1 +m=$(echo $outdir/*.um | wc -w) +echo Converting $n usemod pages to $2/trac... +for file in *.um; do + echo " $file" + $converterdir/convert_usemod_to_trac.py $file +done + +n=$(echo $outdir/trac/* | wc -w) +echo +echo $n out of $m pages have been converted to trac at $2/trac. +echo They can be imported into trac using the trac-admin tool: +echo $ trac-admin /path/to/projenv wiki load $2/trac
_______________________________________________ Patch-gnuradio mailing list Patch-gnuradio@gnu.org http://lists.gnu.org/mailman/listinfo/patch-gnuradio