dirs geri gel (refactor ederken dikkat lütfen...)
This commit is contained in:
+39
-8
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
# -*- 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
|
||||
# the terms of the GNU General Public License as published by the Free
|
||||
@@ -10,19 +10,50 @@
|
||||
#
|
||||
# Please read the COPYING file.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import pisi
|
||||
|
||||
def show_info(filename):
|
||||
pisi.api.init(database=False)
|
||||
pisi.api.init(database=False, comar=False)
|
||||
metadata, files = pisi.api.info_file(filename)
|
||||
pisi.api.finalize()
|
||||
|
||||
paths = [fileinfo.path for fileinfo in files.list]
|
||||
paths.sort()
|
||||
for path in paths:
|
||||
print '/' + path
|
||||
pisi.api.finalize()
|
||||
return 0
|
||||
return paths
|
||||
|
||||
def uniq(alist):
|
||||
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__":
|
||||
for x in sys.argv[1:]:
|
||||
show_info(x)
|
||||
sys.exit(main())
|
||||
|
||||
Reference in New Issue
Block a user