[dots] Added a first version of a command line tool



commit 0b837c97b067fb6323a6556c6f9025b606e35b6f
Author: Fernando Herrera <fherrera onirica com>
Date:   Mon Jun 7 21:20:43 2010 +0200

    Added a first version of a command line tool

 dots/dotscmd.py |   90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 90 insertions(+), 0 deletions(-)
---
diff --git a/dots/dotscmd.py b/dots/dotscmd.py
new file mode 100755
index 0000000..d5cf87b
--- /dev/null
+++ b/dots/dotscmd.py
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+# Dots - A braille translation program.
+#
+# Copyright (C) 2010 Consorcio Fernando de los Rios
+#               Author: Fernando Herrera <fherrera onirica com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from optparse import OptionParser
+from config_builder import ConfigBuilder
+from document_builder import document_new 
+
+
+usage = "usage: %prog [options] <input file>"
+parser = OptionParser(usage=usage)
+
+parser.add_option("-o", "--output", dest="output",
+                  help="write translation to OUTFILE", metavar="OUTFILE")
+parser.add_option("-d", "--use-default-semantics", dest="use_default_semantics",
+                  action="store_true", default=True,
+                  help="include default semantics for the input file type")
+parser.add_option("-a", "--add-semantics", dest="add_semantics", metavar="SEMANTICS", action="store",
+                  help="add extra semantics files separated by comas")
+parser.add_option("-n", "--network", dest="network",
+                  action="store_true", default=True,
+                  help="access the network to download schemas")
+parser.add_option("-t", "--table", dest="table", metavar="TABLE", action="store",
+                  help="use TABLE as translation table for literary text")
+parser.add_option("-c", "--cells", type="int", dest="cells",
+                  help="cells per line", default=40)
+parser.add_option("-l", "--lines", type="int", dest="lines",
+                  help="lines per page", default=25)
+parser.add_option("-p", "--page-numbers", dest="page_numbers",
+                  action="store_true", default=True,
+                  help="include page number on every page")
+parser.add_option("-x", "--page-position", dest="page_position", metavar="POS", action="store", default="bottom",
+                  help="set position for page numbers, where POS is top or bottom")
+
+(options, args) = parser.parse_args()
+if len(args) != 1:
+	parser.error("incorrect number of arguments")
+
+if options.table is None:
+	parser.error("a translation table must be specified")
+
+if options.page_position is not "top" and not "bottom":
+	parser.error("page postion can only be top or bottom")
+
+d = document_new (args[0])
+config_builder = ConfigBuilder()
+
+if options.use_default_semantics:
+	config_builder['xml']['semanticFiles'] = '*,nemeth.sem'
+
+if options.add_semantics is not None:
+	config_builder['xml']['semanticFiles'] += options.add_semantics
+
+if options.network:
+        config_builder['xml']['internetAccess'] = 'yes'
+else:
+        config_builder['xml']['internetAccess'] = 'no'
+
+config_builder['translation']['literaryTextTable'] = options.table
+
+config_builder['outputFormat']['cellsPerLine'] = options.cells
+
+if options.page_numbers:
+        config_builder['outputFormat']['braillePages'] = 'yes'
+else:
+        config_builder['outputFormat']['braillePages'] = 'no'
+
+config_builder['outputFormat']['LinesPerPage'] = options.lines
+config_builder['outputFormat']['braillePageNumberAt'] =  options.page_position
+
+d.translate (config_builder)
+print d.get_braille_text ()
+
+
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]