def addc(hpath, filedir): global counter global notexist global sources if hpath is None: return None if len(hpath) < 3: return None hpath = hpath[1:-1] # removing markers, quotes or angles # if filedir not in the path, the path of the main file # if added to, as it is presumed to be the location # when compiling the project hpath = wstring.localize(hpath) # converting antislash or slash filedir = wstring.localize(filedir) p, n = os.path.split(hpath) if p == "": hpath = os.path.join(filedir, n) # adding the default path hpath = decrease(hpath, filedir) node, ext = os.path.splitext(hpath) if lexer.iswindows(): ext = string.lower(ext) if ext == ".h": if lexer.iswindows(): node = string.lower(node) hpath = node + ".c" # Converting local relative path into absolute path if string.find(hpath, mainpath) == -1: # path not in include hpath = os.path.join(mainpath, hpath) # add it # print hpath if hpath in sources: return None # Already here if os.path.exists(hpath): sources.append(hpath) counter = counter + 1 # print "added", hpath return hpath else: if hpath not in notexist: notexist.append(hpath) return None
def add(hpath): global counter global notexist global source if hpath is None: return None if len(hpath) < 3: return None hpath = hpath[1:-1] # removing quotes if len(hpath) < 1: return None # print hpath node, ext = os.path.splitext(hpath) ext = string.lower(ext) if ext == ".h": if lexer.iswindows(): node = string.lower(node) hpath = node + ".c" # Converting local relative path into absolute path p, dummy = os.path.split(hpath) if len(p) == 0: hpath = os.path.join(mainpath, hpath) # add it print hpath if hpath in sources: return None # Already here if os.path.exists(hpath): sources.append(hpath) counter = counter + 1 # print "added", hpath return hpath else: if hpath not in notexist: notexist.append(hpath) return None
def main(): global sources global dico param = sys.argv paramlen = len(param) if paramlen < 3: usage() replacements = [] # list of couples olddir:newdir offset = 0 temp, pname = os.path.split(param[0]) if pname == "python": offset += 1 mainfile = param[offset] # main file temp, pname = os.path.split(mainfile) if pname == "mover.py": offset += 1 mainfile = param[offset] if len(mainfile) < 3: usage() if mainfile[0] == "-": if mainfile[1] == "v": version() usage() listof = param[offset] # couple or file of couples if listof[0] == "@": # reading list from file listof = listof[1:] f = open(listof, "r") replacements = f.readlines() f.close() else: # reading list from params paths = [] offset += 1 while offset < paramlen: couple = param[offset] replacements.append(couple) offset += 1 # separating old and new paths in couples print "Directories..." for couple in replacements: if wstring.chop(couple) == "": break i = string.find(couple, "@") old = couple[:i] if lexer.iswindows(): old = string.lower(old) dico[old] = couple[i + 1 :] print "from", old, "to", dico[old] processheader(mainfile, sources) processource(mainfile, sources) # extracting headers filenames if len(sources) == 0: sources.append(mainfile) else: print len(sources), " files found" # moving files for f in sources: newf = changepath(f) # define a new path if newf <> f: print f, "-->", newf move(f, newf) # move, and update include directives inside return 0