Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 146740 Details for
Bug 224782
useless comps out the wazoo
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
comps filtering
compsfilter.py (text/plain), 5.33 KB, created by
Bill Nottingham
on 2007-01-27 06:20:19 UTC
(
hide
)
Description:
comps filtering
Filename:
MIME Type:
Creator:
Bill Nottingham
Created:
2007-01-27 06:20:19 UTC
Size:
5.33 KB
patch
obsolete
>#!/usr/bin/python -tt ># This program is free software; you can redistribute it and/or modify ># it under the terms of the GNU General Public License as published by ># the Free Software Foundation; version 2 of the License. ># ># This program is distributed in the hope that it will be useful, ># but WITHOUT ANY WARRANTY; without even the implied warranty of ># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ># GNU Library General Public License for more details. ># ># You should have received a copy of the GNU General Public License ># along with this program; if not, write to the Free Software ># Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. > > >from yum import comps >try: > from xml.etree import cElementTree >except ImportError: > import cElementTree >iterparse = cElementTree.iterparse >import os,sys >from fnmatch import fnmatch > >class FilteredCategory(comps.Category): > def __init__(self, elem = None, group_filter = None): > self.group_filter = group_filter > comps.Category.__init__(self, elem) > > def parse_group_list(self, grouplist_elem): > for child in grouplist_elem: > if child.tag == 'groupid': > found = False > for g in self.group_filter: > if fnmatch(child.text, g): > found = True > if found: > child.clear() > else: > groupid = child.text > self._groups[groupid] = 1 > > >class FilteredComps(comps.Comps): > def __init__(self, overwrite_groups=False, compsfilter = None): > comps.Comps.__init__(self,overwrite_groups) > self.filtered_categories = [] > self.filtered_groups = [] > self.top = None > if compsfilter: > f = open(compsfilter,'r') > lines = f.readlines() > f.close() > for line in lines: > line = line.strip() > if not line.startswith('#'): > if line.startswith('@'): > self.filtered_categories.append(line[1:]) > else: > self.filtered_groups.append(line) > > def dump(self, file = sys.stdout): > if self.top: > cElementTree.ElementTree(self.top).write(file,'UTF-8') > > > def add(self, srcfile = None): > if not srcfile: > raise CompsException > > if type(srcfile) == type('str'): > infile = open(srcfile, 'rt') > else: > infile = srcfile > > self.compscount += 1 > self.compiled = False > > self.parser = iterparse(infile) > > for event, elem in self.parser: > if elem.tag == 'comps': > self.top = elem > if elem.tag == "group": > group = comps.Group(elem) > found = False > for g in self.filtered_groups: > if fnmatch(group.groupid, g): > found = True > if found: > elem.clear() > else: > if self._groups.has_key(group.groupid): > thatgroup = self._groups[group.groupid] > thatgroup.add(group) > else: > self._groups[group.groupid] = group > > if elem.tag == "category": > category = FilteredCategory(elem, self.filtered_groups) > found = False > for c in self.filtered_categories: > if fnmatch(category.categoryid, c): > found = True > if found: > elem.clear() > else: > if self._categories.has_key(category.categoryid): > thatcat = self._categories[category.categoryid] > thatcat.add(category) > else: > self._categories[category.categoryid] = category > > # Can't just clear elements - need them out of the tree. Why > # we need to iterate twice, I'm not sure. > > parent_map = dict((c, p) for p in self.top.getiterator() for c in p) > for g in self.top.getiterator('groupid'): > if not g.text: > parent = parent_map[g] > parent.remove(g) > for g in self.top.getiterator('groupid'): > if not g.text: > parent = parent_map[g] > parent.remove(g) > for g in self.top.getiterator('group'): > if not g.text: > parent = parent_map[g] > parent.remove(g) > for g in self.top.getiterator('group'): > if not g.text: > parent = parent_map[g] > parent.remove(g) > for g in self.top.getiterator('category'): > if not g.text: > parent = parent_map[g] > parent.remove(g) > for g in self.top.getiterator('category'): > if not g.text: > parent = parent_map[g] > parent.remove(g) > > > >def main(): > > try: > compsfile = sys.argv[1] > compsfilter = sys.argv[2] > except: > print >> sys.stderr, "bad usage" > sys.exit(1) > > p = FilteredComps(compsfilter = compsfilter) > p.add(compsfile) > p.dump() >if __name__ == '__main__': > main()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 224782
: 146740