Esempio n. 1
0
    def _compile_shell_pattern(cls, pattern):
        bits = pattern.split()
        if len(bits) > 1:
            regexes = [misc.shell_to_regex(b)[:-1] for b in bits]
            regex = "(%s)$" % "|".join(regexes)
        elif len(bits):
            regex = misc.shell_to_regex(bits[0])
        else:
            # An empty pattern would match everything, so skip it
            return None

        try:
            compiled = re.compile(regex)
        except re.error:
            compiled = None

        return compiled
Esempio n. 2
0
        cvsfiles = map(lambda x: x[1], matches)
        # ignored
        try:
            ignored = open(os.path.join(os.environ["HOME"],
                                        ".cvsignore")).read().split()
        except (IOError, KeyError):
            ignored = []
        try:
            ignored += open(os.path.join(directory,
                                         ".cvsignore")).read().split()
        except IOError:
            pass

        if len(ignored):
            try:
                regexes = [misc.shell_to_regex(i)[:-1] for i in ignored]
                ignore_re = re.compile("(" + "|".join(regexes) + ")")
            except re.error, e:
                misc.run_dialog(
                    _("Error converting to a regular expression\n"
                      "The pattern was '%s'\n"
                      "The error was '%s'") % (",".join(ignored), e))
        else:

            class dummy(object):
                def match(self, *args):
                    return None

            ignore_re = dummy()

        for f, path in files:
Esempio n. 3
0
                retfiles.append( _vc.File(path, name, state, rev, tag, options) )
        # known
        cvsfiles = map(lambda x: x[1], matches)
        # ignored
        try:
            ignored = open(os.path.join(os.environ["HOME"], ".cvsignore")).read().split()
        except (IOError, KeyError):
            ignored = []
        try:
            ignored += open( os.path.join(directory, ".cvsignore")).read().split()
        except IOError:
            pass

        if len(ignored):
            try:
                regexes = [ misc.shell_to_regex(i)[:-1] for i in ignored ]
                ignore_re = re.compile( "(" + "|".join(regexes) + ")" )
            except re.error, e:
                misc.run_dialog(_("Error converting to a regular expression\n"
                                  "The pattern was '%s'\n"
                                  "The error was '%s'") % (",".join(ignored), e))
        else:
            class dummy(object):
                def match(self, *args): return None
            ignore_re = dummy()

        for f,path in files:
            if f not in cvsfiles:
                state = ignore_re.match(f) == None and _vc.STATE_NONE or _vc.STATE_IGNORED
                retfiles.append( _vc.File(path, f, state, "") )
        for d,path in dirs: