Skip to content

Rework import_post into import_posts with batch mode#51

Merged
thavelick merged 4 commits into
mainfrom
rework_import_post_into_import_posts
May 11, 2026
Merged

Rework import_post into import_posts with batch mode#51
thavelick merged 4 commits into
mainfrom
rework_import_post_into_import_posts

Conversation

@thavelick

Copy link
Copy Markdown
Owner

Summary

  • Renamed scripts/import_post.pyscripts/import_posts.py. Now handles both single-file (import_posts.py PATH) and batch (import_posts.py with no args, processes every drafts/*.md).
  • On first error: abort, leave the rest unprocessed, no blog.sql dump, no draft moves. Already-committed DB rows from earlier in the batch stay (UPSERT means re-running is idempotent).
  • On success: dump blog.sql once at end, then move each imported draft to drafts-imported/<stem>.YYYYMMDD-HHMMSS.md. Filename collision → error (no overwrite).
  • Adds make import / make import-one POST=path, README "Publishing a post" section, .gitignore entry for drafts-imported/, and full unit coverage (tests/unit/test_import_posts.py, 19 new tests).
  • Updates two docstring refs in scripts/generate_empty_template.py.

Test plan

  • make test-unit passes (28/28)
  • make test-integration passes (3/3, after make freeze)
  • End-to-end: created a test draft, ran make import, verified DB row + blog.sql update + timestamped move, then cleaned up.

thavelick and others added 3 commits May 10, 2026 23:19
scripts/import_posts.py (renamed from import_post.py) now handles both
single-file and batch flows: bare invocation imports every drafts/*.md,
or pass a path for one file. Aborts on first error; dumps blog.sql once
at end of a successful batch; moves successful drafts to
drafts-imported/<stem>.<timestamp>.md (collision -> error).

Adds make targets (import, import-one), README "Publishing a post"
section, .gitignore entry for drafts-imported/, and full unit coverage
in tests/unit/test_import_posts.py.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop redundant str() calls around shutil.move args; modern shutil
accepts path-likes natively. Replace hand-rolled recursive rmtree
loops in four test teardowns with single shutil.rmtree calls.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace hand-rolled None-checks for db_path/drafts_dir/imported_dir kwargs
with argparse. Gets --help and CLI overrides for free; net -5 lines.
Tests pass paths through argv as flags.

Shebang now `/usr/bin/env -S uv run python` and the script is executable,
so the Makefile can call it directly (./scripts/import_posts.py) instead
of going through `uv run python scripts/...`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@thavelick thavelick force-pushed the rework_import_post_into_import_posts branch from f4eb64f to 7a2d507 Compare May 11, 2026 05:28
Step 1 of "Publishing a post" now points at scripts/generate_empty_template.py
to scaffold the draft file with prefilled front-matter, instead of asking
the writer to type it from scratch. Also bump that script's shebang to
match import_posts.py (uv run python) for consistency.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@thavelick thavelick merged commit 21c9e65 into main May 11, 2026
2 checks passed
@thavelick thavelick deleted the rework_import_post_into_import_posts branch May 11, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant