cout.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. SEVERITY_INFO = 0x01
  20. SEVERITY_WARNING = 0x02
  21. SEVERITY_ERROR = 0x03
  22. DETAILS_OFFSET = 15
  23. def notify(path, cursor, level, message, details = [], indent = 0):
  24. notification = (". " * indent) + path + ":" + (str(cursor) if cursor != None else "") + ": "
  25. if level == SEVERITY_INFO:
  26. notification += "info: "
  27. elif level == SEVERITY_WARNING:
  28. notification += "warning: "
  29. elif level == SEVERITY_ERROR:
  30. notification += "error: "
  31. else:
  32. assert(len("Invalid message severity level specified") == 0)
  33. notification += message + "\n"
  34. for each in details:
  35. notification += ((" " * indent) + "\t" +
  36. str(each[0]) + (" " * (DETAILS_OFFSET - len(each[0]))) + ": " + str(each[1]) + "\n")
  37. print notification