golden hour
/opt/alt/python37/lib/python3.7/site-packages/pip/_vendor/chardet
⬆️ Go Up
Upload
File/Folder
Size
Actions
__init__.py
1.52 KB
Del
OK
__init__.pyc
1020 B
Del
OK
__init__.pyo
1020 B
Del
OK
__pycache__
-
Del
OK
big5freq.py
30.52 KB
Del
OK
big5freq.pyc
53.43 KB
Del
OK
big5freq.pyo
53.43 KB
Del
OK
big5prober.py
1.72 KB
Del
OK
big5prober.pyc
1.39 KB
Del
OK
big5prober.pyo
1.39 KB
Del
OK
chardistribution.py
9.19 KB
Del
OK
chardistribution.pyc
8 KB
Del
OK
chardistribution.pyo
8 KB
Del
OK
charsetgroupprober.py
3.7 KB
Del
OK
charsetgroupprober.pyc
2.91 KB
Del
OK
charsetgroupprober.pyo
2.91 KB
Del
OK
charsetprober.py
4.99 KB
Del
OK
charsetprober.pyc
4.19 KB
Del
OK
charsetprober.pyo
4.19 KB
Del
OK
cli
-
Del
OK
codingstatemachine.py
3.51 KB
Del
OK
codingstatemachine.pyc
3.38 KB
Del
OK
codingstatemachine.pyo
3.38 KB
Del
OK
compat.py
1.11 KB
Del
OK
compat.pyc
417 B
Del
OK
compat.pyo
417 B
Del
OK
cp949prober.py
1.81 KB
Del
OK
cp949prober.pyc
1.4 KB
Del
OK
cp949prober.pyo
1.4 KB
Del
OK
enums.py
1.62 KB
Del
OK
enums.pyc
3.16 KB
Del
OK
enums.pyo
3.16 KB
Del
OK
escprober.py
3.86 KB
Del
OK
escprober.pyc
3.26 KB
Del
OK
escprober.pyo
3.26 KB
Del
OK
escsm.py
10.26 KB
Del
OK
escsm.pyc
7.84 KB
Del
OK
escsm.pyo
7.84 KB
Del
OK
eucjpprober.py
3.66 KB
Del
OK
eucjpprober.pyc
3.08 KB
Del
OK
eucjpprober.pyo
3.08 KB
Del
OK
euckrfreq.py
13.23 KB
Del
OK
euckrfreq.pyc
23.54 KB
Del
OK
euckrfreq.pyo
23.54 KB
Del
OK
euckrprober.py
1.71 KB
Del
OK
euckrprober.pyc
1.4 KB
Del
OK
euckrprober.pyo
1.4 KB
Del
OK
euctwfreq.py
30.88 KB
Del
OK
euctwfreq.pyc
53.44 KB
Del
OK
euctwfreq.pyo
53.44 KB
Del
OK
euctwprober.py
1.71 KB
Del
OK
euctwprober.pyc
1.4 KB
Del
OK
euctwprober.pyo
1.4 KB
Del
OK
gb2312freq.py
20.23 KB
Del
OK
gb2312freq.pyc
37.47 KB
Del
OK
gb2312freq.pyo
37.47 KB
Del
OK
gb2312prober.py
1.71 KB
Del
OK
gb2312prober.pyc
1.41 KB
Del
OK
gb2312prober.pyo
1.41 KB
Del
OK
hebrewprober.py
13.51 KB
Del
OK
hebrewprober.pyc
3.86 KB
Del
OK
hebrewprober.pyo
3.86 KB
Del
OK
jisfreq.py
25.17 KB
Del
OK
jisfreq.pyc
43.47 KB
Del
OK
jisfreq.pyo
43.47 KB
Del
OK
jpcntx.py
19.18 KB
Del
OK
jpcntx.pyc
24.91 KB
Del
OK
jpcntx.pyo
24.91 KB
Del
OK
langbulgarianmodel.py
12.54 KB
Del
OK
langbulgarianmodel.pyc
24.39 KB
Del
OK
langbulgarianmodel.pyo
24.39 KB
Del
OK
langcyrillicmodel.py
17.53 KB
Del
OK
langcyrillicmodel.pyc
29.98 KB
Del
OK
langcyrillicmodel.pyo
29.98 KB
Del
OK
langgreekmodel.py
12.39 KB
Del
OK
langgreekmodel.pyc
24.07 KB
Del
OK
langgreekmodel.pyo
24.07 KB
Del
OK
langhebrewmodel.py
11.08 KB
Del
OK
langhebrewmodel.pyc
22.91 KB
Del
OK
langhebrewmodel.pyo
22.91 KB
Del
OK
langhungarianmodel.py
12.3 KB
Del
OK
langhungarianmodel.pyc
24.36 KB
Del
OK
langhungarianmodel.pyo
24.36 KB
Del
OK
langthaimodel.py
11.03 KB
Del
OK
langthaimodel.pyc
22.89 KB
Del
OK
langthaimodel.pyo
22.89 KB
Del
OK
langturkishmodel.py
10.84 KB
Del
OK
langturkishmodel.pyc
22.91 KB
Del
OK
langturkishmodel.pyo
22.91 KB
Del
OK
latin1prober.py
5.24 KB
Del
OK
latin1prober.pyc
3.75 KB
Del
OK
latin1prober.pyo
3.75 KB
Del
OK
mbcharsetprober.py
3.33 KB
Del
OK
mbcharsetprober.pyc
2.83 KB
Del
OK
mbcharsetprober.pyo
2.83 KB
Del
OK
mbcsgroupprober.py
1.96 KB
Del
OK
mbcsgroupprober.pyc
1.34 KB
Del
OK
mbcsgroupprober.pyo
1.34 KB
Del
OK
mbcssm.py
24.88 KB
Del
OK
mbcssm.pyc
18.69 KB
Del
OK
mbcssm.pyo
18.69 KB
Del
OK
sbcharsetprober.py
5.52 KB
Del
OK
sbcharsetprober.pyc
3.69 KB
Del
OK
sbcharsetprober.pyo
3.69 KB
Del
OK
sbcsgroupprober.py
3.46 KB
Del
OK
sbcsgroupprober.pyc
1.92 KB
Del
OK
sbcsgroupprober.pyo
1.92 KB
Del
OK
sjisprober.py
3.69 KB
Del
OK
sjisprober.pyc
3.1 KB
Del
OK
sjisprober.pyo
3.1 KB
Del
OK
universaldetector.py
12.19 KB
Del
OK
universaldetector.pyc
7.03 KB
Del
OK
universaldetector.pyo
7.03 KB
Del
OK
utf8prober.py
2.7 KB
Del
OK
utf8prober.pyc
2.56 KB
Del
OK
utf8prober.pyo
2.56 KB
Del
OK
version.py
242 B
Del
OK
version.pyc
444 B
Del
OK
version.pyo
444 B
Del
OK
Edit: charsetprober.py
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is Mozilla Universal charset detector code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 2001 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Mark Pilgrim - port to Python # Shy Shalom - original C code # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA ######################### END LICENSE BLOCK ######################### import logging import re from .enums import ProbingState class CharSetProber(object): SHORTCUT_THRESHOLD = 0.95 def __init__(self, lang_filter=None): self._state = None self.lang_filter = lang_filter self.logger = logging.getLogger(__name__) def reset(self): self._state = ProbingState.DETECTING @property def charset_name(self): return None def feed(self, buf): pass @property def state(self): return self._state def get_confidence(self): return 0.0 @staticmethod def filter_high_byte_only(buf): buf = re.sub(b'([\x00-\x7F])+', b' ', buf) return buf @staticmethod def filter_international_words(buf): """ We define three types of bytes: alphabet: english alphabets [a-zA-Z] international: international characters [\x80-\xFF] marker: everything else [^a-zA-Z\x80-\xFF] The input buffer can be thought to contain a series of words delimited by markers. This function works to filter all words that contain at least one international character. All contiguous sequences of markers are replaced by a single space ascii character. This filter applies to all scripts which do not use English characters. """ filtered = bytearray() # This regex expression filters out only words that have at-least one # international character. The word may include one marker character at # the end. words = re.findall(b'[a-zA-Z]*[\x80-\xFF]+[a-zA-Z]*[^a-zA-Z\x80-\xFF]?', buf) for word in words: filtered.extend(word[:-1]) # If the last character in the word is a marker, replace it with a # space as markers shouldn't affect our analysis (they are used # similarly across all languages and may thus have similar # frequencies). last_char = word[-1:] if not last_char.isalpha() and last_char < b'\x80': last_char = b' ' filtered.extend(last_char) return filtered @staticmethod def filter_with_english_letters(buf): """ Returns a copy of ``buf`` that retains only the sequences of English alphabet and high byte characters that are not between <> characters. Also retains English alphabet and high byte characters immediately before occurrences of >. This filter can be applied to all scripts which contain both English characters and extended ASCII characters, but is currently only used by ``Latin1Prober``. """ filtered = bytearray() in_tag = False prev = 0 for curr in range(len(buf)): # Slice here to get bytes instead of an int with Python 3 buf_char = buf[curr:curr + 1] # Check if we're coming out of or entering an HTML tag if buf_char == b'>': in_tag = False elif buf_char == b'<': in_tag = True # If current character is not extended-ASCII and not alphabetic... if buf_char < b'\x80' and not buf_char.isalpha(): # ...and we're not in a tag if curr > prev and not in_tag: # Keep everything after last non-extended-ASCII, # non-alphabetic character filtered.extend(buf[prev:curr]) # Output a space to delimit stretch we kept filtered.extend(b' ') prev = curr + 1 # If we're not in a tag... if not in_tag: # Keep everything after last non-extended-ASCII, non-alphabetic # character filtered.extend(buf[prev:]) return filtered
Save