Esempio n. 1
0
def replace(pattern, replacement) :
	print("Matches:")
	matches = refactoring.find_matches(files, pattern)
	
	print("\n")
	print("Replacing:")
	refactoring.replace_matches(matches, pattern, replacement)
Esempio n. 2
0
def replace(pattern, replacement):
    print("Matches:")
    matches = refactoring.find_matches(files, pattern)

    print("\n")
    print("Replacing:")
    refactoring.replace_matches(matches, pattern, replacement)
Esempio n. 3
0
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)
Esempio n. 4
0
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
Esempio n. 5
0
    "*.ico", "*.icns", "*.qch", "*.qhc", "*.exr", "*.pwm", "*.pvm", "*.pdf",
    "*.otf", "*.exe", "*.fbx", "*.svg", "*.itf", "*.qrc", "*.md", "*/.git*",
    "*/.clang-format", "*/LICENSE", ".git", "Jenkinsfile", ".gitattributes",
    "*/AUTHORS", ""
    "*/tools/meta/templates/*", "*.natvis", "*/depends.cmake",
    "*moduledefine.h", "*moduledefine.hpp", "*/config.json", "*.js",
    "*/CMakeLists.txt"
]

copyright_replacements = {
    r"(\s*[*#]\s+Copyright \(c\) 201\d-)20(?:1\d|2[0])( Inviwo Foundation\s*)":
    r"\g<1>2021\g<2>",
    r"(\s*[*#]\s+Copyright \(c\) )(20(?:1\d|2[0]))( Inviwo Foundation\s*)":
    r"\g<1>\g<2>-2021\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)
Esempio n. 6
0
def replace(pattern, replacement):
    matches = refactoring.find_matches(files, pattern)
    print(matches.size())
Esempio n. 7
0
colorama.init()

paths = [
    "C:/Users/petst55/Work/Inviwo/Inviwo-dev",
    "C:/Users/petst55/Work/Inviwo/Inviwo-research"
]

excludespatterns = [
    "*/ext/*", "*moc_*", "*cmake*", "*/proteindocking/*",
    "*/proteindocking2/*", "*/genetree/*", "*/vrnbase/*"
]

files = refactoring.find_files(paths, ['*.h', '*.cpp'],
                               excludes=excludespatterns)

matches = refactoring.find_matches(files, r":\s*public\s+Processor")

processorswithinit = set(refactoring.find_matches(matches, r"initialize\(\)"))

processorswithdeinit = set(
    refactoring.find_matches(matches, r"deinitialize\(\)"))

lastpart = lambda x: (x.split(r"/Inviwo/")[-1]).split("\\modules\\")[-1]

print("")
print("")
print("## Prcessor with initialize/deinitialize")

l1 = list(processorswithinit.intersection(processorswithdeinit))
l1.sort()
Esempio n. 8
0
n = refactoring.find_files(paths, ['*.h'], excludes=["*/ext/*", "*moc_*", "*cmake*", "*/proteindocking/*", "*/proteindocking2/*", "*/genetree/*"])

err = refactoring.check_file_type(n, "UTF-8")
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
Esempio n. 9
0
import sys 
import os
import re
import colorama
colorama.init()

import refactoring # Note: refactoring.py need to be in the current working directory

paths = ["C:/Users/petst55/Work/Inviwo/Inviwo-dev", "C:/Users/petst55/Work/Inviwo/Inviwo-research"]

excludespatterns = ["*/ext/*", "*moc_*", "*cmake*", "*/proteindocking/*", "*/proteindocking2/*", "*/genetree/*", "*/vrnbase/*"];

files = refactoring.find_files(paths, ['*.h', '*.cpp'], excludes=excludespatterns)

matches = refactoring.find_matches(files, r":\s*public\s+Processor")

processorswithinit = set(refactoring.find_matches(matches, r"initialize\(\)"))

processorswithdeinit = set(refactoring.find_matches(matches, r"deinitialize\(\)"))

lastpart = lambda x: (x.split(r"/Inviwo/")[-1]).split("\\modules\\")[-1]

print("")
print("")
print("## Prcessor with initialize/deinitialize")

l1 = list(processorswithinit.intersection(processorswithdeinit))
l1.sort()

l2 = list(processorswithinit.difference(processorswithdeinit))
l2.sort()