Skip to content

Commit 6682997

Browse files
authored
Prettify and fully automate library generation (#52)
2 parents fb757ab + 0562593 commit 6682997

12 files changed

+9641
-9491
lines changed

scripts/align_labelled_continue.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Revert the ugly labelled continue statements created by fprettify
2+
3+
def revert_fprettify_labels(source_folder,file_name):
4+
5+
import re
6+
import os
7+
8+
# Load whole file; split by lines
9+
with open(os.path.join(source_folder,file_name), 'r') as file:
10+
# Create an empty list to store the lines
11+
file_body = []
12+
13+
# Iterate over the lines of the file
14+
for line in file:
15+
file_body.append(line.rstrip())
16+
17+
18+
file.close()
19+
20+
for i in range(len(file_body)):
21+
if 'continue' in file_body[i]:
22+
old = file_body[i]
23+
nspaces = len(file_body[i-1])-len(file_body[i-1].lstrip())
24+
file_body[i] = re.sub(r'(\s*)([0-9]+)(\s*)(continue)(\s*)'," "*nspaces+r'\2 \4',old)
25+
26+
# Write out
27+
fid = open(os.path.join(source_folder,file_name), 'w')
28+
for i in range(len(file_body)):
29+
fid.write("{}\n".format(file_body[i]))
30+
fid.close()
31+
32+
33+
# Launch script
34+
revert_fprettify_labels("../src","stdlib_linalg_lapack_s.f90")
35+
revert_fprettify_labels("../src","stdlib_linalg_lapack_d.f90")
36+
revert_fprettify_labels("../src","stdlib_linalg_lapack_q.f90")
37+
revert_fprettify_labels("../src","stdlib_linalg_lapack_c.f90")
38+
revert_fprettify_labels("../src","stdlib_linalg_lapack_z.f90")
39+
revert_fprettify_labels("../src","stdlib_linalg_lapack_w.f90")
40+
41+
42+
43+

0 commit comments

Comments
 (0)