Пример #1
0
    def test_toc_generation(self):
        path = Path(get_file_path('toc_simple'))

        generated = Path(get_file_path('codio_structure', extension='yml'))
        if generated.exists():
            generated.unlink()

        generate_toc(get_file_path(), path, ignore_exists=True)

        yaml = load_file('codio_structure', extension='yml')
        yaml = re.sub(r"directory:(.*)$",
                      r"directory: toc_cases",
                      yaml,
                      flags=re.MULTILINE)
        yaml = yaml.strip()
        generated.unlink()

        should_be = load_file('toc_simple', extension='yml')
        self.assertEqual(yaml, should_be)
Пример #2
0
from converter.refs import ref_dict

if __name__ == '__main__':
    parser = ArgumentParser(description='Process latex to codio guides.')
    parser.add_argument('paths',
                        metavar='PATH',
                        type=str,
                        nargs='+',
                        help='path to a book config')
    parser.add_argument('--generate', type=str, help='path to a latex book')
    parser.add_argument('-l', '--log', action='store', default=None)
    parser.add_argument('-y', '--yes', action='store_true')
    parser.add_argument('-r', '--ref', action='store_true')

    args = parser.parse_args()

    logging.basicConfig(filename=args.log,
                        level=logging.DEBUG,
                        format='[%(asctime)s] %(levelname).5s %(message)s',
                        datefmt='%Y.%m.%d %H:%M:%S')

    if args.generate:
        generate_toc(args.paths[0], args.generate)
    elif args.ref:
        config, base_path = load_config_file(args.paths[0])
        ref_dict(config)
    else:
        for path in args.paths:
            config, base_path = load_config_file(path)
            convert(config, base_path, args.yes)
Пример #3
0
 def test_toc_generation_exception(self):
     with self.assertRaises(Exception):
         path = Path(get_file_path('toc_simple'))
         generate_toc(get_file_path(), path)