Skip to content

Commit

Permalink
prettify: Stop removing certain comments
Browse files Browse the repository at this point in the history
  • Loading branch information
oschuett committed Mar 12, 2020
1 parent 698580b commit 0d0e004
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions tools/prettify/prettify_cp2k/normalizeFortranFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@

STR_RE = re.compile(r"('[^'\n]*'|\"[^\"\n]*\")")

COMMENT_TO_REMOVE_RE = re.compile(
r" *! *(?:interface|arguments|parameters|locals?|\** *local +variables *\**|\** *local +parameters *\**) *$",
re.IGNORECASE,
)

MODULE_N_RE = re.compile(
r".*:: *moduleN *= *(['\"])[a-zA-Z_0-9]+\1", flags=re.IGNORECASE
)
Expand Down Expand Up @@ -906,8 +901,7 @@ def cleanDeclarations(routine, logger):

newDecl = StringIO()
for comment in routine["preDeclComments"]:
if not COMMENT_TO_REMOVE_RE.match(comment):
newDecl.write(comment)
newDecl.write(comment)
newDecl.writelines(routine["use"])
writeDeclarations(argDecl, newDecl)
if argDecl and paramDecl:
Expand All @@ -920,7 +914,7 @@ def cleanDeclarations(routine, logger):
newDecl.write("\n")
wrote = 0
for comment in routine["declComments"]:
if comment.strip() and not COMMENT_TO_REMOVE_RE.match(comment):
if comment.strip():
newDecl.write(comment.strip())
newDecl.write("\n")
wrote = 1
Expand All @@ -943,9 +937,8 @@ def cleanDeclarations(routine, logger):
comment_start += 1

for comment in routine["postDeclComments"][comment_start:]:
if not COMMENT_TO_REMOVE_RE.match(comment):
newDecl.write(comment)
newDecl.write("\n")
newDecl.write(comment)
newDecl.write("\n")
routine["declarations"][0] += newDecl.getvalue()


Expand Down

0 comments on commit 0d0e004

Please sign in to comment.