Coverage for app/venv/lib/python3.14/site-packages/weblate/memory/utils.py: 41%
16 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 07:15 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 07:15 +0000
1# Copyright © Michal Čihař <michal@weblate.org>
2#
3# SPDX-License-Identifier: GPL-3.0-or-later
5from __future__ import annotations
7from weblate.trans.util import split_plural
9CATEGORY_FILE = 1
10CATEGORY_SHARED = 2
11CATEGORY_PRIVATE_OFFSET = 10000000
12CATEGORY_USER_OFFSET = 20000000
15def parse_category(category):
16 """
17 Parse category field.
19 Returns tuple with from_file, shared, project_id, user_id.
20 """
21 if category == CATEGORY_FILE:
22 return True, False, None, None
23 if category == CATEGORY_SHARED:
24 return False, True, None, None
25 if CATEGORY_PRIVATE_OFFSET <= category < CATEGORY_USER_OFFSET:
26 return False, False, category - CATEGORY_PRIVATE_OFFSET, None
27 return False, False, None, category - CATEGORY_USER_OFFSET
30def is_valid_memory_entry(*, source: str, target: str, **kwargs):
31 """Validate whether translation memory entry has content."""
32 return any(split_plural(source)) and any(split_plural(target))