utils.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 re
  21. def check_db_metadata(loader, loader_prev):
  22. for each in loader.iterate_properties():
  23. prev = loader_prev.get_property(each.name)
  24. if prev != each.value:
  25. logging.warn("Previous data file has got different metadata:")
  26. logging.warn(" - identification of change trends can be not reliable")
  27. logging.warn(" - use 'info' tool to view more details")
  28. return 1
  29. return 0
  30. def preprocess_path(path):
  31. path = re.sub(r'''[\\]+''', "/", path)
  32. logging.info("Processing: " + path)
  33. return path
  34. def report_bad_path(path):
  35. logging.error("Specified path '" + path + "' is invalid: not found in the database records.")