Dash:
[t2-trunk.git] / misc / lua / parse-desc.lua
blob2e69efaf91d5ccc71bd4cddb31ff6861cc64c935
1 #!/usr/bin/env lua
2 -- --- T2-COPYRIGHT-NOTE-BEGIN ---
3 -- This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 --
5 -- T2 SDE: misc/lua/parse-desc.lua
6 -- Copyright (C) 2005 - 2006 The T2 SDE Project
7 --
8 -- More information can be found in the files COPYING and README.
9 --
10 -- This program is free software; you can redistribute it and/or modify
11 -- it under the terms of the GNU General Public License as published by
12 -- the Free Software Foundation; version 2 of the License. A copy of the
13 -- GNU General Public License can be found in the file COPYING.
14 -- --- T2-COPYRIGHT-NOTE-END ---
16 -- try this:
17 --
18 -- this file looks quite complicated already, but a comparsion to grep might help:
20 -- time lua misc/lua/parse-desc.lua package/base/*/*.desc > /dev/null
21 -- time grep "^[[]" package/base/*/*.desc > /dev/null
24 require "misc/lua/sde/desc"
26 if #arg < 1 then
27 print("Usage: lua misc/lua/parse-desc.lua [path-to-desc-file]")
28 os.exit(1)
29 end
31 function printf(...)
32 io.write(string.format(unpack(arg)))
33 end
36 -- parse all files
37 pkgs = {}
38 for i,file in ipairs(arg) do
39 if i > 0 then
40 _,_,repo,pkg = string.find(file, "package/([^/]*)/([^/]*)/*");
42 -- put all parsed files into a table
43 pkgs[pkg] = desc.parse(file)
44 end
45 end
47 -- output
48 for pkg,tab in pairs(pkgs) do
49 printf("Package %s:\n", pkg);
51 for k,v in pairs(tab) do
52 if type(v) == "table" then
53 printf(" %s: %s\n", k, table.concat(v,"\n "));
54 else
55 printf(" %s: %s\n", k, v);
56 end
57 end
58 end