Beispiel #1
0
	def __iter__(self):
		from polib import unescape as po_unescape
		word = ""
		defi = ""
		msgstr = False
		wordCount = 0
		for line in self._file:
			line = line.strip()
			if not line:
				continue
			if line.startswith("#"):
				continue
			if line.startswith("msgid "):
				if word:
					yield self._glos.newEntry(word, defi)
					wordCount += 1
					word = ""
					defi = ""
				word = po_unescape(line[6:])
				msgstr = False
			elif line.startswith("msgstr "):
				if msgstr:
					log.error("msgid omitted!")
				defi = po_unescape(line[7:])
				msgstr = True
			else:
				if msgstr:
					defi += po_unescape(line)
				else:
					word += po_unescape(line)
		if word:
			yield self._glos.newEntry(word, defi)
			wordCount += 1
		self._wordCount = wordCount
Beispiel #2
0
 def __iter__(self):
     from polib import unescape as po_unescape
     word = ''
     defi = ''
     msgstr = False
     wordCount = 0
     for line in self._file:
         line = line.strip()
         if not line:
             continue
         if line.startswith('#'):
             continue
         if line.startswith('msgid '):
             if word:
                 yield Entry(word, defi) ; wordCount += 1
                 word = ''
                 defi = ''
             word = po_unescape(line[6:])
             msgstr = False
         elif line.startswith('msgstr '):
             if msgstr:
                 log.error('msgid omitted!')
             defi = po_unescape(line[7:])
             msgstr = True
         else:
             if msgstr:
                 defi += po_unescape(line)
             else:
                 word += po_unescape(line)
     if word:
         yield Entry(word, defi) ; wordCount += 1
     self._len = wordCount
Beispiel #3
0
 def __iter__(self):
     word = ''
     defi = ''
     msgstr = False
     wordCount = 0
     for line in self._file:
         line = line.strip()
         if not line:
             continue
         if line.startswith('#'):
             continue
         if line.startswith('msgid '):
             if word:
                 yield Entry(word, defi)
                 wordCount += 1
                 word = ''
                 defi = ''
             word = po_unescape(line[6:])
             msgstr = False
         elif line.startswith('msgstr '):
             if msgstr:
                 log.error('msgid omitted!')
             defi = po_unescape(line[7:])
             msgstr = True
         else:
             if msgstr:
                 defi += po_unescape(line)
             else:
                 word += po_unescape(line)
     if word:
         yield Entry(word, defi)
         wordCount += 1
     self._len = wordCount
Beispiel #4
0
 def __iter__(self):
     try:
         from polib import unescape as po_unescape
     except ModuleNotFoundError as e:
         e.msg += f", run `{pip} install polib` to install"
         raise e
     word = ""
     defi = ""
     msgstr = False
     wordCount = 0
     for line in self._file:
         line = line.strip()
         if not line:
             continue
         if line.startswith("#"):
             continue
         if line.startswith("msgid "):
             if word:
                 yield self._glos.newEntry(word, defi)
                 wordCount += 1
                 word = ""
                 defi = ""
             else:
                 pass
                 # TODO: parse defi and set glos info?
                 # but this should be done in self.open
             word = po_unescape(line[6:])
             msgstr = False
         elif line.startswith("msgstr "):
             if msgstr:
                 log.error("msgid omitted!")
             defi = po_unescape(line[7:])
             msgstr = True
         else:
             if msgstr:
                 defi += po_unescape(line)
             else:
                 word += po_unescape(line)
     if word:
         yield self._glos.newEntry(word, defi)
         wordCount += 1
     self._wordCount = wordCount