- 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>
42 lines
1,020 B
Python
42 lines
1,020 B
Python
from collections import UserDict, UserList
|
|
|
|
__all__ = ["LazyDict", "LazyList"]
|
|
|
|
|
|
class LazyDict(UserDict):
|
|
def __init__(self, data):
|
|
super().__init__()
|
|
self.data = data
|
|
|
|
def __getitem__(self, k):
|
|
v = self.data[k]
|
|
if callable(v):
|
|
v = v(k)
|
|
self.data[k] = v
|
|
return v
|
|
|
|
|
|
class LazyList(UserList):
|
|
def __getitem__(self, k):
|
|
if isinstance(k, slice):
|
|
indices = range(*k.indices(len(self)))
|
|
return [self[i] for i in indices]
|
|
v = self.data[k]
|
|
if callable(v):
|
|
v = v(k)
|
|
self.data[k] = v
|
|
return v
|
|
|
|
def __add__(self, other):
|
|
if isinstance(other, LazyList):
|
|
other = list(other)
|
|
elif isinstance(other, list):
|
|
pass
|
|
else:
|
|
return NotImplemented
|
|
return list(self) + other
|
|
|
|
def __radd__(self, other):
|
|
if not isinstance(other, list):
|
|
return NotImplemented
|
|
return other + list(self)
|