Esempio n. 1
0
def replacestringinfolder(path, old_string, new_string, extension):
    if not stringmanipulation.isextension(extension):
        print "failed to search and replace"
        return
    if len(old_string) == 0:
        print "failed to search and replace"
        return
    find_command = "ls " + path + "/*" + extension
    sed_command = "sed -i 's/" + old_string + "/" + new_string + "/g' *" + extension
    command_string = find_command + " | xargs " + sed_command + " 2> deleteme.txt"
    os.system(command_string)
Esempio n. 2
0
def replacestringinfolder(path, old_string, new_string, extension):
    if (not stringmanipulation.isextension(extension)):
        print 'failed to search and replace'
        return
    if (len(old_string) == 0):
        print 'failed to search and replace'
        return
    find_command = 'ls ' + path + '/*' + extension
    sed_command = 'sed -i \'s/' + old_string + '/' + new_string +\
                     '/g\' *' + extension
    command_string = find_command + ' | xargs ' + sed_command + ' 2> deleteme.txt'
    os.system(command_string)
Esempio n. 3
0
def replacestringinallsubfolders(old_string, new_string, extension):
    if not stringmanipulation.isextension(extension):
        print "failed to search and replace"
        return
    if len(old_string) == 0:
        print "failed to search and replace"
        return

    find_command = 'find ./ -name "*' + extension + '" -type f'
    sed_command = "sed -i 's/" + old_string + "/" + new_string + "/g' *" + extension
    command_string = find_command + " | xargs -P 0 " + sed_command + " 2> deleteme.txt"
    os.system(command_string)
Esempio n. 4
0
def replacestringinallsubfolders(old_string, new_string, extension):
    if (not stringmanipulation.isextension(extension)):
        print 'failed to search and replace'
        return
    if (len(old_string) == 0):
        print 'failed to search and replace'
        return

    find_command = 'find ./ -name \"*' + extension + '\" -type f'
    sed_command = 'sed -i \'s/' + old_string + '/' + new_string +\
                     '/g\' *' + extension
    command_string = find_command + ' | xargs -P 0 ' + sed_command + ' 2> deleteme.txt'
    os.system(command_string)
Esempio n. 5
0
exceptions = [
['GIPSRWLock.h','rw_lock.h'],
['GIPSCriticalsection.h','critical_section.h'],
]

if((len(sys.argv) != 4) and (len(sys.argv) != 5)):
    print 'parameters are: parent directory extension new extension [--commit]'
    quit()

directory = sys.argv[1];
if(not filemanagement.pathexist(directory)):
    print 'path ' + directory + ' does not exist'
    quit()

old_extension = sys.argv[2]
if(not stringmanipulation.isextension(old_extension)):
    print old_extension + ' is not a valid extension'
    quit()

new_extension = sys.argv[3]
if(not stringmanipulation.isextension(new_extension)):
    print new_extension + ' is not a valid extension'
    quit()

if((len(sys.argv) == 5) and (sys.argv[4] != '--commit')):
    print 'parameters are: parent directory extension new extension [--commit]'
    quit()

commit = False
if(len(sys.argv) == 5):
    commit = True