Mercurial > jouvence
annotate scripts/fontaine @ 8:02d2e4d8b0c1
Make renderers responsible for formatting the title page.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 04 Jan 2017 02:55:20 -0800 |
parents | 9053902c750e |
children | a5488b474c6b |
rev | line source |
---|---|
4
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
2 import os.path |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
3 import sys |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
4 import argparse |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
5 |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
6 |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
7 sys.path.append(os.path.dirname(os.path.dirname(__file__))) |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
8 |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
9 |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
10 def main(): |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
11 parser = argparse.ArgumentParser( |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
12 description='Fontaine command line utility') |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
13 parser.add_argument('script') |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
14 args = parser.parse_args() |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
15 |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
16 from fontaine.parser import FontaineParser |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
17 from fontaine.console import ConsoleDocumentRenderer |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
18 p = FontaineParser() |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
19 doc = p.parse(args.script) |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
20 rdr = ConsoleDocumentRenderer() |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
21 rdr.render_doc(doc) |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
22 |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
23 |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
24 if __name__ == '__main__': |
9053902c750e
Add a console renderer and a command line utility to use it.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
25 main() |