#!/usr/bin/env python import os import os.path import shutil # For each itemhelp: line in a .GDEmenus item file, # add a line that says itemopen: def parsedir (rootdir): TEMPNAME = 'changegde_' + os.getpid() + '.temp' for file in os.listdir(rootdir): if os.path.isfile(file): if os.path.splitext(file)[1].upper() == '.item': infile = open(file, 'r') tfile = open(TEMPNAME, 'w') for line in infile: tfile.write(line) if (line.lower().startswith('itemhelp:')): tfile.write('itemopen:gde_help_viewer.csh') infile.close() tfile.close() # double check that the path exists if os.path.exists(TEMPFILE): os.remove(file) shutil.move(TEMPFILE, file) else: parsedir(os.path.join(os.getcwd(), dir)) parsedir(os.getcwd())