Skip to content

services.py — Constants, Helpers, Extension Mapping, and Pipelines #44

@whisper67265

Description

@whisper67265

Problem

Component names/slugs must respect DB limits while staying unique. Supported doc types should follow Weblate’s FILE_FORMATS. Scanning and in-memory configs must be consistent and filterable by extension.

Acceptance Criteria

  • Length limits for component name/slug align with COMPONENT_NAME_LENGTH; truncation uses deterministic hash suffixes within those limits.
  • _submodule_slug normalizes submodule names to URL-safe slugs.
  • _build_extension_to_format maps file extensions (from *.ext autoload patterns) to Weblate format_id values.
  • get_supported_extensions returns all supported extensions, or the intersection with the request’s extensions list when provided (normalized with leading dot, lower case).
  • scan_documentation_files walks the cloned repo, skips root-only files and translation stems (_*{lang_code}), and only includes extensions from get_supported_extensions.
  • generate_component_config builds in-memory dicts: name, slug, filemask, template, new_base, file_format, file_path (no temp JSON files).

Implementation Notes

  • Module docstring documents alignment with Weblate REST behavior where relevant.
  • Prefer LOGGER / report_error for failures in clone/scan paths.

References

  • src/boost_weblate/endpoint/services.py

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions