]>
Commit | Line | Data |
---|---|---|
d8d56d0f JR |
1 | # vi: encoding=utf-8 ts=8 sts=4 sw=4 et |
2 | ||
3 | import string | |
4 | import fnmatch | |
5 | import os | |
6 | import stat | |
7 | import re | |
8 | ||
9 | import path | |
10 | import log | |
11 | import status | |
12 | from mailer import Message | |
13 | from config import config | |
14 | ||
15 | class Blacklist_File: | |
16 | def __init__(self): | |
17 | self.reload() | |
18 | ||
19 | def try_reload(self): | |
20 | mtime = os.stat(path.blacklist_file)[stat.ST_MTIME] | |
21 | if mtime != self.blacklist_file_mtime: | |
22 | log.notice("blacklist file has changed, reloading...") | |
23 | self.reload() | |
24 | return True | |
25 | return False | |
26 | ||
27 | def reload(self): | |
28 | self.blacklist_file_mtime = os.stat(path.blacklist_file)[stat.ST_MTIME] | |
aeaf1b73 | 29 | self.blacklist = set() |
d8d56d0f JR |
30 | status.push("reading package-blacklist") |
31 | with open(path.blacklist_file) as f: | |
32 | for l in f: | |
33 | p = l.rstrip() | |
34 | if re.match(r"^#.*", p): | |
35 | continue | |
aeaf1b73 KK |
36 | self.blacklist.add(p) |
37 | log.notice("blacklist added: %s" % l) | |
d8d56d0f JR |
38 | status.pop() |
39 | ||
40 | def package(self, p): | |
41 | # log.notice("blacklist check: %s (%d)" % (p, self.blacklist.has_key(p))) | |
aeaf1b73 | 42 | if p in self.blacklist: |
d8d56d0f JR |
43 | return True |
44 | return False | |
45 | ||
46 | def packages(self): | |
47 | return self.blacklist | |
48 | ||
49 | blacklist = Blacklist_File() |