#!/usr/bin/env python ## TXTtoTTX.py -- wraps lines of text in ttx xml tags ## version: 1 ## Author: Lee Ball ## Date: 01/08/2011 ## Run this command with python TXTtoTTX.py $filename ## It will output to stdout the lines of the file wrapped in tags. ## Redirect output to store. e.g TXTtoTTX.py filename.txt > filename.ttx ## For now, please simply replace the language code tags in starttag and endtag to what you need until ## I (or someone else) writes an XML supported version of this. ## Copyright 2011 Lee Ball ## ## Licensed under the Apache License, Version 2.0 (the "License"); ## you may not use this file except in compliance with the License. ## You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. import sys import os import string xmlstart = "\n\n" starttag = "" endtag = "" xmlend = "" infile = open(sys.argv[1],"r") sys.stdout.write(xmlstart) for line in infile: if not line.strip(): continue else: sys.stdout.write(starttag) sys.stdout.write(line.strip()) sys.stdout.write(endtag) sys.stdout.write('\n') else: sys.stdout.write(xmlend)