scitex 2.16.0__py3-none-any.whl → 2.16.2__py3-none-any.whl
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.
- scitex/_mcp_tools/audio.py +11 -65
- scitex/audio/README.md +40 -12
- scitex/audio/__init__.py +27 -235
- scitex/audio/_audio_check.py +93 -0
- scitex/audio/_mcp/speak_handlers.py +56 -8
- scitex/audio/_speak.py +295 -0
- scitex/audio/mcp_server.py +98 -73
- scitex/scholar/url_finder/.tmp/open_url/KNOWN_RESOLVERS.py +462 -0
- scitex/scholar/url_finder/.tmp/open_url/README.md +223 -0
- scitex/scholar/url_finder/.tmp/open_url/_DOIToURLResolver.py +694 -0
- scitex/scholar/url_finder/.tmp/open_url/_OpenURLResolver.py +1160 -0
- scitex/scholar/url_finder/.tmp/open_url/_ResolverLinkFinder.py +344 -0
- scitex/scholar/url_finder/.tmp/open_url/__init__.py +24 -0
- scitex/social/__init__.py +1 -24
- scitex/writer/README.md +25 -409
- scitex/writer/__init__.py +98 -13
- {scitex-2.16.0.dist-info → scitex-2.16.2.dist-info}/METADATA +6 -1
- {scitex-2.16.0.dist-info → scitex-2.16.2.dist-info}/RECORD +21 -93
- scitex/dev/plt/data/mpl/PLOTTING_FUNCTIONS.yaml +0 -90
- scitex/dev/plt/data/mpl/PLOTTING_SIGNATURES.yaml +0 -1571
- scitex/dev/plt/data/mpl/PLOTTING_SIGNATURES_DETAILED.yaml +0 -6262
- scitex/dev/plt/data/mpl/SIGNATURES_FLATTENED.yaml +0 -1274
- scitex/dev/plt/data/mpl/dir_ax.txt +0 -459
- scitex/scholar/data/.gitkeep +0 -0
- scitex/scholar/data/README.md +0 -44
- scitex/scholar/data/bib_files/bibliography.bib +0 -1952
- scitex/scholar/data/bib_files/neurovista.bib +0 -277
- scitex/scholar/data/bib_files/neurovista_enriched.bib +0 -441
- scitex/scholar/data/bib_files/neurovista_enriched_enriched.bib +0 -441
- scitex/scholar/data/bib_files/neurovista_processed.bib +0 -338
- scitex/scholar/data/bib_files/openaccess.bib +0 -89
- scitex/scholar/data/bib_files/pac-seizure_prediction_enriched.bib +0 -2178
- scitex/scholar/data/bib_files/pac.bib +0 -698
- scitex/scholar/data/bib_files/pac_enriched.bib +0 -1061
- scitex/scholar/data/bib_files/pac_processed.bib +0 -0
- scitex/scholar/data/bib_files/pac_titles.txt +0 -75
- scitex/scholar/data/bib_files/paywalled.bib +0 -98
- scitex/scholar/data/bib_files/related-papers-by-coauthors.bib +0 -58
- scitex/scholar/data/bib_files/related-papers-by-coauthors_enriched.bib +0 -87
- scitex/scholar/data/bib_files/seizure_prediction.bib +0 -694
- scitex/scholar/data/bib_files/seizure_prediction_processed.bib +0 -0
- scitex/scholar/data/bib_files/test_complete_enriched.bib +0 -437
- scitex/scholar/data/bib_files/test_final_enriched.bib +0 -437
- scitex/scholar/data/bib_files/test_seizure.bib +0 -46
- scitex/scholar/data/impact_factor/JCR_IF_2022.xlsx +0 -0
- scitex/scholar/data/impact_factor/JCR_IF_2024.db +0 -0
- scitex/scholar/data/impact_factor/JCR_IF_2024.xlsx +0 -0
- scitex/scholar/data/impact_factor/JCR_IF_2024_v01.db +0 -0
- scitex/scholar/data/impact_factor.db +0 -0
- scitex/writer/Writer.py +0 -487
- scitex/writer/_clone_writer_project.py +0 -160
- scitex/writer/_compile/__init__.py +0 -41
- scitex/writer/_compile/_compile_async.py +0 -130
- scitex/writer/_compile/_compile_unified.py +0 -148
- scitex/writer/_compile/_parser.py +0 -63
- scitex/writer/_compile/_runner.py +0 -457
- scitex/writer/_compile/_validator.py +0 -46
- scitex/writer/_compile/manuscript.py +0 -110
- scitex/writer/_compile/revision.py +0 -82
- scitex/writer/_compile/supplementary.py +0 -100
- scitex/writer/_dataclasses/__init__.py +0 -44
- scitex/writer/_dataclasses/config/_CONSTANTS.py +0 -46
- scitex/writer/_dataclasses/config/_WriterConfig.py +0 -175
- scitex/writer/_dataclasses/config/__init__.py +0 -9
- scitex/writer/_dataclasses/contents/_ManuscriptContents.py +0 -236
- scitex/writer/_dataclasses/contents/_RevisionContents.py +0 -136
- scitex/writer/_dataclasses/contents/_SupplementaryContents.py +0 -114
- scitex/writer/_dataclasses/contents/__init__.py +0 -9
- scitex/writer/_dataclasses/core/_Document.py +0 -146
- scitex/writer/_dataclasses/core/_DocumentSection.py +0 -546
- scitex/writer/_dataclasses/core/__init__.py +0 -7
- scitex/writer/_dataclasses/results/_CompilationResult.py +0 -165
- scitex/writer/_dataclasses/results/_LaTeXIssue.py +0 -102
- scitex/writer/_dataclasses/results/_SaveSectionsResponse.py +0 -118
- scitex/writer/_dataclasses/results/_SectionReadResponse.py +0 -131
- scitex/writer/_dataclasses/results/__init__.py +0 -11
- scitex/writer/_dataclasses/tree/MINIMUM_FILES.md +0 -121
- scitex/writer/_dataclasses/tree/_ConfigTree.py +0 -86
- scitex/writer/_dataclasses/tree/_ManuscriptTree.py +0 -84
- scitex/writer/_dataclasses/tree/_RevisionTree.py +0 -97
- scitex/writer/_dataclasses/tree/_ScriptsTree.py +0 -118
- scitex/writer/_dataclasses/tree/_SharedTree.py +0 -100
- scitex/writer/_dataclasses/tree/_SupplementaryTree.py +0 -101
- scitex/writer/_dataclasses/tree/__init__.py +0 -23
- scitex/writer/_mcp/__init__.py +0 -4
- scitex/writer/_mcp/handlers.py +0 -32
- scitex/writer/_mcp/tool_schemas.py +0 -33
- scitex/writer/_project/__init__.py +0 -29
- scitex/writer/_project/_create.py +0 -89
- scitex/writer/_project/_trees.py +0 -63
- scitex/writer/_project/_validate.py +0 -61
- scitex/writer/utils/.legacy_git_retry.py +0 -164
- scitex/writer/utils/__init__.py +0 -24
- scitex/writer/utils/_converters.py +0 -635
- scitex/writer/utils/_parse_latex_logs.py +0 -138
- scitex/writer/utils/_parse_script_args.py +0 -156
- scitex/writer/utils/_verify_tree_structure.py +0 -205
- scitex/writer/utils/_watch.py +0 -96
- {scitex-2.16.0.dist-info → scitex-2.16.2.dist-info}/WHEEL +0 -0
- {scitex-2.16.0.dist-info → scitex-2.16.2.dist-info}/entry_points.txt +0 -0
- {scitex-2.16.0.dist-info → scitex-2.16.2.dist-info}/licenses/LICENSE +0 -0
scitex/writer/Writer.py
DELETED
|
@@ -1,487 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# Timestamp: "2025-10-29 06:13:07 (ywatanabe)"
|
|
3
|
-
# File: /home/ywatanabe/proj/scitex-code/src/scitex/writer/_Writer.py
|
|
4
|
-
# ----------------------------------------
|
|
5
|
-
from __future__ import annotations
|
|
6
|
-
|
|
7
|
-
import os
|
|
8
|
-
|
|
9
|
-
__FILE__ = "./src/scitex/writer/_Writer.py"
|
|
10
|
-
__DIR__ = os.path.dirname(__FILE__)
|
|
11
|
-
# ----------------------------------------
|
|
12
|
-
|
|
13
|
-
"""
|
|
14
|
-
Writer class for manuscript LaTeX compilation.
|
|
15
|
-
|
|
16
|
-
Provides object-oriented interface to scitex-writer functionality.
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
from pathlib import Path
|
|
21
|
-
from typing import Callable, Optional
|
|
22
|
-
|
|
23
|
-
from scitex import logging
|
|
24
|
-
from scitex.git import init_git_repo
|
|
25
|
-
|
|
26
|
-
from ._clone_writer_project import (
|
|
27
|
-
clone_writer_project as _clone_writer_project,
|
|
28
|
-
)
|
|
29
|
-
from ._compile import (
|
|
30
|
-
CompilationResult,
|
|
31
|
-
compile_manuscript,
|
|
32
|
-
compile_revision,
|
|
33
|
-
compile_supplementary,
|
|
34
|
-
)
|
|
35
|
-
from ._dataclasses import ManuscriptTree, RevisionTree, SupplementaryTree
|
|
36
|
-
from ._dataclasses.config import DOC_TYPE_DIRS
|
|
37
|
-
from ._dataclasses.tree import ScriptsTree, SharedTree
|
|
38
|
-
from .utils._watch import watch_manuscript
|
|
39
|
-
|
|
40
|
-
logger = logging.getLogger(__name__)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
class Writer:
|
|
44
|
-
"""LaTeX manuscript compiler."""
|
|
45
|
-
|
|
46
|
-
def __init__(
|
|
47
|
-
self,
|
|
48
|
-
project_dir: Path,
|
|
49
|
-
name: Optional[str] = None,
|
|
50
|
-
git_strategy: Optional[str] = "child",
|
|
51
|
-
branch: Optional[str] = None,
|
|
52
|
-
tag: Optional[str] = None,
|
|
53
|
-
):
|
|
54
|
-
"""
|
|
55
|
-
Initialize for project directory.
|
|
56
|
-
|
|
57
|
-
If directory doesn't exist, creates new project.
|
|
58
|
-
|
|
59
|
-
Parameters
|
|
60
|
-
----------
|
|
61
|
-
project_dir : Path
|
|
62
|
-
Path to project directory.
|
|
63
|
-
name : str, optional
|
|
64
|
-
Project name (used if creating new project).
|
|
65
|
-
git_strategy : str, optional
|
|
66
|
-
Git initialization strategy:
|
|
67
|
-
- 'child': Create isolated git in project directory (default)
|
|
68
|
-
- 'parent': Use parent git repository
|
|
69
|
-
- 'origin': Preserve template's original git history
|
|
70
|
-
- None: Disable git initialization
|
|
71
|
-
branch : str, optional
|
|
72
|
-
Specific branch of template repository to clone.
|
|
73
|
-
If None, clones the default branch. Mutually exclusive with tag.
|
|
74
|
-
tag : str, optional
|
|
75
|
-
Specific tag/release of template repository to clone.
|
|
76
|
-
If None, clones the default branch. Mutually exclusive with branch.
|
|
77
|
-
"""
|
|
78
|
-
self.project_name = name or Path(project_dir).name
|
|
79
|
-
self.project_dir = Path(project_dir)
|
|
80
|
-
self.git_strategy = git_strategy
|
|
81
|
-
self.branch = branch
|
|
82
|
-
self.tag = tag
|
|
83
|
-
|
|
84
|
-
ref_info = ""
|
|
85
|
-
if branch:
|
|
86
|
-
ref_info = f" (branch: {branch})"
|
|
87
|
-
elif tag:
|
|
88
|
-
ref_info = f" (tag: {tag})"
|
|
89
|
-
logger.info(
|
|
90
|
-
f"Writer: Initializing with:\n"
|
|
91
|
-
f" Project Name: {self.project_name}\n"
|
|
92
|
-
f" Project Directory: {self.project_dir.absolute()}\n"
|
|
93
|
-
f" Git Strategy: {self.git_strategy}{ref_info}..."
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
# Create or attach to project
|
|
97
|
-
self.project_dir = self._attach_or_create_project(name)
|
|
98
|
-
|
|
99
|
-
# Initialize git repository based on strategy (delegates to template module)
|
|
100
|
-
self.git_root = init_git_repo(self.project_dir, self.git_strategy)
|
|
101
|
-
|
|
102
|
-
# Document accessors (pass git_root for efficiency)
|
|
103
|
-
self.shared = SharedTree(self.project_dir / "00_shared", git_root=self.git_root)
|
|
104
|
-
self.manuscript = ManuscriptTree(
|
|
105
|
-
self.project_dir / "01_manuscript", git_root=self.git_root
|
|
106
|
-
)
|
|
107
|
-
self.supplementary = SupplementaryTree(
|
|
108
|
-
self.project_dir / "02_supplementary", git_root=self.git_root
|
|
109
|
-
)
|
|
110
|
-
self.revision = RevisionTree(
|
|
111
|
-
self.project_dir / "03_revision", git_root=self.git_root
|
|
112
|
-
)
|
|
113
|
-
self.scripts = ScriptsTree(self.project_dir / "scripts", git_root=self.git_root)
|
|
114
|
-
|
|
115
|
-
logger.success(f"Writer: Initialization complete for {self.project_name}")
|
|
116
|
-
|
|
117
|
-
def _attach_or_create_project(self, name: Optional[str] = None) -> Path:
|
|
118
|
-
"""
|
|
119
|
-
Create new project or attach to existing one.
|
|
120
|
-
|
|
121
|
-
If project directory doesn't exist, creates it based on git_strategy:
|
|
122
|
-
- 'child': Full template with git initialization
|
|
123
|
-
- 'parent'/'None': Minimal directory structure
|
|
124
|
-
|
|
125
|
-
Parameters
|
|
126
|
-
----------
|
|
127
|
-
name : str, optional
|
|
128
|
-
Project name (used if creating new project).
|
|
129
|
-
|
|
130
|
-
Returns
|
|
131
|
-
-------
|
|
132
|
-
Path
|
|
133
|
-
Path to the project directory.
|
|
134
|
-
"""
|
|
135
|
-
if self.project_dir.exists():
|
|
136
|
-
logger.info(
|
|
137
|
-
f"Writer: Attached to existing project at {self.project_dir.absolute()}"
|
|
138
|
-
)
|
|
139
|
-
# Verify existing project structure
|
|
140
|
-
self._verify_project_structure()
|
|
141
|
-
return self.project_dir
|
|
142
|
-
|
|
143
|
-
project_name = name or self.project_dir.name
|
|
144
|
-
|
|
145
|
-
logger.info(
|
|
146
|
-
f"Writer: Creating new project '{project_name}' at {self.project_dir.absolute()}"
|
|
147
|
-
)
|
|
148
|
-
|
|
149
|
-
# Initialize project directory structure
|
|
150
|
-
success = _clone_writer_project(
|
|
151
|
-
str(self.project_dir), self.git_strategy, self.branch, self.tag
|
|
152
|
-
)
|
|
153
|
-
|
|
154
|
-
if not success:
|
|
155
|
-
logger.error(
|
|
156
|
-
f"Writer: Failed to initialize project directory for {project_name}"
|
|
157
|
-
)
|
|
158
|
-
raise RuntimeError(
|
|
159
|
-
f"Could not create project directory at {self.project_dir}"
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
# Verify project directory was created
|
|
163
|
-
if not self.project_dir.exists():
|
|
164
|
-
logger.error(
|
|
165
|
-
f"Writer: Project directory {self.project_dir} was not created"
|
|
166
|
-
)
|
|
167
|
-
raise RuntimeError(f"Project directory {self.project_dir} was not created")
|
|
168
|
-
|
|
169
|
-
logger.success(
|
|
170
|
-
f"Writer: Successfully created project at {self.project_dir.absolute()}"
|
|
171
|
-
)
|
|
172
|
-
return self.project_dir
|
|
173
|
-
|
|
174
|
-
def _verify_project_structure(self) -> None:
|
|
175
|
-
"""
|
|
176
|
-
Verify attached project has expected structure.
|
|
177
|
-
|
|
178
|
-
Checks:
|
|
179
|
-
- Required directories exist (01_manuscript, 02_supplementary, 03_revision)
|
|
180
|
-
- .git exists (for git-enabled strategies)
|
|
181
|
-
|
|
182
|
-
Raises
|
|
183
|
-
------
|
|
184
|
-
RuntimeError
|
|
185
|
-
If structure is invalid.
|
|
186
|
-
"""
|
|
187
|
-
required_dirs = [
|
|
188
|
-
self.project_dir / "01_manuscript",
|
|
189
|
-
self.project_dir / "02_supplementary",
|
|
190
|
-
self.project_dir / "03_revision",
|
|
191
|
-
]
|
|
192
|
-
|
|
193
|
-
for dir_path in required_dirs:
|
|
194
|
-
if not dir_path.exists():
|
|
195
|
-
logger.error(f"Writer: Expected directory missing: {dir_path}")
|
|
196
|
-
raise RuntimeError(
|
|
197
|
-
f"Project structure invalid: missing {dir_path.name} directory"
|
|
198
|
-
)
|
|
199
|
-
|
|
200
|
-
logger.success(
|
|
201
|
-
f"Writer: Project structure verified at {self.project_dir.absolute()}"
|
|
202
|
-
)
|
|
203
|
-
|
|
204
|
-
def compile_manuscript(
|
|
205
|
-
self,
|
|
206
|
-
timeout: int = 300,
|
|
207
|
-
log_callback: Optional[Callable[[str], None]] = None,
|
|
208
|
-
progress_callback: Optional[Callable[[int, str], None]] = None,
|
|
209
|
-
) -> CompilationResult:
|
|
210
|
-
"""
|
|
211
|
-
Compile manuscript to PDF with optional live callbacks.
|
|
212
|
-
|
|
213
|
-
Runs scripts/shell/compile_manuscript.sh with configured settings.
|
|
214
|
-
|
|
215
|
-
Parameters
|
|
216
|
-
----------
|
|
217
|
-
timeout : int, optional
|
|
218
|
-
Maximum compilation time in seconds (default: 300).
|
|
219
|
-
log_callback : callable, optional
|
|
220
|
-
Called with each log line: log_callback("Running pdflatex...").
|
|
221
|
-
progress_callback : callable, optional
|
|
222
|
-
Called with progress: progress_callback(50, "Pass 2/3").
|
|
223
|
-
|
|
224
|
-
Returns
|
|
225
|
-
-------
|
|
226
|
-
CompilationResult
|
|
227
|
-
With success status, PDF path, and errors/warnings.
|
|
228
|
-
|
|
229
|
-
Examples
|
|
230
|
-
--------
|
|
231
|
-
>>> writer = Writer(Path("my_paper"))
|
|
232
|
-
>>> result = writer.compile_manuscript()
|
|
233
|
-
>>> if result.success:
|
|
234
|
-
... print(f"PDF created: {result.output_pdf}")
|
|
235
|
-
"""
|
|
236
|
-
return compile_manuscript(
|
|
237
|
-
self.project_dir,
|
|
238
|
-
timeout=timeout,
|
|
239
|
-
log_callback=log_callback,
|
|
240
|
-
progress_callback=progress_callback,
|
|
241
|
-
)
|
|
242
|
-
|
|
243
|
-
def compile_supplementary(
|
|
244
|
-
self,
|
|
245
|
-
timeout: int = 300,
|
|
246
|
-
log_callback: Optional[Callable[[str], None]] = None,
|
|
247
|
-
progress_callback: Optional[Callable[[int, str], None]] = None,
|
|
248
|
-
) -> CompilationResult:
|
|
249
|
-
"""
|
|
250
|
-
Compile supplementary materials to PDF with optional live callbacks.
|
|
251
|
-
|
|
252
|
-
Runs scripts/shell/compile_supplementary.sh with configured settings.
|
|
253
|
-
|
|
254
|
-
Parameters
|
|
255
|
-
----------
|
|
256
|
-
timeout : int, optional
|
|
257
|
-
Maximum compilation time in seconds (default: 300).
|
|
258
|
-
log_callback : callable, optional
|
|
259
|
-
Called with each log line.
|
|
260
|
-
progress_callback : callable, optional
|
|
261
|
-
Called with progress updates.
|
|
262
|
-
|
|
263
|
-
Returns
|
|
264
|
-
-------
|
|
265
|
-
CompilationResult
|
|
266
|
-
With success status, PDF path, and errors/warnings.
|
|
267
|
-
|
|
268
|
-
Examples
|
|
269
|
-
--------
|
|
270
|
-
>>> writer = Writer(Path("my_paper"))
|
|
271
|
-
>>> result = writer.compile_supplementary()
|
|
272
|
-
>>> if result.success:
|
|
273
|
-
... print(f"PDF created: {result.output_pdf}")
|
|
274
|
-
"""
|
|
275
|
-
return compile_supplementary(
|
|
276
|
-
self.project_dir,
|
|
277
|
-
timeout=timeout,
|
|
278
|
-
log_callback=log_callback,
|
|
279
|
-
progress_callback=progress_callback,
|
|
280
|
-
)
|
|
281
|
-
|
|
282
|
-
def compile_revision(
|
|
283
|
-
self,
|
|
284
|
-
track_changes: bool = False,
|
|
285
|
-
timeout: int = 300,
|
|
286
|
-
log_callback: Optional[Callable[[str], None]] = None,
|
|
287
|
-
progress_callback: Optional[Callable[[int, str], None]] = None,
|
|
288
|
-
) -> CompilationResult:
|
|
289
|
-
"""
|
|
290
|
-
Compile revision document with optional change tracking and live callbacks.
|
|
291
|
-
|
|
292
|
-
Runs scripts/shell/compile_revision.sh with configured settings.
|
|
293
|
-
|
|
294
|
-
Parameters
|
|
295
|
-
----------
|
|
296
|
-
track_changes : bool, optional
|
|
297
|
-
Enable change tracking in compiled PDF (default: False).
|
|
298
|
-
timeout : int, optional
|
|
299
|
-
Maximum compilation time in seconds (default: 300).
|
|
300
|
-
log_callback : callable, optional
|
|
301
|
-
Called with each log line.
|
|
302
|
-
progress_callback : callable, optional
|
|
303
|
-
Called with progress updates.
|
|
304
|
-
|
|
305
|
-
Returns
|
|
306
|
-
-------
|
|
307
|
-
CompilationResult
|
|
308
|
-
With success status, PDF path, and errors/warnings.
|
|
309
|
-
|
|
310
|
-
Examples
|
|
311
|
-
--------
|
|
312
|
-
>>> writer = Writer(Path("my_paper"))
|
|
313
|
-
>>> result = writer.compile_revision(track_changes=True)
|
|
314
|
-
>>> if result.success:
|
|
315
|
-
... print(f"Revision PDF: {result.output_pdf}")
|
|
316
|
-
"""
|
|
317
|
-
return compile_revision(
|
|
318
|
-
self.project_dir,
|
|
319
|
-
track_changes=track_changes,
|
|
320
|
-
timeout=timeout,
|
|
321
|
-
log_callback=log_callback,
|
|
322
|
-
progress_callback=progress_callback,
|
|
323
|
-
)
|
|
324
|
-
|
|
325
|
-
def watch(self, on_compile: Optional[Callable] = None) -> None:
|
|
326
|
-
"""Auto-recompile on file changes."""
|
|
327
|
-
watch_manuscript(self.project_dir, on_compile=on_compile)
|
|
328
|
-
|
|
329
|
-
def get_pdf(self, doc_type: str = "manuscript") -> Optional[Path]:
|
|
330
|
-
"""Get output PDF path (Read)."""
|
|
331
|
-
pdf = self.project_dir / DOC_TYPE_DIRS[doc_type] / f"{doc_type}.pdf"
|
|
332
|
-
return pdf if pdf.exists() else None
|
|
333
|
-
|
|
334
|
-
def delete(self) -> bool:
|
|
335
|
-
"""Delete project directory (Delete)."""
|
|
336
|
-
import shutil
|
|
337
|
-
|
|
338
|
-
try:
|
|
339
|
-
logger.warning(
|
|
340
|
-
f"Writer: Deleting project directory at {self.project_dir.absolute()}"
|
|
341
|
-
)
|
|
342
|
-
shutil.rmtree(self.project_dir)
|
|
343
|
-
logger.success(
|
|
344
|
-
f"Writer: Successfully deleted project at {self.project_dir.absolute()}"
|
|
345
|
-
)
|
|
346
|
-
return True
|
|
347
|
-
except Exception as e:
|
|
348
|
-
logger.error(
|
|
349
|
-
f"Writer: Failed to delete project directory at {self.project_dir.absolute()}: {e}"
|
|
350
|
-
)
|
|
351
|
-
return False
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
def run_session() -> None:
|
|
355
|
-
"""Initialize scitex framework, run main function, and cleanup."""
|
|
356
|
-
global CONFIG, CC, sys, plt, rng
|
|
357
|
-
import sys
|
|
358
|
-
|
|
359
|
-
import matplotlib.pyplot as plt
|
|
360
|
-
|
|
361
|
-
import scitex as stx
|
|
362
|
-
|
|
363
|
-
args = parse_args()
|
|
364
|
-
|
|
365
|
-
CONFIG, sys.stdout, sys.stderr, plt, CC, rng = stx.session.start(
|
|
366
|
-
sys,
|
|
367
|
-
plt,
|
|
368
|
-
args=args,
|
|
369
|
-
file=__FILE__,
|
|
370
|
-
sdir_suffix=None,
|
|
371
|
-
verbose=False,
|
|
372
|
-
agg=True,
|
|
373
|
-
)
|
|
374
|
-
|
|
375
|
-
exit_status = main(args)
|
|
376
|
-
|
|
377
|
-
stx.session.close(
|
|
378
|
-
CONFIG,
|
|
379
|
-
verbose=False,
|
|
380
|
-
notify=False,
|
|
381
|
-
message="",
|
|
382
|
-
exit_status=exit_status,
|
|
383
|
-
)
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
def main(args):
|
|
387
|
-
if args.action == "create":
|
|
388
|
-
writer = Writer.create(
|
|
389
|
-
args.project_name,
|
|
390
|
-
git_strategy=args.git_strategy,
|
|
391
|
-
)
|
|
392
|
-
if writer:
|
|
393
|
-
print(f"Created writer project: {writer.project_dir}")
|
|
394
|
-
return 0
|
|
395
|
-
else:
|
|
396
|
-
print("Failed to create writer project")
|
|
397
|
-
return 1
|
|
398
|
-
|
|
399
|
-
elif args.action == "compile":
|
|
400
|
-
writer = Writer(Path(args.dir) if args.dir else Path.cwd())
|
|
401
|
-
|
|
402
|
-
if args.document == "manuscript":
|
|
403
|
-
result = writer.compile_manuscript()
|
|
404
|
-
elif args.document == "supplementary":
|
|
405
|
-
result = writer.compile_supplementary()
|
|
406
|
-
elif args.document == "revision":
|
|
407
|
-
result = writer.compile_revision(track_changes=args.track_changes)
|
|
408
|
-
|
|
409
|
-
if result.success:
|
|
410
|
-
print(f"Compilation successful: {result.output_pdf}")
|
|
411
|
-
return 0
|
|
412
|
-
else:
|
|
413
|
-
print(f"Compilation failed (exit code {result.exit_code})")
|
|
414
|
-
return result.exit_code
|
|
415
|
-
|
|
416
|
-
elif args.action == "info":
|
|
417
|
-
writer = Writer(Path(args.dir) if args.dir else Path.cwd())
|
|
418
|
-
print(f"Project: {writer.project_dir}")
|
|
419
|
-
print("\nDocuments:")
|
|
420
|
-
print(f" - Manuscript: {writer.manuscript}")
|
|
421
|
-
print(f" - Supplementary: {writer.supplementary}")
|
|
422
|
-
print(f" - Revision: {writer.revision}")
|
|
423
|
-
return 0
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
def parse_args():
|
|
427
|
-
import argparse
|
|
428
|
-
|
|
429
|
-
parser = argparse.ArgumentParser(
|
|
430
|
-
description="Writer project management and compilation"
|
|
431
|
-
)
|
|
432
|
-
parser.add_argument(
|
|
433
|
-
"--action",
|
|
434
|
-
"-a",
|
|
435
|
-
type=str,
|
|
436
|
-
choices=["create", "compile", "info"],
|
|
437
|
-
default="info",
|
|
438
|
-
help="Action to perform (default: info)",
|
|
439
|
-
)
|
|
440
|
-
parser.add_argument(
|
|
441
|
-
"--project-name",
|
|
442
|
-
"-n",
|
|
443
|
-
type=str,
|
|
444
|
-
help="Project name (for create action)",
|
|
445
|
-
)
|
|
446
|
-
parser.add_argument(
|
|
447
|
-
"--dir",
|
|
448
|
-
"-d",
|
|
449
|
-
type=str,
|
|
450
|
-
help="Project directory (for compile/info)",
|
|
451
|
-
)
|
|
452
|
-
parser.add_argument(
|
|
453
|
-
"--document",
|
|
454
|
-
"-t",
|
|
455
|
-
type=str,
|
|
456
|
-
choices=["manuscript", "supplementary", "revision"],
|
|
457
|
-
default="manuscript",
|
|
458
|
-
help="Document to compile (default: manuscript)",
|
|
459
|
-
)
|
|
460
|
-
parser.add_argument(
|
|
461
|
-
"--git-strategy",
|
|
462
|
-
"-g",
|
|
463
|
-
type=str,
|
|
464
|
-
choices=["child", "parent", "origin", "none"],
|
|
465
|
-
default="child",
|
|
466
|
-
help="Git strategy (for create action, default: child)",
|
|
467
|
-
)
|
|
468
|
-
parser.add_argument(
|
|
469
|
-
"--track-changes",
|
|
470
|
-
action="store_true",
|
|
471
|
-
help="Enable change tracking (revision only)",
|
|
472
|
-
)
|
|
473
|
-
|
|
474
|
-
return parser.parse_args()
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
if __name__ == "__main__":
|
|
478
|
-
run_session()
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
__all__ = ["Writer"]
|
|
482
|
-
|
|
483
|
-
# python -m scitex.writer.Writer --action create --project-name my_paper
|
|
484
|
-
# python -m scitex.writer.Writer --action compile --dir ./my_paper --document manuscript
|
|
485
|
-
# python -m scitex.writer.Writer --action info --dir ./my_paper
|
|
486
|
-
|
|
487
|
-
# EOF
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# Timestamp: "2025-11-18 15:41:26 (ywatanabe)"
|
|
4
|
-
# File: /home/ywatanabe/proj/scitex-code/src/scitex/writer/_clone_writer_project.py
|
|
5
|
-
|
|
6
|
-
import os
|
|
7
|
-
|
|
8
|
-
"""
|
|
9
|
-
Writer project template management.
|
|
10
|
-
|
|
11
|
-
Provides functions to create and copy writer project templates.
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
from typing import Optional
|
|
15
|
-
|
|
16
|
-
from scitex.logging import getLogger
|
|
17
|
-
|
|
18
|
-
logger = getLogger(__name__)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def clone_writer_project(
|
|
22
|
-
project_dir: str,
|
|
23
|
-
git_strategy: Optional[str] = "child",
|
|
24
|
-
branch: Optional[str] = None,
|
|
25
|
-
tag: Optional[str] = None,
|
|
26
|
-
) -> bool:
|
|
27
|
-
"""
|
|
28
|
-
Initialize a new writer project directory from scitex-writer template.
|
|
29
|
-
|
|
30
|
-
Convenience wrapper for scitex.template.clone_writer_directory.
|
|
31
|
-
Handles template cloning and project setup automatically.
|
|
32
|
-
|
|
33
|
-
Args:
|
|
34
|
-
project_dir: Path to project directory (will be created)
|
|
35
|
-
git_strategy: Git initialization strategy (optional)
|
|
36
|
-
- 'child': Create isolated git in project directory (default)
|
|
37
|
-
- 'parent': Use parent git repository
|
|
38
|
-
- 'origin': Preserve template's original git history
|
|
39
|
-
- None: Disable git initialization
|
|
40
|
-
branch: Specific branch of the template repository to clone (optional)
|
|
41
|
-
If None, clones the default branch. Mutually exclusive with tag.
|
|
42
|
-
tag: Specific tag/release of the template repository to clone (optional)
|
|
43
|
-
If None, clones the default branch. Mutually exclusive with branch.
|
|
44
|
-
|
|
45
|
-
Returns:
|
|
46
|
-
True if successful, False otherwise
|
|
47
|
-
|
|
48
|
-
Examples:
|
|
49
|
-
>>> from scitex.writer import clone_writer_project
|
|
50
|
-
>>> clone_writer_project("my_paper")
|
|
51
|
-
>>> clone_writer_project("./papers/my_paper")
|
|
52
|
-
>>> clone_writer_project("my_paper", git_strategy="parent")
|
|
53
|
-
>>> clone_writer_project("my_paper", branch="develop")
|
|
54
|
-
>>> clone_writer_project("my_paper", tag="v1.0.0")
|
|
55
|
-
"""
|
|
56
|
-
from scitex.template import clone_writer_directory
|
|
57
|
-
|
|
58
|
-
try:
|
|
59
|
-
result = clone_writer_directory(project_dir, git_strategy, branch, tag)
|
|
60
|
-
return result
|
|
61
|
-
except Exception as e:
|
|
62
|
-
logger.error(f"Failed to initialize writer directory: {e}")
|
|
63
|
-
return False
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
def run_session() -> None:
|
|
67
|
-
"""Initialize scitex framework, run main function, and cleanup."""
|
|
68
|
-
global CONFIG, CC, sys, plt, rng
|
|
69
|
-
import sys
|
|
70
|
-
import matplotlib.pyplot as plt
|
|
71
|
-
import scitex as stx
|
|
72
|
-
|
|
73
|
-
args = parse_args()
|
|
74
|
-
|
|
75
|
-
CONFIG, sys.stdout, sys.stderr, plt, CC, rng = stx.session.start(
|
|
76
|
-
sys,
|
|
77
|
-
plt,
|
|
78
|
-
args=args,
|
|
79
|
-
file=__FILE__,
|
|
80
|
-
sdir_suffix=None,
|
|
81
|
-
verbose=False,
|
|
82
|
-
agg=True,
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
exit_status = main(args)
|
|
86
|
-
|
|
87
|
-
stx.session.close(
|
|
88
|
-
CONFIG,
|
|
89
|
-
verbose=False,
|
|
90
|
-
notify=False,
|
|
91
|
-
message="",
|
|
92
|
-
exit_status=exit_status,
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
def main(args):
|
|
97
|
-
result = clone_writer_project(
|
|
98
|
-
args.project_dir,
|
|
99
|
-
git_strategy=args.git_strategy,
|
|
100
|
-
branch=args.branch,
|
|
101
|
-
tag=args.tag,
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
if result:
|
|
105
|
-
print(f"Successfully created writer project: {args.project_dir}")
|
|
106
|
-
return 0
|
|
107
|
-
else:
|
|
108
|
-
print(f"Failed to create writer project: {args.project_dir}")
|
|
109
|
-
return 1
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
def parse_args():
|
|
113
|
-
import argparse
|
|
114
|
-
|
|
115
|
-
parser = argparse.ArgumentParser(description="Clone scitex writer project template")
|
|
116
|
-
parser.add_argument(
|
|
117
|
-
"project_dir",
|
|
118
|
-
type=str,
|
|
119
|
-
help="Path to project directory (will be created)",
|
|
120
|
-
)
|
|
121
|
-
parser.add_argument(
|
|
122
|
-
"--git-strategy",
|
|
123
|
-
"-g",
|
|
124
|
-
type=str,
|
|
125
|
-
choices=["child", "parent", "origin", "none"],
|
|
126
|
-
default="child",
|
|
127
|
-
help="Git initialization strategy (default: child)",
|
|
128
|
-
)
|
|
129
|
-
parser.add_argument(
|
|
130
|
-
"--branch",
|
|
131
|
-
"-b",
|
|
132
|
-
type=str,
|
|
133
|
-
default=None,
|
|
134
|
-
help="Specific branch of template to clone (mutually exclusive with --tag)",
|
|
135
|
-
)
|
|
136
|
-
parser.add_argument(
|
|
137
|
-
"--tag",
|
|
138
|
-
"-t",
|
|
139
|
-
type=str,
|
|
140
|
-
default=None,
|
|
141
|
-
help="Specific tag/release of template to clone (mutually exclusive with --branch)",
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
return parser.parse_args()
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if __name__ == "__main__":
|
|
148
|
-
run_session()
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
__all__ = [
|
|
152
|
-
"clone_writer_project",
|
|
153
|
-
]
|
|
154
|
-
|
|
155
|
-
# python -m scitex.writer._clone_writer_project my_paper --git-strategy child
|
|
156
|
-
# python -m scitex.writer._clone_writer_project ./papers/my_paper
|
|
157
|
-
# python -m scitex.writer._clone_writer_project my_paper --branch develop
|
|
158
|
-
# python -m scitex.writer._clone_writer_project my_paper --tag v1.0.0
|
|
159
|
-
|
|
160
|
-
# EOF
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# Timestamp: "2025-11-08 (ywatanabe)"
|
|
3
|
-
# File: /home/ywatanabe/proj/scitex-code/src/scitex/writer/_compile/__init__.py
|
|
4
|
-
# ----------------------------------------
|
|
5
|
-
from __future__ import annotations
|
|
6
|
-
|
|
7
|
-
import os
|
|
8
|
-
|
|
9
|
-
__FILE__ = "./src/scitex/writer/_compile/__init__.py"
|
|
10
|
-
__DIR__ = os.path.dirname(__FILE__)
|
|
11
|
-
# ----------------------------------------
|
|
12
|
-
|
|
13
|
-
"""
|
|
14
|
-
LaTeX compilation module for writer.
|
|
15
|
-
|
|
16
|
-
Provides organized compilation functionality:
|
|
17
|
-
- manuscript: Manuscript compilation with figure/conversion options
|
|
18
|
-
- supplementary: Supplementary materials compilation
|
|
19
|
-
- revision: Revision response compilation with change tracking
|
|
20
|
-
- _runner: Script execution engine
|
|
21
|
-
- _parser: Output parsing utilities
|
|
22
|
-
- _validator: Pre-compile validation
|
|
23
|
-
"""
|
|
24
|
-
|
|
25
|
-
from .._dataclasses import CompilationResult
|
|
26
|
-
from ._compile_unified import compile
|
|
27
|
-
from ._runner import run_compile
|
|
28
|
-
from .manuscript import compile_manuscript
|
|
29
|
-
from .revision import compile_revision
|
|
30
|
-
from .supplementary import compile_supplementary
|
|
31
|
-
|
|
32
|
-
__all__ = [
|
|
33
|
-
"compile",
|
|
34
|
-
"run_compile",
|
|
35
|
-
"compile_manuscript",
|
|
36
|
-
"compile_supplementary",
|
|
37
|
-
"compile_revision",
|
|
38
|
-
"CompilationResult",
|
|
39
|
-
]
|
|
40
|
-
|
|
41
|
-
# EOF
|