Subversion Repositories programming

Rev

Rev 184 | Rev 368 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 184 Rev 366
Line 44... Line 44...
44
            sys.exit()
44
            sys.exit()
45
 
45
 
46
        ### Get a LIST containing each line in the file
46
        ### Get a LIST containing each line in the file
47
        lines = [l for l in data.split('\n') if len(l) > 0]
47
        lines = [l for l in data.split('\n') if len(l) > 0]
48
 
48
 
-
 
49
        ### Remove comments / blank lines (zero length lines already removed above)
-
 
50
        regex = re.compile ('^\s*#.*$')
-
 
51
        lines = [l for l in lines if not re.match (regex, l)]
-
 
52
        regex = re.compile ('^\s*$')
-
 
53
        lines = [l for l in lines if not re.match (regex, l)]
-
 
54
 
49
        ### Split each line into a tuple, and strip each element of spaces
55
        ### Split each line into a tuple, and strip each element of spaces
50
        result = self.split_lines(lines)
56
        result = self.split_lines(lines)
51
        result = [(re.compile(r), d) for r, d in result]
57
        result = [(re.compile(r), d) for r, d in result]
52
 
58
 
53
        ### Give some information about the dictionary we are using
59
        ### Give some information about the dictionary we are using
Line 58... Line 64...
58
    def split_lines(self, lines):
64
    def split_lines(self, lines):
59
 
65
 
60
        result = []
66
        result = []
61
 
67
 
62
        for l in lines:
68
        for l in lines:
63
            l = l.strip()
-
 
64
 
69
 
65
            if len(l) > 0:
-
 
66
                if l[0] == '#':
-
 
67
                    continue
-
 
68
 
-
 
69
                try:
70
            try:
70
                    r, d = l.split('=')
71
                r, d = l.split('=')
71
                    r = r.strip()
72
                r = r.strip()
72
                    d = d.strip()
73
                d = d.strip()
73
                except ValueError:
74
            except ValueError:
74
                    self.add_to_print_queue(DICT_BAD_LINE, l)
75
                self.add_to_print_queue(DICT_BAD_LINE, l)
75
                    continue
76
                continue
76
 
77
 
77
                result.append( (r, d) )
78
            result.append((r, d))
78
 
79
 
79
        return result
80
        return result
80
 
81
 
81
    def get_matches(self, files, pattern):
82
    def get_matches(self, files, pattern):
82
        """get_matches(files, pattern):
83
        """get_matches(files, pattern):