add missing module

This commit is contained in:
Faik Uygur
2008-03-19 10:20:19 +00:00
parent b57157194e
commit 2cb67da312
+47
View File
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2008, TUBITAK/UEKAE
#
# 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; either version 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
import os
import fnmatch
import pisi.db
def exclude_from(packages, exfrom):
if not os.path.exists(exfrom):
return packages
patterns = []
if os.path.exists(exfrom):
for line in open(exfrom, "r").readlines():
if not line.startswith('#') and not line == '\n':
patterns.append(line.strip())
if patterns:
return exclude(packages, patterns)
return packages
def exclude(packages, patterns):
packages = set(packages)
componentdb = pisi.db.componentdb.ComponentDB()
for pattern in patterns:
# match pattern in package names
match = fnmatch.filter(packages, pattern)
packages = packages - set(match)
if not match:
# match pattern in component names
for compare in fnmatch.filter(componentdb.list_components(), pattern):
packages = packages - set(componentdb.get_union_packages(compare, walk=True))
return list(packages)