post.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #
  2. # Metrix++, Copyright 2009-2013, Metrix++ Project
  3. # Link: http://swi.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 [default: %default].")
  28. def configure(self, options):
  29. self.dbfile = options.__dict__['general.db_file']
  30. self.dbfile_prev = options.__dict__['general.db_file_prev']
  31. def initialize(self):
  32. self.get_plugin_loader().get_database_loader().create_database(self.dbfile, previous_db = self.dbfile_prev)
  33. # do not process files dumped by this module
  34. self.get_plugin_loader().get_plugin('core.dir').add_exclude_rule(re.compile(r'^' + os.path.basename(self.dbfile) + r'$'))
  35. if self.dbfile_prev != None:
  36. self.get_plugin_loader().get_plugin('core.dir').add_exclude_rule(re.compile(r'^' + os.path.basename(self.dbfile_prev) + r'$'))