comparison trunk/src/translator/langfile.py @ 480:f25985f6b222

Translator: catalogues can be saved to disk now.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Mon, 12 Nov 2007 20:40:41 +0100
parents 3b5421d40f9b
children 312da78ab301
comparison
equal deleted inserted replaced
479:044b5393f8bc 480:f25985f6b222
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 # Author: Aziz Köksal 2 # Author: Aziz Köksal
3 # License: GPL2 3 # License: GPL2
4 import yaml 4 import yaml
5 from errors import LoadingError 5 from errors import LoadingError
6
7 # Avoid that all unicode strings are tagged with "!!python/unicode".
8 def unicode_representer(dumper, data):
9 return dumper.represent_scalar(u'tag:yaml.org,2002:str', data)
10 yaml.add_representer(unicode, unicode_representer)
6 11
7 def newLangFile(langCode, authors, license): 12 def newLangFile(langCode, authors, license):
8 return { 13 return {
9 "LangCode":langCode, 14 "LangCode":langCode,
10 "Authors":authors, 15 "Authors":authors,
82 87
83 def createEmptyMsg(self, ID): 88 def createEmptyMsg(self, ID):
84 return {"ID":ID,"Text":"","Annot":"","LastEd":""} 89 return {"ID":ID,"Text":"","Annot":"","LastEd":""}
85 90
86 def save(self): 91 def save(self):
87 #langFile = open(self.filePath, "w") 92 langFile = open(self.filePath, "w")
88 print "Saved", self.filePath 93 yaml.dump(self.doc, stream=langFile, allow_unicode=True)
89 #print yaml.dump(self.doc, allow_unicode=True) 94 langFile.close()
90 #langFile.close()
91 95
92 def getFileName(self): 96 def getFileName(self):
93 from os import path 97 from os import path
94 return path.basename(self.filePath) 98 return path.basename(self.filePath)
95 99