#!/usr/bin/python
#
# Reads the output from './fromwiki' and stuffs it into a PyleWiki DB.
# It's a bit rough - I only tested it once.

import sys
import shelve
import string
from Config import *

db = shelve.open(sys.argv[1])
inp = sys.stdin

line = inp.readline()
while line:
	key = string.strip(inp.readline())
	inp.readline()	# ignore >'s

	text = ""
	line = inp.readline()
	while string.strip(line) != "<<<<<<<<<<<<<<<<<<<<<<<<":
		text = text + line
		line = inp.readline()

	a = {}
	a['text'] = text
	db[key] = a

	line = inp.readline()

db.close()
