Rework import_post into import_posts with batch mode#51
Merged
Conversation
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>
f4eb64f to
7a2d507
Compare
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/import_post.py→scripts/import_posts.py. Now handles both single-file (import_posts.py PATH) and batch (import_posts.pywith no args, processes everydrafts/*.md).blog.sqldump, no draft moves. Already-committed DB rows from earlier in the batch stay (UPSERT means re-running is idempotent).blog.sqlonce at end, then move each imported draft todrafts-imported/<stem>.YYYYMMDD-HHMMSS.md. Filename collision → error (no overwrite).make import/make import-one POST=path, README "Publishing a post" section,.gitignoreentry fordrafts-imported/, and full unit coverage (tests/unit/test_import_posts.py, 19 new tests).scripts/generate_empty_template.py.Test plan
make test-unitpasses (28/28)make test-integrationpasses (3/3, aftermake freeze)make import, verified DB row +blog.sqlupdate + timestamped move, then cleaned up.