Skip to content
Snippets Groups Projects
Commit d2f882b3 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Support for changes in clause headings

parent 64f60ad7
Branches
No related tags found
No related merge requests found
Pipeline #736 passed
...@@ -458,7 +458,10 @@ def find_clauses_with_changes(progress: Progress, mdLines_changes: list[Tuple[st ...@@ -458,7 +458,10 @@ def find_clauses_with_changes(progress: Progress, mdLines_changes: list[Tuple[st
_taskID = progress.add_task('[blue]Find clauses with changes', start=False, total=0) _taskID = progress.add_task('[blue]Find clauses with changes', start=False, total=0)
clauseregex = re.compile('^#+\s(\d+(\.\d+)*|Annex \w(\.\d+)*|\w*(\.\d+)*|~~#).*') clauseregex = re.compile('^#+\s(\d+(\.\d+)*|Annex \w(\.\d+)*|\w*(\.\d+)*).*')
removedclauseregex = re.compile('^\~\~#+\s(\d+(\.\d+)*|Annex \w(\.\d+)*|\w+\s\w*(\.\d+)*).*')
addedclauseregex = re.compile('^\<span\sclass\=\"underline\"\>#+\s(\d+(\.\d+)*|Annex \w(\.\d+)*|\w+\s\w*(\.\d+)*).*')
clauses: list[Clause] = [] clauses: list[Clause] = []
changed_clauses: list[Clause] = [] changed_clauses: list[Clause] = []
changeInClause = False changeInClause = False
...@@ -473,24 +476,37 @@ def find_clauses_with_changes(progress: Progress, mdLines_changes: list[Tuple[st ...@@ -473,24 +476,37 @@ def find_clauses_with_changes(progress: Progress, mdLines_changes: list[Tuple[st
# break # break
# index = index + 1 # index = index + 1
index = 1 def checkClause(_matches):
for line, change in mdLines_changes: nonlocal clause
if change: nonlocal changeInClause
changeInClause = True
if line.startswith('#'):
matches = re.findall(clauseregex, line) # Match heading
if matches: # It may be the end of the clause or the start of a subclause
if index - 2 == clause.from_id: # It is a subclause if index - 2 == clause.from_id: # It is a subclause
clause.from_id = index clause.from_id = index
clause.raw = line clause.raw = line
clause.clause_nr = matches[0][0] clause.clause_nr = _matches[0][0]
else: # It is the end of the clause else: # It is the end of the clause
clause.to_id = index - 1 clause.to_id = index - 1
clauses.append(clause) clauses.append(clause)
if changeInClause: if changeInClause:
changed_clauses.append(clause) changed_clauses.append(clause)
clause = Clause(line, index, index, matches[0][0]) clause = Clause(line, index, index, _matches[0][0])
changeInClause = False changeInClause = False
index = 1
for line, change in mdLines_changes:
if change:
changeInClause = True
if line.startswith('#') or line.startswith("~~#") or line.startswith("<span class=\"underline\">#"):
matches = re.findall(clauseregex, line) # Match heading
removedmatches = re.findall(removedclauseregex, line) # Match removed heading
addedmatches = re.findall(addedclauseregex, line) # Match removed heading
if matches: # It may be the end of the clause or the start of a subclause
checkClause(matches)
elif removedmatches:
checkClause(removedmatches)
elif addedmatches:
checkClause(addedmatches)
else: # it is last clause else: # it is last clause
print("Unknown heading") print("Unknown heading")
......
#!/bin/bash #!/bin/bash
FORGELIB_DOCKER_IMAGE=forge.3gpp.org:5050/tools/3gpp-scripts/forgelib:v2.11.0 FORGELIB_DOCKER_IMAGE=forge.3gpp.org:5050/tools/3gpp-scripts/forgelib:v2.13.0
GENERATE_CHANGEMARKS_DOCKER_IMAGE=generatechangemarks:master GENERATE_CHANGEMARKS_DOCKER_IMAGE=generatechangemarks:master
DOCKER_IMAGE=pandoc/core:3.1.1.0 DOCKER_IMAGE=pandoc/core:3.1.1.0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment