Compare commits
No commits in common. "5e34464718aab064d7c3c4e574e2f60b7a07dca5" and "1118341f26b056a8e92ddaf44ac01a5aa362ca4c" have entirely different histories.
5e34464718
...
1118341f26
44
unifytex
44
unifytex
@ -1,44 +0,0 @@
|
|||||||
#!/bin/python3
|
|
||||||
|
|
||||||
import os
|
|
||||||
import argparse
|
|
||||||
|
|
||||||
def dynamic_includes(folder_path):
|
|
||||||
"""Generate separate LaTeX files recursively"""
|
|
||||||
consolidated_dir = os.path.join(os.getcwd(), "consolidated")
|
|
||||||
os.makedirs(consolidated_dir, exist_ok=True)
|
|
||||||
|
|
||||||
for root, dirs, files in os.walk(folder_path):
|
|
||||||
if not files or os.path.abspath(root) == os.path.abspath(consolidated_dir):
|
|
||||||
continue
|
|
||||||
|
|
||||||
if root == folder_path:
|
|
||||||
folder_name = os.path.basename(folder_path) or "root"
|
|
||||||
else:
|
|
||||||
folder_name = os.path.basename(root)
|
|
||||||
|
|
||||||
output_file = os.path.join(consolidated_dir, f"{folder_name}.tex")
|
|
||||||
|
|
||||||
with open(output_file, "w") as f:
|
|
||||||
f.write("% Autogenerated by unifytex (git.confest.im/boyan_k/Coding_Tools/)\n")
|
|
||||||
for file in sorted(files):
|
|
||||||
if file.endswith(".tex"):
|
|
||||||
relative_path = os.path.relpath(os.path.join(root, file), folder_path)
|
|
||||||
f.write(f"\\input{{{relative_path}}}\n")
|
|
||||||
|
|
||||||
print(f"Generated {output_file}")
|
|
||||||
|
|
||||||
def main():
|
|
||||||
parser = argparse.ArgumentParser(description="Generate separate LaTeX include files for .tex files recursively")
|
|
||||||
parser.add_argument("directory", help="The directory to process.")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
directory = args.directory
|
|
||||||
|
|
||||||
if not os.path.isdir(directory):
|
|
||||||
raise FileNotFoundError(f"Error: The directory '{directory}' does not exist.")
|
|
||||||
|
|
||||||
dynamic_includes(directory)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
Loading…
x
Reference in New Issue
Block a user