예제 #1
0
    def styleCheck(self, lang, filename, source, args):
        """
        Public method to prepare a style check on one Python source file.

        @param lang language of the file or None to determine by internal
            algorithm
        @type str or None
        @param filename source filename
        @type str
        @param source string containing the code to check
        @type str
        @param args arguments used by the codeStyleCheck function (list of
            excludeMessages, includeMessages, repeatMessages, fixCodes,
            noFixCodes, fixIssues, maxLineLength, blankLines, hangClosing,
            docType, codeComplexityArgs, miscellaneousArgs, errors, eol,
            encoding, backup)
        @type list of (str, str, bool, str, str, bool, int, list of (int, int),
            bool, str, dict, dict, list of str, str, str, bool)
        """
        if lang is None:
            lang = 'Python{0}'.format(determinePythonVersion(filename, source))
        if lang not in ['Python2', 'Python3']:
            return

        data = [source, args]
        self.backgroundService.enqueueRequest('style', lang, filename, data)
예제 #2
0
 def styleBatchCheck(self, argumentsList):
     """
     Public method to prepare a style check on multiple Python source files.
     
     @param argumentsList list of arguments tuples with each tuple
         containing filename, source and args as given in styleCheck()
         method
     """
     data = {
         "Python2": [],
         "Python3": [],
     }
     for filename, source, args in argumentsList:
         lang = 'Python{0}'.format(determinePythonVersion(filename, source))
         if lang not in ['Python2', 'Python3']:
             continue
         else:
             data[lang].append((filename, source, args))
     
     self.queuedBatches = []
     for lang in ['Python2', 'Python3']:
         if data[lang]:
             self.queuedBatches.append(lang)
             self.backgroundService.enqueueRequest('batch_style', lang, "",
                                                   data[lang])
             self.batchesFinished = False
    def styleBatchCheck(self, argumentsList):
        """
        Public method to prepare a style check on multiple Python source files.
        
        @param argumentsList list of arguments tuples with each tuple
            containing filename, source and args as given in styleCheck()
            method
        """
        data = {
            "Python2": [],
            "Python3": [],
        }
        for filename, source, args in argumentsList:
            lang = 'Python{0}'.format(determinePythonVersion(filename, source))
            if lang not in ['Python2', 'Python3']:
                continue
            else:
                data[lang].append((filename, source, args))

        self.queuedBatches = []
        for lang in ['Python2', 'Python3']:
            if data[lang]:
                self.queuedBatches.append(lang)
                self.backgroundService.enqueueRequest('batch_style', lang, "",
                                                      data[lang])
                self.batchesFinished = False
예제 #4
0
    def indentCheck(self, lang, filename, source):
        """
        Public method to prepare a style check on one Python source file.

        @param lang language of the file or None to determine by internal
            algorithm (str or None)
        @param filename source filename (string)
        @param source string containing the code to check (string)
        """
        if lang is None:
            lang = "Python{0}".format(determinePythonVersion(filename, source))
        if lang not in ["Python2", "Python3"]:
            return

        self.backgroundService.enqueueRequest("indent", lang, filename, [source])
예제 #5
0
    def indentCheck(self, lang, filename, source):
        """
        Public method to prepare a style check on one Python source file.

        @param lang language of the file or None to determine by internal
            algorithm (str or None)
        @param filename source filename (string)
        @param source string containing the code to check (string)
        """
        if lang is None:
            lang = 'Python{0}'.format(determinePythonVersion(filename, source))
        if lang not in ['Python2', 'Python3']:
            return

        self.backgroundService.enqueueRequest('indent', lang, filename,
                                              [source])
예제 #6
0
    def __determineLanguage(self, filename, source):
        """
        Private methode to determine the language of the file.
        
        @param filename of the sourcefile (str)
        @param source code of the file (str)
        @return language of the file or None if not found (str or None)
        """
        pyVer = determinePythonVersion(filename, source)
        if pyVer:
            return 'Python{0}'.format(pyVer)

        for lang, (env, getArgs, getExt) in self.__supportedLanguages.items():
            if filename.endswith(tuple(getExt())):
                return lang

        return None
예제 #7
0
 def __determineLanguage(self, filename, source):
     """
     Private methode to determine the language of the file.
     
     @param filename of the sourcefile (str)
     @param source code of the file (str)
     @return language of the file or None if not found (str or None)
     """
     pyVer = determinePythonVersion(filename, source)
     if pyVer:
         return 'Python{0}'.format(pyVer)
     
     for lang, (env, getArgs, getExt) in self.__supportedLanguages.items():
         if filename.endswith(tuple(getExt())):
             return lang
     
     return None
예제 #8
0
    def styleCheck(self, lang, filename, source, args):
        """
        Public method to prepare a style check on one Python source file.

        @param lang language of the file or None to determine by internal
            algorithm (str or None)
        @param filename source filename (string)
        @param source string containing the code to check (string)
        @param args arguments used by the codeStyleCheck function (list of
            excludeMessages (str), includeMessages (str), repeatMessages
            (bool), fixCodes (str), noFixCodes (str), fixIssues (bool),
            maxLineLength (int), hangClosing (bool), docType (str), errors
            (list of str), eol (str), encoding (str))
        """
        if lang is None:
            lang = 'Python{0}'.format(determinePythonVersion(filename, source))
        if lang not in ['Python2', 'Python3']:
            return
        
        data = [source, args]
        self.backgroundService.enqueueRequest('style', lang, filename, data)
    def styleCheck(self, lang, filename, source, args):
        """
        Public method to prepare a style check on one Python source file.

        @param lang language of the file or None to determine by internal
            algorithm (str or None)
        @param filename source filename (string)
        @param source string containing the code to check (string)
        @param args arguments used by the codeStyleCheck function (list of
            excludeMessages (str), includeMessages (str), repeatMessages
            (bool), fixCodes (str), noFixCodes (str), fixIssues (bool),
            maxLineLength (int), hangClosing (bool), docType (str), errors
            (list of str), eol (str), encoding (str))
        """
        if lang is None:
            lang = 'Python{0}'.format(determinePythonVersion(filename, source))
        if lang not in ['Python2', 'Python3']:
            return

        data = [source, args]
        self.backgroundService.enqueueRequest('style', lang, filename, data)