Jörg Sommer hat am Sat 01. Oct, 11:58 (+0200) geschrieben: > % diff /tmp/checkrestart =checkrestart > --- /tmp/checkrestart 2011-10-01 11:49:58.607365215 +0200 > +++ /usr/sbin/checkrestart 2011-10-01 11:50:04.000000000 +0200 > @@ -188,7 +188,7 @@ > if os.path.exists(path): > package.initscripts.append(path) > # Remove duplicate inits > - package.initscripts = [ u for u in package.initscripts if u not > in locals()['_[1]'] ] > + package.initscripts = list(set(package.initscripts)) > > restartable = [] > nonrestartable = []
This patch uses a set for initscripts from the beginning:
--- /tmp/checkrestart 2011-10-01 11:49:58.607365215 +0200
+++ /usr/sbin/checkrestart 2011-10-01 13:59:01.000000000 +0200
@@ -180,15 +180,13 @@
if path.startswith('/etc/init.d/'):
if path.endswith('.sh'):
continue
- package.initscripts.append(path)
+ package.initscripts.add(path)
# Alternatively, find init.d scripts that match the process name
if len(package.initscripts) == 0:
for process in package.processes:
path = '/etc/init.d/' + os.path.basename(process.program)
if os.path.exists(path):
- package.initscripts.append(path)
- # Remove duplicate inits
- package.initscripts = [ u for u in package.initscripts if u not in
locals()['_[1]'] ]
+ package.initscripts.add(path)
restartable = []
nonrestartable = []
@@ -452,7 +450,8 @@
class Package:
def __init__(self, name):
self.name = name
- self.initscripts = []
+ # use a set, we don't need duplicates
+ self.initscripts = {}
self.processes = []
if __name__ == '__main__':
--
Optimisten haben gar keine Ahnung von den freudigen Überraschungen, die
Pessimisten erleben.
(Peter Bramm)
signature.asc
Description: Digital signature http://en.wikipedia.org/wiki/OpenPGP

