PageRenderTime 417ms CodeModel.GetById 405ms RepoModel.GetById 0ms app.codeStats 1ms

/static/june_2007_style/make_style.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 88 lines | 60 code | 12 blank | 16 comment | 4 complexity | f776c883fa6dab49adb1019b4917720e MD5 | raw file
  1. #!/usr/bin/env python
  2. import sys, string, os, tempfile, subprocess
  3. # from Cheetah.Template import Template
  4. from subprocess import Popen, PIPE
  5. assert sys.version_info[:2] >= ( 2, 4 )
  6. # To create a new style ( this is an example ):
  7. # In case you have not yet installed required packages:
  8. # % sudo easy_install pyparsing
  9. # % sudo easy_install http://effbot.org/downloads/Imaging-1.1.7.tar.gz
  10. # When you have the above installed, add whatever new style you want to /static/june_2007_style/blue_colors.ini and then:
  11. # % cd ~/static/june_2007_style/
  12. # % python make_style.py blue_colors.ini blue
  13. def run( cmd ):
  14. return Popen( cmd, stdout=PIPE).communicate()[0]
  15. templates = [ ( "base.css.tmpl", "base.css" ),
  16. ( "panel_layout.css.tmpl", "panel_layout.css" ),
  17. ( "masthead.css.tmpl", "masthead.css" ),
  18. ( "library.css.tmpl", "library.css" ),
  19. ( "history.css.tmpl", "history.css" ),
  20. ( "tool_menu.css.tmpl", "tool_menu.css" ),
  21. ( "iphone.css.tmpl", "iphone.css" ),
  22. ( "autocomplete_tagging.css.tmpl", "autocomplete_tagging.css" ),
  23. ( "trackster.css.tmpl", "trackster.css" ) ]
  24. # TODO: Are these images still being used? If not, clean this code up!
  25. images = [
  26. ( "./gradient.py 9 30 $panel_header_bg_top - $panel_header_bg_bottom 0 0 $panel_header_bg_bottom 1 1", "panel_header_bg.png" ),
  27. ( "./gradient.py 9 30 $panel_header_bg_bottom - $panel_header_bg_top 0 0 $panel_header_bg_top 1 1", "panel_header_bg_pressed.png" ),
  28. ( "./gradient.py 9 1000 $menu_bg_top $menu_bg_hatch $menu_bg_over 0 0 $menu_bg_over 1 1", "menu_bg.png" ),
  29. ( "./gradient.py 9 1000 $base_bg_top - $base_bg_bottom 0 0 $base_bg_bottom 1 1", "base_bg.png" ),
  30. ( "./gradient.py 9 500 $form_body_bg_top - $form_body_bg_bottom 0 0 $form_body_bg_bottom 1 1", "form_body_bg.png" ),
  31. ( "./gradient.py 9 50 $masthead_bg $masthead_bg_hatch", "masthead_bg.png" ),
  32. ( "./gradient.py 9 30 $footer_title_bg $footer_title_hatch 000000 0 0.5 000000 1 1", "footer_title_bg.png" ),
  33. ( "./gradient.py 9 50 $form_title_bg_top $form_title_bg_hatch $form_title_bg_bottom 0 0 $form_title_bg_bottom 1 1", "form_title_bg.png" ),
  34. ( "./gradient.py 9 200 $history_ok_bg - FFFFFF 0 0.5 FFFFFF 0.5 1", "ok_bg.png" ),
  35. ( "./gradient.py 9 200 $history_error_bg - FFFFFF 0 0.5 FFFFFF 0.5 1", "error_bg.png" ),
  36. ( "./gradient.py 9 200 $history_running_bg - FFFFFF 0 0.5 FFFFFF 0.5 1", "warn_bg.png" ),
  37. ( "./gradient.py 9 200 $history_queued_bg - FFFFFF 0 0.5 FFFFFF 0.5 1", "gray_bg.png" ),
  38. ( "./callout_top.py 20 10 $panel_header_bg_top $layout_border", "popupmenu_callout_top.png" ),
  39. ( "./circle.py 12 #FFFFFF #D8B365 right > workflow_circle_open.png" ),
  40. ( "./circle.py 12 #BBFFBB #D8B365 right > workflow_circle_green.png" ),
  41. ( "./circle.py 12 #FFFFFF #D8B365 none> workflow_circle_drag.png" ),
  42. ]
  43. # TODO: Are these shared_images still being used? If not, clean this code up!
  44. shared_images = [
  45. # Dialog boxes
  46. ( "ok_large.png", "done_message_bg", "done_message_icon.png" ),
  47. ( "info_large.png", "info_message_bg", "info_message_icon.png" ),
  48. ( "warn_large.png", "warn_message_bg", "warn_message_icon.png" ),
  49. ( "error_large.png", "error_message_bg", "error_message_icon.png" ),
  50. # History icons
  51. ( "ok_small.png", "history_ok_bg", "data_ok.png" ),
  52. ( "error_small.png", "history_error_bg", "data_error.png" ),
  53. ( "wait_small.png", "history_queued_bg", "data_queued.png" ),
  54. ]
  55. if __name__ == "__main__":
  56. if len(sys.argv) > 1: # has params
  57. ini_file, out_dir = sys.argv[1:]
  58. else:
  59. cwd = os.getcwd() # default settings
  60. ini_file, out_dir = cwd + "/blue_colors.ini", cwd + "/blue"
  61. for in_file, out_file in templates:
  62. print in_file ,"->", out_file
  63. subprocess.call( "./process_css.py %s shared_images:../images %s < %s > %s" % ( ini_file, out_dir, in_file, os.path.join( out_dir, out_file ) ), shell=True )
  64. """
  65. for rule, output in images:
  66. t = string.Template( rule ).substitute( context )
  67. print t, "->", output
  68. open( os.path.join( out_dir, output ), "w" ).write( run( t.split() ) )
  69. for src, bg, out in shared_images:
  70. t = "./png_over_color.py shared_images/%s %s %s" % ( src, context[bg], os.path.join( out_dir, out ) )
  71. print t
  72. run( t.split() )
  73. """