From 2328306ff9c66f9ff807295818a06b3e3277331b Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 28 Oct 2019 20:56:32 +0000 Subject: changes (28oct19) git-svn-id: svn://tug.org/texlive/trunk@52552 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/scripts/changes/pyMergeChanges.py | 34 ++++++++++------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'Master/texmf-dist/scripts/changes') diff --git a/Master/texmf-dist/scripts/changes/pyMergeChanges.py b/Master/texmf-dist/scripts/changes/pyMergeChanges.py index 37209bdc649..39c8b220076 100755 --- a/Master/texmf-dist/scripts/changes/pyMergeChanges.py +++ b/Master/texmf-dist/scripts/changes/pyMergeChanges.py @@ -30,6 +30,7 @@ Options: If no option is given, runs interactively. Created on Wed Dec 5 20:28:40 2018 +Revised on Tue Aug 27 17:51:58 2019 """ @@ -131,11 +132,11 @@ if INPUTFILE == OUTPUTFILE: print('Input File and Output File must be different.') sys.exit(1) -RE_ADDED = re.compile(r'\\added(\[[^\]]*\]){0,1}\{([^\}]*)\}') -RE_DELETED = re.compile(r'\\deleted(\[[^\]]*\]){0,1}\{([^\}]*)\}') -RE_REPLACED = re.compile(r'\\replaced(\[[^\]]*\]){0,1}\{([^\}]*)\}\{([^\}]*)\}') -RE_HIGHLIGHT = re.compile(r'\\highlight(\[[^\]]*\]){0,1}\{([^\}]*)\}') -RE_COMMENT = re.compile(r'\\comment(\[[^\]]*\]){0,1}\{([^\}]*)\}') +RE_ADDED = re.compile(r'(\\added)(\[[^\]]*\])?\{(([^\}]?(\{[^\}]*\})?)*)\}') +RE_DELETED = re.compile(r'(\\deleted)(\[[^\]]*\])?\{(([^\}]?(\{[^\}]*\})?)*)\}') +RE_REPLACED = re.compile(r'(\\replaced)(\[[^\]]*\])?\{(([^\}]?(\{[^\}]*\})?)*)\}\{(([^\}]?(\{[^\}]*\})?)*)\}') +RE_HIGHLIGHT = re.compile(r'(\\highlight)(\[[^\]]*\])?\{(([^\}]?(\{[^\}]*\})?)*)\}') +RE_COMMENT = re.compile(r'(\\comment)(\[[^\]]*\])?\{(([^\}]?(\{[^\}]*\})?)*)\}') codecs.open(OUTPUTFILE, mode='w', encoding='utf8').close() with codecs.open(INPUTFILE, mode='r', encoding='utf8') as fin, \ @@ -164,9 +165,9 @@ codecs.open(OUTPUTFILE, mode='a', encoding='utf8') as fout: answer = ask1() if answer == 'a': lineout = (lineout[:matchAdded.start(0)] - + matchAdded.group(2) + lineout[matchAdded.end(0):]) + + matchAdded.group(3) + lineout[matchAdded.end(0):]) lineout = trim_space(lineout, matchAdded.start(0) - + len(matchAdded.group(2))) + + len(matchAdded.group(3))) lineout = trim_space(lineout, matchAdded.start(0)) elif answer == 'r': lineout = (lineout[:matchAdded.start(0)] + lineout[matchAdded.end(0):]) @@ -189,7 +190,7 @@ codecs.open(OUTPUTFILE, mode='a', encoding='utf8') as fout: lineout = (lineout[:matchDeleted.start(0)] + lineout[matchDeleted.end(0):]) lineout = trim_space(lineout, matchDeleted.start(0)) elif answer == 'r': - lineout = (lineout[:matchDeleted.start(0)] + matchDeleted.group(2) + lineout = (lineout[:matchDeleted.start(0)] + matchDeleted.group(3) + lineout[matchDeleted.end(0):]) elif answer == 'k': lineout = lineout @@ -207,15 +208,15 @@ codecs.open(OUTPUTFILE, mode='a', encoding='utf8') as fout: answer = ask1() if answer == 'a': lineout = (lineout[:matchReplaced.start(0)] - + matchReplaced.group(2) + lineout[matchReplaced.end(0):]) + + matchReplaced.group(3) + lineout[matchReplaced.end(0):]) lineout = trim_space(lineout, matchReplaced.start(0) - + len(matchReplaced.group(2))) + + len(matchReplaced.group(3))) lineout = trim_space(lineout, matchReplaced.start(0)) elif answer == 'r': lineout = (lineout[:matchReplaced.start(0)] - + matchReplaced.group(3) + lineout[matchReplaced.end(0):]) + + matchReplaced.group(6) + lineout[matchReplaced.end(0):]) lineout = trim_space(lineout, matchReplaced.start(0) - + len(matchReplaced.group(3))) + + len(matchReplaced.group(6))) lineout = trim_space(lineout, matchReplaced.start(0)) elif answer == 'k': lineout = lineout @@ -233,9 +234,9 @@ codecs.open(OUTPUTFILE, mode='a', encoding='utf8') as fout: answer = ask2() if answer == 'r': lineout = (lineout[:matchHighlight.start(0)] - + matchHighlight.group(2) + lineout[matchHighlight.end(0):]) + + matchHighlight.group(3) + lineout[matchHighlight.end(0):]) lineout = trim_space(lineout, matchHighlight.start(0) - + len(matchHighlight.group(2))) + + len(matchHighlight.group(3))) lineout = trim_space(lineout, matchHighlight.start(0)) elif answer == 'k': lineout = lineout @@ -252,10 +253,7 @@ codecs.open(OUTPUTFILE, mode='a', encoding='utf8') as fout: print('\n** comment commit ** \n' + matchComment.group()) answer = ask2() if answer == 'r': - lineout = (lineout[:matchComment.start(0)] - + matchComment.group(2) + lineout[matchComment.end(0):]) - lineout = trim_space(lineout, matchComment.start(0) - + len(matchComment.group(2))) + lineout = (lineout[:matchComment.start(0)] + lineout[matchComment.end(0):]) lineout = trim_space(lineout, matchComment.start(0)) elif answer == 'k': lineout = lineout -- cgit v1.2.3