forked from FSFE/fsfe-website
Rewrite the whole build process in python, for superior speed and maintenance Co-authored-by: Darragh Elliott <me@delliott.xyz> Co-authored-by: Sofía Aritz <sofiaritz@fsfe.org> Co-authored-by: tobiasd <tobiasd@fsfe.org> Co-authored-by: Tobias Diekershoff <tobiasd@fsfe.org> Reviewed-on: FSFE/fsfe-website#4762 Co-authored-by: delliott <delliott@fsfe.org> Co-committed-by: delliott <delliott@fsfe.org>
27 lines
739 B
Python
27 lines
739 B
Python
# SPDX-FileCopyrightText: Free Software Foundation Europe e.V. <https://fsfe.org>
|
|
#
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
import logging
|
|
import multiprocessing
|
|
from pathlib import Path
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def _do_symlinking(target: Path) -> None:
|
|
source = target.with_suffix("").with_suffix(f".html{target.with_suffix('').suffix}")
|
|
if not source.exists():
|
|
source.symlink_to(target.relative_to(source.parent))
|
|
|
|
|
|
def create_language_symlinks(pool: multiprocessing.Pool, target: Path) -> None:
|
|
"""
|
|
Create symlinks from file.<lang>.html to file.html.<lang>
|
|
"""
|
|
logger.info("Creating language symlinks")
|
|
pool.map(
|
|
_do_symlinking,
|
|
target.glob("**/*.??.html"),
|
|
)
|