Python 3.4-3.7 support;
[librarian.git] / scripts / book2txt
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 #
4 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
5 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
6 #
7 from __future__ import unicode_literals
8
9 from librarian.book2anything import Book2Anything, Option
10 from librarian.parser import WLDocument
11
12
13 class Book2Txt(Book2Anything):
14     format_name = "TXT"
15     ext = "txt"
16     uses_cover = False
17     uses_provider = False
18     parser_options = [
19         Option('-i', '--ignore-dublin-core', dest='parse_dublincore', 
20                 action='store_false', default=True,
21                 help='don\'t try to parse dublin core metadata')
22     ]
23     transform_options = [
24         Option('-w', '--wrap', action='store', type='int', dest='wrapping', default=0,
25                 help='set line wrap column')
26     ]
27     transform_flags = [
28         Option('-r', '--raw', dest='raw-text', 
29                 action='store_true', default=False,
30                 help='Produce raw text, without any surrounding info.')
31     ]
32     transform = WLDocument.as_text
33
34
35 if __name__ == '__main__':
36     Book2Txt.run()