tractatus/.venv-docs/lib/python3.12/site-packages/docx/parts/hdrftr.py
TheFlow ac2db33732 fix(submissions): restructure Economist package and fix article display
- 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>
2025-10-24 08:47:42 +13:00

53 lines
1.7 KiB
Python

"""Header and footer part objects."""
from __future__ import annotations
import os
from typing import TYPE_CHECKING
from docx.opc.constants import CONTENT_TYPE as CT
from docx.oxml.parser import parse_xml
from docx.parts.story import StoryPart
if TYPE_CHECKING:
from docx.package import Package
class FooterPart(StoryPart):
"""Definition of a section footer."""
@classmethod
def new(cls, package: Package):
"""Return newly created footer part."""
partname = package.next_partname("/word/footer%d.xml")
content_type = CT.WML_FOOTER
element = parse_xml(cls._default_footer_xml())
return cls(partname, content_type, element, package)
@classmethod
def _default_footer_xml(cls):
"""Return bytes containing XML for a default footer part."""
path = os.path.join(os.path.split(__file__)[0], "..", "templates", "default-footer.xml")
with open(path, "rb") as f:
xml_bytes = f.read()
return xml_bytes
class HeaderPart(StoryPart):
"""Definition of a section header."""
@classmethod
def new(cls, package: Package):
"""Return newly created header part."""
partname = package.next_partname("/word/header%d.xml")
content_type = CT.WML_HEADER
element = parse_xml(cls._default_header_xml())
return cls(partname, content_type, element, package)
@classmethod
def _default_header_xml(cls):
"""Return bytes containing XML for a default header part."""
path = os.path.join(os.path.split(__file__)[0], "..", "templates", "default-header.xml")
with open(path, "rb") as f:
xml_bytes = f.read()
return xml_bytes