-
Notifications
You must be signed in to change notification settings - Fork 0
🧹 [Extract shared load_module_snapshot function] #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
03eeb1a
6b8f47a
81a1383
0003ba1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
| from pathlib import Path | ||
| from types import MappingProxyType | ||
|
|
||
| from .models import PortingBacklog, PortingModule | ||
| from .models import PortingBacklog, PortingModule, _load_module_snapshot | ||
|
|
||
|
|
||
| SNAPSHOT_PATH = ( | ||
| Path(__file__).resolve().parent / "reference_data" / "commands_snapshot.json" | ||
|
|
@@ -25,16 +25,7 @@ class CommandExecution: | |
|
|
||
| @lru_cache(maxsize=1) | ||
| def load_command_snapshot() -> tuple[PortingModule, ...]: | ||
| raw_entries = json.loads(SNAPSHOT_PATH.read_text()) | ||
| return tuple( | ||
| PortingModule( | ||
| name=entry["name"], | ||
| responsibility=entry["responsibility"], | ||
| source_hint=entry["source_hint"], | ||
| status="mirrored", | ||
| ) | ||
| for entry in raw_entries | ||
| ) | ||
| return _load_module_snapshot(SNAPSHOT_PATH) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
|
|
||
| PORTED_COMMANDS = load_command_snapshot() | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,8 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| from __future__ import annotations | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| import functools | ||||||||||||||||||||||||||||||||||||||||||||||
| import json | ||||||||||||||||||||||||||||||||||||||||||||||
| from pathlib import Path | ||||||||||||||||||||||||||||||||||||||||||||||
| from dataclasses import dataclass, field | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -55,3 +57,16 @@ def summary_lines(self) -> list[str]: | |||||||||||||||||||||||||||||||||||||||||||||
| f'- {module.name} [{module.status}] — {module.responsibility} (from {module.source_hint})' | ||||||||||||||||||||||||||||||||||||||||||||||
| for module in self.modules | ||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| def _load_module_snapshot(path: Path) -> tuple[PortingModule, ...]: | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| raw_entries = json.loads(path.read_text()) | ||||||||||||||||||||||||||||||||||||||||||||||
| return tuple( | ||||||||||||||||||||||||||||||||||||||||||||||
| PortingModule( | ||||||||||||||||||||||||||||||||||||||||||||||
| name=entry["name"], | ||||||||||||||||||||||||||||||||||||||||||||||
| responsibility=entry["responsibility"], | ||||||||||||||||||||||||||||||||||||||||||||||
| source_hint=entry["source_hint"], | ||||||||||||||||||||||||||||||||||||||||||||||
| status="mirrored", | ||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||
| for entry in raw_entries | ||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+62
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The helper function
Suggested change
References
|
||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
| from pathlib import Path | ||
| from types import MappingProxyType | ||
|
|
||
| from .models import PortingBacklog, PortingModule | ||
| from .models import PortingBacklog, PortingModule, _load_module_snapshot | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| from .permissions import ToolPermissionContext | ||
|
|
||
| SNAPSHOT_PATH = ( | ||
|
|
@@ -26,16 +26,7 @@ class ToolExecution: | |
|
|
||
| @lru_cache(maxsize=1) | ||
| def load_tool_snapshot() -> tuple[PortingModule, ...]: | ||
| raw_entries = json.loads(SNAPSHOT_PATH.read_text()) | ||
| return tuple( | ||
| PortingModule( | ||
| name=entry["name"], | ||
| responsibility=entry["responsibility"], | ||
| source_hint=entry["source_hint"], | ||
| status="mirrored", | ||
| ) | ||
| for entry in raw_entries | ||
| ) | ||
| return _load_module_snapshot(SNAPSHOT_PATH) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
|
|
||
| PORTED_TOOLS = load_tool_snapshot() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the import to reflect the renamed
load_module_snapshotfunction inmodels.py.