test.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. class Plugin(core.api.Plugin, core.api.Child, core.api.IConfigurable):
  21. def declare_configuration(self, parser):
  22. parser.add_option("--std.code.test.on", action="store_true", default=False,
  23. help="Enables test plugin (for development purposes) [default: %default]")
  24. def configure(self, options):
  25. self.is_active = options.__dict__['std.code.test.on']
  26. def initialize(self):
  27. if self.is_active == True:
  28. core.api.subscribe_by_parents_interface(core.api.ICode, self)
  29. def callback(self, parent, data, is_updated):
  30. def print_rec(data, indent, region_id):
  31. print (" ." * indent) + str(data.get_region(region_id).get_type()) + " " + data.get_region(region_id).get_name() + " " + str(data.get_region(region_id).get_cursor())
  32. for sub_id in data.get_region(region_id).iterate_subregion_ids():
  33. print_rec(data, indent + 1, sub_id)
  34. print_rec(data, 0, 1)