- ### Get a LIST containing each line in the file
- lines = [l for l in data.split('\n') if len(l) > 0]
-
- ### Remove comments / blank lines (zero length lines already removed above)
- regex = re.compile ('^\s*#.*$')
- lines = [l for l in lines if not re.match (regex, l)]
- regex = re.compile ('^\s*$')
- lines = [l for l in lines if not re.match (regex, l)]
-
- ### Split each line into a tuple, and strip each element of spaces
- result = self.split_lines(lines)
- result = [(re.compile(r), d) for r, d in result]
-
- ### Give some information about the dictionary we are using
- logging.info ('Successfully loaded %d records from %s\n' % \
- (len(result), self.options.dict_file))
-
- return tuple(result)
-
- def split_lines(self, lines):
+ ### Find all of the valid lines in the file
+ valid_lines = [l for l in raw_lines if self.__valid_dict_line (l)]