8 from pathlib
import Path
17 subprocess.check_output([
"git",
"rev-parse",
"--show-toplevel"])
22 except subprocess.CalledProcessError:
23 print(
"This directory is not part of a Git repository.")
28 with open(fname,
"r")
as f:
31 content = re.sub(
r"! BEGIN_HEADER.*?! END_HEADER\n",
"", content, flags=re.DOTALL)
34 content = re.sub(
r"(!.*?$)|(\s*!.*?$)",
"", content, flags=re.MULTILINE)
40 outname = f
"{modulename}_single.f90"
45 gaussjacobiquad = fortdepend.FortranProject()
46 concat_files = gaussjacobiquad.get_all_used_files(modulename)
47 print(f
"Concatenating in reverse order {concat_files}")
51 for fname
in reversed(concat_files):
52 processed_content =
process_files(prj_srcs / fname, strip_comments)
53 exp_dat.append(processed_content)
55 with Path(
get_git_root() /
"dist" / outname).open(
"w")
as f_out:
56 f_out.write(
"".join(exp_dat))
59 if __name__ ==
"__main__":
60 parser = argparse.ArgumentParser(description=
"Export single file algorithms.")
62 "--modulename", type=str, required=
True, help=
"Module to export"
65 "--outname", type=str, required=
False, help=
"Defaults to modulename_single.f90"
69 dest=
"strip_comments",
71 help=
"Remove comments",
75 dest=
"strip_comments",
79 parser.set_defaults(strip_comments=
True)
81 args = parser.parse_args()
82 export_single(args.modulename, args.strip_comments, args.outname)
def export_single(modulename, strip_comments=True, outname=None)
def process_files(fname, strip_comments=True)