From d89c26e8ded908ce1d96a44a42f56a7a03977b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=2E=C3=87a=C4=9Flar=20Onur?= Date: Wed, 14 Feb 2007 23:04:28 +0000 Subject: [PATCH] =?UTF-8?q?pisi=20taraf=C4=B1ndan=20kurulmam=C4=B1=C5=9F?= =?UTF-8?q?=20dosyalar=C4=B1=20bulan=20arkada=C5=9F,=20'./unownedfiles.py?= =?UTF-8?q?=20/sbin/'=20=C5=9Feklinde=20=C3=A7al=C4=B1=C5=9F=C4=B1yor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/unownedfiles.py | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 scripts/unownedfiles.py diff --git a/scripts/unownedfiles.py b/scripts/unownedfiles.py new file mode 100755 index 00000000..66c05327 --- /dev/null +++ b/scripts/unownedfiles.py @@ -0,0 +1,48 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Copyright (C) 2005, 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 sys +import piksemel + + +def findFilesXML(path): + filesXMLs = list() + for root, dirs, files in os.walk(path): + for file in files: + if file == "files.xml": + filesXMLs.append(os.path.join(root, file)) + return filesXMLs + +def parseFilesXML(): + files = set() + for filesXML in findFilesXML("/var/lib/pisi/package/"): + data = open(filesXML).read() + data = piksemel.parseString(data) + for filePath in data.tags("File"): + path = filePath.getTagData("Path") + if filePath.getTag("Hash"): + files.add("/%s" % path) + return files + +if __name__ == "__main__": + try: + sys.argv[1] + except IndexError: + sys.exit("Unsufficient arguments...") + + fileSet = parseFilesXML() + + for root, dirs, files in os.walk(sys.argv[1]): + for file in files: + f = os.path.join(root, file) + if not fileSet.__contains__(f): + print f