273 self.trUtf8("""<p>The hash for some files could not""" |
275 self.trUtf8("""<p>The hash for some files could not""" |
274 """ be generated.</p>""") |
276 """ be generated.</p>""") |
275 ) |
277 ) |
276 else: |
278 else: |
277 editor = e5App().getObject("ViewManager").activeWindow() |
279 editor = e5App().getObject("ViewManager").activeWindow() |
|
280 if (editor.getLanguage() in ['Python', 'Python2'] and |
|
281 "from __future__ import unicode_literals" |
|
282 not in editor.text()): |
|
283 prefix = 'u' |
|
284 else: |
|
285 prefix = '' |
|
286 |
278 line, index = editor.getCursorPosition() |
287 line, index = editor.getCursorPosition() |
279 indLevel = (editor.indentation(line) // |
288 indLevel = (editor.indentation(line) // |
280 editor.indentationWidth()) |
289 editor.indentationWidth()) |
281 if editor.indentationsUseTabs(): |
290 if editor.indentationsUseTabs(): |
282 indString = '\t' |
291 indString = '\t' |
283 else: |
292 else: |
284 indString = editor.indentationWidth() * ' ' |
293 indString = editor.indentationWidth() * ' ' |
285 indent = (indLevel + 1) * indString |
294 indent = (indLevel + 1) * indString |
286 code = ["["] |
295 code = ["["] |
287 for hash in hashes: |
296 for name, hash in hashes: |
288 code.append("{0}{1},".format(indent, str(hash))) |
297 code.append("{0}({1}'{2}', '{3}'),".format( |
|
298 indent, prefix, name, hash)) |
289 code.append("{0}]".format(indLevel * indString)) |
299 code.append("{0}]".format(indLevel * indString)) |
290 |
300 |
291 self.__insertHash(os.linesep.join(code)) |
301 self.__insertHash(os.linesep.join(code)) |