dirs geri gel (refactor ederken dikkat lütfen...)

This commit is contained in:
S.Çağlar Onur
2006-05-25 12:03:08 +00:00
parent 3a77958b78
commit 612d21865b
+39 -8
View File
@@ -1,7 +1,7 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# Copyright (C) 2005, TUBITAK/UEKAE # Copyright (C) 2006, TUBITAK/UEKAE
# #
# This program is free software; you can redistribute it and/or modify it under # 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 # the terms of the GNU General Public License as published by the Free
@@ -10,19 +10,50 @@
# #
# Please read the COPYING file. # Please read the COPYING file.
import os
import sys import sys
import pisi import pisi
def show_info(filename): def show_info(filename):
pisi.api.init(database=False) pisi.api.init(database=False, comar=False)
metadata, files = pisi.api.info_file(filename) metadata, files = pisi.api.info_file(filename)
pisi.api.finalize()
paths = [fileinfo.path for fileinfo in files.list] paths = [fileinfo.path for fileinfo in files.list]
paths.sort() paths.sort()
for path in paths: return paths
print '/' + path
pisi.api.finalize() def uniq(alist):
return 0 set = {}
return [set.setdefault(e, e) for e in alist if e not in set]
def usage(errmsg):
print """
Error: %s
Usage:
lspisi PiSi_package.PiSi (lists the content of package)
lspisi dirs PiSi_package.PiSi (lists directories in the package for the package developer)
""" % (errmsg)
sys.exit(1)
def main():
if len(sys.argv) < 2 or ("dirs" in sys.argv and len(sys.argv) < 3):
usage("PiSi package required...")
if sys.argv[1] == "dirs":
dirlist = []
for file in show_info(sys.argv[2]):
dirlist.append(os.path.dirname(file))
for dir in uniq(dirlist):
print "<Path fileType=\"\">%s</Path>" % dir
else:
for file in show_info(sys.argv[1]):
print "/%s" % file
if __name__ == "__main__": if __name__ == "__main__":
for x in sys.argv[1:]: sys.exit(main())
show_info(x)