Loading generateChangemarks/changemarks.py +53 −40 Original line number Original line Diff line number Diff line Loading @@ -235,9 +235,19 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st else: else: clauseMDlines = readMDFile(progress, outDirectory + '/' + changed_clause.clause_nr +'.md') clauseMDlines = readMDFile(progress, outDirectory + '/' + changed_clause.clause_nr +'.md') j = change.target_start - changed_clause.from_id # index gap if change.source_start >= changed_clause.from_id: index_gap = change.target_start - change.source_start elif change.source_start < changed_clause.from_id: index_gap = change.source_start - change.target_start j = change.target_start - changed_clause.from_id + index_gap for line in change: for line in change: if line.source_line_no != None and line.source_line_no < changed_clause.from_id: j = 0 continue else: #if (not (line.value.strip() == '') and (line.is_added)): #if (not (line.value.strip() == '') and (line.is_added)): #print(vars(line)) if line.is_added: if line.is_added: if line.value.strip().startswith("|"): # It is a table if line.value.strip().startswith("|"): # It is a table tableElements = line.value.strip().split("|") tableElements = line.value.strip().split("|") Loading @@ -252,10 +262,11 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st clauseMDlines.insert(j,modifiedRow) clauseMDlines.insert(j,modifiedRow) clauseMDlines.pop(j + 1) # Todo Check what happens when modifying last row of a table clauseMDlines.pop(j + 1) # Todo Check what happens when modifying last row of a table else: else: clauseMDlines.insert(j, "<span class=\"underline\">" + line.value + "</span>\n\n") if not line.value.strip() == '': clauseMDlines.insert(j, "<span class=\"underline\">" + line.value.strip() + "</span>\n\n") #clauseMDlines.insert(j, "<mark>" + line.value.strip("\n") + "</mark>\n\n") #clauseMDlines.insert(j, "<mark>" + line.value.strip("\n") + "</mark>\n\n") if (j + 1) <= len(clauseMDlines): #if (j + 1) <= len(clauseMDlines): clauseMDlines.pop(j+1) # clauseMDlines.pop(j+1) #elif (not (line.value.strip() == '') and (line.is_removed)): #elif (not (line.value.strip() == '') and (line.is_removed)): elif line.is_removed: elif line.is_removed: if line.value.strip().startswith("|"): # It is a table if line.value.strip().startswith("|"): # It is a table Loading @@ -270,16 +281,18 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st modifiedRow = "|".join(modifiedElements) + "\n" modifiedRow = "|".join(modifiedElements) + "\n" clauseMDlines.insert(j, modifiedRow) clauseMDlines.insert(j, modifiedRow) else: else: clauseMDlines.insert(j, "~~" + line.value.strip() + "~~") if not line.value.strip() == '': clauseMDlines.insert(j, "~~" + line.value.strip() + "~~\n") if (j + 1) <= len(clauseMDlines): clauseMDlines.pop(j+1) j = j + 1 j = j + 1 clauseMDlines.insert(j, "\n\n<br />") #clauseMDlines.insert(j, "\n\n<br />") writeMDFile(progress, clauseMDlines, changed_clause.clause_nr.replace(" ","") + '.md', outDirectory) writeMDFile(progress, clauseMDlines, changed_clause.clause_nr.replace(" ","") + '.md', outDirectory) def process(document:str, outDirectory:str, mr:MR) -> None: def process(document:str, outDirectory:str, mr:MR) -> None: with Progress(TextColumn('{task.description}'), TimeElapsedColumn()) as progress: with Progress(TextColumn('{task.description}'), TimeElapsedColumn()) as progress: sourceText = mr.retrieve_text(mr.source_branch, document) sourceText = mr.retrieve_text(mr.target_branch, document) sourceMdLines = sourceText.splitlines(keepends=False) sourceMdLines = sourceText.splitlines(keepends=False) clauses = find_all_clauses(progress, sourceMdLines) clauses = find_all_clauses(progress, sourceMdLines) changed_clauses = find_changed_clauses(progress, sourceMdLines, clauses, mr, outDirectory) changed_clauses = find_changed_clauses(progress, sourceMdLines, clauses, mr, outDirectory) Loading Loading
generateChangemarks/changemarks.py +53 −40 Original line number Original line Diff line number Diff line Loading @@ -235,9 +235,19 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st else: else: clauseMDlines = readMDFile(progress, outDirectory + '/' + changed_clause.clause_nr +'.md') clauseMDlines = readMDFile(progress, outDirectory + '/' + changed_clause.clause_nr +'.md') j = change.target_start - changed_clause.from_id # index gap if change.source_start >= changed_clause.from_id: index_gap = change.target_start - change.source_start elif change.source_start < changed_clause.from_id: index_gap = change.source_start - change.target_start j = change.target_start - changed_clause.from_id + index_gap for line in change: for line in change: if line.source_line_no != None and line.source_line_no < changed_clause.from_id: j = 0 continue else: #if (not (line.value.strip() == '') and (line.is_added)): #if (not (line.value.strip() == '') and (line.is_added)): #print(vars(line)) if line.is_added: if line.is_added: if line.value.strip().startswith("|"): # It is a table if line.value.strip().startswith("|"): # It is a table tableElements = line.value.strip().split("|") tableElements = line.value.strip().split("|") Loading @@ -252,10 +262,11 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st clauseMDlines.insert(j,modifiedRow) clauseMDlines.insert(j,modifiedRow) clauseMDlines.pop(j + 1) # Todo Check what happens when modifying last row of a table clauseMDlines.pop(j + 1) # Todo Check what happens when modifying last row of a table else: else: clauseMDlines.insert(j, "<span class=\"underline\">" + line.value + "</span>\n\n") if not line.value.strip() == '': clauseMDlines.insert(j, "<span class=\"underline\">" + line.value.strip() + "</span>\n\n") #clauseMDlines.insert(j, "<mark>" + line.value.strip("\n") + "</mark>\n\n") #clauseMDlines.insert(j, "<mark>" + line.value.strip("\n") + "</mark>\n\n") if (j + 1) <= len(clauseMDlines): #if (j + 1) <= len(clauseMDlines): clauseMDlines.pop(j+1) # clauseMDlines.pop(j+1) #elif (not (line.value.strip() == '') and (line.is_removed)): #elif (not (line.value.strip() == '') and (line.is_removed)): elif line.is_removed: elif line.is_removed: if line.value.strip().startswith("|"): # It is a table if line.value.strip().startswith("|"): # It is a table Loading @@ -270,16 +281,18 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st modifiedRow = "|".join(modifiedElements) + "\n" modifiedRow = "|".join(modifiedElements) + "\n" clauseMDlines.insert(j, modifiedRow) clauseMDlines.insert(j, modifiedRow) else: else: clauseMDlines.insert(j, "~~" + line.value.strip() + "~~") if not line.value.strip() == '': clauseMDlines.insert(j, "~~" + line.value.strip() + "~~\n") if (j + 1) <= len(clauseMDlines): clauseMDlines.pop(j+1) j = j + 1 j = j + 1 clauseMDlines.insert(j, "\n\n<br />") #clauseMDlines.insert(j, "\n\n<br />") writeMDFile(progress, clauseMDlines, changed_clause.clause_nr.replace(" ","") + '.md', outDirectory) writeMDFile(progress, clauseMDlines, changed_clause.clause_nr.replace(" ","") + '.md', outDirectory) def process(document:str, outDirectory:str, mr:MR) -> None: def process(document:str, outDirectory:str, mr:MR) -> None: with Progress(TextColumn('{task.description}'), TimeElapsedColumn()) as progress: with Progress(TextColumn('{task.description}'), TimeElapsedColumn()) as progress: sourceText = mr.retrieve_text(mr.source_branch, document) sourceText = mr.retrieve_text(mr.target_branch, document) sourceMdLines = sourceText.splitlines(keepends=False) sourceMdLines = sourceText.splitlines(keepends=False) clauses = find_all_clauses(progress, sourceMdLines) clauses = find_all_clauses(progress, sourceMdLines) changed_clauses = find_changed_clauses(progress, sourceMdLines, clauses, mr, outDirectory) changed_clauses = find_changed_clauses(progress, sourceMdLines, clauses, mr, outDirectory) Loading