On Tuesday 19 April 2011 16:09:22 Richard Hartmann wrote: > http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=600683#15 Thanks for the hint. Currently I have a script that removes entries from ~/.mrconfig for non-existing directories. The script runs just before my weekly global mr update via cron.
This way I can just rm -rf manually the repos I don't want to track anymore and let the config cleanup be done via cron. Script is attached and it's licensed as public domain if anyone wants to use it. Regards, Bastian
#!/usr/bin/python2.6
"""
Removes non-existant directories from ~/.mrconfig
Removed lines are printed.
"""
import re
import os
section_ro = re.compile(r'^\[(.+)\]\n$')
def main(args):
if args:
fname = args[0]
else:
fname = os.path.expanduser('~/.mrconfig')
section = None
remove = False
lines = []
with open(fname) as fd:
for line in fd:
mo = section_ro.match(line)
if mo:
section = mo.groups(1)[0]
if section != "DEFAULT":
remove = not check_path(section)
else:
remove = False
if remove:
print line,
else:
lines.append(line)
with open(fname, 'w') as fd:
for line in lines:
fd.write(line)
def check_path (section):
if not os.path.isabs(section):
path = os.path.join(os.environ["HOME"], section)
else:
path = section
return os.path.isdir(path)
if __name__ == '__main__':
import sys
main(sys.argv[1:])
signature.asc
Description: This is a digitally signed message part.

