[dots] Use configuration



commit acc6858eaf37ccd657d5fc750fc26e239b136250
Author: Fernando Herrera <fherrera onirica com>
Date:   Wed Jun 2 14:37:19 2010 +0200

    Use configuration

 TODO               |    4 ++++
 dots/document.py   |   24 ++++++++++++++++++++++++
 dots/translator.py |   10 +++++++++-
 3 files changed, 37 insertions(+), 1 deletions(-)
---
diff --git a/TODO b/TODO
index 37bcb41..8e6f130 100644
--- a/TODO
+++ b/TODO
@@ -1,2 +1,6 @@
 - Put cursor at beginning of textviews when they are exposed.
 - Add application window.
+
+For model/view branch:
+	- Save the text in the model, not the buffer in the view
+	- 
diff --git a/dots/document.py b/dots/document.py
index 7ec8715..676fa9a 100644
--- a/dots/document.py
+++ b/dots/document.py
@@ -35,3 +35,27 @@ class Document():
 	return self.braille_text
 
 	
+if __name__ == "__main__":
+	import sys
+	from config_builder import ConfigBuilder
+
+	if sys.argv[1] is None:
+		print sys.argv[0] + " [file]"
+	d = Document(sys.argv[1])
+	config_builder = ConfigBuilder()
+
+        config_builder['xml']['semanticFiles'] = '*'
+        config_builder['xml']['semanticFiles'] += ',nemeth.sem'
+        config_builder['xml']['internetAccess'] = 'yes'
+        config_builder['translation']['literaryTextTable'] = "Es-Es-g1.utb"
+        config_builder['outputFormat']['cellsPerLine'] = 40
+        config_builder['outputFormat']['braillePages'] = 'yes'
+        config_builder['outputFormat']['formatFor'] = 'textDevice'
+        config_builder['outputFormat']['LinesPerPage'] = 25
+        config_builder['outputFormat']['braillePageNumberAt'] =  'bottom'
+
+	d.translate (config_builder)
+	print d.get_braille_text()
+	
+	
+		
diff --git a/dots/translator.py b/dots/translator.py
index 8061644..0c01d58 100644
--- a/dots/translator.py
+++ b/dots/translator.py
@@ -17,13 +17,21 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import louisxml
+import tempfile
+import os
 
 class Translator():
     def __init__(self, config):
         self.config = config
 
     def translate(self, input_file):
+	cfgfile = tempfile.NamedTemporaryFile (delete=False)
+	cfgfile.write (str (self.config))
+	cfgfile.close()
 	f = open (input_file)
-	return louisxml.translateString ("", f.read(),0)
+	buf = louisxml.translateString (cfgfile.name, f.read(),0)
+	f.close()
+	os.unlink(cfgfile.name)
+	return buf
 	
 



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