15Oct/090
Komodo Edit tools – add style.css and reset.css
Good morning, planet. Today I am going to share a very useful script I am using in Komodo Edit (it automates adding style.css). It is very (!) simple yet very effective for me and, probably for others who are doing a lot of HTML files and face a problem of repetitive actions.
This thing works as follows (the use case):
- You create a new HTML file in komodo and save it in some directory.
- You double-click the script in the Komodo Edit toolbox.
- The script adds the following folders/files to the project (paths relative to the file currently in editor!)
- css/
- css/style.css
- css/reset.css
- Also the file adds the following HTML code at the cursor in current opened file:
Voila. The needed action is done.
Now, the snippet code:
import sys
import shutil
import os
import os.path
# argv[1] - dir of cur project (%D)
# argv[2] - current file name (%F)
if os.path.exists(sys.argv[1]+'/css/') != True:
os.mkdir(sys.argv[1]+'/css/')
# NB! Edit the paths to style.css and reset.css
# (these will be copied into your project)!
shutil.copy('C:/Work/__distributives/css/reset.css',sys.argv[1]+'/css/')
shutil.copy('C:/Work/__distributives/css/style.css',sys.argv[1]+'/css/')
print '
'
print '
'
Save this as a file somewhere (e.g. C:/Work/__scripts/add_style_css.py).
Open up Komodo Edit and add it to your toolbox (Toolbox->Add->New command...) with the following settings:
- Command: python add_style_css.py %D %F
- Insert output: check
- Start in: whatever the script resides in (e.g. C:/Work/__scripts)
- anything else should bet left as it is
Enjoy