refactor hardcoded paths.
This commit is contained in:
1 parent
5b087286cf
commit
da7733490f
5 files changed
+35
-19
No files matched your search
@@ -2,14 +2,18 @@
|
|||||||
|
|
||||||
Front door: `tw.py`. Individual scripts still work.
|
Front door: `tw.py`. Individual scripts still work.
|
||||||
|
|
||||||
|
From the vault root:
|
||||||
|
|
||||||
```
|
```
|
||||||
python C:\projects\Threadwell\scripts\twitter\tw.py locate --id <snowflake>
|
python scripts/twitter/tw.py locate --id <snowflake>
|
||||||
python C:\projects\Threadwell\scripts\twitter\tw.py graph --id <snowflake>
|
python scripts/twitter/tw.py graph --id <snowflake>
|
||||||
python C:\projects\Threadwell\scripts\twitter\tw.py refresh --id <snowflake> --tip
|
python scripts/twitter/tw.py refresh --id <snowflake> --tip
|
||||||
python C:\projects\Threadwell\scripts\twitter\tw.py lift --id <snowflake> --orig
|
python scripts/twitter/tw.py lift --id <snowflake> --orig
|
||||||
python C:\projects\Threadwell\scripts\twitter\tw.py ocr --id <snowflake>
|
python scripts/twitter/tw.py ocr --id <snowflake>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
`paths.py` sets vault = two parents above this file, dumps = `../manual_slop/docs/twitter`, scratch = `../Threadwell-ai/scratch`.
|
||||||
|
|
||||||
`refresh` = refetch (cookies) + ingest + emit `--force` + media_merge. `--tip` treats `--id` as the tip (climb same-handle `reply_to`). Does not flip `draft`. Does not commit. Frozen Onat ids abort.
|
`refresh` = refetch (cookies) + ingest + emit `--force` + media_merge. `--tip` treats `--id` as the tip (climb same-handle `reply_to`). Does not flip `draft`. Does not commit. Frozen Onat ids abort.
|
||||||
|
|
||||||
Usual publish path after you like the note:
|
Usual publish path after you like the note:
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from pathlib import Path
|
|||||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||||
|
|
||||||
from twitter.models import load_thread
|
from twitter.models import load_thread
|
||||||
|
from twitter.paths import SCRATCH
|
||||||
from twitter.slug import slugify
|
from twitter.slug import slugify
|
||||||
from twitter.tree import branch_roots, by_id, children_map, descendants, spine_ids
|
from twitter.tree import branch_roots, by_id, children_map, descendants, spine_ids
|
||||||
|
|
||||||
@@ -99,7 +100,7 @@ def main(argv: list[str] | None = None) -> int:
|
|||||||
thread = load_thread(path)
|
thread = load_thread(path)
|
||||||
text = render_ssdl(thread) + "\n\n" + render_ascii(thread) + "\n"
|
text = render_ssdl(thread) + "\n\n" + render_ascii(thread) + "\n"
|
||||||
out = args.input if args.input.is_dir() else args.input.parent
|
out = args.input if args.input.is_dir() else args.input.parent
|
||||||
dest = Path(r"C:\projects\Threadwell-ai\scratch") / f"graph_{thread.root_post_id}.txt"
|
dest = SCRATCH / f"graph_{thread.root_post_id}.txt"
|
||||||
dest.parent.mkdir(parents=True, exist_ok=True)
|
dest.parent.mkdir(parents=True, exist_ok=True)
|
||||||
dest.write_text(text, encoding="utf-8")
|
dest.write_text(text, encoding="utf-8")
|
||||||
sys.stdout.buffer.write((str(dest) + "\n").encode("ascii", "replace"))
|
sys.stdout.buffer.write((str(dest) + "\n").encode("ascii", "replace"))
|
||||||
|
|||||||
@@ -20,8 +20,9 @@ import sys
|
|||||||
import tomllib
|
import tomllib
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from paths import VAULT as VAULT_ROOT
|
||||||
|
|
||||||
API = "https://catbox.moe/user/api.php"
|
API = "https://catbox.moe/user/api.php"
|
||||||
CREDS = Path("secrets/credentials.toml")
|
|
||||||
|
|
||||||
|
|
||||||
def load_userhash(vault: Path) -> str:
|
def load_userhash(vault: Path) -> str:
|
||||||
@@ -98,7 +99,7 @@ def rewrite_notes(notes_dir: Path, old_tokens: list[str], url: str) -> int:
|
|||||||
|
|
||||||
def main(argv: list[str] | None = None) -> int:
|
def main(argv: list[str] | None = None) -> int:
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
parser.add_argument("--vault", type=Path, default=Path(r"C:\projects\Threadwell"))
|
parser.add_argument("--vault", type=Path, default=VAULT_ROOT)
|
||||||
parser.add_argument("--thread", type=Path, required=True)
|
parser.add_argument("--thread", type=Path, required=True)
|
||||||
parser.add_argument("--notes", type=Path, required=True)
|
parser.add_argument("--notes", type=Path, required=True)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
"""Repo-relative locations. Script lives at <vault>/scripts/twitter/."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
HERE = Path(__file__).resolve().parent
|
||||||
|
VAULT = HERE.parent.parent
|
||||||
|
PROJECTS = VAULT.parent
|
||||||
|
DUMPS = PROJECTS / "manual_slop" / "docs" / "twitter"
|
||||||
|
WORKSPACE = PROJECTS / "Threadwell-ai"
|
||||||
|
SCRATCH = WORKSPACE / "scratch"
|
||||||
|
COOKIES = VAULT / "secrets" / "twitter_cookies.txt"
|
||||||
|
FROZEN = HERE / "do_not_refetch.txt"
|
||||||
+8
-11
@@ -1,10 +1,12 @@
|
|||||||
"""Front door for common Twitter archive ops.
|
"""Front door for common Twitter archive ops.
|
||||||
|
|
||||||
python C:\\projects\\Threadwell\\scripts\\twitter\\tw.py graph --id 1692565070583136348
|
From the vault root:
|
||||||
python C:\\projects\\Threadwell\\scripts\\twitter\\tw.py refresh --id 1692565070583136348 --tip
|
|
||||||
python C:\\projects\\Threadwell\\scripts\\twitter\\tw.py lift --id 1692565070583136348 --orig
|
python scripts/twitter/tw.py graph --id 1692565070583136348
|
||||||
python C:\\projects\\Threadwell\\scripts\\twitter\\tw.py ocr --id 1692565070583136348
|
python scripts/twitter/tw.py refresh --id 1692565070583136348 --tip
|
||||||
python C:\\projects\\Threadwell\\scripts\\twitter\\tw.py locate --id 1692565070583136348
|
python scripts/twitter/tw.py lift --id 1692565070583136348 --orig
|
||||||
|
python scripts/twitter/tw.py ocr --id 1692565070583136348
|
||||||
|
python scripts/twitter/tw.py locate --id 1692565070583136348
|
||||||
|
|
||||||
refresh = refetch + emit --force (--tip uses the --id as tip).
|
refresh = refetch + emit --force (--tip uses the --id as tip).
|
||||||
Does not commit. Does not flip draft. Never prints cookies or userhash.
|
Does not commit. Does not flip draft. Never prints cookies or userhash.
|
||||||
@@ -17,12 +19,7 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
HERE = Path(__file__).resolve().parent
|
from paths import COOKIES, DUMPS, FROZEN, HERE, SCRATCH, VAULT
|
||||||
VAULT = Path(r"C:\projects\Threadwell")
|
|
||||||
DUMPS = Path(r"C:\projects\manual_slop\docs\twitter")
|
|
||||||
SCRATCH = Path(r"C:\projects\Threadwell-ai\scratch")
|
|
||||||
COOKIES = VAULT / "secrets" / "twitter_cookies.txt"
|
|
||||||
FROZEN = HERE / "do_not_refetch.txt"
|
|
||||||
|
|
||||||
|
|
||||||
def frozen_ids() -> set[str]:
|
def frozen_ids() -> set[str]:
|
||||||
|
|||||||
Reference in new issue
Block a user