info.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #
  2. # Metrix++, Copyright 2009-2013, Metrix++ Project
  3. # Link: http://metrixplusplus.sourceforge.net
  4. #
  5. # This file is a part of Metrix++ Tool.
  6. #
  7. # Metrix++ is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, version 3 of the License.
  10. #
  11. # Metrix++ is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with Metrix++. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. import logging
  20. import time
  21. import core.db.loader
  22. import core.db.post
  23. import core.log
  24. import core.cmdparser
  25. def main():
  26. exit_code = 0
  27. log_plugin = core.log.Plugin()
  28. db_plugin = core.db.post.Plugin()
  29. parser = core.cmdparser.MultiOptionParser(usage="Usage: %prog [options]")
  30. log_plugin.declare_configuration(parser)
  31. db_plugin.declare_configuration(parser)
  32. (options, args) = parser.parse_args()
  33. log_plugin.configure(options)
  34. db_plugin.configure(options)
  35. args = args # used
  36. loader = core.db.loader.Loader()
  37. loader.open_database(db_plugin.dbfile)
  38. loader_prev = None
  39. if db_plugin.dbfile_prev != None:
  40. loader_prev = core.db.loader.Loader()
  41. loader_prev.open_database(db_plugin.dbfile_prev)
  42. print "Properties:"
  43. for each in loader.iterate_properties():
  44. prev_value_str = ""
  45. if loader_prev != None:
  46. prev = loader_prev.get_property(each.name)
  47. if prev != each.value:
  48. prev_value_str = " [previous file: " + loader_prev.get_property(each.name) + "]"
  49. print "(!)",
  50. print "\t" + each.name + "\t=>\t" + each.value + prev_value_str
  51. print "Namespaces:"
  52. for each in loader.iterate_namespace_names():
  53. prev_value_str = ""
  54. if loader_prev != None:
  55. prev = loader_prev.get_namespace(each)
  56. if prev == None:
  57. prev_value_str = " [previous file: missed]"
  58. print "(!)",
  59. print "\t" + each + prev_value_str
  60. for field in loader.get_namespace(each).iterate_field_names():
  61. prev_value_str = ""
  62. if loader_prev != None:
  63. prev = loader_prev.get_namespace(each).get_field_packager(field)
  64. if prev == None:
  65. prev_value_str = " [previous file: missed]"
  66. print "(!)",
  67. print "\t\t- " + field + prev_value_str
  68. return exit_code
  69. if __name__ == '__main__':
  70. ts = time.time()
  71. core.log.set_default_format()
  72. exit_code = main()
  73. logging.warning("Exit code: " + str(exit_code) + ". Time spent: " + str(round((time.time() - ts), 2)) + " seconds. Done")
  74. exit(exit_code) # number of reported messages, errors are reported as non-handled exceptions