scitex 2.16.0__py3-none-any.whl → 2.16.1__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.
Files changed (64) hide show
  1. scitex/_mcp_tools/audio.py +11 -65
  2. scitex/audio/README.md +40 -12
  3. scitex/audio/__init__.py +27 -235
  4. scitex/audio/_audio_check.py +93 -0
  5. scitex/audio/_mcp/speak_handlers.py +56 -8
  6. scitex/audio/_speak.py +295 -0
  7. scitex/audio/mcp_server.py +98 -73
  8. scitex/social/__init__.py +1 -24
  9. scitex/writer/README.md +25 -409
  10. scitex/writer/__init__.py +98 -13
  11. {scitex-2.16.0.dist-info → scitex-2.16.1.dist-info}/METADATA +6 -1
  12. {scitex-2.16.0.dist-info → scitex-2.16.1.dist-info}/RECORD +15 -62
  13. scitex/writer/Writer.py +0 -487
  14. scitex/writer/_clone_writer_project.py +0 -160
  15. scitex/writer/_compile/__init__.py +0 -41
  16. scitex/writer/_compile/_compile_async.py +0 -130
  17. scitex/writer/_compile/_compile_unified.py +0 -148
  18. scitex/writer/_compile/_parser.py +0 -63
  19. scitex/writer/_compile/_runner.py +0 -457
  20. scitex/writer/_compile/_validator.py +0 -46
  21. scitex/writer/_compile/manuscript.py +0 -110
  22. scitex/writer/_compile/revision.py +0 -82
  23. scitex/writer/_compile/supplementary.py +0 -100
  24. scitex/writer/_dataclasses/__init__.py +0 -44
  25. scitex/writer/_dataclasses/config/_CONSTANTS.py +0 -46
  26. scitex/writer/_dataclasses/config/_WriterConfig.py +0 -175
  27. scitex/writer/_dataclasses/config/__init__.py +0 -9
  28. scitex/writer/_dataclasses/contents/_ManuscriptContents.py +0 -236
  29. scitex/writer/_dataclasses/contents/_RevisionContents.py +0 -136
  30. scitex/writer/_dataclasses/contents/_SupplementaryContents.py +0 -114
  31. scitex/writer/_dataclasses/contents/__init__.py +0 -9
  32. scitex/writer/_dataclasses/core/_Document.py +0 -146
  33. scitex/writer/_dataclasses/core/_DocumentSection.py +0 -546
  34. scitex/writer/_dataclasses/core/__init__.py +0 -7
  35. scitex/writer/_dataclasses/results/_CompilationResult.py +0 -165
  36. scitex/writer/_dataclasses/results/_LaTeXIssue.py +0 -102
  37. scitex/writer/_dataclasses/results/_SaveSectionsResponse.py +0 -118
  38. scitex/writer/_dataclasses/results/_SectionReadResponse.py +0 -131
  39. scitex/writer/_dataclasses/results/__init__.py +0 -11
  40. scitex/writer/_dataclasses/tree/MINIMUM_FILES.md +0 -121
  41. scitex/writer/_dataclasses/tree/_ConfigTree.py +0 -86
  42. scitex/writer/_dataclasses/tree/_ManuscriptTree.py +0 -84
  43. scitex/writer/_dataclasses/tree/_RevisionTree.py +0 -97
  44. scitex/writer/_dataclasses/tree/_ScriptsTree.py +0 -118
  45. scitex/writer/_dataclasses/tree/_SharedTree.py +0 -100
  46. scitex/writer/_dataclasses/tree/_SupplementaryTree.py +0 -101
  47. scitex/writer/_dataclasses/tree/__init__.py +0 -23
  48. scitex/writer/_mcp/__init__.py +0 -4
  49. scitex/writer/_mcp/handlers.py +0 -32
  50. scitex/writer/_mcp/tool_schemas.py +0 -33
  51. scitex/writer/_project/__init__.py +0 -29
  52. scitex/writer/_project/_create.py +0 -89
  53. scitex/writer/_project/_trees.py +0 -63
  54. scitex/writer/_project/_validate.py +0 -61
  55. scitex/writer/utils/.legacy_git_retry.py +0 -164
  56. scitex/writer/utils/__init__.py +0 -24
  57. scitex/writer/utils/_converters.py +0 -635
  58. scitex/writer/utils/_parse_latex_logs.py +0 -138
  59. scitex/writer/utils/_parse_script_args.py +0 -156
  60. scitex/writer/utils/_verify_tree_structure.py +0 -205
  61. scitex/writer/utils/_watch.py +0 -96
  62. {scitex-2.16.0.dist-info → scitex-2.16.1.dist-info}/WHEEL +0 -0
  63. {scitex-2.16.0.dist-info → scitex-2.16.1.dist-info}/entry_points.txt +0 -0
  64. {scitex-2.16.0.dist-info → scitex-2.16.1.dist-info}/licenses/LICENSE +0 -0
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # Timestamp: "2025-10-29 (ywatanabe)"
4
- # File: /home/ywatanabe/proj/scitex-code/src/scitex/writer/_project/__init__.py
5
- # ----------------------------------------
6
- from __future__ import annotations
7
- import os
8
-
9
- __FILE__ = "./src/scitex/writer/_project/__init__.py"
10
- __DIR__ = os.path.dirname(__FILE__)
11
- # ----------------------------------------
12
-
13
- """
14
- Project initialization helpers for writer module.
15
-
16
- Handles project creation, attachment, and validation.
17
- """
18
-
19
- from ._create import ensure_project_exists
20
- from ._validate import validate_structure
21
- from ._trees import create_document_trees
22
-
23
- __all__ = [
24
- "ensure_project_exists",
25
- "validate_structure",
26
- "create_document_trees",
27
- ]
28
-
29
- # EOF
@@ -1,89 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # Timestamp: "2025-10-29 (ywatanabe)"
4
- # File: /home/ywatanabe/proj/scitex-code/src/scitex/writer/_project/_create.py
5
- # ----------------------------------------
6
- from __future__ import annotations
7
- import os
8
-
9
- __FILE__ = "./src/scitex/writer/_project/_create.py"
10
- __DIR__ = os.path.dirname(__FILE__)
11
- # ----------------------------------------
12
-
13
- """
14
- Project creation logic for writer module.
15
-
16
- Handles creating new writer projects from template.
17
- """
18
-
19
- from pathlib import Path
20
- from typing import Optional
21
-
22
- from scitex.logging import getLogger
23
- from scitex.writer._clone_writer_project import (
24
- clone_writer_project as _clone_writer_project,
25
- )
26
-
27
- logger = getLogger(__name__)
28
-
29
-
30
- def ensure_project_exists(
31
- project_dir: Path,
32
- project_name: str,
33
- git_strategy: Optional[str] = "child",
34
- branch: Optional[str] = None,
35
- tag: Optional[str] = None,
36
- ) -> Path:
37
- """
38
- Ensure project directory exists, creating it if necessary.
39
-
40
- Parameters
41
- ----------
42
- project_dir : Path
43
- Path to project directory
44
- project_name : str
45
- Name of the project
46
- git_strategy : str or None
47
- Git initialization strategy
48
- branch : str, optional
49
- Specific branch of template repository to clone. If None, clones the default branch.
50
- Mutually exclusive with tag parameter.
51
- tag : str, optional
52
- Specific tag/release of template repository to clone. If None, clones the default branch.
53
- Mutually exclusive with branch parameter.
54
-
55
- Returns
56
- -------
57
- Path
58
- Path to the project directory
59
-
60
- Raises
61
- ------
62
- RuntimeError
63
- If project creation fails
64
- """
65
- if project_dir.exists():
66
- logger.info(f"Attached to existing project at {project_dir.absolute()}")
67
- return project_dir
68
-
69
- logger.info(f"Creating new project '{project_name}' at {project_dir.absolute()}")
70
-
71
- # Initialize project directory structure
72
- success = _clone_writer_project(str(project_dir), git_strategy, branch, tag)
73
-
74
- if not success:
75
- logger.error(f"Failed to initialize project directory for {project_name}")
76
- raise RuntimeError(f"Could not create project directory at {project_dir}")
77
-
78
- # Verify project directory was created
79
- if not project_dir.exists():
80
- logger.error(f"Project directory {project_dir} was not created")
81
- raise RuntimeError(f"Project directory {project_dir} was not created")
82
-
83
- logger.success(f"Successfully created project at {project_dir.absolute()}")
84
- return project_dir
85
-
86
-
87
- __all__ = ["ensure_project_exists"]
88
-
89
- # EOF
@@ -1,63 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # Timestamp: "2025-10-29 (ywatanabe)"
4
- # File: /home/ywatanabe/proj/scitex-code/src/scitex/writer/_project/_trees.py
5
- # ----------------------------------------
6
- from __future__ import annotations
7
- import os
8
-
9
- __FILE__ = "./src/scitex/writer/_project/_trees.py"
10
- __DIR__ = os.path.dirname(__FILE__)
11
- # ----------------------------------------
12
-
13
- """
14
- Document tree creation for writer module.
15
-
16
- Creates and initializes document tree objects for manuscript, supplementary,
17
- revision, and scripts.
18
- """
19
-
20
- from pathlib import Path
21
- from typing import Optional, Tuple
22
-
23
- from scitex.logging import getLogger
24
- from scitex.writer._dataclasses import ManuscriptTree, SupplementaryTree, RevisionTree
25
- from scitex.writer._dataclasses.tree import ScriptsTree
26
-
27
- logger = getLogger(__name__)
28
-
29
-
30
- def create_document_trees(
31
- project_dir: Path,
32
- git_root: Optional[Path],
33
- ) -> Tuple[ManuscriptTree, SupplementaryTree, RevisionTree, ScriptsTree]:
34
- """
35
- Create document tree objects for writer project.
36
-
37
- Parameters
38
- ----------
39
- project_dir : Path
40
- Path to project directory
41
- git_root : Path or None
42
- Path to git root (for efficiency)
43
-
44
- Returns
45
- -------
46
- tuple
47
- (manuscript, supplementary, revision, scripts) tree objects
48
- """
49
- manuscript = ManuscriptTree(project_dir / "01_manuscript", git_root=git_root)
50
- supplementary = SupplementaryTree(
51
- project_dir / "02_supplementary", git_root=git_root
52
- )
53
- revision = RevisionTree(project_dir / "03_revision", git_root=git_root)
54
- scripts = ScriptsTree(project_dir / "scripts", git_root=git_root)
55
-
56
- logger.success("Document trees initialized")
57
-
58
- return manuscript, supplementary, revision, scripts
59
-
60
-
61
- __all__ = ["create_document_trees"]
62
-
63
- # EOF
@@ -1,61 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # Timestamp: "2025-10-29 (ywatanabe)"
4
- # File: /home/ywatanabe/proj/scitex-code/src/scitex/writer/_project/_validate.py
5
- # ----------------------------------------
6
- from __future__ import annotations
7
- import os
8
-
9
- __FILE__ = "./src/scitex/writer/_project/_validate.py"
10
- __DIR__ = os.path.dirname(__FILE__)
11
- # ----------------------------------------
12
-
13
- """
14
- Project structure validation for writer module.
15
-
16
- Verifies that writer projects have expected directory structure.
17
- """
18
-
19
- from pathlib import Path
20
-
21
- from scitex.logging import getLogger
22
-
23
- logger = getLogger(__name__)
24
-
25
-
26
- def validate_structure(project_dir: Path) -> None:
27
- """
28
- Verify attached project has expected structure.
29
-
30
- Checks:
31
- - Required directories exist (01_manuscript, 02_supplementary, 03_revision)
32
-
33
- Parameters
34
- ----------
35
- project_dir : Path
36
- Path to project directory
37
-
38
- Raises
39
- ------
40
- RuntimeError
41
- If structure is invalid
42
- """
43
- required_dirs = [
44
- project_dir / "01_manuscript",
45
- project_dir / "02_supplementary",
46
- project_dir / "03_revision",
47
- ]
48
-
49
- for dir_path in required_dirs:
50
- if not dir_path.exists():
51
- logger.error(f"Expected directory missing: {dir_path}")
52
- raise RuntimeError(
53
- f"Project structure invalid: missing {dir_path.name} directory (expected at: {dir_path})"
54
- )
55
-
56
- logger.success(f"Project structure verified at {project_dir.absolute()}")
57
-
58
-
59
- __all__ = ["validate_structure"]
60
-
61
- # EOF
@@ -1,164 +0,0 @@
1
- #!/usr/bin/env python3
2
- # Timestamp: "2025-10-28 17:10:52 (ywatanabe)"
3
- # File: /home/ywatanabe/proj/scitex-code/src/scitex/writer/git_utils.py
4
- # ----------------------------------------
5
- from __future__ import annotations
6
-
7
- import os
8
-
9
- __FILE__ = "./src/scitex/writer/git_utils.py"
10
- __DIR__ = os.path.dirname(__FILE__)
11
- # ----------------------------------------
12
-
13
- """
14
- Git utilities for Writer.
15
-
16
- Provides git lock handling and retry logic for concurrent access.
17
- """
18
-
19
- import subprocess
20
- import time
21
- from typing import Callable, TypeVar
22
-
23
- from scitex.logging import getLogger
24
-
25
- logger = getLogger(__name__)
26
-
27
- T = TypeVar("T")
28
-
29
-
30
- def git_retry(
31
- operation: Callable[[], T],
32
- max_retries: int = 5,
33
- initial_delay: float = 0.1,
34
- max_delay: float = 2.0,
35
- backoff_factor: float = 2.0,
36
- ) -> T:
37
- """
38
- Retry git operations with exponential backoff.
39
-
40
- Handles git index.lock conflicts when multiple processes access git.
41
-
42
- Args:
43
- operation: Function to retry
44
- max_retries: Maximum number of retry attempts
45
- initial_delay: Initial delay in seconds
46
- max_delay: Maximum delay between retries
47
- backoff_factor: Exponential backoff multiplier
48
-
49
- Returns:
50
- Result of operation
51
-
52
- Raises:
53
- TimeoutError: If all retries exhausted due to lock
54
- Exception: Original exception if not a lock error
55
-
56
- Example:
57
- >>> def commit_file():
58
- ... subprocess.run(["git", "commit", "-m", "msg"], check=True)
59
- >>> git_retry(commit_file)
60
- """
61
- delay = initial_delay
62
- last_exception = None
63
-
64
- for attempt in range(max_retries):
65
- try:
66
- return operation()
67
- except subprocess.CalledProcessError as e:
68
- # Check if it's a lock error
69
- stderr = (
70
- e.stderr
71
- if isinstance(e.stderr, str)
72
- else (e.stderr.decode("utf-8", errors="ignore") if e.stderr else "")
73
- )
74
-
75
- if "index.lock" in stderr and attempt < max_retries - 1:
76
- logger.debug(
77
- f"Git lock detected, retrying in {delay:.2f}s "
78
- f"(attempt {attempt + 1}/{max_retries})"
79
- )
80
- time.sleep(delay)
81
- delay = min(delay * backoff_factor, max_delay)
82
- last_exception = e
83
- continue
84
-
85
- # Not a lock error, or retries exhausted
86
- raise
87
- except Exception:
88
- # Non-git errors: don't retry
89
- raise
90
-
91
- # All retries exhausted
92
- if last_exception:
93
- raise TimeoutError(
94
- f"Could not acquire git lock after {max_retries} attempts"
95
- ) from last_exception
96
-
97
-
98
- def run_session() -> None:
99
- """Initialize scitex framework, run main function, and cleanup."""
100
- global CONFIG, CC, sys, plt, rng
101
- import sys
102
-
103
- import matplotlib.pyplot as plt
104
-
105
- import scitex as stx
106
-
107
- args = parse_args()
108
-
109
- CONFIG, sys.stdout, sys.stderr, plt, CC, rng = stx.session.start(
110
- sys,
111
- plt,
112
- args=args,
113
- file=__FILE__,
114
- sdir_suffix=None,
115
- verbose=False,
116
- agg=True,
117
- )
118
-
119
- exit_status = main(args)
120
-
121
- stx.session.close(
122
- CONFIG,
123
- verbose=False,
124
- notify=False,
125
- message="",
126
- exit_status=exit_status,
127
- )
128
-
129
-
130
- def main(args):
131
- def demo_operation():
132
- print("Simulating git operation...")
133
- return "Success"
134
-
135
- result = git_retry(demo_operation, max_retries=args.max_retries)
136
- print(f"Result: {result}")
137
- return 0
138
-
139
-
140
- def parse_args():
141
- import argparse
142
-
143
- parser = argparse.ArgumentParser(
144
- description="Demonstrate git retry with exponential backoff"
145
- )
146
- parser.add_argument(
147
- "--max-retries",
148
- type=int,
149
- default=5,
150
- help="Maximum retry attempts (default: 5)",
151
- )
152
-
153
- return parser.parse_args()
154
-
155
-
156
- if __name__ == "__main__":
157
- run_session()
158
-
159
-
160
- __all__ = ["git_retry"]
161
-
162
- # python -m scitex.writer.utils._git_retry --max-retries 3
163
-
164
- # EOF
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env python3
2
- # File: /home/ywatanabe/proj/scitex-code/src/scitex/writer/utils/__init__.py
3
-
4
- """Utility functions for writer module."""
5
-
6
- from scitex.writer.utils._converters import (
7
- convert_figure,
8
- csv2latex,
9
- latex2csv,
10
- list_figures,
11
- pdf_to_images,
12
- )
13
- from scitex.writer.utils._verify_tree_structure import verify_tree_structure
14
-
15
- __all__ = [
16
- "convert_figure",
17
- "csv2latex",
18
- "latex2csv",
19
- "list_figures",
20
- "pdf_to_images",
21
- "verify_tree_structure",
22
- ]
23
-
24
- # EOF