Posted By

phalkunz on 05/22/09


Tagged

svn Bash python productivity


Versions (?)

Color coded SVN status


 / Published in: Python
 

URL: http://phalkunz.com/2009/05/23/print-color-coded-svn-status/

  1. #!/usr/bin/python
  2. """
  3. Author: Saophalkun Ponlu (http://phalkunz.com)
  4. Date: May 23, 2009
  5. """
  6.  
  7. import sys, os, re
  8.  
  9. # add more status & color codes
  10. colors = {
  11. "M": "31", # red
  12. "\?": "32", # green
  13. "C": "30;41" # black on red
  14. }
  15.  
  16. # build a paramter list
  17. parameters = "";
  18. for i in range(1, sys.argv.__len__()):
  19. parameters += sys.argv[i] + " ";
  20.  
  21. status = os.popen('svn st ' + parameters);
  22. for line in status:
  23. passed = False
  24. # remove newline character from the line
  25. line = re.sub("\n", "", line)
  26.  
  27. for color in colors:
  28. match = re.match(color+(" "*6), line)
  29. if match:
  30. os.popen("echo '\E[" + colors[color] + "m" + line + "\E[m'", 'w')
  31. passed = True
  32. if(passed):
  33. continue
  34.  
  35. os.popen("echo \"" + line + "\"", 'w')

Report this snippet  

You need to login to post a comment.