From: Per-Erik A. <Per...@au...> - 2008-08-07 07:28:20
|
Oh, I thought you had it checked in. I did some more test with your modification to the function, but it does not seem to work. The error I get is a NameError in checker.py ln 698 in my version of the repo. The line is: module = imp.load_module(self.moduleName, file, filename, smt) I tried to add a print in the modified _hasGlobal, but it never called the function. Cheers Pekka From: Barry Scott [mailto:ba...@ba...] Sent: den 7 augusti 2008 00:22 To: Per-Erik Akerstrom Cc: pyc...@li... Subject: Re: [PyChecker-list] Is it possible to get pychecker to ignore dynamically allocated functions On Aug 4, 2008, at 11:53, Per-Erik Akerstrom wrote: I tried do get it working but I still get the same error message and I'm not sure if I'm doing something wrong or if the issue you fixed is not related to my problem... Did you patch the source of pychecker with my code change? If not you will get the error. Barry I checked out the pychecker module from the cvs repo as described under code on the sourceforge site. I installed it as described in the readme, and then I tried on my old files that uses internalization, and I get the same error. Processing module MaterialLibrarySelector (c:\perforce_work\showcase_main\RTF\src\awRTF\UI\MaterialLibrarySelector.py)... Caught exception importing module MaterialLibrarySelector: File "C:\Python25\Lib\site-packages\pychecker\checker.py", line 698, in setupMainCode() module = imp.load_module(self.moduleName, file, filename, smt) File "c:\perforce_work\showcase_main\RTF\src\awRTF\UI\MaterialLibrarySelector.py", line 575, in <module>() class MaterialLibrarySelector(MaterialSelector, FilterSupport, MaterialSelectionMixin): File "c:\perforce_work\showcase_main\RTF\src\awRTF\UI\MaterialLibrarySelector.py", line 601, in MaterialLibrarySelector() __kManageMatTooltip = _("Manage Material Libraries") NameError: name '_' is not defined Any thoughts? Sorry for leaning on you... Pekka From: Barry Scott [mailto:ba...@ba...] Sent: den 6 juli 2008 11:58 To: Per-Erik Akerstrom Cc: pyc...@li...<mailto:pyc...@li...> Subject: Re: [PyChecker-list] Is it possible to get pychecker to ignore dynamically allocated functions On Jun 30, 2008, at 13:59, Per-Erik Akerstrom wrote: Hi. I'm trying to get pychecker to work for a project and I'm having some problems with integration it with the localization/internalization. There is a conflict between the convention that _ can be used for parameters that are to be ignored and its use in the standard library as the gettext operator. I think of this as a bug in pychecker. The way it is set up is to use a dynamically allocated function called _() to translate a string to another language. This function does not exist at pycheck time and generates an error and aborts the check. NameError: name '_' is not defined I could not find a way to ignore functions that I know will be ok later, and check everything else, much like the options for ignoring other things. We patched the code to fix this bug. def _hasGlobal(operand, module, func, main) : return (func.function.func_globals.has_key(operand) or main or module.moduleLineNums.has_key(operand) or __builtins__.has_key(operand) or # ONELAN: add _ so that users of gettext do not get no global found. operand == '_') # list of strings: ignore unused locals/arguments if name is one of unusedNames = [ '_', 'empty', 'unused', 'dummy', ] Since _ is the getetxt operator you must not use "_" as a variable name as it will hide the global _. You used the letter Q. unusedNames = [ 'Q', 'empty', 'unused', 'dummy', ] Barry |