- tagfile = apt_pkg.ParseTagFile(open(STATE_FILE))
- while tagfile.Step():
- pkgname = tagfile.Section.get("Package")
- autoInst = tagfile.Section.get("Auto-Installed")
+ tagfile = apt_pkg.TagFile(open(STATE_FILE))
+ for section in tagfile:
+ pkgname = section.get("Package")
+ autoInst = section.get("Auto-Installed")
outfile = open(STATE_FILE+".tmp","w")
except IOError, msg:
print "%s, are you root?" % (msg)
sys.exit(1)
outfile = open(STATE_FILE+".tmp","w")
except IOError, msg:
print "%s, are you root?" % (msg)
sys.exit(1)
- while tagfile.Step():
- pkgname = tagfile.Section.get("Package")
- autoInst = tagfile.Section.get("Auto-Installed")
+ for section in tagfile:
+ pkgname = section.get("Package")
+ autoInst = section.get("Auto-Installed")
- outfile.write(str(tagfile.Section)+"\n")
+ outfile.write(str(section)+"\n")
+ if action == 1:
+ for pkgname in pkgs:
+ if options.verbose:
+ print "changing %s to %s" % (pkgname,action)
+ outfile.write("Package: %s\nAuto-Installed: %d\n\n" % (pkgname, action))
# all done, rename the tmpfile
os.chmod(outfile.name, 0644)
os.rename(outfile.name, STATE_FILE)
# all done, rename the tmpfile
os.chmod(outfile.name, 0644)
os.rename(outfile.name, STATE_FILE)
parser.add_option("-f", "--file", action="store", type="string",
dest="filename",
help="read/write a different file")
parser.add_option("-f", "--file", action="store", type="string",
dest="filename",
help="read/write a different file")
help="print verbose status messages to stdout")
(options, args) = parser.parse_args()
help="print verbose status messages to stdout")
(options, args) = parser.parse_args()