Esempio n. 1
0
    def run(self, code):
        """Make the analysis"""
        self._code = code
        # Save the code in a temporary file
        temp = tempfile.NamedTemporaryFile(suffix = '.py')
        temp.write(self._code)
        temp.flush()
        fname = os.path.basename(temp.name)

        self._output_buffer = StringIO()
        checker._printWarnings = self._printWarnings
        checker.main(['dummy_arg', '--only', temp.name])
        # remove all traces of the Temporary file name
        self._report = self._output_buffer.getvalue().replace(temp.name, 'line')
        self._report = self._report.replace(fname[:-3] + ":", "")
        self._output_buffer.close()
        temp.close()
Esempio n. 2
0
    def run(self, code):
        """Make the analysis"""
        self._code = code
        # Save the code in a temporary file
        temp = tempfile.NamedTemporaryFile(suffix='.py')
        temp.write(self._code)
        temp.flush()
        fname = os.path.basename(temp.name)

        self._output_buffer = StringIO()
        checker._printWarnings = self._printWarnings
        checker.main(['dummy_arg', '--only', temp.name])
        # remove all traces of the Temporary file name
        self._report = self._output_buffer.getvalue().replace(
            temp.name, 'line')
        self._report = self._report.replace(fname[:-3] + ":", "")
        self._output_buffer.close()
        temp.close()
Esempio n. 3
0
import sys


class NullFile:
    """ Output eater """
    def write(self, s):
        sys.__stdout__.write(s)

    def flush(self):
        sys.__stdout__.flush()


sys.stderr = NullFile()

from pychecker import checker, Config

##import wxPythonNamespace
##_WXPYTHON_NAMESPACE = wxPythonNamespace.__dict__.keys()
##checker._DEFAULT_MODULE_TOKENS = list(checker._DEFAULT_MODULE_TOKENS)+ _WXPYTHON_NAMESPACE

if __name__ == '__main__':
    try:
        exitcode = checker.main(sys.argv)
        sys.stderr = sys.__stderr__
        for warning in warnings:
            sys.stderr.write(warning + '\n')
        sys.exit(exitcode)
    except Config.UsageError:
        sys.exit(127)
        warnings.append(`(self.file, self.line, self.err)`)

Warning.Warning = WarningWx


import sys

class NullFile :
    """ Output eater """
    def write(self, s) : sys.__stdout__.write(s)
    def flush(self): sys.__stdout__.flush()

sys.stderr = NullFile()


from pychecker import checker, Config

##import wxPythonNamespace
##_WXPYTHON_NAMESPACE = wxPythonNamespace.__dict__.keys()
##checker._DEFAULT_MODULE_TOKENS = list(checker._DEFAULT_MODULE_TOKENS)+ _WXPYTHON_NAMESPACE

if __name__ == '__main__' :
    try :
        exitcode = checker.main(sys.argv)
        sys.stderr = sys.__stderr__
        for warning in warnings:
            sys.stderr.write(warning+'\n')
        sys.exit(exitcode)
    except Config.UsageError :
        sys.exit(127)
Esempio n. 5
0
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
"""
Find problems in Python code using PyChecker

Run ./release/RunPython tools/checker.py

Without arguments runs a Chandler-specific report. Some modules
not handled.

See U{PyChecker manual<http://pychecker.sourceforge.net/>} for specifying
options.
"""

if __name__ == '__main__':
    import sys

    if len(sys.argv) == 1:
        sys.argv.append('Chandler')
        sys.argv.append('application')
        sys.argv.append('i18n')
        sys.argv.append('parcels/osaf')
        sys.argv.append('repository')
        sys.argv.append('tools')
        sys.argv.append('util')
        sys.argv.append('version')

    from pychecker import checker
    checker.main(sys.argv)
Esempio n. 6
0
#   limitations under the License.


"""
Find problems in Python code using PyChecker

Run ./release/RunPython tools/checker.py

Without arguments runs a Chandler-specific report. Some modules
not handled.

See U{PyChecker manual<http://pychecker.sourceforge.net/>} for specifying
options.
"""

if __name__ == '__main__':
    import sys
    
    if len(sys.argv) == 1:
        sys.argv.append('Chandler')
        sys.argv.append('application')
        sys.argv.append('i18n')
        sys.argv.append('parcels/osaf')
        sys.argv.append('repository')
        sys.argv.append('tools')
        sys.argv.append('util')
        sys.argv.append('version')
        
    from pychecker import checker
    checker.main(sys.argv)