def testDefault(self): logging.getLogger().addHandler(logging.StreamHandler()) # might spam your console... self.interceptLogs('otplc.extractor') self.otpl_file.write( "This DT 6 nsubj B-NP NULL\n" "is VBZ 6 cop B-VP NULL\n" "Florian NNP 6 nn B-NP NULL\n" "ʼs POS 3 pos I-NP db:id\n" "weird JJ 6 amod I-NP NULL\n" "test NN 0 root I-NP NULL\n" ". DOT 6 punct O NULL\n\n" "And DT 6 nsubj B-NP NULL\n" "another VBZ 6 cop B-VP NULL\n" "one NN 0 root I-NP NULL\n" ". DOT 6 punct O NULL\n\n" ) self.otpl_file.close() expected = 'This is Florian ʼs weird test .\nAnd another one .\n' self.assertEqual(0, otpl_to_text(Configuration([self.otpl_file.name]))) result = open(make_path_to(self.otpl_file.name, Configuration.TEXT_SUFFIX)).read() self.assertEqual(expected, result)
format='%(levelname)-8s %(module) 10s: %(funcName)s %(message)s') logging.info('verbosity increased') logging.debug('verbosity increased') try: config = Configuration(args.files) except AssertionError as e: logging.error(str(e)) sys.exit(-2) if args.colspec: try: config.colspec = ColumnSpecification.from_string(args.colspec) except ValueError as e: logging.error("colspec parsing failed: %s", str(e)) sys.exit(-3) config.text_suffix = args.text_suffix config.filter = args.filter config.separator = args.separator if args.segment > 0: segment_file_names = [] for otpl_file in config.input_files: segment_file_names.extend(segment_otpl_file(otpl_file, args.segment, config.encoding)) config.input_files = segment_file_names sys.exit(otpl_to_text(config))