Utilities/py3flakes/messages.py

branch
Py2 comp.
changeset 2571
e6bb19eb87ea
parent 2302
f29e9405c851
child 3057
10516539f238
--- a/Utilities/py3flakes/messages.py	Thu Mar 28 20:09:00 2013 +0100
+++ b/Utilities/py3flakes/messages.py	Mon Apr 08 07:52:06 2013 +0200
@@ -7,7 +7,16 @@
 # This module is based on pyflakes for Python2 but was heavily hacked to
 # work with Python3 and Qt (translatable messages)
 
-from PyQt4.QtCore import QCoreApplication
+
+def QT_TRANSLATE_NOOP(mod, txt):
+    """
+    Function to tell 'lupdate' which strings to keep for translation.
+    
+    @param mod module name
+    @param txt translatable string
+    @return the untranslated! string
+    """
+    return txt
 
 
 class Message(object):
@@ -43,14 +52,14 @@
         @return tuple containing file name, line number and message
             (string, integer, string)
         """
-        return (self.filename, self.lineno, self.message.format(*self.message_args))
+        return (self.filename, self.lineno, self.message, self.message_args)
 
 
 class UnusedImport(Message):
     """
     Class defining the "Unused Import" message.
     """
-    message = QCoreApplication.translate('py3Flakes',
+    message = QT_TRANSLATE_NOOP('py3Flakes',
         '{0!r} imported but unused.')
     
     def __init__(self, filename, lineno, name):
@@ -69,9 +78,9 @@
     """
     Class defining the "Redefined While Unused" message.
     """
-    message = QCoreApplication.translate('py3Flakes',
+    message = QT_TRANSLATE_NOOP('py3Flakes', 
         'Redefinition of unused {0!r} from line {1!r}.')
-    
+
     def __init__(self, filename, lineno, name, orig_lineno):
         """
         Constructor
@@ -89,7 +98,7 @@
     """
     Class defining the "Import Shadowed By Loop Var" message.
     """
-    message = QCoreApplication.translate('py3Flakes',
+    message = QT_TRANSLATE_NOOP('py3Flakes',
         'Import {0!r} from line {1!r} shadowed by loop variable.')
     
     def __init__(self, filename, lineno, name, orig_lineno):
@@ -109,7 +118,7 @@
     """
     Class defining the "Import Star Used" message.
     """
-    message = QCoreApplication.translate('py3Flakes',
+    message = QT_TRANSLATE_NOOP('py3Flakes',
         "'from {0} import *' used; unable to detect undefined names.")
     
     def __init__(self, filename, lineno, modname):
@@ -128,7 +137,7 @@
     """
     Class defining the "Undefined Name" message.
     """
-    message = QCoreApplication.translate('py3Flakes', 'Undefined name {0!r}.')
+    message = QT_TRANSLATE_NOOP('py3Flakes', 'Undefined name {0!r}.')
     
     def __init__(self, filename, lineno, name):
         """
@@ -146,7 +155,8 @@
     """
     Class defining the "Undefined Export" message.
     """
-    message = QCoreApplication.translate('py3Flakes', 'Undefined name {0!r} in __all__.')
+    message = QT_TRANSLATE_NOOP('py3Flakes', 
+        'Undefined name {0!r} in __all__.')
     
     def __init__(self, filename, lineno, name):
         """
@@ -164,9 +174,9 @@
     """
     Class defining the "Undefined Local Variable" message.
     """
-    message = QCoreApplication.translate('py3Flakes',
-        "Local variable {0!r} (defined in enclosing scope on line {1!r})"
-        " referenced before assignment.")
+    message = QT_TRANSLATE_NOOP('py3Flakes',
+        "Local variable {0!r} (defined in enclosing scope on line {1!r})" \
+              " referenced before assignment.")
     
     def __init__(self, filename, lineno, name, orig_lineno):
         """
@@ -185,7 +195,7 @@
     """
     Class defining the "Duplicate Argument" message.
     """
-    message = QCoreApplication.translate('py3Flakes',
+    message = QT_TRANSLATE_NOOP('py3Flakes',
         'Duplicate argument {0!r} in function definition.')
     
     def __init__(self, filename, lineno, name):
@@ -204,7 +214,7 @@
     """
     Class defining the "Redefined Function" message.
     """
-    message = QCoreApplication.translate('py3Flakes',
+    message = QT_TRANSLATE_NOOP('py3Flakes',
         'Redefinition of function {0!r} from line {1!r}.')
     
     def __init__(self, filename, lineno, name, orig_lineno):
@@ -224,7 +234,7 @@
     """
     Class defining the "Late Future Import" message.
     """
-    message = QCoreApplication.translate('py3Flakes',
+    message = QT_TRANSLATE_NOOP('py3Flakes',
         'Future import(s) {0!r} after other statements.')
     
     def __init__(self, filename, lineno, names):
@@ -246,7 +256,7 @@
     Indicates that a variable has been explicitly assigned to but not actually
     used.
     """
-    message = QCoreApplication.translate('py3Flakes',
+    message = QT_TRANSLATE_NOOP('py3Flakes',
         'Local variable {0!r} is assigned to but never used.')
     
     def __init__(self, filename, lineno, name):

eric ide

mercurial