def main(): description = 'Dead simple LTSV parser written in C Extension' parser = argparse.ArgumentParser(description=description, add_help=False) parser.add_argument('-f', '--file') args = parser.parse_args() parse_file(args.file)
def test_parse_file(self): """ parse_file() should parse lstv file to dict.""" root_path = os.path.dirname(os.path.abspath(__file__)) test_file_path = os.path.join(root_path, 'test.ltsv') ret = parse_file(test_file_path) self.assertEqual(ret[0]['hoge'], 'foo') self.assertEqual(ret[0]['bar'], 'baz') self.assertEqual(ret[1]['perl'], '5.17.8') self.assertEqual(ret[2]['tennpura'].decode('utf-8'), u'天ぷら')
def bench_c_ext(): pyltsv.parse_file(file_path)
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Add comment here ~~~~~~~~~~~~~~~~ Add descripton here :copyright: (c) 2013 Shinya Ohyanagi, All rights reserved. :license: BSD, see LICENSE for more details. """ from pyltsv import parse_file ret = parse_file('./example_log.ltsv')
def test_no_file(self): """ parse_file() should raise IOError if file not exits. """ try: parse_file('nofile.ltsv') except IOError as e: self.assertEqual(e.message, 'LTSV file not found.')