예제 #1
0
파일: test_reader.py 프로젝트: fnl/otplc
 def guessColspec(self, otpl_text, header):
     self.otpl_file.write(otpl_text)
     self.otpl_file.close()
     expected = ColumnSpecification.from_string(header)
     result = guess_colspec(self.segments)
     self.assertSequenceEqual(str(expected), str(result))
     self.assertEqual(expected, result)
예제 #2
0
파일: otpl-extractor.py 프로젝트: fnl/otplc
# Logging setup
log_adjust = max(min(args.quiet - args.verbose, 2), -2) * 10
logging.basicConfig(level=logging.WARNING + log_adjust,
                    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