You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The service layer is the core of the add-or-update workflow. It needs foundational infrastructure: constants (supported file extensions, default branch names, Weblate API base URLs), helper functions (slug generation, path normalization, VCS workspace management), extension-to-format mapping (.qbk -> QuickBook, .adoc -> AsciiDoc, .po -> gettext), and the construction logic that assembles a processing pipeline. This is the first half of the services module, focused on setup and scanning.
Extension mapping: given a file path, return the correct Weblate format class (QuickBook, AsciiDoc, gettext, JSON, etc.)
scan_repository(workspace_path, extensions) walks the repo tree and returns a list of (relative_path, format_class) tuples
Workspace management: clone or pull the repo into a temp/workspace directory, handle branch checkout
All functions are importable and testable in isolation (no global state, no Django ORM calls in helpers)
Implementation Notes
Keep constants at module top level. The extension mapping should be a dict, not a chain of if/elif. scan_repository should use pathlib.Path.rglob() and filter against SUPPORTED_EXTENSIONS. Workspace management can use subprocess + git or dulwich — match whatever the existing codebase uses. This module will be extended in the next services item (project/component/translation flows), so design for composability.
References
Related files: src/boost_weblate/services.py, src/boost_weblate/formats/quickbook.py
Depends on: Week 20 QuickBook format and utility modules
Problem
The service layer is the core of the add-or-update workflow. It needs foundational infrastructure: constants (supported file extensions, default branch names, Weblate API base URLs), helper functions (slug generation, path normalization, VCS workspace management), extension-to-format mapping (
.qbk-> QuickBook,.adoc-> AsciiDoc,.po-> gettext), and the construction logic that assembles a processing pipeline. This is the first half of the services module, focused on setup and scanning.Acceptance Criteria
src/boost_weblate/services.pydefines constants:SUPPORTED_EXTENSIONS,DEFAULT_BRANCH,WORKSPACE_ROOT, format-class mappingslugify_component(path)-> deterministic slug,normalize_repo_url(url)-> canonical form,ensure_workspace(project_slug)-> local clone pathscan_repository(workspace_path, extensions)walks the repo tree and returns a list of(relative_path, format_class)tuplesImplementation Notes
Keep constants at module top level. The extension mapping should be a dict, not a chain of
if/elif.scan_repositoryshould usepathlib.Path.rglob()and filter againstSUPPORTED_EXTENSIONS. Workspace management can usesubprocess+gitordulwich— match whatever the existing codebase uses. This module will be extended in the next services item (project/component/translation flows), so design for composability.References
src/boost_weblate/services.py,src/boost_weblate/formats/quickbook.py