Coverage for app/venv/lib/python3.14/site-packages/weblate/formats/helpers.py: 62%

8 statements  

« 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 

4 

5from io import BytesIO 

6 

7CONTROLCHARS = { 

8 "\x00", 

9 "\x01", 

10 "\x02", 

11 "\x03", 

12 "\x04", 

13 "\x05", 

14 "\x06", 

15 "\x07", 

16 "\x08", 

17 "\x0b", 

18 "\x0c", 

19 "\x0e", 

20 "\x0f", 

21 "\x10", 

22 "\x11", 

23 "\x12", 

24 "\x13", 

25 "\x14", 

26 "\x15", 

27 "\x16", 

28 "\x17", 

29 "\x18", 

30 "\x19", 

31 "\x1a", 

32 "\x1b", 

33 "\x1c", 

34 "\x1d", 

35 "\x1e", 

36 "\x1f", 

37 "\ufffe", 

38 "\uffff", 

39} 

40CONTROLCHARS_TRANS = str.maketrans(dict.fromkeys(CONTROLCHARS)) 

41 

42 

43class NamedBytesIO(BytesIO): 

44 """StringIO with mode attribute to make ttkit happy.""" 

45 

46 def __init__(self, filename, data) -> None: 

47 super().__init__(data) 

48 self.mode = "r" # type: ignore[misc] 

49 self.name = filename