示例#1
0
    def _init():
        global _cfg, _suppressions, _orig__import__

        args = string.split(os.environ.get('PYCHECKER', ''))
        _cfg, files, _suppressions = Config.setupFromArgs(args)
        utils.initConfig(_cfg)
        fixupBuiltinModules(1)

        # keep the orig __import__ around so we can call it
        import __builtin__
        _orig__import__ = __builtin__.__import__
        __builtin__.__import__ = __import__
示例#2
0
    def _init() :
        global _cfg, _suppressions, _orig__import__

        args = string.split(os.environ.get('PYCHECKER', ''))
        _cfg, files, _suppressions = Config.setupFromArgs(args)
        utils.initConfig(_cfg)
        fixupBuiltinModules(1)

        # keep the orig __import__ around so we can call it
        import __builtin__
        _orig__import__ = __builtin__.__import__
        __builtin__.__import__ = __import__
示例#3
0
def checkSyntax(filename, messageView):
    """ Massively hacked version of main for ActiveGrid IDE integration """
    global _cfg
    _cfg, files, suppressions = Config.setupFromArgs([filename])
    if not files:
        return 0

    global _output, _statusDlg, _count
    _output = messageView
    # wxBug:  Need to show progress dialog box, or message window never gets updated until the method returns
    _statusDlg = wx.ProgressDialog(_("Check Code"),
                                   _("Checking %s") % filename,
                                   maximum=100,
                                   style=wx.PD_AUTO_HIDE | wx.PD_APP_MODAL
                                   | wx.PD_ELAPSED_TIME)
    _count = 0

    # insert this here, so we find files in the local dir before std library
    if sys.path[0] != '':
        sys.path.insert(0, '')

    importWarnings = processFiles(files, _cfg, _print_processing)
    fixupBuiltinModules()
    if _cfg.printParse:
        for module in getAllModules():
            printer.module(module)

    warnings = warn.find(getAllModules(), _cfg, suppressions)

    _statusDlg.Update(100, _("Done"))
    _statusDlg.Destroy()

    if not _cfg.quiet:
        _output.AddLines(_("\nWarnings and Errors...\n"))
    if warnings or importWarnings:
        _printWarnings(importWarnings + warnings)
        return 1

    if not _cfg.quiet:
        _output.AddLines(_("No Syntax Errors"))
    return 0
示例#4
0
def checkSyntax(filename, messageView):
    """ Massively hacked version of main for ActiveGrid IDE integration """
    global _cfg
    _cfg, files, suppressions = Config.setupFromArgs([filename])
    if not files :
        return 0
                
    global _output, _statusDlg, _count
    _output = messageView
    # wxBug:  Need to show progress dialog box, or message window never gets updated until the method returns    
    _statusDlg = wx.ProgressDialog(_("Check Code"), _("Checking %s") % filename, maximum = 100, style = wx.PD_AUTO_HIDE | wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME)  
    _count = 0

    # insert this here, so we find files in the local dir before std library
    if sys.path[0] != '' :
        sys.path.insert(0, '')

    importWarnings = processFiles(files, _cfg, _print_processing)
    fixupBuiltinModules()
    if _cfg.printParse :
        for module in getAllModules() :
            printer.module(module)

    warnings = warn.find(getAllModules(), _cfg, suppressions)
    
    _statusDlg.Update(100, _("Done"))
    _statusDlg.Destroy()
    
    if not _cfg.quiet :
        _output.AddLines(_("\nWarnings and Errors...\n"))
    if warnings or importWarnings :
        _printWarnings(importWarnings + warnings)
        return 1

    if not _cfg.quiet :
        _output.AddLines(_("No Syntax Errors"))
    return 0
示例#5
0
        # read data from the file
        command_file = argv[1][1:]
        try:
            f = open(command_file, 'r')
            command_line = f.read()
            f.close()
        except IOError, err:
            sys.stderr.write("Unable to read commands from file: %s\n  %s\n" % \
                             (command_file, err))
            sys.exit(101)

        # convert to an argv list, keeping argv[0] and the files to process
        argv = argv[:1] + string.split(command_line) + argv[2:]

    global _cfg
    _cfg, files, suppressions = Config.setupFromArgs(argv[1:])
    if not files:
        return 0

    # Now that we've got the args, update the list of evil C objects
    for evil_doer in _cfg.evil:
        _EVIL_C_OBJECTS[evil_doer] = None

    # insert this here, so we find files in the local dir before std library
    sys.path.insert(0, '')

    importWarnings = processFiles(files, _cfg, _print_processing)
    fixupBuiltinModules()
    if _cfg.printParse:
        for module in getAllModules():
            printer.module(module)
示例#6
0
        # read data from the file
        command_file = argv[1][1:]
        try:
            f = open(command_file, 'r')
            command_line = f.read()
            f.close()
        except IOError, err:
            sys.stderr.write("Unable to read commands from file: %s\n  %s\n" % \
                             (command_file, err))
            sys.exit(101)

        # convert to an argv list, keeping argv[0] and the files to process
        argv = argv[:1] + string.split(command_line) + argv[2:]
 
    global _cfg
    _cfg, files, suppressions = Config.setupFromArgs(argv[1:])
    if not files :
        return 0

    # Now that we've got the args, update the list of evil C objects
    for evil_doer in _cfg.evil:
        _EVIL_C_OBJECTS[evil_doer] = None

    # insert this here, so we find files in the local dir before std library
    sys.path.insert(0, '')

    importWarnings = processFiles(files, _cfg, _print_processing)
    fixupBuiltinModules()
    if _cfg.printParse :
        for module in getAllModules() :
            printer.module(module)