MCPcopy Create free account
hub / github.com/Autodesk/Aurora / PatchFile

Function PatchFile

Scripts/installExternalsFunctions.py:435–451  ·  view source on GitHub ↗

Applies patches to the specified file. patches is a list of tuples (old string, new string).

(filename, patches, multiLineMatches=False)

Source from the content-addressed store, hash-verified

433 return (int(major), int(minor), int(patch))
434
435def PatchFile(filename, patches, multiLineMatches=False):
436 """
437 Applies patches to the specified file. patches is a list of tuples
438 (old string, new string).
439 """
440 if multiLineMatches:
441 oldLines = [open(filename, 'r').read()]
442 else:
443 oldLines = open(filename, 'r').readlines()
444 newLines = oldLines
445 for (oldString, newString) in patches:
446 newLines = [s.replace(oldString, newString) for s in newLines]
447 if newLines != oldLines:
448 PrintInfo("Patching file {filename} (original in {oldFilename})..."
449 .format(filename=filename, oldFilename=filename + ".old"))
450 shutil.copy(filename, filename + ".old")
451 open(filename, 'w').writelines(newLines)
452
453def ApplyGitPatch(context, patchfile):
454 try:

Callers 1

InstallTIFFFunction · 0.85

Calls 2

PrintInfoFunction · 0.85
formatMethod · 0.80

Tested by

no test coverage detected