arxiv-to-prompt 0.5.0__tar.gz → 0.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {arxiv_to_prompt-0.5.0/src/arxiv_to_prompt.egg-info → arxiv_to_prompt-0.5.1}/PKG-INFO +1 -1
- {arxiv_to_prompt-0.5.0 → arxiv_to_prompt-0.5.1}/pyproject.toml +1 -1
- {arxiv_to_prompt-0.5.0 → arxiv_to_prompt-0.5.1}/src/arxiv_to_prompt/core.py +40 -25
- {arxiv_to_prompt-0.5.0 → arxiv_to_prompt-0.5.1/src/arxiv_to_prompt.egg-info}/PKG-INFO +1 -1
- {arxiv_to_prompt-0.5.0 → arxiv_to_prompt-0.5.1}/tests/test_core.py +17 -0
- {arxiv_to_prompt-0.5.0 → arxiv_to_prompt-0.5.1}/LICENSE +0 -0
- {arxiv_to_prompt-0.5.0 → arxiv_to_prompt-0.5.1}/README.md +0 -0
- {arxiv_to_prompt-0.5.0 → arxiv_to_prompt-0.5.1}/setup.cfg +0 -0
- {arxiv_to_prompt-0.5.0 → arxiv_to_prompt-0.5.1}/src/arxiv_to_prompt/__init__.py +0 -0
- {arxiv_to_prompt-0.5.0 → arxiv_to_prompt-0.5.1}/src/arxiv_to_prompt/cli.py +0 -0
- {arxiv_to_prompt-0.5.0 → arxiv_to_prompt-0.5.1}/src/arxiv_to_prompt.egg-info/SOURCES.txt +0 -0
- {arxiv_to_prompt-0.5.0 → arxiv_to_prompt-0.5.1}/src/arxiv_to_prompt.egg-info/dependency_links.txt +0 -0
- {arxiv_to_prompt-0.5.0 → arxiv_to_prompt-0.5.1}/src/arxiv_to_prompt.egg-info/entry_points.txt +0 -0
- {arxiv_to_prompt-0.5.0 → arxiv_to_prompt-0.5.1}/src/arxiv_to_prompt.egg-info/requires.txt +0 -0
- {arxiv_to_prompt-0.5.0 → arxiv_to_prompt-0.5.1}/src/arxiv_to_prompt.egg-info/top_level.txt +0 -0
|
@@ -92,40 +92,55 @@ def download_arxiv_source(arxiv_id: str, cache_dir: Optional[str] = None, use_ca
|
|
|
92
92
|
|
|
93
93
|
def find_main_tex(directory: str) -> Optional[str]:
|
|
94
94
|
"""
|
|
95
|
-
Find the main .tex file containing documentclass.
|
|
95
|
+
Find the main .tex file containing documentclass.
|
|
96
|
+
Searches recursively through subdirectories.
|
|
96
97
|
First checks for common naming conventions (main.tex, paper.tex, index.tex).
|
|
97
|
-
If none found, returns the
|
|
98
|
-
since shorter files are typically conference templates or supplementary documents
|
|
98
|
+
If none found, returns the path of the longest .tex file containing documentclass,
|
|
99
|
+
since shorter files are typically conference templates or supplementary documents
|
|
99
100
|
rather than the main manuscript.
|
|
100
101
|
"""
|
|
101
102
|
common_names = ['main.tex', 'paper.tex', 'index.tex']
|
|
102
103
|
main_tex_file = None
|
|
103
104
|
max_line_count = 0
|
|
104
105
|
|
|
105
|
-
#
|
|
106
|
-
for
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
106
|
+
# Walk through directory and subdirectories
|
|
107
|
+
for root, dirs, files in os.walk(directory):
|
|
108
|
+
rel_root = os.path.relpath(root, directory)
|
|
109
|
+
|
|
110
|
+
# First pass: check for common naming conventions
|
|
111
|
+
for file_name in files:
|
|
112
|
+
if file_name in common_names:
|
|
113
|
+
file_path = os.path.join(root, file_name)
|
|
114
|
+
try:
|
|
115
|
+
with open(file_path, 'r', encoding='utf-8') as file:
|
|
116
|
+
lines = file.readlines()
|
|
117
|
+
if any('\\documentclass' in line for line in lines):
|
|
118
|
+
if rel_root == '.':
|
|
119
|
+
return file_name
|
|
120
|
+
return os.path.join(rel_root, file_name)
|
|
121
|
+
except Exception as e:
|
|
122
|
+
logging.warning(f"Could not read file {file_path}: {e}")
|
|
115
123
|
|
|
116
124
|
# Second pass: find the longest .tex file containing documentclass
|
|
117
|
-
for
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
for root, dirs, files in os.walk(directory):
|
|
126
|
+
rel_root = os.path.relpath(root, directory)
|
|
127
|
+
|
|
128
|
+
for file_name in files:
|
|
129
|
+
if file_name.endswith('.tex'):
|
|
130
|
+
file_path = os.path.join(root, file_name)
|
|
131
|
+
try:
|
|
132
|
+
with open(file_path, 'r', encoding='utf-8') as file:
|
|
133
|
+
lines = file.readlines()
|
|
134
|
+
if any('\\documentclass' in line for line in lines):
|
|
135
|
+
line_count = len(lines)
|
|
136
|
+
if line_count > max_line_count:
|
|
137
|
+
if rel_root == '.':
|
|
138
|
+
main_tex_file = file_name
|
|
139
|
+
else:
|
|
140
|
+
main_tex_file = os.path.join(rel_root, file_name)
|
|
141
|
+
max_line_count = line_count
|
|
142
|
+
except Exception as e:
|
|
143
|
+
logging.warning(f"Could not read file {file_path}: {e}")
|
|
129
144
|
|
|
130
145
|
return main_tex_file
|
|
131
146
|
|
|
@@ -153,6 +153,23 @@ def test_find_main_tex(temp_cache_dir):
|
|
|
153
153
|
assert found_main == "main.tex"
|
|
154
154
|
|
|
155
155
|
|
|
156
|
+
def test_find_main_tex_in_subdirectory(temp_cache_dir):
|
|
157
|
+
"""Test finding main tex file in a subdirectory."""
|
|
158
|
+
# Create test directory with subdirectory
|
|
159
|
+
tex_dir = temp_cache_dir / "test_tex_subdir"
|
|
160
|
+
tex_dir.mkdir(parents=True)
|
|
161
|
+
subdir = tex_dir / "paper"
|
|
162
|
+
subdir.mkdir()
|
|
163
|
+
|
|
164
|
+
# Create main.tex in subdirectory
|
|
165
|
+
main_file = subdir / "main.tex"
|
|
166
|
+
main_file.write_text("\\documentclass{article}\n\\begin{document}\nHello\n\\end{document}")
|
|
167
|
+
|
|
168
|
+
# Test finding main file in subdirectory
|
|
169
|
+
found_main = find_main_tex(str(tex_dir))
|
|
170
|
+
assert found_main == os.path.join("paper", "main.tex")
|
|
171
|
+
|
|
172
|
+
|
|
156
173
|
def test_commented_input_commands(temp_cache_dir):
|
|
157
174
|
"""Test that commented-out \\include and \\input commands are ignored."""
|
|
158
175
|
# Create test directory and files
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{arxiv_to_prompt-0.5.0 → arxiv_to_prompt-0.5.1}/src/arxiv_to_prompt.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{arxiv_to_prompt-0.5.0 → arxiv_to_prompt-0.5.1}/src/arxiv_to_prompt.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|