OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.5 KiB

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