import_walenty.py 996 Bytes
#! /usr/bin/python
# -*- coding: utf-8 -*-

import sys, os, shutil, codecs, copy, errno
from xml.sax import saxutils, handler, make_parser
from import_class.WalentyXML import WalentyTeiHandler
from import_class.WalentyPreprocessXML import WalentyPreprocessTeiHandler



if __name__ == '__main__':
    if len(sys.argv) != 2:
        print "WYWOŁANIE: ", sys.argv[0], " ścieżka_do_tei_walentego "
        exit(1)
    xml_file = sys.argv[1]

    xml_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), xml_file)
        
    parser = make_parser()
    parser.setFeature(handler.feature_external_ges, False)

    parser.setContentHandler(WalentyPreprocessTeiHandler())
    parser.parse(xml_path)

    entry_meanings = parser.getContentHandler().entry_meanings
    meanings = parser.getContentHandler().meanings    
    frames = parser.getContentHandler().frames
    
    parser.setContentHandler(WalentyTeiHandler(output, entry_meanings, meanings, frames))
    parser.parse(xml_path)