Ejemplo n.º 1
0
    def getFilteredClassList(classes, includePatt_, excludePatt_):
        # Although lint-check doesn't work with dependencies, we allow
        # '=' in class pattern for convenience; strip those now
        intelli, explicit = textutil.splitPrefixedStrings(includePatt_)
        includePatt = intelli + explicit
        intelli, explicit = textutil.splitPrefixedStrings(excludePatt_)
        excludePatt = intelli + explicit
        if len(includePatt):
            incRegex = map(textutil.toRegExpS, includePatt)
            incRegex = re.compile("|".join(incRegex))
        else:
            incRegex = re.compile(".")  # catch-all
        if len(excludePatt):
            excRegex = map(textutil.toRegExpS, excludePatt)
            excRegex = re.compile("|".join(excRegex))
        else:
            excRegex = re.compile("^$")  # catch-none

        classesFiltered = (c for c in classes if incRegex.search(c) and not excRegex.search(c))
        return classesFiltered
Ejemplo n.º 2
0
    def getFilteredClassList(classes, includePatt_, excludePatt_):
        # Although lint-check doesn't work with dependencies, we allow
        # '=' in class pattern for convenience; strip those now
        intelli, explicit = textutil.splitPrefixedStrings(includePatt_)
        includePatt = intelli + explicit
        intelli, explicit = textutil.splitPrefixedStrings(excludePatt_)
        excludePatt = intelli + explicit
        if len(includePatt):
            incRegex = map(textutil.toRegExpS, includePatt)
            incRegex = re.compile("|".join(incRegex))
        else:
            incRegex = re.compile(".")  # catch-all
        if len(excludePatt):
            excRegex = map(textutil.toRegExpS, excludePatt)
            excRegex = re.compile("|".join(excRegex))
        else:
            excRegex = re.compile("^$")  # catch-none

        classesFiltered = (c for c in classes
                           if incRegex.search(c) and not excRegex.search(c))
        return classesFiltered
Ejemplo n.º 3
0
        def getExcludes(excludeCfg):
            #excludeCfg = self._job.get("exclude", [])
            excludeWithDeps = []
            excludeWithDepsHard = []
            ignore_excludes = self._job.get("config-warnings/exclude", [])

            if len(excludeCfg) == 0:
                return [], []
            else:
                if '*' not in ignore_excludes:  # check individually
                    complain_excludes = [
                        x for x in excludeCfg if not x in ignore_excludes
                    ]
                    if complain_excludes:
                        self._console.warn("Excludes may break code (%r)" %
                                           complain_excludes)

            # Splitting lists
            self._console.debug("Preparing exclude configuration...")
            excludeWithDeps, excludeWithDepsHard = textutil.splitPrefixedStrings(
                excludeCfg)

            # Configuration feedback
            self._console.indent()

            if len(excludeWithDepsHard) > 0:
                #if self._job.get("config-warnings/exclude", True):
                #    self._console.warn("Excluding without dependencies is not supported, treating them as normal excludes: %r" % excludeWithDepsHard)
                #excludeWithDeps.extend(excludeWithDepsHard)
                #excludeWithDepsHard = []
                pass
            self._console.debug(
                "Excluding %s items smart, %s items explicit" %
                (len(excludeWithDeps), len(excludeWithDepsHard)))

            self._console.outdent()

            # Resolve regexps
            self._console.indent()
            self._console.debug("Expanding expressions...")
            for list_ in (excludeWithDeps, excludeWithDepsHard):
                lst = list_[:]
                list_[:] = []
                for elem in lst:
                    try:
                        expanded = textutil.expandGlob(elem, self._classesObj)
                    except RuntimeError, ex:
                        if elem not in ignore_excludes:
                            self._console.warn(
                                "Invalid exclude block: %s\n%s" %
                                (excludeCfg, ex))
                    else:
                        list_.extend(expanded)
Ejemplo n.º 4
0
        def getIncludes(includeCfg):

            # Splitting lists
            self._console.debug("Preparing include configuration...")
            includeWithDeps, includeNoDeps = textutil.splitPrefixedStrings(
                includeCfg)
            self._console.indent()

            if len(includeWithDeps) > 0 or len(includeNoDeps) > 0:
                # Configuration feedback
                self._console.debug(
                    "Including %s items smart, %s items explicit" %
                    (len(includeWithDeps), len(includeNoDeps)))

                if len(includeNoDeps) > 0:
                    if self._job.get("config-warnings/include", True):
                        self._console.warn(
                            "Explicitly included classes may not work")  # ?!

                # Resolve regexps
                self._console.debug("Expanding expressions...")
                try:
                    includeWithDeps = textutil.expandGlobs(
                        includeWithDeps, self._classesObj)
                    includeNoDeps = textutil.expandGlobs(
                        includeNoDeps, self._classesObj)
                except RuntimeError:
                    self._console.error("Invalid include block: %s" %
                                        includeCfg)
                    raise

            elif self._job.get("packages"):
                # Special part include handling
                self._console.info("Including part classes...")
                partsCfg = partsCfg = self._job.get("packages/parts", {})
                includeWithDeps = []
                for partId in partsCfg:
                    includeWithDeps.extend(partsCfg[partId])

                # Configuration feedback
                self._console.debug(
                    "Including %s items smart, %s items explicit" %
                    (len(includeWithDeps), len(includeNoDeps)))

                # Resolve regexps
                self._console.debug("Expanding expressions...")
                includeWithDeps = textutil.expandGlobs(includeWithDeps,
                                                       self._classesObj)

            self._console.outdent()

            return includeWithDeps, includeNoDeps
Ejemplo n.º 5
0
        def getExcludes(excludeCfg):
            # excludeCfg = self._job.get("exclude", [])
            excludeWithDeps = []
            excludeWithDepsHard = []
            ignore_excludes = self._job.get("config-warnings/exclude", [])

            if len(excludeCfg) == 0:
                return [], []
            else:
                if "*" not in ignore_excludes:  # check individually
                    complain_excludes = [x for x in excludeCfg if not x in ignore_excludes]
                    if complain_excludes:
                        self._console.warn("Excludes may break code (%r)" % complain_excludes)

            # Splitting lists
            self._console.debug("Preparing exclude configuration...")
            excludeWithDeps, excludeWithDepsHard = textutil.splitPrefixedStrings(excludeCfg)

            # Configuration feedback
            self._console.indent()

            if len(excludeWithDepsHard) > 0:
                # if self._job.get("config-warnings/exclude", True):
                #    self._console.warn("Excluding without dependencies is not supported, treating them as normal excludes: %r" % excludeWithDepsHard)
                # excludeWithDeps.extend(excludeWithDepsHard)
                # excludeWithDepsHard = []
                pass
            self._console.debug(
                "Excluding %s items smart, %s items explicit" % (len(excludeWithDeps), len(excludeWithDepsHard))
            )

            self._console.outdent()

            # Resolve regexps
            self._console.indent()
            self._console.debug("Expanding expressions...")
            for list_ in (excludeWithDeps, excludeWithDepsHard):
                lst = list_[:]
                list_[:] = []
                for elem in lst:
                    try:
                        expanded = textutil.expandGlob(elem, self._classesObj)
                    except RuntimeError, ex:
                        if elem not in ignore_excludes:
                            self._console.warn("Invalid exclude block: %s\n%s" % (excludeCfg, ex))
                    else:
                        list_.extend(expanded)
Ejemplo n.º 6
0
        def getIncludes(includeCfg):

            # Splitting lists
            self._console.debug("Preparing include configuration...")
            includeWithDeps, includeNoDeps = textutil.splitPrefixedStrings(includeCfg)
            self._console.indent()

            if len(includeWithDeps) > 0 or len(includeNoDeps) > 0:
                # Configuration feedback
                self._console.debug(
                    "Including %s items smart, %s items explicit" % (len(includeWithDeps), len(includeNoDeps))
                )

                if len(includeNoDeps) > 0:
                    if self._job.get("config-warnings/include", True):
                        self._console.warn("Explicitly included classes may not work")  # ?!

                # Resolve regexps
                self._console.debug("Expanding expressions...")
                try:
                    includeWithDeps = textutil.expandGlobs(includeWithDeps, self._classesObj)
                    includeNoDeps = textutil.expandGlobs(includeNoDeps, self._classesObj)
                except RuntimeError:
                    self._console.error("Invalid include block: %s" % includeCfg)
                    raise

            elif self._job.get("packages"):
                # Special part include handling
                self._console.info("Including part classes...")
                partsCfg = partsCfg = self._job.get("packages/parts", {})
                includeWithDeps = []
                for partId in partsCfg:
                    includeWithDeps.extend(partsCfg[partId])

                # Configuration feedback
                self._console.debug(
                    "Including %s items smart, %s items explicit" % (len(includeWithDeps), len(includeNoDeps))
                )

                # Resolve regexps
                self._console.debug("Expanding expressions...")
                includeWithDeps = textutil.expandGlobs(includeWithDeps, self._classesObj)

            self._console.outdent()

            return includeWithDeps, includeNoDeps