302 |
302 |
303 if self.__module is None: |
303 if self.__module is None: |
304 # new file |
304 # new file |
305 try: |
305 try: |
306 tmplName = os.path.join(getConfig('ericCodeTemplatesDir'), "impl.py.tmpl") |
306 tmplName = os.path.join(getConfig('ericCodeTemplatesDir'), "impl.py.tmpl") |
307 tmplFile = open(tmplName, 'r') |
307 tmplFile = open(tmplName, 'r', encoding = "utf-8") |
308 template = tmplFile.read() |
308 template = tmplFile.read() |
309 tmplFile.close() |
309 tmplFile.close() |
310 except IOError as why: |
310 except IOError as why: |
311 QMessageBox.critical(self, |
311 QMessageBox.critical(self, |
312 self.trUtf8("Code Generation"), |
312 self.trUtf8("Code Generation"), |
335 indentStr = line.replace(line.lstrip(), "") |
335 indentStr = line.replace(line.lstrip(), "") |
336 break |
336 break |
337 else: |
337 else: |
338 # extend existing file |
338 # extend existing file |
339 try: |
339 try: |
340 srcFile = open(self.srcFile, 'r') |
340 srcFile = open(self.srcFile, 'r', encoding = "utf-8") |
341 sourceImpl = srcFile.readlines() |
341 sourceImpl = srcFile.readlines() |
342 srcFile.close() |
342 srcFile.close() |
343 if not sourceImpl[-1].endswith(os.linesep): |
343 if not sourceImpl[-1].endswith(os.linesep): |
344 sourceImpl[-1] = "%s%s" % (sourceImpl[-1], os.linesep) |
344 sourceImpl[-1] = "%s%s" % (sourceImpl[-1], os.linesep) |
345 except IOError as why: |
345 except IOError as why: |
392 else: |
392 else: |
393 sourceImpl[appendAtIndex:appendAtIndex] = slotsCode |
393 sourceImpl[appendAtIndex:appendAtIndex] = slotsCode |
394 |
394 |
395 # write the new code |
395 # write the new code |
396 try: |
396 try: |
397 srcFile = open(self.filenameEdit.text(), 'w') |
397 srcFile = open(self.filenameEdit.text(), 'w', encoding = "utf-8") |
398 srcFile.write("".join(sourceImpl)) |
398 srcFile.write("".join(sourceImpl)) |
399 srcFile.close() |
399 srcFile.close() |
400 except IOError as why: |
400 except IOError as why: |
401 QMessageBox.critical(self, |
401 QMessageBox.critical(self, |
402 self.trUtf8("Code Generation"), |
402 self.trUtf8("Code Generation"), |