Skip to content

Commit 225f3fa

Browse files
MaoSong2022MaoSong2022
authored andcommitted
refactor(main.py, preprocess.py): move directory creating to main.py
this helps understand the code
1 parent 2e9e786 commit 225f3fa

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

main.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,18 @@ def process_one_file(file_name: str) -> None:
8484
log.info(f"[VRDU] file: {file_name}, paper has been processed")
8585
return
8686

87+
# make a copy of the original tex file
88+
original_tex = os.path.join(main_directory, "paper_original.tex")
89+
shutil.copyfile(file_name, original_tex)
90+
91+
# remove the output folder if it exists
8792
output_directory = os.path.join(main_directory, "output")
8893
if os.path.exists(output_directory):
8994
shutil.rmtree(output_directory)
9095

91-
# make a copy of the original tex file
92-
original_tex = os.path.join(main_directory, "paper_original.tex")
93-
shutil.copyfile(file_name, original_tex)
96+
# output_directory stores the intermediate results
97+
# result_directory stores the final results
98+
os.makedirs(os.path.join(main_directory, "output/result"))
9499

95100
cwd = os.getcwd()
96101

vrdu/preprocess.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
log = logger.get_logger(__name__)
1212

1313

14-
1514
def remove_comments(original_tex: str) -> None:
1615
"""
1716
Removes comments from a TeX file.
@@ -187,7 +186,3 @@ def run(original_tex: str) -> None:
187186

188187
# Step 3: delete table of contents
189188
delete_table_of_contents(original_tex)
190-
191-
# create output folder
192-
main_directory = os.path.dirname(original_tex)
193-
os.makedirs(os.path.join(main_directory, "output/result"))

0 commit comments

Comments
 (0)