Problem with __str__ method and character encoding

gialloporpora gialloporpora at gmail.com
Fri Dec 7 15:17:50 CET 2012


Risposta al messaggio di gialloporpora :

> This is the code in my test.py:

Sorry, I have wrongly pasted the code:


class msgmarker(object):
	def __init__(self, msgid, msgstr, index, encoding="utf-8"):
		self._encoding =encoding
		self.set(msgid, msgstr)
		self._index = index
		
	def __repr__(self):
		return "<msgmarker object>"
		
	def __str__(self):
		return u'msgid: "%s"\nmsgstr: "%s"' %(self.msgid, self.msgstr)

	def isUntranslated(self):
		return self.msgid==self.msgstr
		
	def isFuzzy(self):
		return self.msgstr[0:2]=="=="

	def markFuzzy(self):
		self.msgstr = "==%s" %(self.msgstr)
	def set(self, msgid, msgstr):
		if not(isinstance(msgid, unicode)): msgid = msgid.decode(self._encoding)
		if not(isinstance(msgstr, unicode)): msgstr = 
msgstr.decode(self._encoding)
		self.msgid = msgid
		self.msgstr = msgstr
	
	def setmsgstr(self, msgstr):
		if not(isinstance(msgstr, unicode)): msgstr = 
msgstr.decode(self._encoding)
		self.msgstr = msgstr

	def getIndex(self):
		return self._index
	def getIndex(self):
		return self._index
	
		





-- 
*Antivirus aggiornato: e siamo sicuri che basti? * - http://bit.ly/SXuDAc
Sto ascoltando: *Robert Plant – One More Cup of Coffee (Valley Below) * 
- http://bit.ly/TtyHMq



More information about the Python-list mailing list