def replace(pattern, replacement): print("Matches:") matches = refactoring.find_matches(files, pattern) print("\n") print("Replacing:") refactoring.replace_matches(matches, pattern, replacement)
def replace(pattern, replacement) : print("Matches:") matches = refactoring.find_matches(files, pattern) print("\n") print("Replacing:") refactoring.replace_matches(matches, pattern, replacement)
def update(paths, year): copyright_replacements = { f"(\\s*[*#]\\s+Copyright \\(c\\) 20\\d\\d-)(?!{year})20\\d\\d( Inviwo Foundation\\s*)": f"\\g<1>{year}\\g<2>", f"(\\s*[*#]\\s+Copyright \\(c\\) )((?!{year})20\\d\\d)( Inviwo Foundation\\s*)": f"\\g<1>\\g<2>-{year}\\g<3>" } files = refactoring.find_files(paths, ['*'], excludes=excludespatterns) print("Looking in {} files".format(len(files))) summary = "" for pattern, replacement in copyright_replacements.items(): print("Matches: {}".format(pattern)) matches = refactoring.find_matches(files, pattern) print("\nReplacing:") refactoring.replace_matches(matches, pattern, replacement) summary += "Replaced {} matches of {}\n".format(len(matches), pattern) print("\n") print(summary)
"*/proteindocking/*", "*/proteindocking2/*", "*/genetree/*" ]) err2 = refactoring.check_file_type(n2, "UTF-8") if len(err2) > 0: sys.exit("Encoding errors") pattern = r"(\s*)InviwoProcessorInfo\(\);" replacement = r"\1virtual const ProcessorInfo getProcessorInfo() const override;\n\1static const ProcessorInfo processorInfo_;" print("Matches:") matches = refactoring.find_matches(n, pattern) print("\n") print("Replacing:") refactoring.replace_matches(matches, pattern, replacement) # Step 2: # replace: # ProcessorDisplayName(VolumeRaycaster, "Volume Raycaster"); # ProcessorTags(VolumeRaycaster, Tags::GL); # ProcessorCategory(VolumeRaycaster, "Volume Rendering"); # ProcessorCodeState(VolumeRaycaster, CODE_STATE_STABLE); # with: # const ProcessorInfo VolumeRaycaster::processorInfo_{ # "org.inviwo.VolumeRaycaster", // Class identifer # "Volume Raycaster", // Display name # "Volume Rendering", // Category # CODE_STATE_STABLE, // Code state # Tags::GL // Tags # };
if len(err)>0: sys.exit("Encoding errors") n2 = refactoring.find_files(paths, ['*.cpp'], excludes=["*/ext/*", "*moc_*", "*cmake*", "*/proteindocking/*", "*/proteindocking2/*", "*/genetree/*"]) err2 = refactoring.check_file_type(n2, "UTF-8") if len(err2)>0: sys.exit("Encoding errors") pattern = r"(\s*)InviwoProcessorInfo\(\);" replacement = r"\1virtual const ProcessorInfo getProcessorInfo() const override;\n\1static const ProcessorInfo processorInfo_;" print("Matches:") matches = refactoring.find_matches(n, pattern) print("\n") print("Replacing:") refactoring.replace_matches(matches, pattern, replacement) # Step 2: # replace: # ProcessorDisplayName(VolumeRaycaster, "Volume Raycaster"); # ProcessorTags(VolumeRaycaster, Tags::GL); # ProcessorCategory(VolumeRaycaster, "Volume Rendering"); # ProcessorCodeState(VolumeRaycaster, CODE_STATE_STABLE); # with: # const ProcessorInfo VolumeRaycaster::processorInfo_{ # "org.inviwo.VolumeRaycaster", // Class identifer # "Volume Raycaster", // Display name # "Volume Rendering", // Category # CODE_STATE_STABLE, // Code state # Tags::GL // Tags