[gps-users] A small script taht automaticly creates all missing
output dirs.
Per Sandberg
per.sandberg at bredband.net
Thu Oct 26 19:30:34 CEST 2006
Feel free to use.
/Per
############################################################
"""This macro will create missing directories for a
project tree when loading it into GPS.
To install just copy the file to ine of the plug-in directories in GPS.
${HOME}/.gps/plug-ins
${GPS_ROOT}/share/gps/plug-ins
"""
import GPS
import os
from os.path import *
import string
def on_project_changed(self):
CreatedDirs=False
if GPS.Preference ("Auto-Create-Dirs").get():
prjs=GPS.Project.root().dependencies(True)
prjs.append(GPS.Project.root())
created=[]
for i in prjs :
dirs=[i.get_attribute_as_string("Exec_Dir"),
i.get_attribute_as_string("Library_Dir"),
i.get_attribute_as_string("Object_Dir")]
for j in dirs:
if i and i not in [".",""," "]:
dir=join(dirname(i.file().name()),j).strip()
if dir[-1:] not in ["\\","/"]:
if not exists(dir):
os.makedirs(dir)
created.append(dir)
CreatedDirs=True
if CreatedDirs:
GPS.Console("").clear()
GPS.Console("").write("Created missing dirs\n")
GPS.Console("").write(string.join(created) + "\n")
GPS.Project.recompute()
def on_gps_started(hook):
GPS.parse_xml("""<preference name="Auto-Create-Dirs"
page="General"
label="Auto Create Missing Dirs"
tip="Atuomaticly creates missing Directories."
default="True"
type="boolean" />""")
GPS.Hook("project_view_changed").add(on_project_changed)
GPS.Hook("gps_started").add(on_gps_started)
More information about the gps-users
mailing list