post.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 core.api
  20. import os.path
  21. import re
  22. class Plugin(core.api.Plugin, core.api.IConfigurable):
  23. def declare_configuration(self, parser):
  24. parser.add_option("--general.db-file", default='./metrixpp.db',
  25. help="Primary database file to write (by the collector) and post-process (by other tools) [default: %default]")
  26. parser.add_option("--general.db-file-prev", default=None,
  27. help="Database file with data collected for the past/previous revision."
  28. " If it is set for the collector tool to perform an incremental/iterative collection,"
  29. " it may reduce the processing time significantly."
  30. " Post-processing tools use it in order to recognise/evaluate change trends. [default: %default].")
  31. def configure(self, options):
  32. self.dbfile = options.__dict__['general.db_file']
  33. self.dbfile_prev = options.__dict__['general.db_file_prev']
  34. def initialize(self):
  35. self.get_plugin_loader().get_database_loader().create_database(self.dbfile, previous_db = self.dbfile_prev)
  36. # do not process files dumped by this module
  37. self.get_plugin_loader().get_plugin('core.dir').add_exclude_rule(re.compile(r'^' + os.path.basename(self.dbfile) + r'$'))
  38. if self.dbfile_prev != None:
  39. self.get_plugin_loader().get_plugin('core.dir').add_exclude_rule(re.compile(r'^' + os.path.basename(self.dbfile_prev) + r'$'))