def __init__(self):
        self.parser = self.init_parser()
        self.args = self.parser.parse_args()

        # auto-detect input type if not specified
        if not self.args.input:
            self.args.input = util.autodetect_file_type(self.args.filename)
            # exit if we still don't have an input type
            if not self.args.input:
                print >> sys.stderr, \
                    'Could not determine document input type; ' + \
                    'please specify with --input'
                exit(-1)

        self.run()
Exemplo n.º 2
0
    def __init__(self):
        self.parser = self.init_parser()
        self.args = self.parser.parse_args()

        # auto-detect input type if not specified
        if not self.args.input:
            self.args.input = util.autodetect_file_type(self.args.filename)
            # exit if we still don't have an input type
            if not self.args.input:
                print >> sys.stderr, \
                    'Could not determine document input type; ' + \
                    'please specify with --input'
                exit(-1)

        self.run()
 def test_autodetect_file_type(self):
     self.assertEqual('tei', autodetect_file_type(FIXTURES['tei']))
     self.assertEqual('ead', autodetect_file_type(FIXTURES['ead']))
     self.assertEqual('text', autodetect_file_type(FIXTURES['text']))
     self.assertEqual(None, autodetect_file_type(FIXTURES['generic-xml']))