Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/chardet/mbcsgroupprober.py: 94%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

17 statements  

1######################## BEGIN LICENSE BLOCK ######################## 

2# The Original Code is Mozilla Universal charset detector code. 

3# 

4# The Initial Developer of the Original Code is 

5# Netscape Communications Corporation. 

6# Portions created by the Initial Developer are Copyright (C) 2001 

7# the Initial Developer. All Rights Reserved. 

8# 

9# Contributor(s): 

10# Mark Pilgrim - port to Python 

11# Shy Shalom - original C code 

12# Proofpoint, Inc. 

13# 

14# This library is free software; you can redistribute it and/or 

15# modify it under the terms of the GNU Lesser General Public 

16# License as published by the Free Software Foundation; either 

17# version 2.1 of the License, or (at your option) any later version. 

18# 

19# This library is distributed in the hope that it will be useful, 

20# but WITHOUT ANY WARRANTY; without even the implied warranty of 

21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 

22# Lesser General Public License for more details. 

23# 

24# You should have received a copy of the GNU Lesser General Public 

25# License along with this library; if not, see 

26# <https://www.gnu.org/licenses/>. 

27######################### END LICENSE BLOCK ######################### 

28 

29from .big5prober import Big5Prober 

30from .charsetgroupprober import CharSetGroupProber 

31from .cp949prober import CP949Prober 

32from .enums import EncodingEra, LanguageFilter 

33from .eucjpprober import EUCJPProber 

34from .euckrprober import EUCKRProber 

35from .gb18030prober import GB18030Prober 

36from .johabprober import JOHABProber 

37from .sjisprober import SJISProber 

38from .utf8prober import UTF8Prober 

39 

40 

41class MBCSGroupProber(CharSetGroupProber): 

42 def __init__( 

43 self, 

44 *, 

45 lang_filter: LanguageFilter = LanguageFilter.ALL, 

46 encoding_era: EncodingEra = EncodingEra.ALL, 

47 ) -> None: 

48 super().__init__(lang_filter=lang_filter, encoding_era=encoding_era) 

49 self.probers = [ 

50 UTF8Prober(), 

51 SJISProber(), 

52 EUCJPProber(), 

53 GB18030Prober(), # Detects both GB18030 and GB2312 (subset) 

54 EUCKRProber(), 

55 CP949Prober(), 

56 Big5Prober(), 

57 JOHABProber(), 

58 ] 

59 # Filter probers based on encoding era and language 

60 self.probers = self._filter_probers(self.probers) 

61 self.reset()