- 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 %r"%left
- 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 %r"%left
- if fcdistro not in known_fcdistros:
- raise Exception, 'Unknown fcdistro %r'%fcdistro
- # 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 >> stderr,'%s:%d:qualifer %s does not apply'%(filename,lineno,left)
- continue
- # we're in, let's add (default) or remove (if plus_minus is minus)
- if plus_minus == '-':
- if self.options.verbose: print >> stderr,'%s:%d: from %s, excluding %r'%(filename,lineno,left,rights)
- excluded += rights.split()
- else:
- if self.options.verbose: print >> stderr,'%s:%d: from %s, including %r'%(filename,lineno,left,rights)
+ 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(f"Unknown keyword {left}")
+ elif left == self.keyword: