- Create Economist SubmissionTracking package correctly: * mainArticle = full blog post content * coverLetter = 216-word SIR— letter * Links to blog post via blogPostId - Archive 'Letter to The Economist' from blog posts (it's the cover letter) - Fix date display on article cards (use published_at) - Target publication already displaying via blue badge Database changes: - Make blogPostId optional in SubmissionTracking model - Economist package ID: 68fa85ae49d4900e7f2ecd83 - Le Monde package ID: 68fa2abd2e6acd5691932150 Next: Enhanced modal with tabs, validation, export 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import typing
|
|
|
|
from ._errors import IllegalDestination
|
|
from ._path import combine, frombase, isbase
|
|
from ._tools import copy_file_data
|
|
|
|
if typing.TYPE_CHECKING:
|
|
from ._base import FS
|
|
|
|
|
|
def copy_file(src_fs: FS, src_path: str, dst_fs: FS, dst_path: str):
|
|
if src_fs is dst_fs and src_path == dst_path:
|
|
raise IllegalDestination(f"cannot copy {src_path!r} to itself")
|
|
|
|
with src_fs.open(src_path, "rb") as src_file:
|
|
with dst_fs.open(dst_path, "wb") as dst_file:
|
|
copy_file_data(src_file, dst_file)
|
|
|
|
|
|
def copy_structure(
|
|
src_fs: FS,
|
|
dst_fs: FS,
|
|
src_root: str = "/",
|
|
dst_root: str = "/",
|
|
):
|
|
if src_fs is dst_fs and isbase(src_root, dst_root):
|
|
raise IllegalDestination(f"cannot copy {src_fs!r} to itself")
|
|
|
|
dst_fs.makedirs(dst_root, recreate=True)
|
|
for dir_path in src_fs.walk.dirs(src_root):
|
|
dst_fs.makedir(combine(dst_root, frombase(src_root, dir_path)), recreate=True)
|
|
|
|
|
|
def copy_dir(src_fs: FS, src_path: str, dst_fs: FS, dst_path: str):
|
|
copy_structure(src_fs, dst_fs, src_path, dst_path)
|
|
|
|
for file_path in src_fs.walk.files(src_path):
|
|
copy_path = combine(dst_path, frombase(src_path, file_path))
|
|
copy_file(src_fs, file_path, dst_fs, copy_path)
|
|
|
|
|
|
def copy_fs(src_fs: FS, dst_fs: FS):
|
|
copy_dir(src_fs, "/", dst_fs, "/")
|