diff options
author | Shubham Saini <shubham6405@gmail.com> | 2019-08-05 08:32:33 +0000 |
---|---|---|
committer | Shubham Saini <shubham6405@gmail.com> | 2019-08-05 08:32:33 +0000 |
commit | 227b2d30a8675b44918f9d9ca89b24144a938215 (patch) | |
tree | 9f8e6a28724514b6fdf463a9ab2067a7ef309b72 /venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/chardet/eucjpprober.py | |
parent | 842a8cfbbbdb1f92889d892e4859dbd5d40c5be8 (diff) |
removing venv files
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/chardet/eucjpprober.py')
-rw-r--r-- | venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/chardet/eucjpprober.py | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/chardet/eucjpprober.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/chardet/eucjpprober.py deleted file mode 100644 index a81ee1e..0000000 --- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/chardet/eucjpprober.py +++ /dev/null | |||
@@ -1,92 +0,0 @@ | |||
1 | ######################## BEGIN LICENSE BLOCK ######################## | ||
2 | # The Original Code is mozilla.org 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) 1998 | ||
7 | # the Initial Developer. All Rights Reserved. | ||
8 | # | ||
9 | # Contributor(s): | ||
10 | # Mark Pilgrim - port to Python | ||
11 | # | ||
12 | # This library is free software; you can redistribute it and/or | ||
13 | # modify it under the terms of the GNU Lesser General Public | ||
14 | # License as published by the Free Software Foundation; either | ||
15 | # version 2.1 of the License, or (at your option) any later version. | ||
16 | # | ||
17 | # This library is distributed in the hope that it will be useful, | ||
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
20 | # Lesser General Public License for more details. | ||
21 | # | ||
22 | # You should have received a copy of the GNU Lesser General Public | ||
23 | # License along with this library; if not, write to the Free Software | ||
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
25 | # 02110-1301 USA | ||
26 | ######################### END LICENSE BLOCK ######################### | ||
27 | |||
28 | from .enums import ProbingState, MachineState | ||
29 | from .mbcharsetprober import MultiByteCharSetProber | ||
30 | from .codingstatemachine import CodingStateMachine | ||
31 | from .chardistribution import EUCJPDistributionAnalysis | ||
32 | from .jpcntx import EUCJPContextAnalysis | ||
33 | from .mbcssm import EUCJP_SM_MODEL | ||
34 | |||
35 | |||
36 | class EUCJPProber(MultiByteCharSetProber): | ||
37 | def __init__(self): | ||
38 | super(EUCJPProber, self).__init__() | ||
39 | self.coding_sm = CodingStateMachine(EUCJP_SM_MODEL) | ||
40 | self.distribution_analyzer = EUCJPDistributionAnalysis() | ||
41 | self.context_analyzer = EUCJPContextAnalysis() | ||
42 | self.reset() | ||
43 | |||
44 | def reset(self): | ||
45 | super(EUCJPProber, self).reset() | ||
46 | self.context_analyzer.reset() | ||
47 | |||
48 | @property | ||
49 | def charset_name(self): | ||
50 | return "EUC-JP" | ||
51 | |||
52 | @property | ||
53 | def language(self): | ||
54 | return "Japanese" | ||
55 | |||
56 | def feed(self, byte_str): | ||
57 | for i in range(len(byte_str)): | ||
58 | # PY3K: byte_str is a byte array, so byte_str[i] is an int, not a byte | ||
59 | coding_state = self.coding_sm.next_state(byte_str[i]) | ||
60 | if coding_state == MachineState.ERROR: | ||
61 | self.logger.debug('%s %s prober hit error at byte %s', | ||
62 | self.charset_name, self.language, i) | ||
63 | self._state = ProbingState.NOT_ME | ||
64 | break | ||
65 | elif coding_state == MachineState.ITS_ME: | ||
66 | self._state = ProbingState.FOUND_IT | ||
67 | break | ||
68 | elif coding_state == MachineState.START: | ||
69 | char_len = self.coding_sm.get_current_charlen() | ||
70 | if i == 0: | ||
71 | self._last_char[1] = byte_str[0] | ||
72 | self.context_analyzer.feed(self._last_char, char_len) | ||
73 | self.distribution_analyzer.feed(self._last_char, char_len) | ||
74 | else: | ||
75 | self.context_analyzer.feed(byte_str[i - 1:i + 1], | ||
76 | char_len) | ||
77 | self.distribution_analyzer.feed(byte_str[i - 1:i + 1], | ||
78 | char_len) | ||
79 | |||
80 | self._last_char[0] = byte_str[-1] | ||
81 | |||
82 | if self.state == ProbingState.DETECTING: | ||
83 | if (self.context_analyzer.got_enough_data() and | ||
84 | (self.get_confidence() > self.SHORTCUT_THRESHOLD)): | ||
85 | self._state = ProbingState.FOUND_IT | ||
86 | |||
87 | return self.state | ||
88 | |||
89 | def get_confidence(self): | ||
90 | context_conf = self.context_analyzer.get_confidence() | ||
91 | distrib_conf = self.distribution_analyzer.get_confidence() | ||
92 | return max(context_conf, distrib_conf) | ||