Utilities/py3flakes/translations.py

changeset 3205
157dcfafc5d2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Utilities/py3flakes/translations.py	Wed Jan 15 18:59:03 2014 +0100
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2014 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing message translations for pyflakes warning messages.
+"""
+
+from PyQt4.QtCore import QCoreApplication
+
+__all__ = ["getTranslatedFlakesMessage"]
+
+_messages = {
+    'F01': QCoreApplication.translate(
+        'pyFlakes',
+        '{0!r} imported but unused.'),
+    'F02': QCoreApplication.translate(
+        'pyFlakes',
+        'Redefinition of unused {0!r} from line {1!r}.'),
+    'F03': QCoreApplication.translate(
+        'pyFlakes',
+        'Import {0!r} from line {1!r} shadowed by loop variable.'),
+    'F04': QCoreApplication.translate(
+        'pyFlakes',
+        "'from {0} import *' used; unable to detect undefined names."),
+    'F05': QCoreApplication.translate(
+        'pyFlakes',
+        'Undefined name {0!r}.'),
+    'F06': QCoreApplication.translate(
+        'pyFlakes',
+        'Undefined name {0!r} in __all__.'),
+    'F07': QCoreApplication.translate(
+        'pyFlakes',
+        "Local variable {0!r} (defined in enclosing scope on line {1!r})"
+        " referenced before assignment."),
+    'F08': QCoreApplication.translate(
+        'pyFlakes',
+        'Duplicate argument {0!r} in function definition.'),
+    'F09': QCoreApplication.translate(
+        'pyFlakes',
+        'Redefinition of function {0!r} from line {1!r}.'),
+    'F10': QCoreApplication.translate(
+        'pyFlakes',
+        'Future import(s) {0!r} after other statements.'),
+    'F11': QCoreApplication.translate(
+        'pyFlakes',
+        'Local variable {0!r} is assigned to but never used.'),
+
+}
+
+
+def getTranslatedFlakesMessage(message_id, message_args):
+    """
+    Module function to get a translated and formatted message for a
+    given pyflakes message ID.
+    
+    @param message_id message ID (string)
+    @param message_args arguments for a formatted message (list)
+    @return translated and formatted message (string)
+    """
+    if message_id in _messages:
+        return QCoreApplication.translate(
+            "pyFlakes", _messages[message_id]).format(*message_args)
+    else:
+        return QCoreApplication.translate(
+            "pyFlakes", "no message defined for code '{0}'")\
+            .format(message_id)

eric ide

mercurial