- for line in file(filename).readlines():
- lineno += 1
- line = line.strip()
- if self.m_comment.match(line) or self.m_blank.match(line):
- continue
- try:
- lefts, rights = line.split(':', 1)
- for left in lefts.split():
- ########## single ident
- if self.m_ident.match(left):
- if left not in known_keywords:
- raise Exception("Unknown keyword {left}".format(**locals()))
- elif left == self.keyword:
- included += rights.split()
- else:
- m = self.m_qualified.match(left)
- if m:
- (plus_minus, kw, qual, fcdistro) = m.groups()
- if kw not in known_keywords:
- raise Exception("Unknown keyword in {left}".format(**locals()))
- if fcdistro not in known_fcdistros:
- raise Exception('Unknown fcdistro {fcdistro}'.format(**locals()))
- # skip if another keyword
- if kw != self.keyword: continue
- # does this fcdistro match ?
- (distro, version) = m_fcdistro_cutter.match(fcdistro).groups()
- version = int (version)
- # skip if another distro family
- if distro != self.distro: continue
- # skip if the qualifier does not fit
- if not self.match (qual, version):
- if self.options.verbose:
- print('{filename}:{lineno}:qualifer {left} does not apply'
- .format(**locals()), file=stderr)
- continue
- # we're in, let's add (default) or remove (if plus_minus is minus)
- if plus_minus == '-':
- if self.options.verbose:
- print('{filename}:{lineno}: from {left}, excluding {rights}'
- .format(**locals()), file=stderr)
- excluded += rights.split()
- else:
- if self.options.verbose:
- print('{filename}:{lineno}: from {left}, including {rights}'\
- .format(**locals()), file=stderr)
+ with open(filename) as feed:
+ for lineno, line in enumerate(feed, 1):
+ line = line.strip()
+ if self.m_comment.match(line) or self.m_blank.match(line):
+ continue
+ try:
+ lefts, rights = line.split(':', 1)
+ for left in lefts.split():
+ ########## single ident
+ if self.m_ident.match(left):
+ if left not in known_keywords:
+ raise Exception("Unknown keyword {left}".format(**locals()))
+ elif left == self.keyword: