update charade
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Kenneth Reitz · committed by Kenneth Reitz · parent b60b11e · Browse files · 41 files·+4488 added−4705 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
41 files+4488 added−4705 removed
- other:+4488 added−4705 removed
Provenance
- Commit
ad31149- Tree
527059a- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent
b60b11e
41 files changed+4488 added−4705 removed
modified:requests/packages/charade/__init__.py+26 added-27 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# This library is free software; you can redistribute it and/or3-# modify it under the terms of the GNU Lesser General Public4-# License as published by the Free Software Foundation; either5-# version 2.1 of the License, or (at your option) any later version.6-#7-# This library is distributed in the hope that it will be useful,8-# but WITHOUT ANY WARRANTY; without even the implied warranty of9-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU10-# Lesser General Public License for more details.11-#12-# You should have received a copy of the GNU Lesser General Public13-# License along with this library; if not, write to the Free Software14-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA15-# 02110-1301 USA16-######################### END LICENSE BLOCK #########################17-18-__version__ = "1.1"19-20-21-def detect(aBuf):22- from . import universaldetector23- u = universaldetector.UniversalDetector()24- u.reset()25- u.feed(aBuf)26- u.close()27- return u.result1+######################## BEGIN LICENSE BLOCK ########################2+# This library is free software; you can redistribute it and/or3+# modify it under the terms of the GNU Lesser General Public4+# License as published by the Free Software Foundation; either5+# version 2.1 of the License, or (at your option) any later version.6+# 7+# This library is distributed in the hope that it will be useful,8+# but WITHOUT ANY WARRANTY; without even the implied warranty of9+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU10+# Lesser General Public License for more details.11+# 12+# You should have received a copy of the GNU Lesser General Public13+# License along with this library; if not, write to the Free Software14+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA15+# 02110-1301 USA16+######################### END LICENSE BLOCK #########################17+18+__version__ = "1.0.0"19+20+def detect(aBuf):21+ from . import universaldetector22+ u = universaldetector.UniversalDetector()23+ u.reset()24+ u.feed(aBuf)25+ u.close()26+ return u.resultmodified:requests/packages/charade/big5freq.py+11 added-9 removed
1 ######################## BEGIN LICENSE BLOCK ########################2 # The Original Code is Mozilla Communicator client code.3-# 3+#4 # The Initial Developer of the Original Code is5 # Netscape Communications Corporation.6 # Portions created by the Initial Developer are Copyright (C) 19987 # the Initial Developer. All Rights Reserved.8-# 8+#9 # Contributor(s):10 # Mark Pilgrim - port to Python11 #12 # This library is free software; you can redistribute it and/or13 # modify it under the terms of the GNU Lesser General Public14 # License as published by the Free Software Foundation; either15 # version 2.1 of the License, or (at your option) any later version.16-# 16+#17 # This library is distributed in the hope that it will be useful,18 # but WITHOUT ANY WARRANTY; without even the implied warranty of19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20 # Lesser General Public License for more details.21-# 21+#22 # You should have received a copy of the GNU Lesser General Public23 # License along with this library; if not, write to the Free Software24 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25 # 02110-1301 USA26 ######################### END LICENSE BLOCK #########################27 28 # Big5 frequency table29-# by Taiwan's Mandarin Promotion Council 29+# by Taiwan's Mandarin Promotion Council30 # <http://www.edu.tw:81/mandr/>31-# 31+#32 # 128 --> 0.4226133 # 256 --> 0.5785134 # 512 --> 0.7485135 # 1024 --> 0.8938436 # 2048 --> 0.9758337-# 37+#38 # Ideal Distribution Ratio = 0.74851/(1-0.74851) =2.9839 # Random Distribution Ration = 512/(5401-512)=0.10540-# 40+#41 # Typical Distribution Ratio about 25% of Ideal one, still much higher than RDR42 43 BIG5_TYPICAL_DISTRIBUTION_RATIO = 0.7544 45 #Char to FreqOrder table46 BIG5_TABLE_SIZE = 537647 48-Big5CharToFreqOrder = ( \48+Big5CharToFreqOrder = (49 1,1801,1506, 255,1431, 198, 9, 82, 6,5008, 177, 202,3681,1256,2821, 110, # 1650 3814, 33,3274, 261, 76, 44,2114, 16,2946,2187,1176, 659,3971, 26,3451,2653, # 3251 1198,3972,3350,4202, 410,2215, 302, 590, 361,1964, 8, 204, 58,4510,5009,1932, # 4852 63,5010,5011, 317,1614, 75, 222, 159,4203,2417,1480,5012,3555,3091, 224,2822, # 64867 unmodified lines920 13920,13921,13922,13923,13924,13925,13926,13927,13928,13929,13930,13931,13932,13933,13934,13935, #13936921 13936,13937,13938,13939,13940,13941,13942,13943,13944,13945,13946,13947,13948,13949,13950,13951, #13952922 13952,13953,13954,13955,13956,13957,13958,13959,13960,13961,13962,13963,13964,13965,13966,13967, #13968923 13968,13969,13970,13971,13972) #13973924+925+# flake8: noqamodified:requests/packages/charade/big5prober.py+42 added-42 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Communicator client code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-#22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-from .mbcharsetprober import MultiByteCharSetProber29-from .codingstatemachine import CodingStateMachine30-from .chardistribution import Big5DistributionAnalysis31-from .mbcssm import Big5SMModel32-33-34-class Big5Prober(MultiByteCharSetProber):35- def __init__(self):36- MultiByteCharSetProber.__init__(self)37- self._mCodingSM = CodingStateMachine(Big5SMModel)38- self._mDistributionAnalyzer = Big5DistributionAnalysis()39- self.reset()40-41- def get_charset_name(self):42- return "Big5"1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Communicator client code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+#22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+from .mbcharsetprober import MultiByteCharSetProber29+from .codingstatemachine import CodingStateMachine30+from .chardistribution import Big5DistributionAnalysis31+from .mbcssm import Big5SMModel32+33+34+class Big5Prober(MultiByteCharSetProber):35+ def __init__(self):36+ MultiByteCharSetProber.__init__(self)37+ self._mCodingSM = CodingStateMachine(Big5SMModel)38+ self._mDistributionAnalyzer = Big5DistributionAnalysis()39+ self.reset()40+41+ def get_charset_name(self):42+ return "Big5"modified:requests/packages/charade/chardistribution.py+230 added-228 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Communicator client code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-#22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-from .euctwfreq import (EUCTWCharToFreqOrder, EUCTW_TABLE_SIZE,29- EUCTW_TYPICAL_DISTRIBUTION_RATIO)30-from .euckrfreq import (EUCKRCharToFreqOrder, EUCKR_TABLE_SIZE,31- EUCKR_TYPICAL_DISTRIBUTION_RATIO)32-from .gb2312freq import (GB2312CharToFreqOrder, GB2312_TABLE_SIZE,33- GB2312_TYPICAL_DISTRIBUTION_RATIO)34-from .big5freq import (Big5CharToFreqOrder, BIG5_TABLE_SIZE,35- BIG5_TYPICAL_DISTRIBUTION_RATIO)36-from .jisfreq import (JISCharToFreqOrder, JIS_TABLE_SIZE,37- JIS_TYPICAL_DISTRIBUTION_RATIO)38-from .compat import wrap_ord39-40-ENOUGH_DATA_THRESHOLD = 102441-SURE_YES = 0.9942-SURE_NO = 0.0143-44-45-class CharDistributionAnalysis:46- def __init__(self):47- # Mapping table to get frequency order from char order (get from48- # GetOrder())49- self._mCharToFreqOrder = None50- # Size of above table51- self._mTableSize = None52- # This is a constant value which varies from language to language,53- # used in calculating confidence. See54- # http://www.mozilla.org/projects/intl/UniversalCharsetDetection.html55- # for further detail.56- self._mTypicalDistributionRatio = None57- self.reset()58-59- def reset(self):60- """reset analyser, clear any state"""61- # If this flag is set to constants.True, detection is done and62- # conclusion has been made63- self._mDone = False64- # Total characters encountered65- self._mTotalChars = 066- # The number of characters whose frequency order is less than 51267- self._mFreqChars = 068-69- def feed(self, aStr, aCharLen):70- """feed a character with known length"""71- if aCharLen == 2:72- # we only care about 2-bytes character in our distribution analysis73- order = self.get_order(aStr)74- else:75- order = -176- if order >= 0:77- self._mTotalChars += 178- # order is valid79- if order < self._mTableSize:80- if 512 > self._mCharToFreqOrder[order]:81- self._mFreqChars += 182-83- def get_confidence(self):84- """return confidence based on existing data"""85- # if we didn't receive any character in our consideration range, return86- # negative answer87- if self._mTotalChars <= 0:88- return SURE_NO89-90- if self._mTotalChars != self._mFreqChars:91- r = self._mFreqChars / ((self._mTotalChars - self._mFreqChars)92- * self._mTypicalDistributionRatio)93- if r < SURE_YES:94- return r95-96- # normalize confidence (we don't want to be 100% sure)97- return SURE_YES98-99- def got_enough_data(self):100- # It is not necessary to receive all data to draw conclusion.101- # For charset detection, certain amount of data is enough102- return self._mTotalChars > ENOUGH_DATA_THRESHOLD103-104- def get_order(self, aStr):105- # We do not handle characters based on the original encoding string,106- # but convert this encoding string to a number, here called order.107- # This allows multiple encodings of a language to share one frequency108- # table.109- return -1110-111-112-class EUCTWDistributionAnalysis(CharDistributionAnalysis):113- def __init__(self):114- CharDistributionAnalysis.__init__(self)115- self._mCharToFreqOrder = EUCTWCharToFreqOrder116- self._mTableSize = EUCTW_TABLE_SIZE117- self._mTypicalDistributionRatio = EUCTW_TYPICAL_DISTRIBUTION_RATIO118-119- def get_order(self, aStr):120- # for euc-TW encoding, we are interested121- # first byte range: 0xc4 -- 0xfe122- # second byte range: 0xa1 -- 0xfe123- # no validation needed here. State machine has done that124- if aStr[0] >= '\xC4':125- return 94 * (wrap_ord(aStr[0]) - 0xC4) + wrap_ord(aStr[1]) - 0xA1126- else:127- return -1128-129-130-class EUCKRDistributionAnalysis(CharDistributionAnalysis):131- def __init__(self):132- CharDistributionAnalysis.__init__(self)133- self._mCharToFreqOrder = EUCKRCharToFreqOrder134- self._mTableSize = EUCKR_TABLE_SIZE135- self._mTypicalDistributionRatio = EUCKR_TYPICAL_DISTRIBUTION_RATIO136-137- def get_order(self, aStr):138- # for euc-KR encoding, we are interested139- # first byte range: 0xb0 -- 0xfe140- # second byte range: 0xa1 -- 0xfe141- # no validation needed here. State machine has done that142- if aStr[0] >= '\xB0':143- return 94 * (wrap_ord(aStr[0]) - 0xB0) + wrap_ord(aStr[1]) - 0xA1144- else:145- return -1146-147-148-class GB2312DistributionAnalysis(CharDistributionAnalysis):149- def __init__(self):150- CharDistributionAnalysis.__init__(self)151- self._mCharToFreqOrder = GB2312CharToFreqOrder152- self._mTableSize = GB2312_TABLE_SIZE153- self._mTypicalDistributionRatio = GB2312_TYPICAL_DISTRIBUTION_RATIO154-155- def get_order(self, aStr):156- # for GB2312 encoding, we are interested157- # first byte range: 0xb0 -- 0xfe158- # second byte range: 0xa1 -- 0xfe159- # no validation needed here. State machine has done that160- if (aStr[0] >= '\xB0') and (aStr[1] >= '\xA1'):161- return 94 * (wrap_ord(aStr[0]) - 0xB0) + wrap_ord(aStr[1]) - 0xA1162- else:163- return -1164-165-166-class Big5DistributionAnalysis(CharDistributionAnalysis):167- def __init__(self):168- CharDistributionAnalysis.__init__(self)169- self._mCharToFreqOrder = Big5CharToFreqOrder170- self._mTableSize = BIG5_TABLE_SIZE171- self._mTypicalDistributionRatio = BIG5_TYPICAL_DISTRIBUTION_RATIO172-173- def get_order(self, aStr):174- # for big5 encoding, we are interested175- # first byte range: 0xa4 -- 0xfe176- # second byte range: 0x40 -- 0x7e , 0xa1 -- 0xfe177- # no validation needed here. State machine has done that178- if aStr[0] >= '\xA4':179- if aStr[1] >= '\xA1':180- return (157 * (wrap_ord(aStr[0]) - 0xA4) + wrap_ord(aStr[1])181- - 0xA1 + 63)182- else:183- return (157 * (wrap_ord(aStr[0]) - 0xA4) + wrap_ord(aStr[1])184- - 0x40)185- else:186- return -1187-188-189-class SJISDistributionAnalysis(CharDistributionAnalysis):190- def __init__(self):191- CharDistributionAnalysis.__init__(self)192- self._mCharToFreqOrder = JISCharToFreqOrder193- self._mTableSize = JIS_TABLE_SIZE194- self._mTypicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO195-196- def get_order(self, aStr):197- # for sjis encoding, we are interested198- # first byte range: 0x81 -- 0x9f , 0xe0 -- 0xfe199- # second byte range: 0x40 -- 0x7e, 0x81 -- oxfe200- # no validation needed here. State machine has done that201- if (aStr[0] >= '\x81') and (aStr[0] <= '\x9F'):202- order = 188 * (wrap_ord(aStr[0]) - 0x81)203- elif (aStr[0] >= '\xE0') and (aStr[0] <= '\xEF'):204- order = 188 * (wrap_ord(aStr[0]) - 0xE0 + 31)205- else:206- return -1207- order = order + wrap_ord(aStr[1]) - 0x40208- if aStr[1] > '\x7F':209- order = -1210- return order211-212-213-class EUCJPDistributionAnalysis(CharDistributionAnalysis):214- def __init__(self):215- CharDistributionAnalysis.__init__(self)216- self._mCharToFreqOrder = JISCharToFreqOrder217- self._mTableSize = JIS_TABLE_SIZE218- self._mTypicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO219-220- def get_order(self, aStr):221- # for euc-JP encoding, we are interested222- # first byte range: 0xa0 -- 0xfe223- # second byte range: 0xa1 -- 0xfe224- # no validation needed here. State machine has done that225- if aStr[0] >= '\xA0':226- return 94 * (wrap_ord(aStr[0]) - 0xA1) + wrap_ord(aStr[1]) - 0xa1227- else:228- return -11+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Communicator client code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+#22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+from .euctwfreq import (EUCTWCharToFreqOrder, EUCTW_TABLE_SIZE,29+ EUCTW_TYPICAL_DISTRIBUTION_RATIO)30+from .euckrfreq import (EUCKRCharToFreqOrder, EUCKR_TABLE_SIZE,31+ EUCKR_TYPICAL_DISTRIBUTION_RATIO)32+from .gb2312freq import (GB2312CharToFreqOrder, GB2312_TABLE_SIZE,33+ GB2312_TYPICAL_DISTRIBUTION_RATIO)34+from .big5freq import (Big5CharToFreqOrder, BIG5_TABLE_SIZE,35+ BIG5_TYPICAL_DISTRIBUTION_RATIO)36+from .jisfreq import (JISCharToFreqOrder, JIS_TABLE_SIZE,37+ JIS_TYPICAL_DISTRIBUTION_RATIO)38+from .compat import wrap_ord39+40+ENOUGH_DATA_THRESHOLD = 102441+SURE_YES = 0.9942+SURE_NO = 0.0143+44+45+class CharDistributionAnalysis:46+ def __init__(self):47+ # Mapping table to get frequency order from char order (get from48+ # GetOrder())49+ self._mCharToFreqOrder = None50+ self._mTableSize = None # Size of above table51+ # This is a constant value which varies from language to language,52+ # used in calculating confidence. See53+ # http://www.mozilla.org/projects/intl/UniversalCharsetDetection.html54+ # for further detail.55+ self._mTypicalDistributionRatio = None56+ self.reset()57+58+ def reset(self):59+ """reset analyser, clear any state"""60+ # If this flag is set to True, detection is done and conclusion has61+ # been made62+ self._mDone = False63+ self._mTotalChars = 0 # Total characters encountered64+ # The number of characters whose frequency order is less than 51265+ self._mFreqChars = 066+67+ def feed(self, aBuf, aCharLen):68+ """feed a character with known length"""69+ if aCharLen == 2:70+ # we only care about 2-bytes character in our distribution analysis71+ order = self.get_order(aBuf)72+ else:73+ order = -174+ if order >= 0:75+ self._mTotalChars += 176+ # order is valid77+ if order < self._mTableSize:78+ if 512 > self._mCharToFreqOrder[order]:79+ self._mFreqChars += 180+81+ def get_confidence(self):82+ """return confidence based on existing data"""83+ # if we didn't receive any character in our consideration range,84+ # return negative answer85+ if self._mTotalChars <= 0:86+ return SURE_NO87+88+ if self._mTotalChars != self._mFreqChars:89+ r = (self._mFreqChars / ((self._mTotalChars - self._mFreqChars)90+ * self._mTypicalDistributionRatio))91+ if r < SURE_YES:92+ return r93+94+ # normalize confidence (we don't want to be 100% sure)95+ return SURE_YES96+97+ def got_enough_data(self):98+ # It is not necessary to receive all data to draw conclusion.99+ # For charset detection, certain amount of data is enough100+ return self._mTotalChars > ENOUGH_DATA_THRESHOLD101+102+ def get_order(self, aBuf):103+ # We do not handle characters based on the original encoding string,104+ # but convert this encoding string to a number, here called order.105+ # This allows multiple encodings of a language to share one frequency106+ # table.107+ return -1108+109+110+class EUCTWDistributionAnalysis(CharDistributionAnalysis):111+ def __init__(self):112+ CharDistributionAnalysis.__init__(self)113+ self._mCharToFreqOrder = EUCTWCharToFreqOrder114+ self._mTableSize = EUCTW_TABLE_SIZE115+ self._mTypicalDistributionRatio = EUCTW_TYPICAL_DISTRIBUTION_RATIO116+117+ def get_order(self, aBuf):118+ # for euc-TW encoding, we are interested119+ # first byte range: 0xc4 -- 0xfe120+ # second byte range: 0xa1 -- 0xfe121+ # no validation needed here. State machine has done that122+ first_char = wrap_ord(aBuf[0])123+ if first_char >= 0xC4:124+ return 94 * (first_char - 0xC4) + wrap_ord(aBuf[1]) - 0xA1125+ else:126+ return -1127+128+129+class EUCKRDistributionAnalysis(CharDistributionAnalysis):130+ def __init__(self):131+ CharDistributionAnalysis.__init__(self)132+ self._mCharToFreqOrder = EUCKRCharToFreqOrder133+ self._mTableSize = EUCKR_TABLE_SIZE134+ self._mTypicalDistributionRatio = EUCKR_TYPICAL_DISTRIBUTION_RATIO135+136+ def get_order(self, aBuf):137+ # for euc-KR encoding, we are interested138+ # first byte range: 0xb0 -- 0xfe139+ # second byte range: 0xa1 -- 0xfe140+ # no validation needed here. State machine has done that141+ first_char = wrap_ord(aBuf[0])142+ if first_char >= 0xB0:143+ return 94 * (first_char - 0xB0) + wrap_ord(aBuf[1]) - 0xA1144+ else:145+ return -1146+147+148+class GB2312DistributionAnalysis(CharDistributionAnalysis):149+ def __init__(self):150+ CharDistributionAnalysis.__init__(self)151+ self._mCharToFreqOrder = GB2312CharToFreqOrder152+ self._mTableSize = GB2312_TABLE_SIZE153+ self._mTypicalDistributionRatio = GB2312_TYPICAL_DISTRIBUTION_RATIO154+155+ def get_order(self, aBuf):156+ # for GB2312 encoding, we are interested157+ # first byte range: 0xb0 -- 0xfe158+ # second byte range: 0xa1 -- 0xfe159+ # no validation needed here. State machine has done that160+ first_char, second_char = wrap_ord(aBuf[0]), wrap_ord(aBuf[1])161+ if (first_char >= 0xB0) and (second_char >= 0xA1):162+ return 94 * (first_char - 0xB0) + second_char - 0xA1163+ else:164+ return -1165+166+167+class Big5DistributionAnalysis(CharDistributionAnalysis):168+ def __init__(self):169+ CharDistributionAnalysis.__init__(self)170+ self._mCharToFreqOrder = Big5CharToFreqOrder171+ self._mTableSize = BIG5_TABLE_SIZE172+ self._mTypicalDistributionRatio = BIG5_TYPICAL_DISTRIBUTION_RATIO173+174+ def get_order(self, aBuf):175+ # for big5 encoding, we are interested176+ # first byte range: 0xa4 -- 0xfe177+ # second byte range: 0x40 -- 0x7e , 0xa1 -- 0xfe178+ # no validation needed here. State machine has done that179+ first_char, second_char = wrap_ord(aBuf[0]), wrap_ord(aBuf[1])180+ if first_char >= 0xA4:181+ if second_char >= 0xA1:182+ return 157 * (first_char - 0xA4) + second_char - 0xA1 + 63183+ else:184+ return 157 * (first_char - 0xA4) + second_char - 0x40185+ else:186+ return -1187+188+189+class SJISDistributionAnalysis(CharDistributionAnalysis):190+ def __init__(self):191+ CharDistributionAnalysis.__init__(self)192+ self._mCharToFreqOrder = JISCharToFreqOrder193+ self._mTableSize = JIS_TABLE_SIZE194+ self._mTypicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO195+196+ def get_order(self, aBuf):197+ # for sjis encoding, we are interested198+ # first byte range: 0x81 -- 0x9f , 0xe0 -- 0xfe199+ # second byte range: 0x40 -- 0x7e, 0x81 -- oxfe200+ # no validation needed here. State machine has done that201+ first_char, second_char = wrap_ord(aBuf[0]), wrap_ord(aBuf[1])202+ if (first_char >= 0x81) and (first_char <= 0x9F):203+ order = 188 * (first_char - 0x81)204+ elif (first_char >= 0xE0) and (first_char <= 0xEF):205+ order = 188 * (first_char - 0xE0 + 31)206+ else:207+ return -1208+ order = order + second_char - 0x40209+ if second_char > 0x7F:210+ order = -1211+ return order212+213+214+class EUCJPDistributionAnalysis(CharDistributionAnalysis):215+ def __init__(self):216+ CharDistributionAnalysis.__init__(self)217+ self._mCharToFreqOrder = JISCharToFreqOrder218+ self._mTableSize = JIS_TABLE_SIZE219+ self._mTypicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO220+221+ def get_order(self, aBuf):222+ # for euc-JP encoding, we are interested223+ # first byte range: 0xa0 -- 0xfe224+ # second byte range: 0xa1 -- 0xfe225+ # no validation needed here. State machine has done that226+ char = wrap_ord(aBuf[0])227+ if char >= 0xA0:228+ return 94 * (char - 0xA1) + wrap_ord(aBuf[1]) - 0xa1229+ else:230+ return -1modified:requests/packages/charade/charsetgroupprober.py+106 added-107 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Communicator client code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-#22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-import sys29-from . import constants30-from .charsetprober import CharSetProber31-32-33-class CharSetGroupProber(CharSetProber):34- def __init__(self):35- CharSetProber.__init__(self)36- self._mActiveNum = 037- self._mProbers = []38- self._mBestGuessProber = None39-40- def reset(self):41- CharSetProber.reset(self)42- self._mActiveNum = 043- for prober in self._mProbers:44- if prober:45- prober.reset()46- prober.active = True47- self._mActiveNum += 148- self._mBestGuessProber = None49-50- def get_charset_name(self):51- if not self._mBestGuessProber:52- self.get_confidence()53- if not self._mBestGuessProber:54- return None55- # self._mBestGuessProber = self._mProbers[0]56- return self._mBestGuessProber.get_charset_name()57-58- def feed(self, aBuf):59- for prober in self._mProbers:60- if not prober:61- continue62- if not prober.active:63- continue64- st = prober.feed(aBuf)65- if not st:66- continue67- if st == constants.eFoundIt:68- self._mBestGuessProber = prober69- return self.get_state()70- elif st == constants.eNotMe:71- prober.active = False72- self._mActiveNum -= 173- if self._mActiveNum <= 0:74- self._mState = constants.eNotMe75- return self.get_state()76- return self.get_state()77-78- def get_confidence(self):79- st = self.get_state()80- if st == constants.eFoundIt:81- return 0.9982- elif st == constants.eNotMe:83- return 0.0184- bestConf = 0.085- self._mBestGuessProber = None86- for prober in self._mProbers:87- if not prober:88- continue89- if not prober.active:90- if constants._debug:91- sys.stderr.write(prober.get_charset_name() + ' not '92- 'active\n')93- continue94- cf = prober.get_confidence()95- if constants._debug:96- sys.stderr.write('%s confidence = %s\n' %97- (prober.get_charset_name(), cf))98- if bestConf < cf:99- bestConf = cf100- self._mBestGuessProber = prober101-102- if not self._mBestGuessProber:103- return 0.0104- return bestConf105-# else:106-# self._mBestGuessProber = self._mProbers[0]107-# return self._mBestGuessProber.get_confidence()1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Communicator client code.3+# 4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+# 9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+# 22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+from . import constants29+import sys30+from .charsetprober import CharSetProber31+32+33+class CharSetGroupProber(CharSetProber):34+ def __init__(self):35+ CharSetProber.__init__(self)36+ self._mActiveNum = 037+ self._mProbers = []38+ self._mBestGuessProber = None39+40+ def reset(self):41+ CharSetProber.reset(self)42+ self._mActiveNum = 043+ for prober in self._mProbers:44+ if prober:45+ prober.reset()46+ prober.active = True47+ self._mActiveNum += 148+ self._mBestGuessProber = None49+50+ def get_charset_name(self):51+ if not self._mBestGuessProber:52+ self.get_confidence()53+ if not self._mBestGuessProber:54+ return None55+# self._mBestGuessProber = self._mProbers[0]56+ return self._mBestGuessProber.get_charset_name()57+58+ def feed(self, aBuf):59+ for prober in self._mProbers:60+ if not prober:61+ continue62+ if not prober.active:63+ continue64+ st = prober.feed(aBuf)65+ if not st:66+ continue67+ if st == constants.eFoundIt:68+ self._mBestGuessProber = prober69+ return self.get_state()70+ elif st == constants.eNotMe:71+ prober.active = False72+ self._mActiveNum -= 173+ if self._mActiveNum <= 0:74+ self._mState = constants.eNotMe75+ return self.get_state()76+ return self.get_state()77+78+ def get_confidence(self):79+ st = self.get_state()80+ if st == constants.eFoundIt:81+ return 0.9982+ elif st == constants.eNotMe:83+ return 0.0184+ bestConf = 0.085+ self._mBestGuessProber = None86+ for prober in self._mProbers:87+ if not prober:88+ continue89+ if not prober.active:90+ if constants._debug:91+ sys.stderr.write(prober.get_charset_name()92+ + ' not active\n')93+ continue94+ cf = prober.get_confidence()95+ if constants._debug:96+ sys.stderr.write('%s confidence = %s\n' %97+ (prober.get_charset_name(), cf))98+ if bestConf < cf:99+ bestConf = cf100+ self._mBestGuessProber = prober101+ if not self._mBestGuessProber:102+ return 0.0103+ return bestConf104+# else:105+# self._mBestGuessProber = self._mProbers[0]106+# return self._mBestGuessProber.get_confidence()modified:requests/packages/charade/charsetprober.py
modified:requests/packages/charade/codingstatemachine.py+61 added-64 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is mozilla.org code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-#22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-from .constants import eStart, eError29-from .compat import wrap_ord30-31-32-class CodingStateMachine:33- def __init__(self, sm):34- self._mModel = sm35- self._mCurrentBytePos = 036- self._mCurrentCharLen = 037- self.reset()38-39- def reset(self):40- self._mCurrentState = eStart41-42- def next_state(self, c):43- # for each byte we get its class44- # if it is first byte, we also get byte length45- try:46- byteCls = self._mModel['classTable'][wrap_ord(c)]47- except IndexError:48- return eError49- if self._mCurrentState == eStart:50- self._mCurrentBytePos = 051- self._mCurrentCharLen = self._mModel['charLenTable'][byteCls]52-53- # from byte's class and stateTable, we get its next state54- next_state = (self._mCurrentState + self._mModel['classFactor'] +55- byteCls)56- self._mCurrentState = self._mModel['stateTable'][next_state]57- self._mCurrentBytePos += 158- return self._mCurrentState59-60- def get_current_charlen(self):61- return self._mCurrentCharLen62-63- def get_coding_state_machine(self):64- return self._mModel['name']1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is mozilla.org code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+#22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+from .constants import eStart29+from .compat import wrap_ord30+31+32+class CodingStateMachine:33+ def __init__(self, sm):34+ self._mModel = sm35+ self._mCurrentBytePos = 036+ self._mCurrentCharLen = 037+ self.reset()38+39+ def reset(self):40+ self._mCurrentState = eStart41+42+ def next_state(self, c):43+ # for each byte we get its class44+ # if it is first byte, we also get byte length45+ # PY3K: aBuf is a byte stream, so c is an int, not a byte46+ byteCls = self._mModel['classTable'][wrap_ord(c)]47+ if self._mCurrentState == eStart:48+ self._mCurrentBytePos = 049+ self._mCurrentCharLen = self._mModel['charLenTable'][byteCls]50+ # from byte's class and stateTable, we get its next state51+ curr_state = (self._mCurrentState * self._mModel['classFactor']52+ + byteCls)53+ self._mCurrentState = self._mModel['stateTable'][curr_state]54+ self._mCurrentBytePos += 155+ return self._mCurrentState56+57+ def get_current_charlen(self):58+ return self._mCurrentCharLen59+60+ def get_coding_state_machine(self):61+ return self._mModel['name']modified:requests/packages/charade/compat.py+2 added-5 removed
17 unmodified lines18 # 02110-1301 USA19 ######################### END LICENSE BLOCK #########################20 21 22-from sys import version_info23-24-22 def wrap_ord(a):26- if isinstance(a, str) and version_info < (3, 0):23+ if isinstance(a, str):24 return ord(a)28- elif isinstance(a, int) and version_info >= (3, 0):25+ elif isinstance(a, int):26 return amodified:requests/packages/charade/constants.py+39 added-39 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Universal charset detector code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 20017-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-# Shy Shalom - original C code12-#13-# This library is free software; you can redistribute it and/or14-# modify it under the terms of the GNU Lesser General Public15-# License as published by the Free Software Foundation; either16-# version 2.1 of the License, or (at your option) any later version.17-#18-# This library is distributed in the hope that it will be useful,19-# but WITHOUT ANY WARRANTY; without even the implied warranty of20-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21-# Lesser General Public License for more details.22-#23-# You should have received a copy of the GNU Lesser General Public24-# License along with this library; if not, write to the Free Software25-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26-# 02110-1301 USA27-######################### END LICENSE BLOCK #########################28-29-_debug = 030-31-eDetecting = 032-eFoundIt = 133-eNotMe = 234-35-eStart = 036-eError = 137-eItsMe = 238-39-SHORTCUT_THRESHOLD = 0.951+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Universal charset detector code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 20017+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+# Shy Shalom - original C code12+#13+# This library is free software; you can redistribute it and/or14+# modify it under the terms of the GNU Lesser General Public15+# License as published by the Free Software Foundation; either16+# version 2.1 of the License, or (at your option) any later version.17+# 18+# This library is distributed in the hope that it will be useful,19+# but WITHOUT ANY WARRANTY; without even the implied warranty of20+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21+# Lesser General Public License for more details.22+# 23+# You should have received a copy of the GNU Lesser General Public24+# License along with this library; if not, write to the Free Software25+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26+# 02110-1301 USA27+######################### END LICENSE BLOCK #########################28+29+_debug = 030+31+eDetecting = 032+eFoundIt = 133+eNotMe = 234+35+eStart = 036+eError = 137+eItsMe = 238+39+SHORTCUT_THRESHOLD = 0.95modified:requests/packages/charade/escprober.py+86 added-84 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is mozilla.org code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-#22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-from . import constants29-from .escsm import (HZSMModel, ISO2022CNSMModel, ISO2022JPSMModel,30- ISO2022KRSMModel)31-from .charsetprober import CharSetProber32-from .codingstatemachine import CodingStateMachine33-34-35-class EscCharSetProber(CharSetProber):36- def __init__(self):37- CharSetProber.__init__(self)38- self._mCodingSM = [39- CodingStateMachine(HZSMModel),40- CodingStateMachine(ISO2022CNSMModel),41- CodingStateMachine(ISO2022JPSMModel),42- CodingStateMachine(ISO2022KRSMModel)43- ]44- self.reset()45-46- def reset(self):47- CharSetProber.reset(self)48- for codingSM in self._mCodingSM:49- if not codingSM:50- continue51- codingSM.active = True52- codingSM.reset()53- self._mActiveSM = len(self._mCodingSM)54- self._mDetectedCharset = None55-56- def get_charset_name(self):57- return self._mDetectedCharset58-59- def get_confidence(self):60- if self._mDetectedCharset:61- return 0.9962- else:63- return 0.0064-65- def feed(self, aBuf):66- for c in aBuf:67- for codingSM in self._mCodingSM:68- if not codingSM:69- continue70- if not codingSM.active:71- continue72- codingState = codingSM.next_state(c)73- if codingState == constants.eError:74- codingSM.active = False75- self._mActiveSM -= 176- if self._mActiveSM <= 0:77- self._mState = constants.eNotMe78- return self.get_state()79- elif codingState == constants.eItsMe:80- self._mState = constants.eFoundIt81- self._mDetectedCharset = codingSM.get_coding_state_machine()82- return self.get_state()83-84- return self.get_state()1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is mozilla.org code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+#22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+from . import constants29+from .escsm import (HZSMModel, ISO2022CNSMModel, ISO2022JPSMModel,30+ ISO2022KRSMModel)31+from .charsetprober import CharSetProber32+from .codingstatemachine import CodingStateMachine33+from .compat import wrap_ord34+35+36+class EscCharSetProber(CharSetProber):37+ def __init__(self):38+ CharSetProber.__init__(self)39+ self._mCodingSM = [40+ CodingStateMachine(HZSMModel),41+ CodingStateMachine(ISO2022CNSMModel),42+ CodingStateMachine(ISO2022JPSMModel),43+ CodingStateMachine(ISO2022KRSMModel)44+ ]45+ self.reset()46+47+ def reset(self):48+ CharSetProber.reset(self)49+ for codingSM in self._mCodingSM:50+ if not codingSM:51+ continue52+ codingSM.active = True53+ codingSM.reset()54+ self._mActiveSM = len(self._mCodingSM)55+ self._mDetectedCharset = None56+57+ def get_charset_name(self):58+ return self._mDetectedCharset59+60+ def get_confidence(self):61+ if self._mDetectedCharset:62+ return 0.9963+ else:64+ return 0.0065+66+ def feed(self, aBuf):67+ for c in aBuf:68+ # PY3K: aBuf is a byte array, so c is an int, not a byte69+ for codingSM in self._mCodingSM:70+ if not codingSM:71+ continue72+ if not codingSM.active:73+ continue74+ codingState = codingSM.next_state(wrap_ord(c))75+ if codingState == constants.eError:76+ codingSM.active = False77+ self._mActiveSM -= 178+ if self._mActiveSM <= 0:79+ self._mState = constants.eNotMe80+ return self.get_state()81+ elif codingState == constants.eItsMe:82+ self._mState = constants.eFoundIt83+ self._mDetectedCharset = codingSM.get_coding_state_machine() # nopep884+ return self.get_state()85+86+ return self.get_state()modified:requests/packages/charade/escsm.py+242 added-240 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is mozilla.org code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-#22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-from .constants import eStart, eError, eItsMe29-30-HZ_cls = (31- 1, 0, 0, 0, 0, 0, 0, 0, # 00 - 0732- 0, 0, 0, 0, 0, 0, 0, 0, # 08 - 0f33- 0, 0, 0, 0, 0, 0, 0, 0, # 10 - 1734- 0, 0, 0, 1, 0, 0, 0, 0, # 18 - 1f35- 0, 0, 0, 0, 0, 0, 0, 0, # 20 - 2736- 0, 0, 0, 0, 0, 0, 0, 0, # 28 - 2f37- 0, 0, 0, 0, 0, 0, 0, 0, # 30 - 3738- 0, 0, 0, 0, 0, 0, 0, 0, # 38 - 3f39- 0, 0, 0, 0, 0, 0, 0, 0, # 40 - 4740- 0, 0, 0, 0, 0, 0, 0, 0, # 48 - 4f41- 0, 0, 0, 0, 0, 0, 0, 0, # 50 - 5742- 0, 0, 0, 0, 0, 0, 0, 0, # 58 - 5f43- 0, 0, 0, 0, 0, 0, 0, 0, # 60 - 6744- 0, 0, 0, 0, 0, 0, 0, 0, # 68 - 6f45- 0, 0, 0, 0, 0, 0, 0, 0, # 70 - 7746- 0, 0, 0, 4, 0, 5, 2, 0, # 78 - 7f47- 1, 1, 1, 1, 1, 1, 1, 1, # 80 - 8748- 1, 1, 1, 1, 1, 1, 1, 1, # 88 - 8f49- 1, 1, 1, 1, 1, 1, 1, 1, # 90 - 9750- 1, 1, 1, 1, 1, 1, 1, 1, # 98 - 9f51- 1, 1, 1, 1, 1, 1, 1, 1, # a0 - a752- 1, 1, 1, 1, 1, 1, 1, 1, # a8 - af53- 1, 1, 1, 1, 1, 1, 1, 1, # b0 - b754- 1, 1, 1, 1, 1, 1, 1, 1, # b8 - bf55- 1, 1, 1, 1, 1, 1, 1, 1, # c0 - c756- 1, 1, 1, 1, 1, 1, 1, 1, # c8 - cf57- 1, 1, 1, 1, 1, 1, 1, 1, # d0 - d758- 1, 1, 1, 1, 1, 1, 1, 1, # d8 - df59- 1, 1, 1, 1, 1, 1, 1, 1, # e0 - e760- 1, 1, 1, 1, 1, 1, 1, 1, # e8 - ef61- 1, 1, 1, 1, 1, 1, 1, 1, # f0 - f762- 1, 1, 1, 1, 1, 1, 1, 1, # f8 - ff63-)64-65-HZ_st = (66- eStart, eError, 3, eStart, eStart, eStart, eError, eError, # 00-0767- eError, eError, eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, # 08-0f68- eItsMe, eItsMe, eError, eError, eStart, eStart, 4, eError, # 10-1769- 5, eError, 6, eError, 5, 5, 4, eError, # 18-1f70- 4, eError, 4, 4, 4, eError, 4, eError, # 20-2771- 4, eItsMe, eStart, eStart, eStart, eStart, eStart, eStart, # 28-2f72-)73-74-HZCharLenTable = (0, 0, 0, 0, 0, 0)75-76-HZSMModel = {'classTable': HZ_cls,77- 'classFactor': 6,78- 'stateTable': HZ_st,79- 'charLenTable': HZCharLenTable,80- 'name': "HZ-GB-2312"}81-82-ISO2022CN_cls = (83- 2, 0, 0, 0, 0, 0, 0, 0, # 00 - 0784- 0, 0, 0, 0, 0, 0, 0, 0, # 08 - 0f85- 0, 0, 0, 0, 0, 0, 0, 0, # 10 - 1786- 0, 0, 0, 1, 0, 0, 0, 0, # 18 - 1f87- 0, 0, 0, 0, 0, 0, 0, 0, # 20 - 2788- 0, 3, 0, 0, 0, 0, 0, 0, # 28 - 2f89- 0, 0, 0, 0, 0, 0, 0, 0, # 30 - 3790- 0, 0, 0, 0, 0, 0, 0, 0, # 38 - 3f91- 0, 0, 0, 4, 0, 0, 0, 0, # 40 - 4792- 0, 0, 0, 0, 0, 0, 0, 0, # 48 - 4f93- 0, 0, 0, 0, 0, 0, 0, 0, # 50 - 5794- 0, 0, 0, 0, 0, 0, 0, 0, # 58 - 5f95- 0, 0, 0, 0, 0, 0, 0, 0, # 60 - 6796- 0, 0, 0, 0, 0, 0, 0, 0, # 68 - 6f97- 0, 0, 0, 0, 0, 0, 0, 0, # 70 - 7798- 0, 0, 0, 0, 0, 0, 0, 0, # 78 - 7f99- 2, 2, 2, 2, 2, 2, 2, 2, # 80 - 87100- 2, 2, 2, 2, 2, 2, 2, 2, # 88 - 8f101- 2, 2, 2, 2, 2, 2, 2, 2, # 90 - 97102- 2, 2, 2, 2, 2, 2, 2, 2, # 98 - 9f103- 2, 2, 2, 2, 2, 2, 2, 2, # a0 - a7104- 2, 2, 2, 2, 2, 2, 2, 2, # a8 - af105- 2, 2, 2, 2, 2, 2, 2, 2, # b0 - b7106- 2, 2, 2, 2, 2, 2, 2, 2, # b8 - bf107- 2, 2, 2, 2, 2, 2, 2, 2, # c0 - c7108- 2, 2, 2, 2, 2, 2, 2, 2, # c8 - cf109- 2, 2, 2, 2, 2, 2, 2, 2, # d0 - d7110- 2, 2, 2, 2, 2, 2, 2, 2, # d8 - df111- 2, 2, 2, 2, 2, 2, 2, 2, # e0 - e7112- 2, 2, 2, 2, 2, 2, 2, 2, # e8 - ef113- 2, 2, 2, 2, 2, 2, 2, 2, # f0 - f7114- 2, 2, 2, 2, 2, 2, 2, 2, # f8 - ff115-)116-117-ISO2022CN_st = (118- eStart, 3, eError, eStart, eStart, eStart, eStart, eStart, # 00-07119- eStart, eError, eError, eError, eError, eError, eError, eError, # 08-0f120- eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, # 10-17121- eItsMe, eItsMe, eItsMe, eError, eError, eError, 4, eError, # 18-1f122- eError, eError, eError, eItsMe, eError, eError, eError, eError, # 20-27123- 5, 6, eError, eError, eError, eError, eError, eError, # 28-2f124- eError, eError, eError, eItsMe, eError, eError, eError, eError, # 30-37125- eError, eError, eError, eError, eError, eItsMe, eError, eStart, # 38-3f126-)127-128-ISO2022CNCharLenTable = (0, 0, 0, 0, 0, 0, 0, 0, 0)129-130-ISO2022CNSMModel = {'classTable': ISO2022CN_cls,131- 'classFactor': 9,132- 'stateTable': ISO2022CN_st,133- 'charLenTable': ISO2022CNCharLenTable,134- 'name': "ISO-2022-CN"}135-136-ISO2022JP_cls = (137- 2, 0, 0, 0, 0, 0, 0, 0, # 00 - 07138- 0, 0, 0, 0, 0, 0, 2, 2, # 08 - 0f139- 0, 0, 0, 0, 0, 0, 0, 0, # 10 - 17140- 0, 0, 0, 1, 0, 0, 0, 0, # 18 - 1f141- 0, 0, 0, 0, 7, 0, 0, 0, # 20 - 27142- 3, 0, 0, 0, 0, 0, 0, 0, # 28 - 2f143- 0, 0, 0, 0, 0, 0, 0, 0, # 30 - 37144- 0, 0, 0, 0, 0, 0, 0, 0, # 38 - 3f145- 6, 0, 4, 0, 8, 0, 0, 0, # 40 - 47146- 0, 9, 5, 0, 0, 0, 0, 0, # 48 - 4f147- 0, 0, 0, 0, 0, 0, 0, 0, # 50 - 57148- 0, 0, 0, 0, 0, 0, 0, 0, # 58 - 5f149- 0, 0, 0, 0, 0, 0, 0, 0, # 60 - 67150- 0, 0, 0, 0, 0, 0, 0, 0, # 68 - 6f151- 0, 0, 0, 0, 0, 0, 0, 0, # 70 - 77152- 0, 0, 0, 0, 0, 0, 0, 0, # 78 - 7f153- 2, 2, 2, 2, 2, 2, 2, 2, # 80 - 87154- 2, 2, 2, 2, 2, 2, 2, 2, # 88 - 8f155- 2, 2, 2, 2, 2, 2, 2, 2, # 90 - 97156- 2, 2, 2, 2, 2, 2, 2, 2, # 98 - 9f157- 2, 2, 2, 2, 2, 2, 2, 2, # a0 - a7158- 2, 2, 2, 2, 2, 2, 2, 2, # a8 - af159- 2, 2, 2, 2, 2, 2, 2, 2, # b0 - b7160- 2, 2, 2, 2, 2, 2, 2, 2, # b8 - bf161- 2, 2, 2, 2, 2, 2, 2, 2, # c0 - c7162- 2, 2, 2, 2, 2, 2, 2, 2, # c8 - cf163- 2, 2, 2, 2, 2, 2, 2, 2, # d0 - d7164- 2, 2, 2, 2, 2, 2, 2, 2, # d8 - df165- 2, 2, 2, 2, 2, 2, 2, 2, # e0 - e7166- 2, 2, 2, 2, 2, 2, 2, 2, # e8 - ef167- 2, 2, 2, 2, 2, 2, 2, 2, # f0 - f7168- 2, 2, 2, 2, 2, 2, 2, 2, # f8 - ff169-)170-171-ISO2022JP_st = (172- eStart, 3, eError, eStart, eStart, eStart, eStart, eStart, # 00-07173- eStart, eStart, eError, eError, eError, eError, eError, eError, # 08-0f174- eError, eError, eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, # 10-17175- eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eError, eError, # 18-1f176- eError, 5, eError, eError, eError, 4, eError, eError, # 20-27177- eError, eError, eError, 6, eItsMe, eError, eItsMe, eError, # 28-2f178- eError, eError, eError, eError, eError, eError, eItsMe, eItsMe, # 30-37179- eError, eError, eError, eItsMe, eError, eError, eError, eError, # 38-3f180- eError, eError, eError, eError, eItsMe, eError, eStart, eStart, # 40-47181-)182-183-ISO2022JPCharLenTable = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)184-185-ISO2022JPSMModel = {'classTable': ISO2022JP_cls,186- 'classFactor': 10,187- 'stateTable': ISO2022JP_st,188- 'charLenTable': ISO2022JPCharLenTable,189- 'name': "ISO-2022-JP"}190-191-ISO2022KR_cls = (192- 2, 0, 0, 0, 0, 0, 0, 0, # 00 - 07193- 0, 0, 0, 0, 0, 0, 0, 0, # 08 - 0f194- 0, 0, 0, 0, 0, 0, 0, 0, # 10 - 17195- 0, 0, 0, 1, 0, 0, 0, 0, # 18 - 1f196- 0, 0, 0, 0, 3, 0, 0, 0, # 20 - 27197- 0, 4, 0, 0, 0, 0, 0, 0, # 28 - 2f198- 0, 0, 0, 0, 0, 0, 0, 0, # 30 - 37199- 0, 0, 0, 0, 0, 0, 0, 0, # 38 - 3f200- 0, 0, 0, 5, 0, 0, 0, 0, # 40 - 47201- 0, 0, 0, 0, 0, 0, 0, 0, # 48 - 4f202- 0, 0, 0, 0, 0, 0, 0, 0, # 50 - 57203- 0, 0, 0, 0, 0, 0, 0, 0, # 58 - 5f204- 0, 0, 0, 0, 0, 0, 0, 0, # 60 - 67205- 0, 0, 0, 0, 0, 0, 0, 0, # 68 - 6f206- 0, 0, 0, 0, 0, 0, 0, 0, # 70 - 77207- 0, 0, 0, 0, 0, 0, 0, 0, # 78 - 7f208- 2, 2, 2, 2, 2, 2, 2, 2, # 80 - 87209- 2, 2, 2, 2, 2, 2, 2, 2, # 88 - 8f210- 2, 2, 2, 2, 2, 2, 2, 2, # 90 - 97211- 2, 2, 2, 2, 2, 2, 2, 2, # 98 - 9f212- 2, 2, 2, 2, 2, 2, 2, 2, # a0 - a7213- 2, 2, 2, 2, 2, 2, 2, 2, # a8 - af214- 2, 2, 2, 2, 2, 2, 2, 2, # b0 - b7215- 2, 2, 2, 2, 2, 2, 2, 2, # b8 - bf216- 2, 2, 2, 2, 2, 2, 2, 2, # c0 - c7217- 2, 2, 2, 2, 2, 2, 2, 2, # c8 - cf218- 2, 2, 2, 2, 2, 2, 2, 2, # d0 - d7219- 2, 2, 2, 2, 2, 2, 2, 2, # d8 - df220- 2, 2, 2, 2, 2, 2, 2, 2, # e0 - e7221- 2, 2, 2, 2, 2, 2, 2, 2, # e8 - ef222- 2, 2, 2, 2, 2, 2, 2, 2, # f0 - f7223- 2, 2, 2, 2, 2, 2, 2, 2, # f8 - ff224-)225-226-ISO2022KR_st = (227- eStart, 3, eError, eStart, eStart, eStart, eError, eError, # 00-07228- eError, eError, eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, # 08-0f229- eItsMe, eItsMe, eError, eError, eError, 4, eError, eError, # 10-17230- eError, eError, eError, eError, 5, eError, eError, eError, # 18-1f231- eError, eError, eError, eItsMe, eStart, eStart, eStart, eStart, # 20-27232-)233-234-ISO2022KRCharLenTable = (0, 0, 0, 0, 0, 0)235-236-ISO2022KRSMModel = {'classTable': ISO2022KR_cls,237- 'classFactor': 6,238- 'stateTable': ISO2022KR_st,239- 'charLenTable': ISO2022KRCharLenTable,240- 'name': "ISO-2022-KR"}1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is mozilla.org code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+#22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+from .constants import eStart, eError, eItsMe29+30+HZ_cls = (31+1,0,0,0,0,0,0,0, # 00 - 0732+0,0,0,0,0,0,0,0, # 08 - 0f33+0,0,0,0,0,0,0,0, # 10 - 1734+0,0,0,1,0,0,0,0, # 18 - 1f35+0,0,0,0,0,0,0,0, # 20 - 2736+0,0,0,0,0,0,0,0, # 28 - 2f37+0,0,0,0,0,0,0,0, # 30 - 3738+0,0,0,0,0,0,0,0, # 38 - 3f39+0,0,0,0,0,0,0,0, # 40 - 4740+0,0,0,0,0,0,0,0, # 48 - 4f41+0,0,0,0,0,0,0,0, # 50 - 5742+0,0,0,0,0,0,0,0, # 58 - 5f43+0,0,0,0,0,0,0,0, # 60 - 6744+0,0,0,0,0,0,0,0, # 68 - 6f45+0,0,0,0,0,0,0,0, # 70 - 7746+0,0,0,4,0,5,2,0, # 78 - 7f47+1,1,1,1,1,1,1,1, # 80 - 8748+1,1,1,1,1,1,1,1, # 88 - 8f49+1,1,1,1,1,1,1,1, # 90 - 9750+1,1,1,1,1,1,1,1, # 98 - 9f51+1,1,1,1,1,1,1,1, # a0 - a752+1,1,1,1,1,1,1,1, # a8 - af53+1,1,1,1,1,1,1,1, # b0 - b754+1,1,1,1,1,1,1,1, # b8 - bf55+1,1,1,1,1,1,1,1, # c0 - c756+1,1,1,1,1,1,1,1, # c8 - cf57+1,1,1,1,1,1,1,1, # d0 - d758+1,1,1,1,1,1,1,1, # d8 - df59+1,1,1,1,1,1,1,1, # e0 - e760+1,1,1,1,1,1,1,1, # e8 - ef61+1,1,1,1,1,1,1,1, # f0 - f762+1,1,1,1,1,1,1,1, # f8 - ff63+)64+65+HZ_st = (66+eStart,eError, 3,eStart,eStart,eStart,eError,eError,# 00-0767+eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 08-0f68+eItsMe,eItsMe,eError,eError,eStart,eStart, 4,eError,# 10-1769+ 5,eError, 6,eError, 5, 5, 4,eError,# 18-1f70+ 4,eError, 4, 4, 4,eError, 4,eError,# 20-2771+ 4,eItsMe,eStart,eStart,eStart,eStart,eStart,eStart,# 28-2f72+)73+74+HZCharLenTable = (0, 0, 0, 0, 0, 0)75+76+HZSMModel = {'classTable': HZ_cls,77+ 'classFactor': 6,78+ 'stateTable': HZ_st,79+ 'charLenTable': HZCharLenTable,80+ 'name': "HZ-GB-2312"}81+82+ISO2022CN_cls = (83+2,0,0,0,0,0,0,0, # 00 - 0784+0,0,0,0,0,0,0,0, # 08 - 0f85+0,0,0,0,0,0,0,0, # 10 - 1786+0,0,0,1,0,0,0,0, # 18 - 1f87+0,0,0,0,0,0,0,0, # 20 - 2788+0,3,0,0,0,0,0,0, # 28 - 2f89+0,0,0,0,0,0,0,0, # 30 - 3790+0,0,0,0,0,0,0,0, # 38 - 3f91+0,0,0,4,0,0,0,0, # 40 - 4792+0,0,0,0,0,0,0,0, # 48 - 4f93+0,0,0,0,0,0,0,0, # 50 - 5794+0,0,0,0,0,0,0,0, # 58 - 5f95+0,0,0,0,0,0,0,0, # 60 - 6796+0,0,0,0,0,0,0,0, # 68 - 6f97+0,0,0,0,0,0,0,0, # 70 - 7798+0,0,0,0,0,0,0,0, # 78 - 7f99+2,2,2,2,2,2,2,2, # 80 - 87100+2,2,2,2,2,2,2,2, # 88 - 8f101+2,2,2,2,2,2,2,2, # 90 - 97102+2,2,2,2,2,2,2,2, # 98 - 9f103+2,2,2,2,2,2,2,2, # a0 - a7104+2,2,2,2,2,2,2,2, # a8 - af105+2,2,2,2,2,2,2,2, # b0 - b7106+2,2,2,2,2,2,2,2, # b8 - bf107+2,2,2,2,2,2,2,2, # c0 - c7108+2,2,2,2,2,2,2,2, # c8 - cf109+2,2,2,2,2,2,2,2, # d0 - d7110+2,2,2,2,2,2,2,2, # d8 - df111+2,2,2,2,2,2,2,2, # e0 - e7112+2,2,2,2,2,2,2,2, # e8 - ef113+2,2,2,2,2,2,2,2, # f0 - f7114+2,2,2,2,2,2,2,2, # f8 - ff115+)116+117+ISO2022CN_st = (118+eStart, 3,eError,eStart,eStart,eStart,eStart,eStart,# 00-07119+eStart,eError,eError,eError,eError,eError,eError,eError,# 08-0f120+eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,# 10-17121+eItsMe,eItsMe,eItsMe,eError,eError,eError, 4,eError,# 18-1f122+eError,eError,eError,eItsMe,eError,eError,eError,eError,# 20-27123+ 5, 6,eError,eError,eError,eError,eError,eError,# 28-2f124+eError,eError,eError,eItsMe,eError,eError,eError,eError,# 30-37125+eError,eError,eError,eError,eError,eItsMe,eError,eStart,# 38-3f126+)127+128+ISO2022CNCharLenTable = (0, 0, 0, 0, 0, 0, 0, 0, 0)129+130+ISO2022CNSMModel = {'classTable': ISO2022CN_cls,131+ 'classFactor': 9,132+ 'stateTable': ISO2022CN_st,133+ 'charLenTable': ISO2022CNCharLenTable,134+ 'name': "ISO-2022-CN"}135+136+ISO2022JP_cls = (137+2,0,0,0,0,0,0,0, # 00 - 07138+0,0,0,0,0,0,2,2, # 08 - 0f139+0,0,0,0,0,0,0,0, # 10 - 17140+0,0,0,1,0,0,0,0, # 18 - 1f141+0,0,0,0,7,0,0,0, # 20 - 27142+3,0,0,0,0,0,0,0, # 28 - 2f143+0,0,0,0,0,0,0,0, # 30 - 37144+0,0,0,0,0,0,0,0, # 38 - 3f145+6,0,4,0,8,0,0,0, # 40 - 47146+0,9,5,0,0,0,0,0, # 48 - 4f147+0,0,0,0,0,0,0,0, # 50 - 57148+0,0,0,0,0,0,0,0, # 58 - 5f149+0,0,0,0,0,0,0,0, # 60 - 67150+0,0,0,0,0,0,0,0, # 68 - 6f151+0,0,0,0,0,0,0,0, # 70 - 77152+0,0,0,0,0,0,0,0, # 78 - 7f153+2,2,2,2,2,2,2,2, # 80 - 87154+2,2,2,2,2,2,2,2, # 88 - 8f155+2,2,2,2,2,2,2,2, # 90 - 97156+2,2,2,2,2,2,2,2, # 98 - 9f157+2,2,2,2,2,2,2,2, # a0 - a7158+2,2,2,2,2,2,2,2, # a8 - af159+2,2,2,2,2,2,2,2, # b0 - b7160+2,2,2,2,2,2,2,2, # b8 - bf161+2,2,2,2,2,2,2,2, # c0 - c7162+2,2,2,2,2,2,2,2, # c8 - cf163+2,2,2,2,2,2,2,2, # d0 - d7164+2,2,2,2,2,2,2,2, # d8 - df165+2,2,2,2,2,2,2,2, # e0 - e7166+2,2,2,2,2,2,2,2, # e8 - ef167+2,2,2,2,2,2,2,2, # f0 - f7168+2,2,2,2,2,2,2,2, # f8 - ff169+)170+171+ISO2022JP_st = (172+eStart, 3,eError,eStart,eStart,eStart,eStart,eStart,# 00-07173+eStart,eStart,eError,eError,eError,eError,eError,eError,# 08-0f174+eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 10-17175+eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,# 18-1f176+eError, 5,eError,eError,eError, 4,eError,eError,# 20-27177+eError,eError,eError, 6,eItsMe,eError,eItsMe,eError,# 28-2f178+eError,eError,eError,eError,eError,eError,eItsMe,eItsMe,# 30-37179+eError,eError,eError,eItsMe,eError,eError,eError,eError,# 38-3f180+eError,eError,eError,eError,eItsMe,eError,eStart,eStart,# 40-47181+)182+183+ISO2022JPCharLenTable = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)184+185+ISO2022JPSMModel = {'classTable': ISO2022JP_cls,186+ 'classFactor': 10,187+ 'stateTable': ISO2022JP_st,188+ 'charLenTable': ISO2022JPCharLenTable,189+ 'name': "ISO-2022-JP"}190+191+ISO2022KR_cls = (192+2,0,0,0,0,0,0,0, # 00 - 07193+0,0,0,0,0,0,0,0, # 08 - 0f194+0,0,0,0,0,0,0,0, # 10 - 17195+0,0,0,1,0,0,0,0, # 18 - 1f196+0,0,0,0,3,0,0,0, # 20 - 27197+0,4,0,0,0,0,0,0, # 28 - 2f198+0,0,0,0,0,0,0,0, # 30 - 37199+0,0,0,0,0,0,0,0, # 38 - 3f200+0,0,0,5,0,0,0,0, # 40 - 47201+0,0,0,0,0,0,0,0, # 48 - 4f202+0,0,0,0,0,0,0,0, # 50 - 57203+0,0,0,0,0,0,0,0, # 58 - 5f204+0,0,0,0,0,0,0,0, # 60 - 67205+0,0,0,0,0,0,0,0, # 68 - 6f206+0,0,0,0,0,0,0,0, # 70 - 77207+0,0,0,0,0,0,0,0, # 78 - 7f208+2,2,2,2,2,2,2,2, # 80 - 87209+2,2,2,2,2,2,2,2, # 88 - 8f210+2,2,2,2,2,2,2,2, # 90 - 97211+2,2,2,2,2,2,2,2, # 98 - 9f212+2,2,2,2,2,2,2,2, # a0 - a7213+2,2,2,2,2,2,2,2, # a8 - af214+2,2,2,2,2,2,2,2, # b0 - b7215+2,2,2,2,2,2,2,2, # b8 - bf216+2,2,2,2,2,2,2,2, # c0 - c7217+2,2,2,2,2,2,2,2, # c8 - cf218+2,2,2,2,2,2,2,2, # d0 - d7219+2,2,2,2,2,2,2,2, # d8 - df220+2,2,2,2,2,2,2,2, # e0 - e7221+2,2,2,2,2,2,2,2, # e8 - ef222+2,2,2,2,2,2,2,2, # f0 - f7223+2,2,2,2,2,2,2,2, # f8 - ff224+)225+226+ISO2022KR_st = (227+eStart, 3,eError,eStart,eStart,eStart,eError,eError,# 00-07228+eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 08-0f229+eItsMe,eItsMe,eError,eError,eError, 4,eError,eError,# 10-17230+eError,eError,eError,eError, 5,eError,eError,eError,# 18-1f231+eError,eError,eError,eItsMe,eStart,eStart,eStart,eStart,# 20-27232+)233+234+ISO2022KRCharLenTable = (0, 0, 0, 0, 0, 0)235+236+ISO2022KRSMModel = {'classTable': ISO2022KR_cls,237+ 'classFactor': 6,238+ 'stateTable': ISO2022KR_st,239+ 'charLenTable': ISO2022KRCharLenTable,240+ 'name': "ISO-2022-KR"}241+242+# flake8: noqamodified:requests/packages/charade/eucjpprober.py+90 added-89 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is mozilla.org code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-#22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-import sys29-from . import constants30-from .mbcharsetprober import MultiByteCharSetProber31-from .codingstatemachine import CodingStateMachine32-from .chardistribution import EUCJPDistributionAnalysis33-from .jpcntx import EUCJPContextAnalysis34-from .mbcssm import EUCJPSMModel35-36-37-class EUCJPProber(MultiByteCharSetProber):38- def __init__(self):39- MultiByteCharSetProber.__init__(self)40- self._mCodingSM = CodingStateMachine(EUCJPSMModel)41- self._mDistributionAnalyzer = EUCJPDistributionAnalysis()42- self._mContextAnalyzer = EUCJPContextAnalysis()43- self.reset()44-45- def reset(self):46- MultiByteCharSetProber.reset(self)47- self._mContextAnalyzer.reset()48-49- def get_charset_name(self):50- return "EUC-JP"51-52- def feed(self, aBuf):53- aLen = len(aBuf)54- for i in range(0, aLen):55- codingState = self._mCodingSM.next_state(aBuf[i])56- if codingState == constants.eError:57- if constants._debug:58- sys.stderr.write(self.get_charset_name() +59- ' prober hit error at byte ' + str(i) +60- '\n')61- self._mState = constants.eNotMe62- break63- elif codingState == constants.eItsMe:64- self._mState = constants.eFoundIt65- break66- elif codingState == constants.eStart:67- charLen = self._mCodingSM.get_current_charlen()68- if i == 0:69- self._mLastChar[1] = aBuf[0]70- self._mContextAnalyzer.feed(self._mLastChar, charLen)71- self._mDistributionAnalyzer.feed(self._mLastChar, charLen)72- else:73- self._mContextAnalyzer.feed(aBuf[i - 1:i + 1], charLen)74- self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],75- charLen)76-77- self._mLastChar[0] = aBuf[aLen - 1]78-79- if self.get_state() == constants.eDetecting:80- if (self._mContextAnalyzer.got_enough_data() and81- (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):82- self._mState = constants.eFoundIt83-84- return self.get_state()85-86- def get_confidence(self):87- contxtCf = self._mContextAnalyzer.get_confidence()88- distribCf = self._mDistributionAnalyzer.get_confidence()89- return max(contxtCf, distribCf)1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is mozilla.org code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+#22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+import sys29+from . import constants30+from .mbcharsetprober import MultiByteCharSetProber31+from .codingstatemachine import CodingStateMachine32+from .chardistribution import EUCJPDistributionAnalysis33+from .jpcntx import EUCJPContextAnalysis34+from .mbcssm import EUCJPSMModel35+36+37+class EUCJPProber(MultiByteCharSetProber):38+ def __init__(self):39+ MultiByteCharSetProber.__init__(self)40+ self._mCodingSM = CodingStateMachine(EUCJPSMModel)41+ self._mDistributionAnalyzer = EUCJPDistributionAnalysis()42+ self._mContextAnalyzer = EUCJPContextAnalysis()43+ self.reset()44+45+ def reset(self):46+ MultiByteCharSetProber.reset(self)47+ self._mContextAnalyzer.reset()48+49+ def get_charset_name(self):50+ return "EUC-JP"51+52+ def feed(self, aBuf):53+ aLen = len(aBuf)54+ for i in range(0, aLen):55+ # PY3K: aBuf is a byte array, so aBuf[i] is an int, not a byte56+ codingState = self._mCodingSM.next_state(aBuf[i])57+ if codingState == constants.eError:58+ if constants._debug:59+ sys.stderr.write(self.get_charset_name()60+ + ' prober hit error at byte ' + str(i)61+ + '\n')62+ self._mState = constants.eNotMe63+ break64+ elif codingState == constants.eItsMe:65+ self._mState = constants.eFoundIt66+ break67+ elif codingState == constants.eStart:68+ charLen = self._mCodingSM.get_current_charlen()69+ if i == 0:70+ self._mLastChar[1] = aBuf[0]71+ self._mContextAnalyzer.feed(self._mLastChar, charLen)72+ self._mDistributionAnalyzer.feed(self._mLastChar, charLen)73+ else:74+ self._mContextAnalyzer.feed(aBuf[i - 1:i + 1], charLen)75+ self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],76+ charLen)77+78+ self._mLastChar[0] = aBuf[aLen - 1]79+80+ if self.get_state() == constants.eDetecting:81+ if (self._mContextAnalyzer.got_enough_data() and82+ (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):83+ self._mState = constants.eFoundIt84+85+ return self.get_state()86+87+ def get_confidence(self):88+ contxtCf = self._mContextAnalyzer.get_confidence()89+ distribCf = self._mDistributionAnalyzer.get_confidence()90+ return max(contxtCf, distribCf)modified:requests/packages/charade/euckrfreq.py+2 added
590 unmodified lines591 8688,8689,8690,8691,8692,8693,8694,8695,8696,8697,8698,8699,8700,8701,8702,8703,592 8704,8705,8706,8707,8708,8709,8710,8711,8712,8713,8714,8715,8716,8717,8718,8719,593 8720,8721,8722,8723,8724,8725,8726,8727,8728,8729,8730,8731,8732,8733,8734,8735,594 8736,8737,8738,8739,8740,8741)595+596+# flake8: noqamodified:requests/packages/charade/euckrprober.py+42 added-42 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is mozilla.org code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-#22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-from .mbcharsetprober import MultiByteCharSetProber29-from .codingstatemachine import CodingStateMachine30-from .chardistribution import EUCKRDistributionAnalysis31-from .mbcssm import EUCKRSMModel32-33-34-class EUCKRProber(MultiByteCharSetProber):35- def __init__(self):36- MultiByteCharSetProber.__init__(self)37- self._mCodingSM = CodingStateMachine(EUCKRSMModel)38- self._mDistributionAnalyzer = EUCKRDistributionAnalysis()39- self.reset()40-41- def get_charset_name(self):42- return "EUC-KR"1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is mozilla.org code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+#22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+from .mbcharsetprober import MultiByteCharSetProber29+from .codingstatemachine import CodingStateMachine30+from .chardistribution import EUCKRDistributionAnalysis31+from .mbcssm import EUCKRSMModel32+33+34+class EUCKRProber(MultiByteCharSetProber):35+ def __init__(self):36+ MultiByteCharSetProber.__init__(self)37+ self._mCodingSM = CodingStateMachine(EUCKRSMModel)38+ self._mDistributionAnalyzer = EUCKRDistributionAnalysis()39+ self.reset()40+41+ def get_charset_name(self):42+ return "EUC-KR"modified:requests/packages/charade/euctwfreq.py+9 added-7 removed
11 unmodified lines12 # This library is free software; you can redistribute it and/or13 # modify it under the terms of the GNU Lesser General Public14 # License as published by the Free Software Foundation; either15 # version 2.1 of the License, or (at your option) any later version.16-# 16+#17 # This library is distributed in the hope that it will be useful,18 # but WITHOUT ANY WARRANTY; without even the implied warranty of19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20 # Lesser General Public License for more details.21-# 21+#22 # You should have received a copy of the GNU Lesser General Public23 # License along with this library; if not, write to the Free Software24 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25 # 02110-1301 USA26 ######################### END LICENSE BLOCK #########################27 28 # EUCTW frequency table29-# Converted from big5 work 30-# by Taiwan's Mandarin Promotion Council 29+# Converted from big5 work30+# by Taiwan's Mandarin Promotion Council31 # <http:#www.edu.tw:81/mandr/>32 33 # 128 --> 0.4226134 # 256 --> 0.578512 unmodified lines37 # 2048 --> 0.9758338 #39 # Idea Distribution Ratio = 0.74851/(1-0.74851) =2.9840 # Random Distribution Ration = 512/(5401-512)=0.10541-# 41+#42 # Typical Distribution Ratio about 25% of Ideal one, still much higher than RDR43 44 EUCTW_TYPICAL_DISTRIBUTION_RATIO = 0.7545 46-# Char to FreqOrder table , 46+# Char to FreqOrder table ,47 EUCTW_TABLE_SIZE = 810248 49-EUCTWCharToFreqOrder = ( \49+EUCTWCharToFreqOrder = (50 1,1800,1506, 255,1431, 198, 9, 82, 6,7310, 177, 202,3615,1256,2808, 110, # 274251 3735, 33,3241, 261, 76, 44,2113, 16,2931,2184,1176, 659,3868, 26,3404,2643, # 275852 1198,3869,3313,4060, 410,2211, 302, 590, 361,1963, 8, 204, 58,4296,7311,1931, # 277453 63,7312,7313, 317,1614, 75, 222, 159,4061,2412,1480,7314,3500,3068, 224,2809, # 2790369 unmodified lines423 8678,8679,8680,8681,8682,8683,8684,8685,8686,8687,8688,8689,8690,8691,8692,8693, # 8694424 8694,8695,8696,8697,8698,8699,8700,8701,8702,8703,8704,8705,8706,8707,8708,8709, # 8710425 8710,8711,8712,8713,8714,8715,8716,8717,8718,8719,8720,8721,8722,8723,8724,8725, # 8726426 8726,8727,8728,8729,8730,8731,8732,8733,8734,8735,8736,8737,8738,8739,8740,8741) # 8742427+428+# flake8: noqamodified:requests/packages/charade/euctwprober.py+41 added-42 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is mozilla.org code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-#22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-from .mbcharsetprober import MultiByteCharSetProber29-from .codingstatemachine import CodingStateMachine30-from .chardistribution import EUCTWDistributionAnalysis31-from .mbcssm import EUCTWSMModel32-33-34-class EUCTWProber(MultiByteCharSetProber):35- def __init__(self):36- MultiByteCharSetProber.__init__(self)37- self._mCodingSM = CodingStateMachine(EUCTWSMModel)38- self._mDistributionAnalyzer = EUCTWDistributionAnalysis()39- self.reset()40-41- def get_charset_name(self):42- return "EUC-TW"1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is mozilla.org code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+# 22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+from .mbcharsetprober import MultiByteCharSetProber29+from .codingstatemachine import CodingStateMachine30+from .chardistribution import EUCTWDistributionAnalysis31+from .mbcssm import EUCTWSMModel32+33+class EUCTWProber(MultiByteCharSetProber):34+ def __init__(self):35+ MultiByteCharSetProber.__init__(self)36+ self._mCodingSM = CodingStateMachine(EUCTWSMModel)37+ self._mDistributionAnalyzer = EUCTWDistributionAnalysis()38+ self.reset()39+40+ def get_charset_name(self):41+ return "EUC-TW"modified:requests/packages/charade/gb2312freq.py+5 added-4 removed
11 unmodified lines12 # This library is free software; you can redistribute it and/or13 # modify it under the terms of the GNU Lesser General Public14 # License as published by the Free Software Foundation; either15 # version 2.1 of the License, or (at your option) any later version.16-# 16+#17 # This library is distributed in the hope that it will be useful,18 # but WITHOUT ANY WARRANTY; without even the implied warranty of19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20 # Lesser General Public License for more details.21-# 21+#22 # You should have received a copy of the GNU Lesser General Public23 # License along with this library; if not, write to the Free Software24 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25 # 02110-1301 USA9 unmodified lines35 # 6768 --> 1.00 -- 0.0236 #37 # Ideal Distribution Ratio = 0.79135/(1-0.79135) = 3.7938 # Random Distribution Ration = 512 / (3755 - 512) = 0.15739-# 39+#40 # Typical Distribution Ratio about 25% of Ideal one, still much higher that RDR41 42 GB2312_TYPICAL_DISTRIBUTION_RATIO = 0.943 44 GB2312_TABLE_SIZE = 376045 46-GB2312CharToFreqOrder = ( \46+GB2312CharToFreqOrder = (47 1671, 749,1443,2364,3924,3807,2330,3921,1704,3463,2691,1511,1515, 572,3191,2205,48 2361, 224,2558, 479,1711, 963,3162, 440,4060,1905,2966,2947,3580,2647,3961,3842,49 2204, 869,4207, 970,2678,5626,2944,2956,1479,4048, 514,3595, 588,1346,2820,3409,50 249,4088,1746,1873,2047,1774, 581,1813, 358,1174,3590,1014,1561,4844,2245, 670,417 unmodified lines468 3990,5971,5557,5558,5772,6477,6095,2787,4641,5972,5121,6096,6097,6272,6763,3703,469 5867,5507,6273,4206,6274,4789,6098,6764,3619,3646,3833,3804,2394,3788,4936,3978,470 4866,4899,6099,6100,5559,6478,6765,3599,5868,6101,5869,5870,6275,6766,4527,6767)471 472+# flake8: noqamodified:requests/packages/charade/gb2312prober.py+41 added-42 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is mozilla.org code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-#22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-from .mbcharsetprober import MultiByteCharSetProber29-from .codingstatemachine import CodingStateMachine30-from .chardistribution import GB2312DistributionAnalysis31-from .mbcssm import GB2312SMModel32-33-34-class GB2312Prober(MultiByteCharSetProber):35- def __init__(self):36- MultiByteCharSetProber.__init__(self)37- self._mCodingSM = CodingStateMachine(GB2312SMModel)38- self._mDistributionAnalyzer = GB2312DistributionAnalysis()39- self.reset()40-41- def get_charset_name(self):42- return "GB2312"1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is mozilla.org code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+# 22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+from .mbcharsetprober import MultiByteCharSetProber29+from .codingstatemachine import CodingStateMachine30+from .chardistribution import GB2312DistributionAnalysis31+from .mbcssm import GB2312SMModel32+33+class GB2312Prober(MultiByteCharSetProber):34+ def __init__(self):35+ MultiByteCharSetProber.__init__(self)36+ self._mCodingSM = CodingStateMachine(GB2312SMModel)37+ self._mDistributionAnalyzer = GB2312DistributionAnalysis()38+ self.reset()39+40+ def get_charset_name(self):41+ return "GB2312"modified:requests/packages/charade/hebrewprober.py+283 added-281 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Universal charset detector code.3-#4-# The Initial Developer of the Original Code is5-# Shy Shalom6-# Portions created by the Initial Developer are Copyright (C) 20057-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-#22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-from .charsetprober import CharSetProber29-from . import constants30-31-# This prober doesn't actually recognize a language or a charset.32-# It is a helper prober for the use of the Hebrew model probers33-34-### General ideas of the Hebrew charset recognition ###35-#36-# Four main charsets exist in Hebrew:37-# "ISO-8859-8" - Visual Hebrew38-# "windows-1255" - Logical Hebrew39-# "ISO-8859-8-I" - Logical Hebrew40-# "x-mac-hebrew" - ?? Logical Hebrew ??41-#42-# Both "ISO" charsets use a completely identical set of code points, whereas43-# "windows-1255" and "x-mac-hebrew" are two different proper supersets of44-# these code points. windows-1255 defines additional characters in the range45-# 0x80-0x9F as some misc punctuation marks as well as some Hebrew-specific46-# diacritics and additional 'Yiddish' ligature letters in the range 0xc0-0xd6.47-# x-mac-hebrew defines similar additional code points but with a different48-# mapping.49-#50-# As far as an average Hebrew text with no diacritics is concerned, all four51-# charsets are identical with respect to code points. Meaning that for the52-# main Hebrew alphabet, all four map the same values to all 27 Hebrew letters53-# (including final letters).54-#55-# The dominant difference between these charsets is their directionality.56-# "Visual" directionality means that the text is ordered as if the renderer is57-# not aware of a BIDI rendering algorithm. The renderer sees the text and58-# draws it from left to right. The text itself when ordered naturally is read59-# backwards. A buffer of Visual Hebrew generally looks like so:60-# "[last word of first line spelled backwards] [whole line ordered backwards61-# and spelled backwards] [first word of first line spelled backwards]62-# [end of line] [last word of second line] ... etc' "63-# adding punctuation marks, numbers and English text to visual text is64-# naturally also "visual" and from left to right.65-#66-# "Logical" directionality means the text is ordered "naturally" according to67-# the order it is read. It is the responsibility of the renderer to display68-# the text from right to left. A BIDI algorithm is used to place general69-# punctuation marks, numbers and English text in the text.70-#71-# Texts in x-mac-hebrew are almost impossible to find on the Internet. From72-# what little evidence I could find, it seems that its general directionality73-# is Logical.74-#75-# To sum up all of the above, the Hebrew probing mechanism knows about two76-# charsets:77-# Visual Hebrew - "ISO-8859-8" - backwards text - Words and sentences are78-# backwards while line order is natural. For charset recognition purposes79-# the line order is unimportant (In fact, for this implementation, even80-# word order is unimportant).81-# Logical Hebrew - "windows-1255" - normal, naturally ordered text.82-#83-# "ISO-8859-8-I" is a subset of windows-1255 and doesn't need to be84-# specifically identified.85-# "x-mac-hebrew" is also identified as windows-1255. A text in x-mac-hebrew86-# that contain special punctuation marks or diacritics is displayed with87-# some unconverted characters showing as question marks. This problem might88-# be corrected using another model prober for x-mac-hebrew. Due to the fact89-# that x-mac-hebrew texts are so rare, writing another model prober isn't90-# worth the effort and performance hit.91-#92-#### The Prober ####93-#94-# The prober is divided between two SBCharSetProbers and a HebrewProber,95-# all of which are managed, created, fed data, inquired and deleted by the96-# SBCSGroupProber. The two SBCharSetProbers identify that the text is in97-# fact some kind of Hebrew, Logical or Visual. The final decision about which98-# one is it is made by the HebrewProber by combining final-letter scores99-# with the scores of the two SBCharSetProbers to produce a final answer.100-#101-# The SBCSGroupProber is responsible for stripping the original text of HTML102-# tags, English characters, numbers, low-ASCII punctuation characters, spaces103-# and new lines. It reduces any sequence of such characters to a single space.104-# The buffer fed to each prober in the SBCS group prober is pure text in105-# high-ASCII.106-# The two SBCharSetProbers (model probers) share the same language model:107-# Win1255Model.108-# The first SBCharSetProber uses the model normally as any other109-# SBCharSetProber does, to recognize windows-1255, upon which this model was110-# built. The second SBCharSetProber is told to make the pair-of-letter111-# lookup in the language model backwards. This in practice exactly simulates112-# a visual Hebrew model using the windows-1255 logical Hebrew model.113-#114-# The HebrewProber is not using any language model. All it does is look for115-# final-letter evidence suggesting the text is either logical Hebrew or visual116-# Hebrew. Disjointed from the model probers, the results of the HebrewProber117-# alone are meaningless. HebrewProber always returns 0.00 as confidence118-# since it never identifies a charset by itself. Instead, the pointer to the119-# HebrewProber is passed to the model probers as a helper "Name Prober".120-# When the Group prober receives a positive identification from any prober,121-# it asks for the name of the charset identified. If the prober queried is a122-# Hebrew model prober, the model prober forwards the call to the123-# HebrewProber to make the final decision. In the HebrewProber, the124-# decision is made according to the final-letters scores maintained and Both125-# model probers scores. The answer is returned in the form of the name of the126-# charset identified, either "windows-1255" or "ISO-8859-8".127-128-# windows-1255 / ISO-8859-8 code points of interest129-FINAL_KAF = '\xea'130-NORMAL_KAF = '\xeb'131-FINAL_MEM = '\xed'132-NORMAL_MEM = '\xee'133-FINAL_NUN = '\xef'134-NORMAL_NUN = '\xf0'135-FINAL_PE = '\xf3'136-NORMAL_PE = '\xf4'137-FINAL_TSADI = '\xf5'138-NORMAL_TSADI = '\xf6'139-140-# Minimum Visual vs Logical final letter score difference.141-# If the difference is below this, don't rely solely on the final letter score142-# distance.143-MIN_FINAL_CHAR_DISTANCE = 5144-145-# Minimum Visual vs Logical model score difference.146-# If the difference is below this, don't rely at all on the model score147-# distance.148-MIN_MODEL_DISTANCE = 0.01149-150-VISUAL_HEBREW_NAME = "ISO-8859-8"151-LOGICAL_HEBREW_NAME = "windows-1255"152-153-154-class HebrewProber(CharSetProber):155- def __init__(self):156- CharSetProber.__init__(self)157- self._mLogicalProber = None158- self._mVisualProber = None159- self.reset()160-161- def reset(self):162- self._mFinalCharLogicalScore = 0163- self._mFinalCharVisualScore = 0164- # The two last characters seen in the previous buffer,165- # mPrev and mBeforePrev are initialized to space in order to simulate a166- # word delimiter at the beginning of the data167- self._mPrev = ' '168- self._mBeforePrev = ' '169- # These probers are owned by the group prober.170-171- def set_model_probers(self, logicalProber, visualProber):172- self._mLogicalProber = logicalProber173- self._mVisualProber = visualProber174-175- def is_final(self, c):176- return c in [FINAL_KAF, FINAL_MEM, FINAL_NUN, FINAL_PE, FINAL_TSADI]177-178- def is_non_final(self, c):179- # The normal Tsadi is not a good Non-Final letter due to words like180- # 'lechotet' (to chat) containing an apostrophe after the tsadi. This181- # apostrophe is converted to a space in FilterWithoutEnglishLetters182- # causing the Non-Final tsadi to appear at an end of a word even183- # though this is not the case in the original text.184- # The letters Pe and Kaf rarely display a related behavior of not being185- # a good Non-Final letter. Words like 'Pop', 'Winamp' and 'Mubarak'186- # for example legally end with a Non-Final Pe or Kaf. However, the187- # benefit of these letters as Non-Final letters outweighs the damage188- # since these words are quite rare.189- return c in [NORMAL_KAF, NORMAL_MEM, NORMAL_NUN, NORMAL_PE]190-191- def feed(self, aBuf):192- # Final letter analysis for logical-visual decision.193- # Look for evidence that the received buffer is either logical Hebrew194- # or visual Hebrew.195- # The following cases are checked:196- # 1) A word longer than 1 letter, ending with a final letter. This is197- # an indication that the text is laid out "naturally" since the final198- # letter really appears at the end. +1 for logical score.199- # 2) A word longer than 1 letter, ending with a Non-Final letter. In200- # normal Hebrew, words ending with Kaf, Mem, Nun, Pe or Tsadi,201- # should not end with the Non-Final form of that letter. Exceptions202- # to this rule are mentioned above in isNonFinal(). This is an203- # indication that the text is laid out backwards. +1 for visual204- # score205- # 3) A word longer than 1 letter, starting with a final letter. Final206- # letters should not appear at the beginning of a word. This is an207- # indication that the text is laid out backwards. +1 for visual208- # score.209- #210- # The visual score and logical score are accumulated throughout the211- # text and are finally checked against each other in GetCharSetName().212- # No checking for final letters in the middle of words is done since213- # that case is not an indication for either Logical or Visual text.214- #215- # We automatically filter out all 7-bit characters (replace them with216- # spaces) so the word boundary detection works properly. [MAP]217-218- if self.get_state() == constants.eNotMe:219- # Both model probers say it's not them. No reason to continue.220- return constants.eNotMe221-222- aBuf = self.filter_high_bit_only(aBuf)223-224- for cur in aBuf:225- if cur == ' ':226- # We stand on a space - a word just ended227- if self._mBeforePrev != ' ':228- # next-to-last char was not a space so self._mPrev is not a229- # 1 letter word230- if self.is_final(self._mPrev):231- # case (1) [-2:not space][-1:final letter][cur:space]232- self._mFinalCharLogicalScore += 1233- elif self.is_non_final(self._mPrev):234- # case (2) [-2:not space]235- # [-1:Non-Final letter][cur:space]236- self._mFinalCharVisualScore += 1237- else:238- # Not standing on a space239- if ((self._mBeforePrev == ' ') and240- (self.is_final(self._mPrev)) and (cur != ' ')):241- # case (3) [-2:space][-1:final letter][cur:not space]242- self._mFinalCharVisualScore += 1243- self._mBeforePrev = self._mPrev244- self._mPrev = cur245-246- # Forever detecting, till the end or until both model probers return247- # eNotMe (handled above)248- return constants.eDetecting249-250- def get_charset_name(self):251- # Make the decision: is it Logical or Visual?252- # If the final letter score distance is dominant enough, rely on it.253- finalsub = self._mFinalCharLogicalScore - self._mFinalCharVisualScore254- if finalsub >= MIN_FINAL_CHAR_DISTANCE:255- return LOGICAL_HEBREW_NAME256- if finalsub <= -MIN_FINAL_CHAR_DISTANCE:257- return VISUAL_HEBREW_NAME258-259- # It's not dominant enough, try to rely on the model scores instead.260- modelsub = (self._mLogicalProber.get_confidence()261- - self._mVisualProber.get_confidence())262- if modelsub > MIN_MODEL_DISTANCE:263- return LOGICAL_HEBREW_NAME264- if modelsub < -MIN_MODEL_DISTANCE:265- return VISUAL_HEBREW_NAME266-267- # Still no good, back to final letter distance, maybe it'll save268- # the day.269- if finalsub < 0.0:270- return VISUAL_HEBREW_NAME271-272- # (finalsub > 0 - Logical) or (don't know what to do) default to273- # Logical.274- return LOGICAL_HEBREW_NAME275-276- def get_state(self):277- # Remain active as long as any of the model probers are active.278- if (self._mLogicalProber.get_state() == constants.eNotMe) and \279- (self._mVisualProber.get_state() == constants.eNotMe):280- return constants.eNotMe281- return constants.eDetecting1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Universal charset detector code.3+#4+# The Initial Developer of the Original Code is5+# Shy Shalom6+# Portions created by the Initial Developer are Copyright (C) 20057+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+#22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+from .charsetprober import CharSetProber29+from .constants import eNotMe, eDetecting30+from .compat import wrap_ord31+32+# This prober doesn't actually recognize a language or a charset.33+# It is a helper prober for the use of the Hebrew model probers34+35+### General ideas of the Hebrew charset recognition ###36+#37+# Four main charsets exist in Hebrew:38+# "ISO-8859-8" - Visual Hebrew39+# "windows-1255" - Logical Hebrew40+# "ISO-8859-8-I" - Logical Hebrew41+# "x-mac-hebrew" - ?? Logical Hebrew ??42+#43+# Both "ISO" charsets use a completely identical set of code points, whereas44+# "windows-1255" and "x-mac-hebrew" are two different proper supersets of45+# these code points. windows-1255 defines additional characters in the range46+# 0x80-0x9F as some misc punctuation marks as well as some Hebrew-specific47+# diacritics and additional 'Yiddish' ligature letters in the range 0xc0-0xd6.48+# x-mac-hebrew defines similar additional code points but with a different49+# mapping.50+#51+# As far as an average Hebrew text with no diacritics is concerned, all four52+# charsets are identical with respect to code points. Meaning that for the53+# main Hebrew alphabet, all four map the same values to all 27 Hebrew letters54+# (including final letters).55+#56+# The dominant difference between these charsets is their directionality.57+# "Visual" directionality means that the text is ordered as if the renderer is58+# not aware of a BIDI rendering algorithm. The renderer sees the text and59+# draws it from left to right. The text itself when ordered naturally is read60+# backwards. A buffer of Visual Hebrew generally looks like so:61+# "[last word of first line spelled backwards] [whole line ordered backwards62+# and spelled backwards] [first word of first line spelled backwards]63+# [end of line] [last word of second line] ... etc' "64+# adding punctuation marks, numbers and English text to visual text is65+# naturally also "visual" and from left to right.66+#67+# "Logical" directionality means the text is ordered "naturally" according to68+# the order it is read. It is the responsibility of the renderer to display69+# the text from right to left. A BIDI algorithm is used to place general70+# punctuation marks, numbers and English text in the text.71+#72+# Texts in x-mac-hebrew are almost impossible to find on the Internet. From73+# what little evidence I could find, it seems that its general directionality74+# is Logical.75+#76+# To sum up all of the above, the Hebrew probing mechanism knows about two77+# charsets:78+# Visual Hebrew - "ISO-8859-8" - backwards text - Words and sentences are79+# backwards while line order is natural. For charset recognition purposes80+# the line order is unimportant (In fact, for this implementation, even81+# word order is unimportant).82+# Logical Hebrew - "windows-1255" - normal, naturally ordered text.83+#84+# "ISO-8859-8-I" is a subset of windows-1255 and doesn't need to be85+# specifically identified.86+# "x-mac-hebrew" is also identified as windows-1255. A text in x-mac-hebrew87+# that contain special punctuation marks or diacritics is displayed with88+# some unconverted characters showing as question marks. This problem might89+# be corrected using another model prober for x-mac-hebrew. Due to the fact90+# that x-mac-hebrew texts are so rare, writing another model prober isn't91+# worth the effort and performance hit.92+#93+#### The Prober ####94+#95+# The prober is divided between two SBCharSetProbers and a HebrewProber,96+# all of which are managed, created, fed data, inquired and deleted by the97+# SBCSGroupProber. The two SBCharSetProbers identify that the text is in98+# fact some kind of Hebrew, Logical or Visual. The final decision about which99+# one is it is made by the HebrewProber by combining final-letter scores100+# with the scores of the two SBCharSetProbers to produce a final answer.101+#102+# The SBCSGroupProber is responsible for stripping the original text of HTML103+# tags, English characters, numbers, low-ASCII punctuation characters, spaces104+# and new lines. It reduces any sequence of such characters to a single space.105+# The buffer fed to each prober in the SBCS group prober is pure text in106+# high-ASCII.107+# The two SBCharSetProbers (model probers) share the same language model:108+# Win1255Model.109+# The first SBCharSetProber uses the model normally as any other110+# SBCharSetProber does, to recognize windows-1255, upon which this model was111+# built. The second SBCharSetProber is told to make the pair-of-letter112+# lookup in the language model backwards. This in practice exactly simulates113+# a visual Hebrew model using the windows-1255 logical Hebrew model.114+#115+# The HebrewProber is not using any language model. All it does is look for116+# final-letter evidence suggesting the text is either logical Hebrew or visual117+# Hebrew. Disjointed from the model probers, the results of the HebrewProber118+# alone are meaningless. HebrewProber always returns 0.00 as confidence119+# since it never identifies a charset by itself. Instead, the pointer to the120+# HebrewProber is passed to the model probers as a helper "Name Prober".121+# When the Group prober receives a positive identification from any prober,122+# it asks for the name of the charset identified. If the prober queried is a123+# Hebrew model prober, the model prober forwards the call to the124+# HebrewProber to make the final decision. In the HebrewProber, the125+# decision is made according to the final-letters scores maintained and Both126+# model probers scores. The answer is returned in the form of the name of the127+# charset identified, either "windows-1255" or "ISO-8859-8".128+129+# windows-1255 / ISO-8859-8 code points of interest130+FINAL_KAF = 0xea131+NORMAL_KAF = 0xeb132+FINAL_MEM = 0xed133+NORMAL_MEM = 0xee134+FINAL_NUN = 0xef135+NORMAL_NUN = 0xf0136+FINAL_PE = 0xf3137+NORMAL_PE = 0xf4138+FINAL_TSADI = 0xf5139+NORMAL_TSADI = 0xf6140+141+# Minimum Visual vs Logical final letter score difference.142+# If the difference is below this, don't rely solely on the final letter score143+# distance.144+MIN_FINAL_CHAR_DISTANCE = 5145+146+# Minimum Visual vs Logical model score difference.147+# If the difference is below this, don't rely at all on the model score148+# distance.149+MIN_MODEL_DISTANCE = 0.01150+151+VISUAL_HEBREW_NAME = "ISO-8859-8"152+LOGICAL_HEBREW_NAME = "windows-1255"153+154+155+class HebrewProber(CharSetProber):156+ def __init__(self):157+ CharSetProber.__init__(self)158+ self._mLogicalProber = None159+ self._mVisualProber = None160+ self.reset()161+162+ def reset(self):163+ self._mFinalCharLogicalScore = 0164+ self._mFinalCharVisualScore = 0165+ # The two last characters seen in the previous buffer,166+ # mPrev and mBeforePrev are initialized to space in order to simulate167+ # a word delimiter at the beginning of the data168+ self._mPrev = ' '169+ self._mBeforePrev = ' '170+ # These probers are owned by the group prober.171+172+ def set_model_probers(self, logicalProber, visualProber):173+ self._mLogicalProber = logicalProber174+ self._mVisualProber = visualProber175+176+ def is_final(self, c):177+ return wrap_ord(c) in [FINAL_KAF, FINAL_MEM, FINAL_NUN, FINAL_PE,178+ FINAL_TSADI]179+180+ def is_non_final(self, c):181+ # The normal Tsadi is not a good Non-Final letter due to words like182+ # 'lechotet' (to chat) containing an apostrophe after the tsadi. This183+ # apostrophe is converted to a space in FilterWithoutEnglishLetters184+ # causing the Non-Final tsadi to appear at an end of a word even185+ # though this is not the case in the original text.186+ # The letters Pe and Kaf rarely display a related behavior of not being187+ # a good Non-Final letter. Words like 'Pop', 'Winamp' and 'Mubarak'188+ # for example legally end with a Non-Final Pe or Kaf. However, the189+ # benefit of these letters as Non-Final letters outweighs the damage190+ # since these words are quite rare.191+ return wrap_ord(c) in [NORMAL_KAF, NORMAL_MEM, NORMAL_NUN, NORMAL_PE]192+193+ def feed(self, aBuf):194+ # Final letter analysis for logical-visual decision.195+ # Look for evidence that the received buffer is either logical Hebrew196+ # or visual Hebrew.197+ # The following cases are checked:198+ # 1) A word longer than 1 letter, ending with a final letter. This is199+ # an indication that the text is laid out "naturally" since the200+ # final letter really appears at the end. +1 for logical score.201+ # 2) A word longer than 1 letter, ending with a Non-Final letter. In202+ # normal Hebrew, words ending with Kaf, Mem, Nun, Pe or Tsadi,203+ # should not end with the Non-Final form of that letter. Exceptions204+ # to this rule are mentioned above in isNonFinal(). This is an205+ # indication that the text is laid out backwards. +1 for visual206+ # score207+ # 3) A word longer than 1 letter, starting with a final letter. Final208+ # letters should not appear at the beginning of a word. This is an209+ # indication that the text is laid out backwards. +1 for visual210+ # score.211+ #212+ # The visual score and logical score are accumulated throughout the213+ # text and are finally checked against each other in GetCharSetName().214+ # No checking for final letters in the middle of words is done since215+ # that case is not an indication for either Logical or Visual text.216+ #217+ # We automatically filter out all 7-bit characters (replace them with218+ # spaces) so the word boundary detection works properly. [MAP]219+220+ if self.get_state() == eNotMe:221+ # Both model probers say it's not them. No reason to continue.222+ return eNotMe223+224+ aBuf = self.filter_high_bit_only(aBuf)225+226+ for cur in aBuf:227+ if cur == ' ':228+ # We stand on a space - a word just ended229+ if self._mBeforePrev != ' ':230+ # next-to-last char was not a space so self._mPrev is not a231+ # 1 letter word232+ if self.is_final(self._mPrev):233+ # case (1) [-2:not space][-1:final letter][cur:space]234+ self._mFinalCharLogicalScore += 1235+ elif self.is_non_final(self._mPrev):236+ # case (2) [-2:not space][-1:Non-Final letter][237+ # cur:space]238+ self._mFinalCharVisualScore += 1239+ else:240+ # Not standing on a space241+ if ((self._mBeforePrev == ' ') and242+ (self.is_final(self._mPrev)) and (cur != ' ')):243+ # case (3) [-2:space][-1:final letter][cur:not space]244+ self._mFinalCharVisualScore += 1245+ self._mBeforePrev = self._mPrev246+ self._mPrev = cur247+248+ # Forever detecting, till the end or until both model probers return249+ # eNotMe (handled above)250+ return eDetecting251+252+ def get_charset_name(self):253+ # Make the decision: is it Logical or Visual?254+ # If the final letter score distance is dominant enough, rely on it.255+ finalsub = self._mFinalCharLogicalScore - self._mFinalCharVisualScore256+ if finalsub >= MIN_FINAL_CHAR_DISTANCE:257+ return LOGICAL_HEBREW_NAME258+ if finalsub <= -MIN_FINAL_CHAR_DISTANCE:259+ return VISUAL_HEBREW_NAME260+261+ # It's not dominant enough, try to rely on the model scores instead.262+ modelsub = (self._mLogicalProber.get_confidence()263+ - self._mVisualProber.get_confidence())264+ if modelsub > MIN_MODEL_DISTANCE:265+ return LOGICAL_HEBREW_NAME266+ if modelsub < -MIN_MODEL_DISTANCE:267+ return VISUAL_HEBREW_NAME268+269+ # Still no good, back to final letter distance, maybe it'll save the270+ # day.271+ if finalsub < 0.0:272+ return VISUAL_HEBREW_NAME273+274+ # (finalsub > 0 - Logical) or (don't know what to do) default to275+ # Logical.276+ return LOGICAL_HEBREW_NAME277+278+ def get_state(self):279+ # Remain active as long as any of the model probers are active.280+ if (self._mLogicalProber.get_state() == eNotMe) and \281+ (self._mVisualProber.get_state() == eNotMe):282+ return eNotMe283+ return eDetectingmodified:requests/packages/charade/jisfreq.py+9 added-7 removed
11 unmodified lines12 # This library is free software; you can redistribute it and/or13 # modify it under the terms of the GNU Lesser General Public14 # License as published by the Free Software Foundation; either15 # version 2.1 of the License, or (at your option) any later version.16-# 16+#17 # This library is distributed in the hope that it will be useful,18 # but WITHOUT ANY WARRANTY; without even the implied warranty of19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20 # Lesser General Public License for more details.21-# 21+#22 # You should have received a copy of the GNU Lesser General Public23 # License along with this library; if not, write to the Free Software24 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25 # 02110-1301 USA1 unmodified line27 28 # Sampling from about 20M text materials include literature and computer technology29 #30 # Japanese frequency table, applied to both S-JIS and EUC-JP31-# They are sorted in order. 31+# They are sorted in order.32 33 # 128 --> 0.7709434 # 256 --> 0.8571035 # 512 --> 0.926351 unmodified line37 # 2048 --> 0.9943138 #39 # Ideal Distribution Ratio = 0.92635 / (1-0.92635) = 12.5840 # Random Distribution Ration = 512 / (2965+62+83+86-512) = 0.19141-# 42-# Typical Distribution Ratio, 25% of IDR 41+#42+# Typical Distribution Ratio, 25% of IDR43 44 JIS_TYPICAL_DISTRIBUTION_RATIO = 3.045 46-# Char to FreqOrder table , 46+# Char to FreqOrder table ,47 JIS_TABLE_SIZE = 436848 49-JISCharToFreqOrder = ( \49+JISCharToFreqOrder = (50 40, 1, 6, 182, 152, 180, 295,2127, 285, 381,3295,4304,3068,4606,3165,3510, # 1651 3511,1822,2785,4607,1193,2226,5070,4608, 171,2996,1247, 18, 179,5071, 856,1661, # 3252 1262,5072, 619, 127,3431,3512,3230,1899,1700, 232, 228,1294,1298, 284, 283,2041, # 4853 2042,1061,1062, 48, 49, 44, 45, 433, 434,1040,1041, 996, 787,2997,1255,4305, # 64510 unmodified lines564 8208,8209,8210,8211,8212,8213,8214,8215,8216,8217,8218,8219,8220,8221,8222,8223, # 8224565 8224,8225,8226,8227,8228,8229,8230,8231,8232,8233,8234,8235,8236,8237,8238,8239, # 8240566 8240,8241,8242,8243,8244,8245,8246,8247,8248,8249,8250,8251,8252,8253,8254,8255, # 8256567 8256,8257,8258,8259,8260,8261,8262,8263,8264,8265,8266,8267,8268,8269,8270,8271) # 8272568+569+# flake8: noqamodified:requests/packages/charade/jpcntx.py+219 added-563 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Communicator client code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-#22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-from .compat import wrap_ord29-30-NUM_OF_CATEGORY = 631-DONT_KNOW = -132-ENOUGH_REL_THRESHOLD = 10033-MAX_REL_THRESHOLD = 100034-MINIMUM_DATA_THRESHOLD = 435-36-# This is hiragana 2-char sequence table, the number in each cell represents37-# its frequency category38-jp2CharContext = (39- (0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,40- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,41- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,42- 0, 0, 0, 0, 0, 0, 0, 1),43-44- (2, 4, 0, 4, 0, 3, 0, 4, 0, 3, 4, 4, 4, 2, 4, 3, 3, 4, 3, 2, 3, 3, 4, 2,45- 3, 3, 3, 2, 4, 1, 4, 3, 3, 1, 5, 4, 3, 4, 3, 4, 3, 5, 3, 0, 3, 5, 4,46- 2, 0, 3, 1, 0, 3, 3, 0, 3, 3, 0, 1, 1, 0, 4, 3, 0, 3, 3, 0, 4, 0, 2,47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 0, 0, 0, 0, 0, 0, 2),443-444- (0, 4, 0, 4, 0, 4, 0, 3, 0, 4, 4, 3, 4, 2, 4, 3, 2, 0, 4, 4, 4, 3, 5, 3,445- 5, 3, 3, 2, 4, 2, 4, 3, 4, 3, 1, 4, 0, 2, 3, 4, 4, 4, 3, 3, 3, 4,446- 4, 4, 3, 4, 1, 3, 4, 3, 2, 1, 2, 1, 3, 3, 3, 4, 4, 3, 3, 5, 0, 4,447- 0, 3, 0, 4, 3, 3, 3, 2, 1, 0, 3, 0, 0, 3, 3),448-449- (0, 4, 0, 3, 0, 3, 0, 3, 0, 3, 5, 5, 3, 3, 3, 3, 4, 3, 4, 3, 3, 3, 4, 4,450- 4, 3, 3, 3, 3, 4, 3, 5, 3, 3, 1, 3, 2, 4, 5, 5, 5, 5, 4, 3, 4, 5,451- 5, 3, 2, 2, 3, 3, 3, 3, 2, 3, 3, 1, 2, 3, 2, 4, 3, 3, 3, 4, 0, 4,452- 0, 2, 0, 4, 3, 2, 2, 1, 2, 0, 3, 0, 0, 4, 1),453-)454-455-456-class JapaneseContextAnalysis:457- def __init__(self):458- self.reset()459-460- def reset(self):461- # total sequence received462- self._mTotalRel = 0463- # category counters, each interger counts sequence in its category464- self._mRelSample = [0] * NUM_OF_CATEGORY465- # if last byte in current buffer is not the last byte of a character,466- # we need to know how many bytes to skip in next buffer467- self._mNeedToSkipCharNum = 0468- # The order of previous char469- self._mLastCharOrder = -1470- # If this flag is set to constants.True, detection is done and471- # conclusion has been made472- self._mDone = False473-474- def feed(self, aBuf, aLen):475- if self._mDone:476- return477-478- # The buffer we got is byte oriented, and a character may span in more479- # than one buffers. In case the last one or two byte in last buffer is480- # not complete, we record how many byte needed to complete that481- # character and skip these bytes here. We can choose to record those482- # bytes as well and analyse the character once it is complete, but483- # since a character will not make much difference, by simply skipping484- # this character will simply our logic and improve performance.485- i = self._mNeedToSkipCharNum486- while i < aLen:487- order, charLen = self.get_order(aBuf[i:i + 2])488- i += charLen489- if i > aLen:490- self._mNeedToSkipCharNum = i - aLen491- self._mLastCharOrder = -1492- else:493- if (order != -1) and (self._mLastCharOrder != -1):494- self._mTotalRel += 1495- if self._mTotalRel > MAX_REL_THRESHOLD:496- self._mDone = True497- break498- self._mRelSample[499- jp2CharContext[self._mLastCharOrder][order]500- ] += 1501- self._mLastCharOrder = order502-503- def got_enough_data(self):504- return self._mTotalRel > ENOUGH_REL_THRESHOLD505-506- def get_confidence(self):507- # This is just one way to calculate confidence. It works well for me.508- if self._mTotalRel > MINIMUM_DATA_THRESHOLD:509- return (self._mTotalRel - self._mRelSample[0]) / self._mTotalRel510- else:511- return DONT_KNOW512-513- def get_order(self, aStr):514- return -1, 1515-516-517-class SJISContextAnalysis(JapaneseContextAnalysis):518- def get_order(self, aStr):519- if not aStr:520- return -1, 1521- # find out current char's byte length522- char = wrap_ord(aStr[0])523- try:524- if (((char >= 0x81) and (char <= 0x9F)) or525- ((char >= 0xE0) and (char <= 0xFC))):526- charLen = 2527- else:528- charLen = 1529- except UnicodeDecodeError:530- return -1, 1531-532- # return its order if it is hiragana533- if len(aStr) > 1:534- char_1 = wrap_ord(aStr[1])535- if ((char == 202) and (0x9F <= char_1 <= 0xF1)):536- return char_1 - 0x9F, charLen537-538- return -1, charLen539-540-541-class EUCJPContextAnalysis(JapaneseContextAnalysis):542- def get_order(self, aStr):543- if not aStr:544- return -1, 1545- # find out current char's byte length546- char = wrap_ord(aStr[0])547- try:548- if (char == 0x8E) or (0xA1 <= char <= 0xFE):549- charLen = 2550- elif aStr[0] == 0x8F:551- charLen = 3552- else:553- charLen = 1554- except UnicodeDecodeError:555- return -1, 1556-557- # return its order if it is hiragana558- if len(aStr) > 1:559- char_1 = wrap_ord(aStr[1])560- if (char == 0xA4) and (0xA1 <= char_1 <= 0xF3):561- return char_1 - 0xA1, charLen562-563- return -1, charLen1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Communicator client code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+#22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+from .compat import wrap_ord29+30+NUM_OF_CATEGORY = 631+DONT_KNOW = -132+ENOUGH_REL_THRESHOLD = 10033+MAX_REL_THRESHOLD = 100034+MINIMUM_DATA_THRESHOLD = 435+36+# This is hiragana 2-char sequence table, the number in each cell represents its frequency category37+jp2CharContext = (38+(0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1),39+(2,4,0,4,0,3,0,4,0,3,4,4,4,2,4,3,3,4,3,2,3,3,4,2,3,3,3,2,4,1,4,3,3,1,5,4,3,4,3,4,3,5,3,0,3,5,4,2,0,3,1,0,3,3,0,3,3,0,1,1,0,4,3,0,3,3,0,4,0,2,0,3,5,5,5,5,4,0,4,1,0,3,4),40+(0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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1,3,3,3,4,4,3,3,5,0,4,0,3,0,4,3,3,3,2,1,0,3,0,0,3,3),120+(0,4,0,3,0,3,0,3,0,3,5,5,3,3,3,3,4,3,4,3,3,3,4,4,4,3,3,3,3,4,3,5,3,3,1,3,2,4,5,5,5,5,4,3,4,5,5,3,2,2,3,3,3,3,2,3,3,1,2,3,2,4,3,3,3,4,0,4,0,2,0,4,3,2,2,1,2,0,3,0,0,4,1),121+)122+123+class JapaneseContextAnalysis:124+ def __init__(self):125+ self.reset()126+127+ def reset(self):128+ self._mTotalRel = 0 # total sequence received129+ # category counters, each interger counts sequence in its category130+ self._mRelSample = [0] * NUM_OF_CATEGORY131+ # if last byte in current buffer is not the last byte of a character,132+ # we need to know how many bytes to skip in next buffer133+ self._mNeedToSkipCharNum = 0134+ self._mLastCharOrder = -1 # The order of previous char135+ # If this flag is set to True, detection is done and conclusion has136+ # been made137+ self._mDone = False138+139+ def feed(self, aBuf, aLen):140+ if self._mDone:141+ return142+143+ # The buffer we got is byte oriented, and a character may span in more than one144+ # buffers. In case the last one or two byte in last buffer is not145+ # complete, we record how many byte needed to complete that character146+ # and skip these bytes here. We can choose to record those bytes as147+ # well and analyse the character once it is complete, but since a148+ # character will not make much difference, by simply skipping149+ # this character will simply our logic and improve performance.150+ i = self._mNeedToSkipCharNum151+ while i < aLen:152+ order, charLen = self.get_order(aBuf[i:i + 2])153+ i += charLen154+ if i > aLen:155+ self._mNeedToSkipCharNum = i - aLen156+ self._mLastCharOrder = -1157+ else:158+ if (order != -1) and (self._mLastCharOrder != -1):159+ self._mTotalRel += 1160+ if self._mTotalRel > MAX_REL_THRESHOLD:161+ self._mDone = True162+ break163+ self._mRelSample[jp2CharContext[self._mLastCharOrder][order]] += 1164+ self._mLastCharOrder = order165+166+ def got_enough_data(self):167+ return self._mTotalRel > ENOUGH_REL_THRESHOLD168+169+ def get_confidence(self):170+ # This is just one way to calculate confidence. It works well for me.171+ if self._mTotalRel > MINIMUM_DATA_THRESHOLD:172+ return (self._mTotalRel - self._mRelSample[0]) / self._mTotalRel173+ else:174+ return DONT_KNOW175+176+ def get_order(self, aBuf):177+ return -1, 1178+179+class SJISContextAnalysis(JapaneseContextAnalysis):180+ def get_order(self, aBuf):181+ if not aBuf:182+ return -1, 1183+ # find out current char's byte length184+ first_char = wrap_ord(aBuf[0])185+ if ((0x81 <= first_char <= 0x9F) or (0xE0 <= first_char <= 0xFC)):186+ charLen = 2187+ else:188+ charLen = 1189+190+ # return its order if it is hiragana191+ if len(aBuf) > 1:192+ second_char = wrap_ord(aBuf[1])193+ if (first_char == 202) and (0x9F <= second_char <= 0xF1):194+ return second_char - 0x9F, charLen195+196+ return -1, charLen197+198+class EUCJPContextAnalysis(JapaneseContextAnalysis):199+ def get_order(self, aBuf):200+ if not aBuf:201+ return -1, 1202+ # find out current char's byte length203+ first_char = wrap_ord(aBuf[0])204+ if (first_char == 0x8E) or (0xA1 <= first_char <= 0xFE):205+ charLen = 2206+ elif first_char == 0x8F:207+ charLen = 3208+ else:209+ charLen = 1210+211+ # return its order if it is hiragana212+ if len(aBuf) > 1:213+ second_char = wrap_ord(aBuf[1])214+ if (first_char == 0xA4) and (0xA1 <= second_char <= 0xF3):215+ return second_char - 0xA1, charLen216+217+ return -1, charLen218+219+# flake8: noqamodified:requests/packages/charade/langbulgarianmodel.py+229 added-262 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Communicator client code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-#22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-# 255: Control characters that usually does not exist in any text29-# 254: Carriage/Return30-# 253: symbol (punctuation) that does not belong to word31-# 252: 0 - 932-33-# Character Mapping Table:34-# this table is modified base on win1251BulgarianCharToOrderMap, so35-# only number <64 is sure valid36-37-Latin5_BulgarianCharToOrderMap = (38-255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 255, 255, 254, 255, 255, # 0039-255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, # 1040-253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, # 2041-252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 253, 253, 253, 253, 253, 253, # 3042-253, 77, 90, 99, 100, 72, 109, 107, 101, 79, 185, 81, 102, 76, 94, 82, # 4043-110, 186, 108, 91, 74, 119, 84, 96, 111, 187, 115, 253, 253, 253, 253, 253, # 5044-253, 65, 69, 70, 66, 63, 68, 112, 103, 92, 194, 104, 95, 86, 87, 71, # 6045-116, 195, 85, 93, 97, 113, 196, 197, 198, 199, 200, 253, 253, 253, 253, 253, # 7046-194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, # 8047-210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, # 9048- 81, 226, 227, 228, 229, 230, 105, 231, 232, 233, 234, 235, 236, 45, 237, 238, # a049- 31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, # b050- 39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61, 239, 67, 240, 60, 56, # c051- 1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, # d052- 7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52, 241, 42, 16, # e053- 62, 242, 243, 244, 58, 245, 98, 246, 247, 248, 249, 250, 251, 91, 252, 253, # f054-)55-56-win1251BulgarianCharToOrderMap = (57-255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 255, 255, 254, 255, 255, # 0058-255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, # 1059-253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, # 2060-252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 253, 253, 253, 253, 253, 253, # 3061-253, 77, 90, 99, 100, 72, 109, 107, 101, 79, 185, 81, 102, 76, 94, 82, # 4062-110, 186, 108, 91, 74, 119, 84, 96, 111, 187, 115, 253, 253, 253, 253, 253, # 5063-253, 65, 69, 70, 66, 63, 68, 112, 103, 92, 194, 104, 95, 86, 87, 71, # 6064-116, 195, 85, 93, 97, 113, 196, 197, 198, 199, 200, 253, 253, 253, 253, 253, # 7065-206, 207, 208, 209, 210, 211, 212, 213, 120, 214, 215, 216, 217, 218, 219, 220, # 8066-221, 78, 64, 83, 121, 98, 117, 105, 222, 223, 224, 225, 226, 227, 228, 229, # 9067- 88, 230, 231, 232, 233, 122, 89, 106, 234, 235, 236, 237, 238, 45, 239, 240, # a068- 73, 80, 118, 114, 241, 242, 243, 244, 245, 62, 58, 246, 247, 248, 249, 250, # b069- 31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, # c070- 39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61, 251, 67, 252, 60, 56, # d071- 1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, # e072- 7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52, 253, 42, 16, # f073-)74-75-# Model Table: 76-# total sequences: 100%77-# first 512 sequences: 96.9392%78-# first 1024 sequences:3.0618%79-# rest sequences: 0.2992%80-# negative sequences: 0.0020%81-B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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,242- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,243- 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,244- 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,245- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,246-)247-248-Latin5BulgarianModel = {249- 'charToOrderMap': Latin5_BulgarianCharToOrderMap,250- 'precedenceMatrix': BulgarianLangModel,251- 'mTypicalPositiveRatio': 0.969392,252- 'keepEnglishLetter': False,253- 'charsetName': "ISO-8859-5"254-}255-256-Win1251BulgarianModel = {257- 'charToOrderMap': win1251BulgarianCharToOrderMap,258- 'precedenceMatrix': BulgarianLangModel,259- 'mTypicalPositiveRatio': 0.969392,260- 'keepEnglishLetter': False,261- 'charsetName': "windows-1251"262-}1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Communicator client code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+#22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+# 255: Control characters that usually does not exist in any text29+# 254: Carriage/Return30+# 253: symbol (punctuation) that does not belong to word31+# 252: 0 - 932+33+# Character Mapping Table:34+# this table is modified base on win1251BulgarianCharToOrderMap, so35+# only number <64 is sure valid36+37+Latin5_BulgarianCharToOrderMap = (38+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0039+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1040+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2041+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3042+253, 77, 90, 99,100, 72,109,107,101, 79,185, 81,102, 76, 94, 82, # 4043+110,186,108, 91, 74,119, 84, 96,111,187,115,253,253,253,253,253, # 5044+253, 65, 69, 70, 66, 63, 68,112,103, 92,194,104, 95, 86, 87, 71, # 6045+116,195, 85, 93, 97,113,196,197,198,199,200,253,253,253,253,253, # 7046+194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209, # 8047+210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225, # 9048+ 81,226,227,228,229,230,105,231,232,233,234,235,236, 45,237,238, # a049+ 31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, # b050+ 39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61,239, 67,240, 60, 56, # c051+ 1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, # d052+ 7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52,241, 42, 16, # e053+ 62,242,243,244, 58,245, 98,246,247,248,249,250,251, 91,252,253, # f054+)55+56+win1251BulgarianCharToOrderMap = (57+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0058+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1059+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2060+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3061+253, 77, 90, 99,100, 72,109,107,101, 79,185, 81,102, 76, 94, 82, # 4062+110,186,108, 91, 74,119, 84, 96,111,187,115,253,253,253,253,253, # 5063+253, 65, 69, 70, 66, 63, 68,112,103, 92,194,104, 95, 86, 87, 71, # 6064+116,195, 85, 93, 97,113,196,197,198,199,200,253,253,253,253,253, # 7065+206,207,208,209,210,211,212,213,120,214,215,216,217,218,219,220, # 8066+221, 78, 64, 83,121, 98,117,105,222,223,224,225,226,227,228,229, # 9067+ 88,230,231,232,233,122, 89,106,234,235,236,237,238, 45,239,240, # a068+ 73, 80,118,114,241,242,243,244,245, 62, 58,246,247,248,249,250, # b069+ 31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, # c070+ 39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61,251, 67,252, 60, 56, # d071+ 1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, # e072+ 7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52,253, 42, 16, # f073+)74+75+# Model Table:76+# total sequences: 100%77+# first 512 sequences: 96.9392%78+# first 1024 sequences:3.0618%79+# rest sequences: 0.2992%80+# negative sequences: 0.0020%81+BulgarianLangModel = (82+0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,2,3,3,3,3,3,83+3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,3,3,3,2,2,3,2,2,1,2,2,84+3,1,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,0,3,3,3,3,3,3,3,3,3,3,0,3,0,1,85+0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,86+3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,2,3,3,3,3,3,3,3,3,0,3,1,0,87+0,1,0,0,0,0,0,0,0,0,1,1,0,1,0,0,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2,1,0,0,1,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,197+0,0,0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,198+3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,199+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,200+1,0,0,1,2,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,201+0,1,1,0,1,1,1,0,0,1,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,202+1,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,2,0,0,2,0,1,0,0,1,0,0,1,203+1,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,204+0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,205+1,1,1,1,1,1,1,2,0,0,0,0,0,0,2,1,0,1,1,0,0,1,1,1,0,1,0,0,0,0,0,0,206+2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,207+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,208+1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,0,1,1,1,1,1,0,1,0,0,209+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,210+)211+212+Latin5BulgarianModel = {213+ 'charToOrderMap': Latin5_BulgarianCharToOrderMap,214+ 'precedenceMatrix': BulgarianLangModel,215+ 'mTypicalPositiveRatio': 0.969392,216+ 'keepEnglishLetter': False,217+ 'charsetName': "ISO-8859-5"218+}219+220+Win1251BulgarianModel = {221+ 'charToOrderMap': win1251BulgarianCharToOrderMap,222+ 'precedenceMatrix': BulgarianLangModel,223+ 'mTypicalPositiveRatio': 0.969392,224+ 'keepEnglishLetter': False,225+ 'charsetName': "windows-1251"226+}227+228+229+# flake8: noqamodified:requests/packages/charade/langcyrillicmodel.py+331 added-329 removed
1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Communicator client code.1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Communicator client code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-# 22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-# KOI8-R language model29-# Character Mapping Table:30-KOI8R_CharToOrderMap = (31-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0032-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1033-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2034-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3035-253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 4036-155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 5037-253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 6038- 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 7039-191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206, # 8040-207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222, # 9041-223,224,225, 68,226,227,228,229,230,231,232,233,234,235,236,237, # a042-238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253, # b043- 27, 3, 21, 28, 13, 2, 39, 19, 26, 4, 23, 11, 8, 12, 5, 1, # c044- 15, 16, 9, 7, 6, 14, 24, 10, 17, 18, 20, 25, 30, 29, 22, 54, # d045- 59, 37, 44, 58, 41, 48, 53, 46, 55, 42, 60, 36, 49, 38, 31, 34, # e046- 35, 43, 45, 32, 40, 52, 56, 33, 61, 62, 51, 57, 47, 63, 50, 70, # f047-)48-49-win1251_CharToOrderMap = (50-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0051-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1052-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2053-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3054-253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 4055-155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 5056-253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 6057- 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 7058-191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,59-207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,60-223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,61-239,240,241,242,243,244,245,246, 68,247,248,249,250,251,252,253,62- 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,63- 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,64- 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,65- 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,66-)67-68-latin5_CharToOrderMap = (69-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0070-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1071-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2072-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3073-253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 4074-155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 5075-253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 6076- 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 7077-191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,78-207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,79-223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,80- 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,81- 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,82- 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,83- 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,84-239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255,85-)86-87-macCyrillic_CharToOrderMap = (88-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0089-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1090-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2091-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3092-253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 4093-155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 5094-253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 6095- 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 7096- 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,97- 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,98-191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,99-207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,100-223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,101-239,240,241,242,243,244,245,246,247,248,249,250,251,252, 68, 16,102- 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,103- 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27,255,104-)105-106-IBM855_CharToOrderMap = (107-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00108-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10109-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20110-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30111-253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40112-155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50113-253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60114- 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70115-191,192,193,194, 68,195,196,197,198,199,200,201,202,203,204,205,116-206,207,208,209,210,211,212,213,214,215,216,217, 27, 59, 54, 70,117- 3, 37, 21, 44, 28, 58, 13, 41, 2, 48, 39, 53, 19, 46,218,219,118-220,221,222,223,224, 26, 55, 4, 42,225,226,227,228, 23, 60,229,119-230,231,232,233,234,235, 11, 36,236,237,238,239,240,241,242,243,120- 8, 49, 12, 38, 5, 31, 1, 34, 15,244,245,246,247, 35, 16,248,121- 43, 9, 45, 7, 32, 6, 40, 14, 52, 24, 56, 10, 33, 17, 61,249,122-250, 18, 62, 20, 51, 25, 57, 30, 47, 29, 63, 22, 50,251,252,255,123-)124-125-IBM866_CharToOrderMap = (126-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00127-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10128-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20129-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30130-253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40131-155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50132-253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60133- 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70134- 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,135- 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,136- 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,137-191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,138-207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,139-223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,140- 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,141-239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255,142-)143-144-# Model Table: 145-# total sequences: 100%146-# first 512 sequences: 97.6601%147-# first 1024 sequences: 2.3389%148-# rest sequences: 0.1237%149-# negative sequences: 0.0009% 150-RussianLangModel = (151-0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,1,3,3,3,2,3,2,3,3,152-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,3,2,2,2,2,2,0,0,2,153-3,3,3,2,3,3,3,3,3,3,3,3,3,3,2,3,3,0,0,3,3,3,3,3,3,3,3,3,2,3,2,0,154-0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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1,0,0,279-)280-281-Koi8rModel = {282- 'charToOrderMap': KOI8R_CharToOrderMap,283- 'precedenceMatrix': RussianLangModel,284- 'mTypicalPositiveRatio': 0.976601,285- 'keepEnglishLetter': False,286- 'charsetName': "KOI8-R"287-}288-289-Win1251CyrillicModel = {290- 'charToOrderMap': win1251_CharToOrderMap,291- 'precedenceMatrix': RussianLangModel,292- 'mTypicalPositiveRatio': 0.976601,293- 'keepEnglishLetter': False,294- 'charsetName': "windows-1251"295-}296-297-Latin5CyrillicModel = {298- 'charToOrderMap': latin5_CharToOrderMap,299- 'precedenceMatrix': RussianLangModel,300- 'mTypicalPositiveRatio': 0.976601,301- 'keepEnglishLetter': False,302- 'charsetName': "ISO-8859-5"303-}304-305-MacCyrillicModel = {306- 'charToOrderMap': macCyrillic_CharToOrderMap,307- 'precedenceMatrix': RussianLangModel,308- 'mTypicalPositiveRatio': 0.976601,309- 'keepEnglishLetter': False,310- 'charsetName': "MacCyrillic"311-};312-313-Ibm866Model = {314- 'charToOrderMap': IBM866_CharToOrderMap,315- 'precedenceMatrix': RussianLangModel,316- 'mTypicalPositiveRatio': 0.976601,317- 'keepEnglishLetter': False,318- 'charsetName': "IBM866"319-}320-321-Ibm855Model = {322- 'charToOrderMap': IBM855_CharToOrderMap,323- 'precedenceMatrix': RussianLangModel,324- 'mTypicalPositiveRatio': 0.976601,325- 'keepEnglishLetter': False,326- 'charsetName': "IBM855"327-}328-329-# flake8: noqa3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+#22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+from . import constants29+30+# KOI8-R language model31+# Character Mapping Table:32+KOI8R_CharToOrderMap = (33+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0034+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1035+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2036+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3037+253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 4038+155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 5039+253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 6040+ 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 7041+191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206, # 8042+207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222, # 9043+223,224,225, 68,226,227,228,229,230,231,232,233,234,235,236,237, # a044+238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253, # b045+ 27, 3, 21, 28, 13, 2, 39, 19, 26, 4, 23, 11, 8, 12, 5, 1, # c046+ 15, 16, 9, 7, 6, 14, 24, 10, 17, 18, 20, 25, 30, 29, 22, 54, # d047+ 59, 37, 44, 58, 41, 48, 53, 46, 55, 42, 60, 36, 49, 38, 31, 34, # e048+ 35, 43, 45, 32, 40, 52, 56, 33, 61, 62, 51, 57, 47, 63, 50, 70, # f049+)50+51+win1251_CharToOrderMap = (52+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0053+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1054+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2055+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3056+253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 4057+155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 5058+253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 6059+ 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 7060+191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,61+207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,62+223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,63+239,240,241,242,243,244,245,246, 68,247,248,249,250,251,252,253,64+ 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,65+ 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,66+ 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,67+ 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,68+)69+70+latin5_CharToOrderMap = (71+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0072+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1073+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2074+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3075+253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 4076+155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 5077+253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 6078+ 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 7079+191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,80+207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,81+223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,82+ 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,83+ 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,84+ 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,85+ 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,86+239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255,87+)88+89+macCyrillic_CharToOrderMap = (90+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0091+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1092+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2093+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3094+253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 4095+155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 5096+253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 6097+ 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 7098+ 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,99+ 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,100+191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,101+207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,102+223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,103+239,240,241,242,243,244,245,246,247,248,249,250,251,252, 68, 16,104+ 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,105+ 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27,255,106+)107+108+IBM855_CharToOrderMap = (109+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00110+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10111+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20112+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30113+253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40114+155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50115+253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60116+ 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70117+191,192,193,194, 68,195,196,197,198,199,200,201,202,203,204,205,118+206,207,208,209,210,211,212,213,214,215,216,217, 27, 59, 54, 70,119+ 3, 37, 21, 44, 28, 58, 13, 41, 2, 48, 39, 53, 19, 46,218,219,120+220,221,222,223,224, 26, 55, 4, 42,225,226,227,228, 23, 60,229,121+230,231,232,233,234,235, 11, 36,236,237,238,239,240,241,242,243,122+ 8, 49, 12, 38, 5, 31, 1, 34, 15,244,245,246,247, 35, 16,248,123+ 43, 9, 45, 7, 32, 6, 40, 14, 52, 24, 56, 10, 33, 17, 61,249,124+250, 18, 62, 20, 51, 25, 57, 30, 47, 29, 63, 22, 50,251,252,255,125+)126+127+IBM866_CharToOrderMap = (128+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00129+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10130+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20131+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30132+253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40133+155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50134+253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60135+ 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70136+ 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,137+ 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,138+ 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,139+191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,140+207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,141+223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,142+ 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,143+239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255,144+)145+146+# Model Table:147+# total sequences: 100%148+# first 512 sequences: 97.6601%149+# first 1024 sequences: 2.3389%150+# rest sequences: 0.1237%151+# negative sequences: 0.0009%152+RussianLangModel = (153+0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,1,3,3,3,2,3,2,3,3,154+3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,3,2,2,2,2,2,0,0,2,155+3,3,3,2,3,3,3,3,3,3,3,3,3,3,2,3,3,0,0,3,3,3,3,3,3,3,3,3,2,3,2,0,156+0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,157+3,3,3,2,2,3,3,3,3,3,3,3,3,3,2,3,3,0,0,3,3,3,3,3,3,3,3,2,3,3,1,0,158+0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,159+3,2,3,2,3,3,3,3,3,3,3,3,3,3,3,3,3,0,0,3,3,3,3,3,3,3,3,3,3,3,2,1,160+0,0,0,0,0,0,0,2,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,161+3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,0,0,3,3,3,3,3,3,3,3,3,3,3,2,1,162+0,0,0,0,0,1,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,163+3,3,3,3,3,3,3,3,2,2,2,3,1,3,3,1,3,3,3,3,2,2,3,0,2,2,2,3,3,2,1,0,164+0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,165+3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,0,0,0,0,0,0,0,0,0,0,1,274+1,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,275+2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,276+1,1,1,0,1,0,1,0,0,1,1,1,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,277+1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,278+1,1,0,1,1,0,1,0,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,0,279+0,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,280+0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,281+)282+283+Koi8rModel = {284+ 'charToOrderMap': KOI8R_CharToOrderMap,285+ 'precedenceMatrix': RussianLangModel,286+ 'mTypicalPositiveRatio': 0.976601,287+ 'keepEnglishLetter': False,288+ 'charsetName': "KOI8-R"289+}290+291+Win1251CyrillicModel = {292+ 'charToOrderMap': win1251_CharToOrderMap,293+ 'precedenceMatrix': RussianLangModel,294+ 'mTypicalPositiveRatio': 0.976601,295+ 'keepEnglishLetter': False,296+ 'charsetName': "windows-1251"297+}298+299+Latin5CyrillicModel = {300+ 'charToOrderMap': latin5_CharToOrderMap,301+ 'precedenceMatrix': RussianLangModel,302+ 'mTypicalPositiveRatio': 0.976601,303+ 'keepEnglishLetter': False,304+ 'charsetName': "ISO-8859-5"305+}306+307+MacCyrillicModel = {308+ 'charToOrderMap': macCyrillic_CharToOrderMap,309+ 'precedenceMatrix': RussianLangModel,310+ 'mTypicalPositiveRatio': 0.976601,311+ 'keepEnglishLetter': False,312+ 'charsetName': "MacCyrillic"313+};314+315+Ibm866Model = {316+ 'charToOrderMap': IBM866_CharToOrderMap,317+ 'precedenceMatrix': RussianLangModel,318+ 'mTypicalPositiveRatio': 0.976601,319+ 'keepEnglishLetter': False,320+ 'charsetName': "IBM866"321+}322+323+Ibm855Model = {324+ 'charToOrderMap': IBM855_CharToOrderMap,325+ 'precedenceMatrix': RussianLangModel,326+ 'mTypicalPositiveRatio': 0.976601,327+ 'keepEnglishLetter': False,328+ 'charsetName': "IBM855"329+}330+331+# flake8: noqamodified:requests/packages/charade/langgreekmodel.py+227 added-225 removed
1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Communicator client code.1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Communicator client code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-# 22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-# 255: Control characters that usually does not exist in any text29-# 254: Carriage/Return30-# 253: symbol (punctuation) that does not belong to word31-# 252: 0 - 932-33-# Character Mapping Table:34-Latin7_CharToOrderMap = (35-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0036-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1037-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2038-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3039-253, 82,100,104, 94, 98,101,116,102,111,187,117, 92, 88,113, 85, # 4040- 79,118,105, 83, 67,114,119, 95, 99,109,188,253,253,253,253,253, # 5041-253, 72, 70, 80, 81, 60, 96, 93, 89, 68,120, 97, 77, 86, 69, 55, # 6042- 78,115, 65, 66, 58, 76,106,103, 87,107,112,253,253,253,253,253, # 7043-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 8044-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 9045-253,233, 90,253,253,253,253,253,253,253,253,253,253, 74,253,253, # a046-253,253,253,253,247,248, 61, 36, 46, 71, 73,253, 54,253,108,123, # b047-110, 31, 51, 43, 41, 34, 91, 40, 52, 47, 44, 53, 38, 49, 59, 39, # c048- 35, 48,250, 37, 33, 45, 56, 50, 84, 57,120,121, 17, 18, 22, 15, # d049-124, 1, 29, 20, 21, 3, 32, 13, 25, 5, 11, 16, 10, 6, 30, 4, # e050- 9, 8, 14, 7, 2, 12, 28, 23, 42, 24, 64, 75, 19, 26, 27,253, # f051-)52-53-win1253_CharToOrderMap = (54-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0055-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1056-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2057-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3058-253, 82,100,104, 94, 98,101,116,102,111,187,117, 92, 88,113, 85, # 4059- 79,118,105, 83, 67,114,119, 95, 99,109,188,253,253,253,253,253, # 5060-253, 72, 70, 80, 81, 60, 96, 93, 89, 68,120, 97, 77, 86, 69, 55, # 6061- 78,115, 65, 66, 58, 76,106,103, 87,107,112,253,253,253,253,253, # 7062-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 8063-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 9064-253,233, 61,253,253,253,253,253,253,253,253,253,253, 74,253,253, # a065-253,253,253,253,247,253,253, 36, 46, 71, 73,253, 54,253,108,123, # b066-110, 31, 51, 43, 41, 34, 91, 40, 52, 47, 44, 53, 38, 49, 59, 39, # c067- 35, 48,250, 37, 33, 45, 56, 50, 84, 57,120,121, 17, 18, 22, 15, # d068-124, 1, 29, 20, 21, 3, 32, 13, 25, 5, 11, 16, 10, 6, 30, 4, # e069- 9, 8, 14, 7, 2, 12, 28, 23, 42, 24, 64, 75, 19, 26, 27,253, # f070-)71-72-# Model Table: 73-# total sequences: 100%74-# first 512 sequences: 98.2851%75-# first 1024 sequences:1.7001%76-# rest sequences: 0.0359%77-# negative sequences: 0.0148% 78-GreekLangModel = (79-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,80-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,81-0,0,3,2,2,3,3,3,3,3,3,3,3,1,3,3,3,0,2,2,3,3,0,3,0,3,2,0,3,3,3,0,82-3,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,83-0,3,3,3,3,3,0,3,3,0,3,2,3,3,0,3,2,3,3,3,0,0,3,0,3,0,3,3,2,0,0,0,84-2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,85-0,2,3,2,2,3,3,3,3,3,3,3,3,0,3,3,3,3,0,2,3,3,0,3,3,3,3,2,3,3,3,0,86-2,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,87-0,2,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,0,2,1,3,3,3,3,2,3,3,2,3,3,2,0,88-0,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,89-0,3,3,3,3,0,3,3,3,3,3,3,0,3,3,0,3,3,3,3,3,3,3,3,3,3,0,3,2,3,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,199-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,200-0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,2,0,2,0,0,0,201-0,0,0,0,0,0,0,0,2,1,0,0,0,0,0,0,2,0,0,0,1,2,0,0,0,0,0,0,0,0,0,0,202-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,203-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,204-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,205-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,206-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,207-)208-209-Latin7GreekModel = {210- 'charToOrderMap': Latin7_CharToOrderMap,211- 'precedenceMatrix': GreekLangModel,212- 'mTypicalPositiveRatio': 0.982851,213- 'keepEnglishLetter': False,214- 'charsetName': "ISO-8859-7"215-}216-217-Win1253GreekModel = {218- 'charToOrderMap': win1253_CharToOrderMap,219- 'precedenceMatrix': GreekLangModel,220- 'mTypicalPositiveRatio': 0.982851,221- 'keepEnglishLetter': False,222- 'charsetName': "windows-1253"223-}224-225-# flake8: noqa3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+#22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+from . import constants29+30+# 255: Control characters that usually does not exist in any text31+# 254: Carriage/Return32+# 253: symbol (punctuation) that does not belong to word33+# 252: 0 - 934+35+# Character Mapping Table:36+Latin7_CharToOrderMap = (37+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0038+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1039+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2040+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3041+253, 82,100,104, 94, 98,101,116,102,111,187,117, 92, 88,113, 85, # 4042+ 79,118,105, 83, 67,114,119, 95, 99,109,188,253,253,253,253,253, # 5043+253, 72, 70, 80, 81, 60, 96, 93, 89, 68,120, 97, 77, 86, 69, 55, # 6044+ 78,115, 65, 66, 58, 76,106,103, 87,107,112,253,253,253,253,253, # 7045+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 8046+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 9047+253,233, 90,253,253,253,253,253,253,253,253,253,253, 74,253,253, # a048+253,253,253,253,247,248, 61, 36, 46, 71, 73,253, 54,253,108,123, # b049+110, 31, 51, 43, 41, 34, 91, 40, 52, 47, 44, 53, 38, 49, 59, 39, # c050+ 35, 48,250, 37, 33, 45, 56, 50, 84, 57,120,121, 17, 18, 22, 15, # d051+124, 1, 29, 20, 21, 3, 32, 13, 25, 5, 11, 16, 10, 6, 30, 4, # e052+ 9, 8, 14, 7, 2, 12, 28, 23, 42, 24, 64, 75, 19, 26, 27,253, # f053+)54+55+win1253_CharToOrderMap = (56+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0057+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1058+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2059+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3060+253, 82,100,104, 94, 98,101,116,102,111,187,117, 92, 88,113, 85, # 4061+ 79,118,105, 83, 67,114,119, 95, 99,109,188,253,253,253,253,253, # 5062+253, 72, 70, 80, 81, 60, 96, 93, 89, 68,120, 97, 77, 86, 69, 55, # 6063+ 78,115, 65, 66, 58, 76,106,103, 87,107,112,253,253,253,253,253, # 7064+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 8065+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 9066+253,233, 61,253,253,253,253,253,253,253,253,253,253, 74,253,253, # a067+253,253,253,253,247,253,253, 36, 46, 71, 73,253, 54,253,108,123, # b068+110, 31, 51, 43, 41, 34, 91, 40, 52, 47, 44, 53, 38, 49, 59, 39, # c069+ 35, 48,250, 37, 33, 45, 56, 50, 84, 57,120,121, 17, 18, 22, 15, # d070+124, 1, 29, 20, 21, 3, 32, 13, 25, 5, 11, 16, 10, 6, 30, 4, # e071+ 9, 8, 14, 7, 2, 12, 28, 23, 42, 24, 64, 75, 19, 26, 27,253, # f072+)73+74+# Model Table:75+# total sequences: 100%76+# first 512 sequences: 98.2851%77+# first 1024 sequences:1.7001%78+# rest sequences: 0.0359%79+# negative sequences: 0.0148%80+GreekLangModel = (81+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,82+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,83+0,0,3,2,2,3,3,3,3,3,3,3,3,1,3,3,3,0,2,2,3,3,0,3,0,3,2,0,3,3,3,0,84+3,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,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0,0,0,0,0,0,0,209+)210+211+Latin7GreekModel = {212+ 'charToOrderMap': Latin7_CharToOrderMap,213+ 'precedenceMatrix': GreekLangModel,214+ 'mTypicalPositiveRatio': 0.982851,215+ 'keepEnglishLetter': False,216+ 'charsetName': "ISO-8859-7"217+}218+219+Win1253GreekModel = {220+ 'charToOrderMap': win1253_CharToOrderMap,221+ 'precedenceMatrix': GreekLangModel,222+ 'mTypicalPositiveRatio': 0.982851,223+ 'keepEnglishLetter': False,224+ 'charsetName': "windows-1253"225+}226+227+# flake8: noqamodified:requests/packages/charade/langhebrewmodel.py+203 added-201 removed
1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Universal charset detector code.1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Universal charset detector code.3-#4-# The Initial Developer of the Original Code is5-# Simon Montagu6-# Portions created by the Initial Developer are Copyright (C) 20057-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-# Shy Shalom - original C code12-# Shoshannah Forbes - original C code (?)13-#14-# This library is free software; you can redistribute it and/or15-# modify it under the terms of the GNU Lesser General Public16-# License as published by the Free Software Foundation; either17-# 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 of21-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU22-# Lesser General Public License for more details.23-# 24-# You should have received a copy of the GNU Lesser General Public25-# License along with this library; if not, write to the Free Software26-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA27-# 02110-1301 USA28-######################### END LICENSE BLOCK #########################29-30-# 255: Control characters that usually does not exist in any text31-# 254: Carriage/Return32-# 253: symbol (punctuation) that does not belong to word33-# 252: 0 - 934-35-# Windows-1255 language model36-# Character Mapping Table:37-win1255_CharToOrderMap = (38-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0039-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1040-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2041-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3042-253, 69, 91, 79, 80, 92, 89, 97, 90, 68,111,112, 82, 73, 95, 85, # 4043- 78,121, 86, 71, 67,102,107, 84,114,103,115,253,253,253,253,253, # 5044-253, 50, 74, 60, 61, 42, 76, 70, 64, 53,105, 93, 56, 65, 54, 49, # 6045- 66,110, 51, 43, 44, 63, 81, 77, 98, 75,108,253,253,253,253,253, # 7046-124,202,203,204,205, 40, 58,206,207,208,209,210,211,212,213,214,47-215, 83, 52, 47, 46, 72, 32, 94,216,113,217,109,218,219,220,221,48- 34,116,222,118,100,223,224,117,119,104,125,225,226, 87, 99,227,49-106,122,123,228, 55,229,230,101,231,232,120,233, 48, 39, 57,234,50- 30, 59, 41, 88, 33, 37, 36, 31, 29, 35,235, 62, 28,236,126,237,51-238, 38, 45,239,240,241,242,243,127,244,245,246,247,248,249,250,52- 9, 8, 20, 16, 3, 2, 24, 14, 22, 1, 25, 15, 4, 11, 6, 23,53- 12, 19, 13, 26, 18, 27, 21, 17, 7, 10, 5,251,252,128, 96,253,54-)55-56-# Model Table: 57-# total sequences: 100%58-# first 512 sequences: 98.4004%59-# first 1024 sequences: 1.5981%60-# rest sequences: 0.087%61-# negative sequences: 0.0015% 62-HebrewLangModel = (63-0,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,2,3,2,1,2,0,1,0,0,64-3,0,3,1,0,0,1,3,2,0,1,1,2,0,2,2,2,1,1,1,1,2,1,1,1,2,0,0,2,2,0,1,65-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,66-1,2,1,2,1,2,0,0,2,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,67-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3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Model,196- 'mTypicalPositiveRatio': 0.984004,197- 'keepEnglishLetter': False,198- 'charsetName': "windows-1255"199-}200-201-# flake8: noqa3+#4+# The Initial Developer of the Original Code is5+# Simon Montagu6+# Portions created by the Initial Developer are Copyright (C) 20057+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+# Shy Shalom - original C code12+# Shoshannah Forbes - original C code (?)13+#14+# This library is free software; you can redistribute it and/or15+# modify it under the terms of the GNU Lesser General Public16+# License as published by the Free Software Foundation; either17+# 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 of21+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU22+# Lesser General Public License for more details.23+#24+# You should have received a copy of the GNU Lesser General Public25+# License along with this library; if not, write to the Free Software26+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA27+# 02110-1301 USA28+######################### END LICENSE BLOCK #########################29+30+from . import constants31+32+# 255: Control characters that usually does not exist in any text33+# 254: Carriage/Return34+# 253: symbol (punctuation) that does not belong to word35+# 252: 0 - 936+37+# Windows-1255 language model38+# Character Mapping Table:39+win1255_CharToOrderMap = (40+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0041+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1042+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2043+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3044+253, 69, 91, 79, 80, 92, 89, 97, 90, 68,111,112, 82, 73, 95, 85, # 4045+ 78,121, 86, 71, 67,102,107, 84,114,103,115,253,253,253,253,253, # 5046+253, 50, 74, 60, 61, 42, 76, 70, 64, 53,105, 93, 56, 65, 54, 49, # 6047+ 66,110, 51, 43, 44, 63, 81, 77, 98, 75,108,253,253,253,253,253, # 7048+124,202,203,204,205, 40, 58,206,207,208,209,210,211,212,213,214,49+215, 83, 52, 47, 46, 72, 32, 94,216,113,217,109,218,219,220,221,50+ 34,116,222,118,100,223,224,117,119,104,125,225,226, 87, 99,227,51+106,122,123,228, 55,229,230,101,231,232,120,233, 48, 39, 57,234,52+ 30, 59, 41, 88, 33, 37, 36, 31, 29, 35,235, 62, 28,236,126,237,53+238, 38, 45,239,240,241,242,243,127,244,245,246,247,248,249,250,54+ 9, 8, 20, 16, 3, 2, 24, 14, 22, 1, 25, 15, 4, 11, 6, 23,55+ 12, 19, 13, 26, 18, 27, 21, 17, 7, 10, 5,251,252,128, 96,253,56+)57+58+# Model Table:59+# total sequences: 100%60+# first 512 sequences: 98.4004%61+# first 1024 sequences: 1.5981%62+# rest sequences: 0.087%63+# negative sequences: 0.0015%64+HebrewLangModel = (65+0,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,2,3,2,1,2,0,1,0,0,66+3,0,3,1,0,0,1,3,2,0,1,1,2,0,2,2,2,1,1,1,1,2,1,1,1,2,0,0,2,2,0,1,67+3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,68+1,2,1,2,1,2,0,0,2,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,69+3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,70+1,2,1,3,1,1,0,0,2,0,0,0,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,71+3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,0,1,2,2,1,3,72+1,2,1,1,2,2,0,0,2,2,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,1,0,1,1,0,73+3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,2,2,2,2,3,2,74+1,2,1,2,2,2,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,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0,1,0,1,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,184+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185+1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,186+0,0,0,0,0,0,0,0,1,0,1,1,2,0,1,0,0,1,1,1,0,1,0,0,1,0,0,0,1,0,0,1,187+1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188+1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,0,2,1,1,1,1,1,0,1,0,0,0,0,1,0,1,189+0,1,1,1,2,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,0,0,0,0,0,0,190+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,191+1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192+0,0,0,0,0,0,0,0,0,0,1,2,1,0,0,0,0,0,1,1,1,1,1,0,1,0,0,0,1,1,0,0,193+)194+195+Win1255HebrewModel = {196+ 'charToOrderMap': win1255_CharToOrderMap,197+ 'precedenceMatrix': HebrewLangModel,198+ 'mTypicalPositiveRatio': 0.984004,199+ 'keepEnglishLetter': False,200+ 'charsetName': "windows-1255"201+}202+203+# flake8: noqamodified:requests/packages/charade/langhungarianmodel.py+227 added-225 removed
1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Communicator client code.1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Communicator client code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-# 22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-# 255: Control characters that usually does not exist in any text29-# 254: Carriage/Return30-# 253: symbol (punctuation) that does not belong to word31-# 252: 0 - 932-33-# Character Mapping Table:34-Latin2_HungarianCharToOrderMap = (35-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0036-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1037-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2038-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3039-253, 28, 40, 54, 45, 32, 50, 49, 38, 39, 53, 36, 41, 34, 35, 47,40- 46, 71, 43, 33, 37, 57, 48, 64, 68, 55, 52,253,253,253,253,253,41-253, 2, 18, 26, 17, 1, 27, 12, 20, 9, 22, 7, 6, 13, 4, 8,42- 23, 67, 10, 5, 3, 21, 19, 65, 62, 16, 11,253,253,253,253,253,43-159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,44-175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,45-191,192,193,194,195,196,197, 75,198,199,200,201,202,203,204,205,46- 79,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,47-221, 51, 81,222, 78,223,224,225,226, 44,227,228,229, 61,230,231,48-232,233,234, 58,235, 66, 59,236,237,238, 60, 69, 63,239,240,241,49- 82, 14, 74,242, 70, 80,243, 72,244, 15, 83, 77, 84, 30, 76, 85,50-245,246,247, 25, 73, 42, 24,248,249,250, 31, 56, 29,251,252,253,51-)52-53-win1250HungarianCharToOrderMap = (54-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0055-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1056-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2057-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3058-253, 28, 40, 54, 45, 32, 50, 49, 38, 39, 53, 36, 41, 34, 35, 47,59- 46, 72, 43, 33, 37, 57, 48, 64, 68, 55, 52,253,253,253,253,253,60-253, 2, 18, 26, 17, 1, 27, 12, 20, 9, 22, 7, 6, 13, 4, 8,61- 23, 67, 10, 5, 3, 21, 19, 65, 62, 16, 11,253,253,253,253,253,62-161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,63-177,178,179,180, 78,181, 69,182,183,184,185,186,187,188,189,190,64-191,192,193,194,195,196,197, 76,198,199,200,201,202,203,204,205,65- 81,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,66-221, 51, 83,222, 80,223,224,225,226, 44,227,228,229, 61,230,231,67-232,233,234, 58,235, 66, 59,236,237,238, 60, 70, 63,239,240,241,68- 84, 14, 75,242, 71, 82,243, 73,244, 15, 85, 79, 86, 30, 77, 87,69-245,246,247, 25, 74, 42, 24,248,249,250, 31, 56, 29,251,252,253,70-)71-72-# Model Table: 73-# total sequences: 100%74-# first 512 sequences: 94.7368%75-# first 1024 sequences:5.2623%76-# rest sequences: 0.8894%77-# negative sequences: 0.0009% 78-HungarianLangModel = (79-0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,80-3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,2,2,3,3,1,1,2,2,2,2,2,1,2,81-3,2,2,3,3,3,3,3,2,3,3,3,3,3,3,1,2,3,3,3,3,2,3,3,1,1,3,3,0,1,1,1,82-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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0,0,0,0,0,0,0,207-)208-209-Latin2HungarianModel = {210- 'charToOrderMap': Latin2_HungarianCharToOrderMap,211- 'precedenceMatrix': HungarianLangModel,212- 'mTypicalPositiveRatio': 0.947368,213- 'keepEnglishLetter': True,214- 'charsetName': "ISO-8859-2"215-}216-217-Win1250HungarianModel = {218- 'charToOrderMap': win1250HungarianCharToOrderMap,219- 'precedenceMatrix': HungarianLangModel,220- 'mTypicalPositiveRatio': 0.947368,221- 'keepEnglishLetter': True,222- 'charsetName': "windows-1250"223-}224-225-# flake8: noqa3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+#22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+from . import constants29+30+# 255: Control characters that usually does not exist in any text31+# 254: Carriage/Return32+# 253: symbol (punctuation) that does not belong to word33+# 252: 0 - 934+35+# Character Mapping Table:36+Latin2_HungarianCharToOrderMap = (37+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0038+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1039+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2040+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3041+253, 28, 40, 54, 45, 32, 50, 49, 38, 39, 53, 36, 41, 34, 35, 47,42+ 46, 71, 43, 33, 37, 57, 48, 64, 68, 55, 52,253,253,253,253,253,43+253, 2, 18, 26, 17, 1, 27, 12, 20, 9, 22, 7, 6, 13, 4, 8,44+ 23, 67, 10, 5, 3, 21, 19, 65, 62, 16, 11,253,253,253,253,253,45+159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,46+175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,47+191,192,193,194,195,196,197, 75,198,199,200,201,202,203,204,205,48+ 79,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,49+221, 51, 81,222, 78,223,224,225,226, 44,227,228,229, 61,230,231,50+232,233,234, 58,235, 66, 59,236,237,238, 60, 69, 63,239,240,241,51+ 82, 14, 74,242, 70, 80,243, 72,244, 15, 83, 77, 84, 30, 76, 85,52+245,246,247, 25, 73, 42, 24,248,249,250, 31, 56, 29,251,252,253,53+)54+55+win1250HungarianCharToOrderMap = (56+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0057+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1058+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2059+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3060+253, 28, 40, 54, 45, 32, 50, 49, 38, 39, 53, 36, 41, 34, 35, 47,61+ 46, 72, 43, 33, 37, 57, 48, 64, 68, 55, 52,253,253,253,253,253,62+253, 2, 18, 26, 17, 1, 27, 12, 20, 9, 22, 7, 6, 13, 4, 8,63+ 23, 67, 10, 5, 3, 21, 19, 65, 62, 16, 11,253,253,253,253,253,64+161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,65+177,178,179,180, 78,181, 69,182,183,184,185,186,187,188,189,190,66+191,192,193,194,195,196,197, 76,198,199,200,201,202,203,204,205,67+ 81,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,68+221, 51, 83,222, 80,223,224,225,226, 44,227,228,229, 61,230,231,69+232,233,234, 58,235, 66, 59,236,237,238, 60, 70, 63,239,240,241,70+ 84, 14, 75,242, 71, 82,243, 73,244, 15, 85, 79, 86, 30, 77, 87,71+245,246,247, 25, 74, 42, 24,248,249,250, 31, 56, 29,251,252,253,72+)73+74+# Model Table:75+# total sequences: 100%76+# first 512 sequences: 94.7368%77+# first 1024 sequences:5.2623%78+# rest sequences: 0.8894%79+# negative sequences: 0.0009%80+HungarianLangModel = (81+0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,82+3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,2,2,3,3,1,1,2,2,2,2,2,1,2,83+3,2,2,3,3,3,3,3,2,3,3,3,3,3,3,1,2,3,3,3,3,2,3,3,1,1,3,3,0,1,1,1,84+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,85+3,2,1,3,3,3,3,3,2,3,3,3,3,3,1,1,2,3,3,3,3,3,3,3,1,1,3,2,0,1,1,1,86+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,87+3,3,3,3,3,3,3,3,3,3,3,1,1,2,3,3,3,1,3,3,3,3,3,1,3,3,2,2,0,3,2,3,88+0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,89+3,3,3,3,3,3,2,3,3,3,2,3,3,2,3,3,3,3,3,2,3,3,2,2,3,2,3,2,0,3,2,2,90+0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,91+3,3,3,3,3,3,2,3,3,3,3,3,2,3,3,3,1,2,3,2,2,3,1,2,3,3,2,2,0,3,3,3,92+0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,93+3,3,3,3,3,3,3,3,3,3,2,2,3,3,3,3,3,3,2,3,3,3,3,2,3,3,3,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0,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,203+0,0,0,1,0,0,0,0,0,0,1,1,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,204+0,1,1,1,0,1,0,0,1,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,205+2,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,206+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,207+1,0,0,1,1,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,208+0,1,1,1,1,1,1,0,1,1,0,1,0,1,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,209+)210+211+Latin2HungarianModel = {212+ 'charToOrderMap': Latin2_HungarianCharToOrderMap,213+ 'precedenceMatrix': HungarianLangModel,214+ 'mTypicalPositiveRatio': 0.947368,215+ 'keepEnglishLetter': True,216+ 'charsetName': "ISO-8859-2"217+}218+219+Win1250HungarianModel = {220+ 'charToOrderMap': win1250HungarianCharToOrderMap,221+ 'precedenceMatrix': HungarianLangModel,222+ 'mTypicalPositiveRatio': 0.947368,223+ 'keepEnglishLetter': True,224+ 'charsetName': "windows-1250"225+}226+227+# flake8: noqamodified:requests/packages/charade/langthaimodel.py+200 added-200 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Communicator client code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-# 22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-# 255: Control characters that usually does not exist in any text29-# 254: Carriage/Return30-# 253: symbol (punctuation) that does not belong to word31-# 252: 0 - 932-33-# The following result for thai was collected from a limited sample (1M). 34-35-# Character Mapping Table:36-TIS620CharToOrderMap = (37-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0038-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1039-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2040-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3041-253,182,106,107,100,183,184,185,101, 94,186,187,108,109,110,111, # 4042-188,189,190, 89, 95,112,113,191,192,193,194,253,253,253,253,253, # 5043-253, 64, 72, 73,114, 74,115,116,102, 81,201,117, 90,103, 78, 82, # 6044- 96,202, 91, 79, 84,104,105, 97, 98, 92,203,253,253,253,253,253, # 7045-209,210,211,212,213, 88,214,215,216,217,218,219,220,118,221,222,46-223,224, 99, 85, 83,225,226,227,228,229,230,231,232,233,234,235,47-236, 5, 30,237, 24,238, 75, 8, 26, 52, 34, 51,119, 47, 58, 57,48- 49, 53, 55, 43, 20, 19, 44, 14, 48, 3, 17, 25, 39, 62, 31, 54,49- 45, 9, 16, 2, 61, 15,239, 12, 42, 46, 18, 21, 76, 4, 66, 63,50- 22, 10, 1, 36, 23, 13, 40, 27, 32, 35, 86,240,241,242,243,244,51- 11, 28, 41, 29, 33,245, 50, 37, 6, 7, 67, 77, 38, 93,246,247,52- 68, 56, 59, 65, 69, 60, 70, 80, 71, 87,248,249,250,251,252,253,53-)54-55-# Model Table: 56-# total sequences: 100%57-# first 512 sequences: 92.6386%58-# first 1024 sequences:7.3177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2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,186-0,0,1,1,0,0,2,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,187-0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,188-2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,189-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,190-)191-192-TIS620ThaiModel = {193- 'charToOrderMap': TIS620CharToOrderMap,194- 'precedenceMatrix': ThaiLangModel,195- 'mTypicalPositiveRatio': 0.926386,196- 'keepEnglishLetter': False,197- 'charsetName': "TIS-620"198-}199-200-# flake8: noqa1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Communicator client code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+#22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+# 255: Control characters that usually does not exist in any text29+# 254: Carriage/Return30+# 253: symbol (punctuation) that does not belong to word31+# 252: 0 - 932+33+# The following result for thai was collected from a limited sample (1M).34+35+# Character Mapping Table:36+TIS620CharToOrderMap = (37+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0038+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1039+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2040+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3041+253,182,106,107,100,183,184,185,101, 94,186,187,108,109,110,111, # 4042+188,189,190, 89, 95,112,113,191,192,193,194,253,253,253,253,253, # 5043+253, 64, 72, 73,114, 74,115,116,102, 81,201,117, 90,103, 78, 82, # 6044+ 96,202, 91, 79, 84,104,105, 97, 98, 92,203,253,253,253,253,253, # 7045+209,210,211,212,213, 88,214,215,216,217,218,219,220,118,221,222,46+223,224, 99, 85, 83,225,226,227,228,229,230,231,232,233,234,235,47+236, 5, 30,237, 24,238, 75, 8, 26, 52, 34, 51,119, 47, 58, 57,48+ 49, 53, 55, 43, 20, 19, 44, 14, 48, 3, 17, 25, 39, 62, 31, 54,49+ 45, 9, 16, 2, 61, 15,239, 12, 42, 46, 18, 21, 76, 4, 66, 63,50+ 22, 10, 1, 36, 23, 13, 40, 27, 32, 35, 86,240,241,242,243,244,51+ 11, 28, 41, 29, 33,245, 50, 37, 6, 7, 67, 77, 38, 93,246,247,52+ 68, 56, 59, 65, 69, 60, 70, 80, 71, 87,248,249,250,251,252,253,53+)54+55+# Model Table:56+# total sequences: 100%57+# first 512 sequences: 92.6386%58+# first 1024 sequences:7.3177%59+# rest sequences: 1.0230%60+# negative sequences: 0.0436%61+ThaiLangModel = (62+0,1,3,3,3,3,0,0,3,3,0,3,3,0,3,3,3,3,3,3,3,3,0,0,3,3,3,0,3,3,3,3,63+0,3,3,0,0,0,1,3,0,3,3,2,3,3,0,1,2,3,3,3,3,0,2,0,2,0,0,3,2,1,2,2,64+3,0,3,3,2,3,0,0,3,3,0,3,3,0,3,3,3,3,3,3,3,3,3,0,3,2,3,0,2,2,2,3,65+0,2,3,0,0,0,0,1,0,1,2,3,1,1,3,2,2,0,1,1,0,0,1,0,0,0,0,0,0,0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191+192+TIS620ThaiModel = {193+ 'charToOrderMap': TIS620CharToOrderMap,194+ 'precedenceMatrix': ThaiLangModel,195+ 'mTypicalPositiveRatio': 0.926386,196+ 'keepEnglishLetter': False,197+ 'charsetName': "TIS-620"198+}199+200+# flake8: noqamodified:requests/packages/charade/latin1prober.py+139 added-142 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Universal charset detector code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 20017-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-# Shy Shalom - original C code12-#13-# This library is free software; you can redistribute it and/or14-# modify it under the terms of the GNU Lesser General Public15-# License as published by the Free Software Foundation; either16-# version 2.1 of the License, or (at your option) any later version.17-#18-# This library is distributed in the hope that it will be useful,19-# but WITHOUT ANY WARRANTY; without even the implied warranty of20-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21-# Lesser General Public License for more details.22-#23-# You should have received a copy of the GNU Lesser General Public24-# License along with this library; if not, write to the Free Software25-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26-# 02110-1301 USA27-######################### END LICENSE BLOCK #########################28-29-from .charsetprober import CharSetProber30-from .constants import eError, eNotMe31-from .compat import wrap_ord32-33-FREQ_CAT_NUM = 434-35-UDF = 0 # undefined36-OTH = 1 # other37-ASC = 2 # ascii capital letter38-ASS = 3 # ascii small letter39-ACV = 4 # accent capital vowel40-ACO = 5 # accent capital other41-ASV = 6 # accent small vowel42-ASO = 7 # accent small other43-CLASS_NUM = 8 # total classes44-45-Latin1_CharToClass = (46- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 00 - 0747- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 08 - 0F48- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 10 - 1749- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 18 - 1F50- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 20 - 2751- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 28 - 2F52- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 30 - 3753- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 38 - 3F54- OTH, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 40 - 4755- ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 48 - 4F56- ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 50 - 5757- ASC, ASC, ASC, OTH, OTH, OTH, OTH, OTH, # 58 - 5F58- OTH, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 60 - 6759- ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 68 - 6F60- ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 70 - 7761- ASS, ASS, ASS, OTH, OTH, OTH, OTH, OTH, # 78 - 7F62- OTH, UDF, OTH, ASO, OTH, OTH, OTH, OTH, # 80 - 8763- OTH, OTH, ACO, OTH, ACO, UDF, ACO, UDF, # 88 - 8F64- UDF, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 90 - 9765- OTH, OTH, ASO, OTH, ASO, UDF, ASO, ACO, # 98 - 9F66- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A0 - A767- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A8 - AF68- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B0 - B769- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B8 - BF70- ACV, ACV, ACV, ACV, ACV, ACV, ACO, ACO, # C0 - C771- ACV, ACV, ACV, ACV, ACV, ACV, ACV, ACV, # C8 - CF72- ACO, ACO, ACV, ACV, ACV, ACV, ACV, OTH, # D0 - D773- ACV, ACV, ACV, ACV, ACV, ACO, ACO, ACO, # D8 - DF74- ASV, ASV, ASV, ASV, ASV, ASV, ASO, ASO, # E0 - E775- ASV, ASV, ASV, ASV, ASV, ASV, ASV, ASV, # E8 - EF76- ASO, ASO, ASV, ASV, ASV, ASV, ASV, OTH, # F0 - F777- ASV, ASV, ASV, ASV, ASV, ASO, ASO, ASO, # F8 - FF78-)79-80-# 0 : illegal81-# 1 : very unlikely82-# 2 : normal83-# 3 : very likely84-Latin1ClassModel = (85- # UDF OTH ASC ASS ACV ACO ASV ASO86- 0, 0, 0, 0, 0, 0, 0, 0, # UDF87- 0, 3, 3, 3, 3, 3, 3, 3, # OTH88- 0, 3, 3, 3, 3, 3, 3, 3, # ASC89- 0, 3, 3, 3, 1, 1, 3, 3, # ASS90- 0, 3, 3, 3, 1, 2, 1, 2, # ACV91- 0, 3, 3, 3, 3, 3, 3, 3, # ACO92- 0, 3, 1, 3, 1, 1, 1, 3, # ASV93- 0, 3, 1, 3, 1, 1, 3, 3, # ASO94-)95-96-97-class Latin1Prober(CharSetProber):98- def __init__(self):99- CharSetProber.__init__(self)100- self.reset()101-102- def reset(self):103- self._mLastCharClass = OTH104- self._mFreqCounter = [0] * FREQ_CAT_NUM105- CharSetProber.reset(self)106-107- def get_charset_name(self):108- return "windows-1252"109-110- def feed(self, aBuf):111- aBuf = self.filter_with_english_letters(aBuf)112- for c in aBuf:113- try:114- charClass = Latin1_CharToClass[wrap_ord(c)]115- except IndexError:116- return eError117- freq = Latin1ClassModel[(self._mLastCharClass * CLASS_NUM)118- + charClass]119- if freq == 0:120- self._mState = eNotMe121- break122- self._mFreqCounter[freq] += 1123- self._mLastCharClass = charClass124-125- return self.get_state()126-127- def get_confidence(self):128- if self.get_state() == eNotMe:129- return 0.01130-131- total = sum(self._mFreqCounter)132- if total < 0.01:133- confidence = 0.0134- else:135- confidence = ((self._mFreqCounter[3] / total)136- - (self._mFreqCounter[1] * 20.0 / total))137- if confidence < 0.0:138- confidence = 0.0139- # lower the confidence of latin1 so that other more accurate detector140- # can take priority.141- confidence = confidence * 0.5142- return confidence1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Universal charset detector code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 20017+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+# Shy Shalom - original C code12+#13+# This library is free software; you can redistribute it and/or14+# modify it under the terms of the GNU Lesser General Public15+# License as published by the Free Software Foundation; either16+# version 2.1 of the License, or (at your option) any later version.17+#18+# This library is distributed in the hope that it will be useful,19+# but WITHOUT ANY WARRANTY; without even the implied warranty of20+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21+# Lesser General Public License for more details.22+#23+# You should have received a copy of the GNU Lesser General Public24+# License along with this library; if not, write to the Free Software25+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26+# 02110-1301 USA27+######################### END LICENSE BLOCK #########################28+29+from .charsetprober import CharSetProber30+from .constants import eNotMe31+from .compat import wrap_ord32+33+FREQ_CAT_NUM = 434+35+UDF = 0 # undefined36+OTH = 1 # other37+ASC = 2 # ascii capital letter38+ASS = 3 # ascii small letter39+ACV = 4 # accent capital vowel40+ACO = 5 # accent capital other41+ASV = 6 # accent small vowel42+ASO = 7 # accent small other43+CLASS_NUM = 8 # total classes44+45+Latin1_CharToClass = (46+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 00 - 0747+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 08 - 0F48+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 10 - 1749+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 18 - 1F50+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 20 - 2751+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 28 - 2F52+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 30 - 3753+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 38 - 3F54+ OTH, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 40 - 4755+ ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 48 - 4F56+ ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 50 - 5757+ ASC, ASC, ASC, OTH, OTH, OTH, OTH, OTH, # 58 - 5F58+ OTH, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 60 - 6759+ ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 68 - 6F60+ ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 70 - 7761+ ASS, ASS, ASS, OTH, OTH, OTH, OTH, OTH, # 78 - 7F62+ OTH, UDF, OTH, ASO, OTH, OTH, OTH, OTH, # 80 - 8763+ OTH, OTH, ACO, OTH, ACO, UDF, ACO, UDF, # 88 - 8F64+ UDF, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 90 - 9765+ OTH, OTH, ASO, OTH, ASO, UDF, ASO, ACO, # 98 - 9F66+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A0 - A767+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A8 - AF68+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B0 - B769+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B8 - BF70+ ACV, ACV, ACV, ACV, ACV, ACV, ACO, ACO, # C0 - C771+ ACV, ACV, ACV, ACV, ACV, ACV, ACV, ACV, # C8 - CF72+ ACO, ACO, ACV, ACV, ACV, ACV, ACV, OTH, # D0 - D773+ ACV, ACV, ACV, ACV, ACV, ACO, ACO, ACO, # D8 - DF74+ ASV, ASV, ASV, ASV, ASV, ASV, ASO, ASO, # E0 - E775+ ASV, ASV, ASV, ASV, ASV, ASV, ASV, ASV, # E8 - EF76+ ASO, ASO, ASV, ASV, ASV, ASV, ASV, OTH, # F0 - F777+ ASV, ASV, ASV, ASV, ASV, ASO, ASO, ASO, # F8 - FF78+)79+80+# 0 : illegal81+# 1 : very unlikely82+# 2 : normal83+# 3 : very likely84+Latin1ClassModel = (85+ # UDF OTH ASC ASS ACV ACO ASV ASO86+ 0, 0, 0, 0, 0, 0, 0, 0, # UDF87+ 0, 3, 3, 3, 3, 3, 3, 3, # OTH88+ 0, 3, 3, 3, 3, 3, 3, 3, # ASC89+ 0, 3, 3, 3, 1, 1, 3, 3, # ASS90+ 0, 3, 3, 3, 1, 2, 1, 2, # ACV91+ 0, 3, 3, 3, 3, 3, 3, 3, # ACO92+ 0, 3, 1, 3, 1, 1, 1, 3, # ASV93+ 0, 3, 1, 3, 1, 1, 3, 3, # ASO94+)95+96+97+class Latin1Prober(CharSetProber):98+ def __init__(self):99+ CharSetProber.__init__(self)100+ self.reset()101+102+ def reset(self):103+ self._mLastCharClass = OTH104+ self._mFreqCounter = [0] * FREQ_CAT_NUM105+ CharSetProber.reset(self)106+107+ def get_charset_name(self):108+ return "windows-1252"109+110+ def feed(self, aBuf):111+ aBuf = self.filter_with_english_letters(aBuf)112+ for c in aBuf:113+ charClass = Latin1_CharToClass[wrap_ord(c)]114+ freq = Latin1ClassModel[(self._mLastCharClass * CLASS_NUM)115+ + charClass]116+ if freq == 0:117+ self._mState = eNotMe118+ break119+ self._mFreqCounter[freq] += 1120+ self._mLastCharClass = charClass121+122+ return self.get_state()123+124+ def get_confidence(self):125+ if self.get_state() == eNotMe:126+ return 0.01127+128+ total = sum(self._mFreqCounter)129+ if total < 0.01:130+ confidence = 0.0131+ else:132+ confidence = ((self._mFreqCounter[3] / total)133+ - (self._mFreqCounter[1] * 20.0 / total))134+ if confidence < 0.0:135+ confidence = 0.0136+ # lower the confidence of latin1 so that other more accurate137+ # detector can take priority.138+ confidence = confidence * 0.5139+ return confidencemodified:requests/packages/charade/mbcharsetprober.py+86 added-86 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Universal charset detector code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 20017-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-# Shy Shalom - original C code12-# Proofpoint, Inc.13-#14-# This library is free software; you can redistribute it and/or15-# modify it under the terms of the GNU Lesser General Public16-# License as published by the Free Software Foundation; either17-# 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 of21-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU22-# Lesser General Public License for more details.23-#24-# You should have received a copy of the GNU Lesser General Public25-# License along with this library; if not, write to the Free Software26-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA27-# 02110-1301 USA28-######################### END LICENSE BLOCK #########################29-30-import sys31-from . import constants32-from .charsetprober import CharSetProber33-34-35-class MultiByteCharSetProber(CharSetProber):36- def __init__(self):37- CharSetProber.__init__(self)38- self._mDistributionAnalyzer = None39- self._mCodingSM = None40- self._mLastChar = ['\x00', '\x00']41-42- def reset(self):43- CharSetProber.reset(self)44- if self._mCodingSM:45- self._mCodingSM.reset()46- if self._mDistributionAnalyzer:47- self._mDistributionAnalyzer.reset()48- self._mLastChar = ['\x00', '\x00']49-50- def get_charset_name(self):51- pass52-53- def feed(self, aBuf):54- aLen = len(aBuf)55- for i in range(0, aLen):56- codingState = self._mCodingSM.next_state(aBuf[i])57- if codingState == constants.eError:58- if constants._debug:59- sys.stderr.write(self.get_charset_name() +60- ' prober hit error at byte ' + str(i) +61- '\n')62- self._mState = constants.eNotMe63- break64- elif codingState == constants.eItsMe:65- self._mState = constants.eFoundIt66- break67- elif codingState == constants.eStart:68- charLen = self._mCodingSM.get_current_charlen()69- if i == 0:70- self._mLastChar[1] = aBuf[0]71- self._mDistributionAnalyzer.feed(self._mLastChar, charLen)72- else:73- self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],74- charLen)75-76- self._mLastChar[0] = aBuf[aLen - 1]77-78- if self.get_state() == constants.eDetecting:79- if (self._mDistributionAnalyzer.got_enough_data() and80- (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):81- self._mState = constants.eFoundIt82-83- return self.get_state()84-85- def get_confidence(self):86- return self._mDistributionAnalyzer.get_confidence()1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Universal charset detector code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 20017+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+# Shy Shalom - original C code12+# Proofpoint, Inc.13+#14+# This library is free software; you can redistribute it and/or15+# modify it under the terms of the GNU Lesser General Public16+# License as published by the Free Software Foundation; either17+# 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 of21+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU22+# Lesser General Public License for more details.23+#24+# You should have received a copy of the GNU Lesser General Public25+# License along with this library; if not, write to the Free Software26+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA27+# 02110-1301 USA28+######################### END LICENSE BLOCK #########################29+30+import sys31+from . import constants32+from .charsetprober import CharSetProber33+34+35+class MultiByteCharSetProber(CharSetProber):36+ def __init__(self):37+ CharSetProber.__init__(self)38+ self._mDistributionAnalyzer = None39+ self._mCodingSM = None40+ self._mLastChar = [0, 0]41+42+ def reset(self):43+ CharSetProber.reset(self)44+ if self._mCodingSM:45+ self._mCodingSM.reset()46+ if self._mDistributionAnalyzer:47+ self._mDistributionAnalyzer.reset()48+ self._mLastChar = [0, 0]49+50+ def get_charset_name(self):51+ pass52+53+ def feed(self, aBuf):54+ aLen = len(aBuf)55+ for i in range(0, aLen):56+ codingState = self._mCodingSM.next_state(aBuf[i])57+ if codingState == constants.eError:58+ if constants._debug:59+ sys.stderr.write(self.get_charset_name()60+ + ' prober hit error at byte ' + str(i)61+ + '\n')62+ self._mState = constants.eNotMe63+ break64+ elif codingState == constants.eItsMe:65+ self._mState = constants.eFoundIt66+ break67+ elif codingState == constants.eStart:68+ charLen = self._mCodingSM.get_current_charlen()69+ if i == 0:70+ self._mLastChar[1] = aBuf[0]71+ self._mDistributionAnalyzer.feed(self._mLastChar, charLen)72+ else:73+ self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],74+ charLen)75+76+ self._mLastChar[0] = aBuf[aLen - 1]77+78+ if self.get_state() == constants.eDetecting:79+ if (self._mDistributionAnalyzer.got_enough_data() and80+ (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):81+ self._mState = constants.eFoundIt82+83+ return self.get_state()84+85+ def get_confidence(self):86+ return self._mDistributionAnalyzer.get_confidence()modified:requests/packages/charade/mbcsgroupprober.py+52 added-52 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Universal charset detector code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 20017-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-# Shy Shalom - original C code12-# Proofpoint, Inc.13-#14-# This library is free software; you can redistribute it and/or15-# modify it under the terms of the GNU Lesser General Public16-# License as published by the Free Software Foundation; either17-# 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 of21-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU22-# Lesser General Public License for more details.23-#24-# You should have received a copy of the GNU Lesser General Public25-# License along with this library; if not, write to the Free Software26-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA27-# 02110-1301 USA28-######################### END LICENSE BLOCK #########################29-30-from .charsetgroupprober import CharSetGroupProber31-from .utf8prober import UTF8Prober32-from .sjisprober import SJISProber33-from .eucjpprober import EUCJPProber34-from .gb2312prober import GB2312Prober35-from .euckrprober import EUCKRProber36-from .big5prober import Big5Prober37-from .euctwprober import EUCTWProber38-39-40-class MBCSGroupProber(CharSetGroupProber):41- def __init__(self):42- CharSetGroupProber.__init__(self)43- self._mProbers = [44- UTF8Prober(),45- SJISProber(),46- EUCJPProber(),47- GB2312Prober(),48- EUCKRProber(),49- Big5Prober(),50- EUCTWProber()51- ]52- self.reset()1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Universal charset detector code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 20017+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+# Shy Shalom - original C code12+# Proofpoint, Inc.13+#14+# This library is free software; you can redistribute it and/or15+# modify it under the terms of the GNU Lesser General Public16+# License as published by the Free Software Foundation; either17+# 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 of21+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU22+# Lesser General Public License for more details.23+#24+# You should have received a copy of the GNU Lesser General Public25+# License along with this library; if not, write to the Free Software26+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA27+# 02110-1301 USA28+######################### END LICENSE BLOCK #########################29+30+from .charsetgroupprober import CharSetGroupProber31+from .utf8prober import UTF8Prober32+from .sjisprober import SJISProber33+from .eucjpprober import EUCJPProber34+from .gb2312prober import GB2312Prober35+from .euckrprober import EUCKRProber36+from .big5prober import Big5Prober37+from .euctwprober import EUCTWProber38+39+40+class MBCSGroupProber(CharSetGroupProber):41+ def __init__(self):42+ CharSetGroupProber.__init__(self)43+ self._mProbers = [44+ UTF8Prober(),45+ SJISProber(),46+ EUCJPProber(),47+ GB2312Prober(),48+ EUCKRProber(),49+ Big5Prober(),50+ EUCTWProber()51+ ]52+ self.reset()modified:requests/packages/charade/mbcssm.py+535 added-529 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is mozilla.org code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-#22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-from .constants import eStart, eError, eItsMe29-30-# BIG531-32-BIG5_cls = (33- 1, 1, 1, 1, 1, 1, 1, 1, # 00 - 07 #allow 0x00 as legal value34- 1, 1, 1, 1, 1, 1, 0, 0, # 08 - 0f35- 1, 1, 1, 1, 1, 1, 1, 1, # 10 - 1736- 1, 1, 1, 0, 1, 1, 1, 1, # 18 - 1f37- 1, 1, 1, 1, 1, 1, 1, 1, # 20 - 2738- 1, 1, 1, 1, 1, 1, 1, 1, # 28 - 2f39- 1, 1, 1, 1, 1, 1, 1, 1, # 30 - 3740- 1, 1, 1, 1, 1, 1, 1, 1, # 38 - 3f41- 2, 2, 2, 2, 2, 2, 2, 2, # 40 - 4742- 2, 2, 2, 2, 2, 2, 2, 2, # 48 - 4f43- 2, 2, 2, 2, 2, 2, 2, 2, # 50 - 5744- 2, 2, 2, 2, 2, 2, 2, 2, # 58 - 5f45- 2, 2, 2, 2, 2, 2, 2, 2, # 60 - 6746- 2, 2, 2, 2, 2, 2, 2, 2, # 68 - 6f47- 2, 2, 2, 2, 2, 2, 2, 2, # 70 - 7748- 2, 2, 2, 2, 2, 2, 2, 1, # 78 - 7f49- 4, 4, 4, 4, 4, 4, 4, 4, # 80 - 8750- 4, 4, 4, 4, 4, 4, 4, 4, # 88 - 8f51- 4, 4, 4, 4, 4, 4, 4, 4, # 90 - 9752- 4, 4, 4, 4, 4, 4, 4, 4, # 98 - 9f53- 4, 3, 3, 3, 3, 3, 3, 3, # a0 - a754- 3, 3, 3, 3, 3, 3, 3, 3, # a8 - af55- 3, 3, 3, 3, 3, 3, 3, 3, # b0 - b756- 3, 3, 3, 3, 3, 3, 3, 3, # b8 - bf57- 3, 3, 3, 3, 3, 3, 3, 3, # c0 - c758- 3, 3, 3, 3, 3, 3, 3, 3, # c8 - cf59- 3, 3, 3, 3, 3, 3, 3, 3, # d0 - d760- 3, 3, 3, 3, 3, 3, 3, 3, # d8 - df61- 3, 3, 3, 3, 3, 3, 3, 3, # e0 - e762- 3, 3, 3, 3, 3, 3, 3, 3, # e8 - ef63- 3, 3, 3, 3, 3, 3, 3, 3, # f0 - f764- 3, 3, 3, 3, 3, 3, 3, 0) # f8 - ff65-66-BIG5_st = (67- eError, eStart, eStart, 3, eError, eError, eError, eError, # 00-0768- eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eError, # 08-0f69- eError, eStart, eStart, eStart, eStart, eStart, eStart, eStart, # 10-1770-)71-72-Big5CharLenTable = (0, 1, 1, 2, 0)73-74-Big5SMModel = {'classTable': BIG5_cls,75- 'classFactor': 5,76- 'stateTable': BIG5_st,77- 'charLenTable': Big5CharLenTable,78- 'name': 'Big5'}79-80-# EUC-JP81-82-EUCJP_cls = (83- 4, 4, 4, 4, 4, 4, 4, 4, # 00 - 0784- 4, 4, 4, 4, 4, 4, 5, 5, # 08 - 0f85- 4, 4, 4, 4, 4, 4, 4, 4, # 10 - 1786- 4, 4, 4, 5, 4, 4, 4, 4, # 18 - 1f87- 4, 4, 4, 4, 4, 4, 4, 4, # 20 - 2788- 4, 4, 4, 4, 4, 4, 4, 4, # 28 - 2f89- 4, 4, 4, 4, 4, 4, 4, 4, # 30 - 3790- 4, 4, 4, 4, 4, 4, 4, 4, # 38 - 3f91- 4, 4, 4, 4, 4, 4, 4, 4, # 40 - 4792- 4, 4, 4, 4, 4, 4, 4, 4, # 48 - 4f93- 4, 4, 4, 4, 4, 4, 4, 4, # 50 - 5794- 4, 4, 4, 4, 4, 4, 4, 4, # 58 - 5f95- 4, 4, 4, 4, 4, 4, 4, 4, # 60 - 6796- 4, 4, 4, 4, 4, 4, 4, 4, # 68 - 6f97- 4, 4, 4, 4, 4, 4, 4, 4, # 70 - 7798- 4, 4, 4, 4, 4, 4, 4, 4, # 78 - 7f99- 5, 5, 5, 5, 5, 5, 5, 5, # 80 - 87100- 5, 5, 5, 5, 5, 5, 1, 3, # 88 - 8f101- 5, 5, 5, 5, 5, 5, 5, 5, # 90 - 97102- 5, 5, 5, 5, 5, 5, 5, 5, # 98 - 9f103- 5, 2, 2, 2, 2, 2, 2, 2, # a0 - a7104- 2, 2, 2, 2, 2, 2, 2, 2, # a8 - af105- 2, 2, 2, 2, 2, 2, 2, 2, # b0 - b7106- 2, 2, 2, 2, 2, 2, 2, 2, # b8 - bf107- 2, 2, 2, 2, 2, 2, 2, 2, # c0 - c7108- 2, 2, 2, 2, 2, 2, 2, 2, # c8 - cf109- 2, 2, 2, 2, 2, 2, 2, 2, # d0 - d7110- 2, 2, 2, 2, 2, 2, 2, 2, # d8 - df111- 0, 0, 0, 0, 0, 0, 0, 0, # e0 - e7112- 0, 0, 0, 0, 0, 0, 0, 0, # e8 - ef113- 0, 0, 0, 0, 0, 0, 0, 0, # f0 - f7114- 0, 0, 0, 0, 0, 0, 0, 5) # f8 - ff115-116-EUCJP_st = (117- 3, 4, 3, 5, eStart, eError, eError, eError, # 00-07118- eError, eError, eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, # 08-0f119- eItsMe, eItsMe, eStart, eError, eStart, eError, eError, eError, # 10-17120- eError, eError, eStart, eError, eError, eError, 3, eError, # 18-1f121- 3, eError, eError, eError, eStart, eStart, eStart, eStart, # 20-27122-)123-124-EUCJPCharLenTable = (2, 2, 2, 3, 1, 0)125-126-EUCJPSMModel = {'classTable': EUCJP_cls,127- 'classFactor': 6,128- 'stateTable': EUCJP_st,129- 'charLenTable': EUCJPCharLenTable,130- 'name': 'EUC-JP'}131-132-# EUC-KR133-134-EUCKR_cls = (135- 1, 1, 1, 1, 1, 1, 1, 1, # 00 - 07136- 1, 1, 1, 1, 1, 1, 0, 0, # 08 - 0f137- 1, 1, 1, 1, 1, 1, 1, 1, # 10 - 17138- 1, 1, 1, 0, 1, 1, 1, 1, # 18 - 1f139- 1, 1, 1, 1, 1, 1, 1, 1, # 20 - 27140- 1, 1, 1, 1, 1, 1, 1, 1, # 28 - 2f141- 1, 1, 1, 1, 1, 1, 1, 1, # 30 - 37142- 1, 1, 1, 1, 1, 1, 1, 1, # 38 - 3f143- 1, 1, 1, 1, 1, 1, 1, 1, # 40 - 47144- 1, 1, 1, 1, 1, 1, 1, 1, # 48 - 4f145- 1, 1, 1, 1, 1, 1, 1, 1, # 50 - 57146- 1, 1, 1, 1, 1, 1, 1, 1, # 58 - 5f147- 1, 1, 1, 1, 1, 1, 1, 1, # 60 - 67148- 1, 1, 1, 1, 1, 1, 1, 1, # 68 - 6f149- 1, 1, 1, 1, 1, 1, 1, 1, # 70 - 77150- 1, 1, 1, 1, 1, 1, 1, 1, # 78 - 7f151- 0, 0, 0, 0, 0, 0, 0, 0, # 80 - 87152- 0, 0, 0, 0, 0, 0, 0, 0, # 88 - 8f153- 0, 0, 0, 0, 0, 0, 0, 0, # 90 - 97154- 0, 0, 0, 0, 0, 0, 0, 0, # 98 - 9f155- 0, 2, 2, 2, 2, 2, 2, 2, # a0 - a7156- 2, 2, 2, 2, 2, 3, 3, 3, # a8 - af157- 2, 2, 2, 2, 2, 2, 2, 2, # b0 - b7158- 2, 2, 2, 2, 2, 2, 2, 2, # b8 - bf159- 2, 2, 2, 2, 2, 2, 2, 2, # c0 - c7160- 2, 3, 2, 2, 2, 2, 2, 2, # c8 - cf161- 2, 2, 2, 2, 2, 2, 2, 2, # d0 - d7162- 2, 2, 2, 2, 2, 2, 2, 2, # d8 - df163- 2, 2, 2, 2, 2, 2, 2, 2, # e0 - e7164- 2, 2, 2, 2, 2, 2, 2, 2, # e8 - ef165- 2, 2, 2, 2, 2, 2, 2, 2, # f0 - f7166- 2, 2, 2, 2, 2, 2, 2, 0, # f8 - ff167-)168-169-EUCKR_st = (170- eError, eStart, 3, eError, eError, eError, eError, eError, # 00-07171- eItsMe, eItsMe, eItsMe, eItsMe, eError, eError, eStart, eStart, # 08-0f172-)173-174-EUCKRCharLenTable = (0, 1, 2, 0)175-176-EUCKRSMModel = {'classTable': EUCKR_cls,177- 'classFactor': 4,178- 'stateTable': EUCKR_st,179- 'charLenTable': EUCKRCharLenTable,180- 'name': 'EUC-KR'}181-182-# EUC-TW183-184-EUCTW_cls = (185- 2, 2, 2, 2, 2, 2, 2, 2, # 00 - 07186- 2, 2, 2, 2, 2, 2, 0, 0, # 08 - 0f187- 2, 2, 2, 2, 2, 2, 2, 2, # 10 - 17188- 2, 2, 2, 0, 2, 2, 2, 2, # 18 - 1f189- 2, 2, 2, 2, 2, 2, 2, 2, # 20 - 27190- 2, 2, 2, 2, 2, 2, 2, 2, # 28 - 2f191- 2, 2, 2, 2, 2, 2, 2, 2, # 30 - 37192- 2, 2, 2, 2, 2, 2, 2, 2, # 38 - 3f193- 2, 2, 2, 2, 2, 2, 2, 2, # 40 - 47194- 2, 2, 2, 2, 2, 2, 2, 2, # 48 - 4f195- 2, 2, 2, 2, 2, 2, 2, 2, # 50 - 57196- 2, 2, 2, 2, 2, 2, 2, 2, # 58 - 5f197- 2, 2, 2, 2, 2, 2, 2, 2, # 60 - 67198- 2, 2, 2, 2, 2, 2, 2, 2, # 68 - 6f199- 2, 2, 2, 2, 2, 2, 2, 2, # 70 - 77200- 2, 2, 2, 2, 2, 2, 2, 2, # 78 - 7f201- 0, 0, 0, 0, 0, 0, 0, 0, # 80 - 87202- 0, 0, 0, 0, 0, 0, 6, 0, # 88 - 8f203- 0, 0, 0, 0, 0, 0, 0, 0, # 90 - 97204- 0, 0, 0, 0, 0, 0, 0, 0, # 98 - 9f205- 0, 3, 4, 4, 4, 4, 4, 4, # a0 - a7206- 5, 5, 1, 1, 1, 1, 1, 1, # a8 - af207- 1, 1, 1, 1, 1, 1, 1, 1, # b0 - b7208- 1, 1, 1, 1, 1, 1, 1, 1, # b8 - bf209- 1, 1, 3, 1, 3, 3, 3, 3, # c0 - c7210- 3, 3, 3, 3, 3, 3, 3, 3, # c8 - cf211- 3, 3, 3, 3, 3, 3, 3, 3, # d0 - d7212- 3, 3, 3, 3, 3, 3, 3, 3, # d8 - df213- 3, 3, 3, 3, 3, 3, 3, 3, # e0 - e7214- 3, 3, 3, 3, 3, 3, 3, 3, # e8 - ef215- 3, 3, 3, 3, 3, 3, 3, 3, # f0 - f7216- 3, 3, 3, 3, 3, 3, 3, 0, # f8 - ff217-)218-219-EUCTW_st = (220- eError, eError, eStart, 3, 3, 3, 4, eError, # 00-07221- eError, eError, eError, eError, eError, eError, eItsMe, eItsMe, # 08-0f222- eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eError, eStart, eError, # 10-17223- eStart, eStart, eStart, eError, eError, eError, eError, eError, # 18-1f224- 5, eError, eError, eError, eStart, eError, eStart, eStart, # 20-27225- eStart, eError, eStart, eStart, eStart, eStart, eStart, eStart, # 28-2f226-)227-228-EUCTWCharLenTable = (0, 0, 1, 2, 2, 2, 3)229-230-EUCTWSMModel = {'classTable': EUCTW_cls,231- 'classFactor': 7,232- 'stateTable': EUCTW_st,233- 'charLenTable': EUCTWCharLenTable,234- 'name': 'x-euc-tw'}235-236-# GB2312237-238-GB2312_cls = (239- 1, 1, 1, 1, 1, 1, 1, 1, # 00 - 07240- 1, 1, 1, 1, 1, 1, 0, 0, # 08 - 0f241- 1, 1, 1, 1, 1, 1, 1, 1, # 10 - 17242- 1, 1, 1, 0, 1, 1, 1, 1, # 18 - 1f243- 1, 1, 1, 1, 1, 1, 1, 1, # 20 - 27244- 1, 1, 1, 1, 1, 1, 1, 1, # 28 - 2f245- 3, 3, 3, 3, 3, 3, 3, 3, # 30 - 37246- 3, 3, 1, 1, 1, 1, 1, 1, # 38 - 3f247- 2, 2, 2, 2, 2, 2, 2, 2, # 40 - 47248- 2, 2, 2, 2, 2, 2, 2, 2, # 48 - 4f249- 2, 2, 2, 2, 2, 2, 2, 2, # 50 - 57250- 2, 2, 2, 2, 2, 2, 2, 2, # 58 - 5f251- 2, 2, 2, 2, 2, 2, 2, 2, # 60 - 67252- 2, 2, 2, 2, 2, 2, 2, 2, # 68 - 6f253- 2, 2, 2, 2, 2, 2, 2, 2, # 70 - 77254- 2, 2, 2, 2, 2, 2, 2, 4, # 78 - 7f255- 5, 6, 6, 6, 6, 6, 6, 6, # 80 - 87256- 6, 6, 6, 6, 6, 6, 6, 6, # 88 - 8f257- 6, 6, 6, 6, 6, 6, 6, 6, # 90 - 97258- 6, 6, 6, 6, 6, 6, 6, 6, # 98 - 9f259- 6, 6, 6, 6, 6, 6, 6, 6, # a0 - a7260- 6, 6, 6, 6, 6, 6, 6, 6, # a8 - af261- 6, 6, 6, 6, 6, 6, 6, 6, # b0 - b7262- 6, 6, 6, 6, 6, 6, 6, 6, # b8 - bf263- 6, 6, 6, 6, 6, 6, 6, 6, # c0 - c7264- 6, 6, 6, 6, 6, 6, 6, 6, # c8 - cf265- 6, 6, 6, 6, 6, 6, 6, 6, # d0 - d7266- 6, 6, 6, 6, 6, 6, 6, 6, # d8 - df267- 6, 6, 6, 6, 6, 6, 6, 6, # e0 - e7268- 6, 6, 6, 6, 6, 6, 6, 6, # e8 - ef269- 6, 6, 6, 6, 6, 6, 6, 6, # f0 - f7270- 6, 6, 6, 6, 6, 6, 6, 0, # f8 - ff271-)272-273-GB2312_st = (274- eError, eStart, eStart, eStart, eStart, eStart, 3, eError, # 00-07275- eError, eError, eError, eError, eError, eError, eItsMe, eItsMe, # 08-0f276- eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eError, eError, eStart, # 10-17277- 4, eError, eStart, eStart, eError, eError, eError, eError, # 18-1f278- eError, eError, 5, eError, eError, eError, eItsMe, eError, # 20-27279- eError, eError, eStart, eStart, eStart, eStart, eStart, eStart, # 28-2f280-)281-282-# To be accurate, the length of class 6 can be either 2 or 4.283-# But it is not necessary to discriminate between the two since284-# it is used for frequency analysis only, and we are validing285-# each code range there as well. So it is safe to set it to be286-# 2 here.287-GB2312CharLenTable = (0, 1, 1, 1, 1, 1, 2)288-289-GB2312SMModel = {'classTable': GB2312_cls,290- 'classFactor': 7,291- 'stateTable': GB2312_st,292- 'charLenTable': GB2312CharLenTable,293- 'name': 'GB2312'}294-295-# Shift_JIS296-297-SJIS_cls = (298- 1, 1, 1, 1, 1, 1, 1, 1, # 00 - 07299- 1, 1, 1, 1, 1, 1, 0, 0, # 08 - 0f300- 1, 1, 1, 1, 1, 1, 1, 1, # 10 - 17301- 1, 1, 1, 0, 1, 1, 1, 1, # 18 - 1f302- 1, 1, 1, 1, 1, 1, 1, 1, # 20 - 27303- 1, 1, 1, 1, 1, 1, 1, 1, # 28 - 2f304- 1, 1, 1, 1, 1, 1, 1, 1, # 30 - 37305- 1, 1, 1, 1, 1, 1, 1, 1, # 38 - 3f306- 2, 2, 2, 2, 2, 2, 2, 2, # 40 - 47307- 2, 2, 2, 2, 2, 2, 2, 2, # 48 - 4f308- 2, 2, 2, 2, 2, 2, 2, 2, # 50 - 57309- 2, 2, 2, 2, 2, 2, 2, 2, # 58 - 5f310- 2, 2, 2, 2, 2, 2, 2, 2, # 60 - 67311- 2, 2, 2, 2, 2, 2, 2, 2, # 68 - 6f312- 2, 2, 2, 2, 2, 2, 2, 2, # 70 - 77313- 2, 2, 2, 2, 2, 2, 2, 1, # 78 - 7f314- 3, 3, 3, 3, 3, 3, 3, 3, # 80 - 87315- 3, 3, 3, 3, 3, 3, 3, 3, # 88 - 8f316- 3, 3, 3, 3, 3, 3, 3, 3, # 90 - 97317- 3, 3, 3, 3, 3, 3, 3, 3, # 98 - 9f318- #0xa0 is illegal in sjis encoding, but some pages does319- #contain such byte. We need to be more error forgiven.320- 2, 2, 2, 2, 2, 2, 2, 2, # a0 - a7321- 2, 2, 2, 2, 2, 2, 2, 2, # a8 - af322- 2, 2, 2, 2, 2, 2, 2, 2, # b0 - b7323- 2, 2, 2, 2, 2, 2, 2, 2, # b8 - bf324- 2, 2, 2, 2, 2, 2, 2, 2, # c0 - c7325- 2, 2, 2, 2, 2, 2, 2, 2, # c8 - cf326- 2, 2, 2, 2, 2, 2, 2, 2, # d0 - d7327- 2, 2, 2, 2, 2, 2, 2, 2, # d8 - df328- 3, 3, 3, 3, 3, 3, 3, 3, # e0 - e7329- 3, 3, 3, 3, 3, 4, 4, 4, # e8 - ef330- 4, 4, 4, 4, 4, 4, 4, 4, # f0 - f7331- 4, 4, 4, 4, 4, 0, 0, 0) # f8 - ff332-333-SJIS_st = (334- eError, eStart, eStart, 3, eError, eError, eError, eError, # 00-07335- eError, eError, eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, # 08-0f336- eItsMe, eItsMe, eError, eError, eStart, eStart, eStart, eStart, # 10-17337-)338-339-SJISCharLenTable = (0, 1, 1, 2, 0, 0)340-341-SJISSMModel = {'classTable': SJIS_cls,342- 'classFactor': 6,343- 'stateTable': SJIS_st,344- 'charLenTable': SJISCharLenTable,345- 'name': 'Shift_JIS'}346-347-# UCS2-BE348-349-UCS2BE_cls = (350- 0, 0, 0, 0, 0, 0, 0, 0, # 00 - 07351- 0, 0, 1, 0, 0, 2, 0, 0, # 08 - 0f352- 0, 0, 0, 0, 0, 0, 0, 0, # 10 - 17353- 0, 0, 0, 3, 0, 0, 0, 0, # 18 - 1f354- 0, 0, 0, 0, 0, 0, 0, 0, # 20 - 27355- 0, 3, 3, 3, 3, 3, 0, 0, # 28 - 2f356- 0, 0, 0, 0, 0, 0, 0, 0, # 30 - 37357- 0, 0, 0, 0, 0, 0, 0, 0, # 38 - 3f358- 0, 0, 0, 0, 0, 0, 0, 0, # 40 - 47359- 0, 0, 0, 0, 0, 0, 0, 0, # 48 - 4f360- 0, 0, 0, 0, 0, 0, 0, 0, # 50 - 57361- 0, 0, 0, 0, 0, 0, 0, 0, # 58 - 5f362- 0, 0, 0, 0, 0, 0, 0, 0, # 60 - 67363- 0, 0, 0, 0, 0, 0, 0, 0, # 68 - 6f364- 0, 0, 0, 0, 0, 0, 0, 0, # 70 - 77365- 0, 0, 0, 0, 0, 0, 0, 0, # 78 - 7f366- 0, 0, 0, 0, 0, 0, 0, 0, # 80 - 87367- 0, 0, 0, 0, 0, 0, 0, 0, # 88 - 8f368- 0, 0, 0, 0, 0, 0, 0, 0, # 90 - 97369- 0, 0, 0, 0, 0, 0, 0, 0, # 98 - 9f370- 0, 0, 0, 0, 0, 0, 0, 0, # a0 - a7371- 0, 0, 0, 0, 0, 0, 0, 0, # a8 - af372- 0, 0, 0, 0, 0, 0, 0, 0, # b0 - b7373- 0, 0, 0, 0, 0, 0, 0, 0, # b8 - bf374- 0, 0, 0, 0, 0, 0, 0, 0, # c0 - c7375- 0, 0, 0, 0, 0, 0, 0, 0, # c8 - cf376- 0, 0, 0, 0, 0, 0, 0, 0, # d0 - d7377- 0, 0, 0, 0, 0, 0, 0, 0, # d8 - df378- 0, 0, 0, 0, 0, 0, 0, 0, # e0 - e7379- 0, 0, 0, 0, 0, 0, 0, 0, # e8 - ef380- 0, 0, 0, 0, 0, 0, 0, 0, # f0 - f7381- 0, 0, 0, 0, 0, 0, 4, 5, # f8 - ff382-)383-384-UCS2BE_st = (385- 5, 7, 7, eError, 4, 3, eError, eError, # 00-07386- eError, eError, eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, # 08-0f387- eItsMe, eItsMe, 6, 6, 6, 6, eError, eError, # 10-17388- 6, 6, 6, 6, 6, eItsMe, 6, 6, # 18-1f389- 6, 6, 6, 6, 5, 7, 7, eError, # 20-27390- 5, 8, 6, 6, eError, 6, 6, 6, # 28-2f391- 6, 6, 6, 6, eError, eError, eStart, eStart, # 30-37392-)393-394-UCS2BECharLenTable = (2, 2, 2, 0, 2, 2)395-396-UCS2BESMModel = {'classTable': UCS2BE_cls,397- 'classFactor': 6,398- 'stateTable': UCS2BE_st,399- 'charLenTable': UCS2BECharLenTable,400- 'name': 'UTF-16BE'}401-402-# UCS2-LE403-404-UCS2LE_cls = (405- 0, 0, 0, 0, 0, 0, 0, 0, # 00 - 07406- 0, 0, 1, 0, 0, 2, 0, 0, # 08 - 0f407- 0, 0, 0, 0, 0, 0, 0, 0, # 10 - 17408- 0, 0, 0, 3, 0, 0, 0, 0, # 18 - 1f409- 0, 0, 0, 0, 0, 0, 0, 0, # 20 - 27410- 0, 3, 3, 3, 3, 3, 0, 0, # 28 - 2f411- 0, 0, 0, 0, 0, 0, 0, 0, # 30 - 37412- 0, 0, 0, 0, 0, 0, 0, 0, # 38 - 3f413- 0, 0, 0, 0, 0, 0, 0, 0, # 40 - 47414- 0, 0, 0, 0, 0, 0, 0, 0, # 48 - 4f415- 0, 0, 0, 0, 0, 0, 0, 0, # 50 - 57416- 0, 0, 0, 0, 0, 0, 0, 0, # 58 - 5f417- 0, 0, 0, 0, 0, 0, 0, 0, # 60 - 67418- 0, 0, 0, 0, 0, 0, 0, 0, # 68 - 6f419- 0, 0, 0, 0, 0, 0, 0, 0, # 70 - 77420- 0, 0, 0, 0, 0, 0, 0, 0, # 78 - 7f421- 0, 0, 0, 0, 0, 0, 0, 0, # 80 - 87422- 0, 0, 0, 0, 0, 0, 0, 0, # 88 - 8f423- 0, 0, 0, 0, 0, 0, 0, 0, # 90 - 97424- 0, 0, 0, 0, 0, 0, 0, 0, # 98 - 9f425- 0, 0, 0, 0, 0, 0, 0, 0, # a0 - a7426- 0, 0, 0, 0, 0, 0, 0, 0, # a8 - af427- 0, 0, 0, 0, 0, 0, 0, 0, # b0 - b7428- 0, 0, 0, 0, 0, 0, 0, 0, # b8 - bf429- 0, 0, 0, 0, 0, 0, 0, 0, # c0 - c7430- 0, 0, 0, 0, 0, 0, 0, 0, # c8 - cf431- 0, 0, 0, 0, 0, 0, 0, 0, # d0 - d7432- 0, 0, 0, 0, 0, 0, 0, 0, # d8 - df433- 0, 0, 0, 0, 0, 0, 0, 0, # e0 - e7434- 0, 0, 0, 0, 0, 0, 0, 0, # e8 - ef435- 0, 0, 0, 0, 0, 0, 0, 0, # f0 - f7436- 0, 0, 0, 0, 0, 0, 4, 5, # f8 - ff437-)438-439-UCS2LE_st = (440- 6, 6, 7, 6, 4, 3, eError, eError, # 00-07441- eError, eError, eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, # 08-0f442- eItsMe, eItsMe, 5, 5, 5, eError, eItsMe, eError, # 10-17443- 5, 5, 5, eError, 5, eError, 6, 6, # 18-1f444- 7, 6, 8, 8, 5, 5, 5, eError, # 20-27445- 5, 5, 5, eError, eError, eError, 5, 5, # 28-2f446- 5, 5, 5, eError, 5, eError, eStart, eStart, # 30-37447-)448-449-UCS2LECharLenTable = (2, 2, 2, 2, 2, 2)450-451-UCS2LESMModel = {'classTable': UCS2LE_cls,452- 'classFactor': 6,453- 'stateTable': UCS2LE_st,454- 'charLenTable': UCS2LECharLenTable,455- 'name': 'UTF-16LE'}456-457-# UTF-8458-459-UTF8_cls = (460- 1, 1, 1, 1, 1, 1, 1, 1, # 00 - 07 #allow 0x00 as a legal value461- 1, 1, 1, 1, 1, 1, 0, 0, # 08 - 0f462- 1, 1, 1, 1, 1, 1, 1, 1, # 10 - 17463- 1, 1, 1, 0, 1, 1, 1, 1, # 18 - 1f464- 1, 1, 1, 1, 1, 1, 1, 1, # 20 - 27465- 1, 1, 1, 1, 1, 1, 1, 1, # 28 - 2f466- 1, 1, 1, 1, 1, 1, 1, 1, # 30 - 37467- 1, 1, 1, 1, 1, 1, 1, 1, # 38 - 3f468- 1, 1, 1, 1, 1, 1, 1, 1, # 40 - 47469- 1, 1, 1, 1, 1, 1, 1, 1, # 48 - 4f470- 1, 1, 1, 1, 1, 1, 1, 1, # 50 - 57471- 1, 1, 1, 1, 1, 1, 1, 1, # 58 - 5f472- 1, 1, 1, 1, 1, 1, 1, 1, # 60 - 67473- 1, 1, 1, 1, 1, 1, 1, 1, # 68 - 6f474- 1, 1, 1, 1, 1, 1, 1, 1, # 70 - 77475- 1, 1, 1, 1, 1, 1, 1, 1, # 78 - 7f476- 2, 2, 2, 2, 3, 3, 3, 3, # 80 - 87477- 4, 4, 4, 4, 4, 4, 4, 4, # 88 - 8f478- 4, 4, 4, 4, 4, 4, 4, 4, # 90 - 97479- 4, 4, 4, 4, 4, 4, 4, 4, # 98 - 9f480- 5, 5, 5, 5, 5, 5, 5, 5, # a0 - a7481- 5, 5, 5, 5, 5, 5, 5, 5, # a8 - af482- 5, 5, 5, 5, 5, 5, 5, 5, # b0 - b7483- 5, 5, 5, 5, 5, 5, 5, 5, # b8 - bf484- 0, 0, 6, 6, 6, 6, 6, 6, # c0 - c7485- 6, 6, 6, 6, 6, 6, 6, 6, # c8 - cf486- 6, 6, 6, 6, 6, 6, 6, 6, # d0 - d7487- 6, 6, 6, 6, 6, 6, 6, 6, # d8 - df488- 7, 8, 8, 8, 8, 8, 8, 8, # e0 - e7489- 8, 8, 8, 8, 8, 9, 8, 8, # e8 - ef490- 10, 11, 11, 11, 11, 11, 11, 11, # f0 - f7491- 12, 13, 13, 13, 14, 15, 0, 0, # f8 - ff492-)493-494-UTF8_st = (495- eError, eStart, eError, eError, eError, eError, 12, 10, # 00-07496- 9, 11, 8, 7, 6, 5, 4, 3, # 08-0f497- eError, eError, eError, eError, eError, eError, eError, eError, # 10-17498- eError, eError, eError, eError, eError, eError, eError, eError, # 18-1f499- eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, # 20-27500- eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, # 28-2f501- eError, eError, 5, 5, 5, 5, eError, eError, # 30-37502- eError, eError, eError, eError, eError, eError, eError, eError, # 38-3f503- eError, eError, eError, 5, 5, 5, eError, eError, # 40-47504- eError, eError, eError, eError, eError, eError, eError, eError, # 48-4f505- eError, eError, 7, 7, 7, 7, eError, eError, # 50-57506- eError, eError, eError, eError, eError, eError, eError, eError, # 58-5f507- eError, eError, eError, eError, 7, 7, eError, eError, # 60-67508- eError, eError, eError, eError, eError, eError, eError, eError, # 68-6f509- eError, eError, 9, 9, 9, 9, eError, eError, # 70-77510- eError, eError, eError, eError, eError, eError, eError, eError, # 78-7f511- eError, eError, eError, eError, eError, 9, eError, eError, # 80-87512- eError, eError, eError, eError, eError, eError, eError, eError, # 88-8f513- eError, eError, 12, 12, 12, 12, eError, eError, # 90-97514- eError, eError, eError, eError, eError, eError, eError, eError, # 98-9f515- eError, eError, eError, eError, eError, 12, eError, eError, # a0-a7516- eError, eError, eError, eError, eError, eError, eError, eError, # a8-af517- eError, eError, 12, 12, 12, eError, eError, eError, # b0-b7518- eError, eError, eError, eError, eError, eError, eError, eError, # b8-bf519- eError, eError, eStart, eStart, eStart, eStart, eError, eError, # c0-c7520- eError, eError, eError, eError, eError, eError, eError, eError, # c8-cf521-)522-523-UTF8CharLenTable = (0, 1, 0, 0, 0, 0, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6)524-525-UTF8SMModel = {'classTable': UTF8_cls,526- 'classFactor': 16,527- 'stateTable': UTF8_st,528- 'charLenTable': UTF8CharLenTable,529- 'name': 'UTF-8'}1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is mozilla.org code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+#22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+from .constants import eStart, eError, eItsMe29+30+# BIG531+32+BIG5_cls = (33+ 1,1,1,1,1,1,1,1, # 00 - 07 #allow 0x00 as legal value34+ 1,1,1,1,1,1,0,0, # 08 - 0f35+ 1,1,1,1,1,1,1,1, # 10 - 1736+ 1,1,1,0,1,1,1,1, # 18 - 1f37+ 1,1,1,1,1,1,1,1, # 20 - 2738+ 1,1,1,1,1,1,1,1, # 28 - 2f39+ 1,1,1,1,1,1,1,1, # 30 - 3740+ 1,1,1,1,1,1,1,1, # 38 - 3f41+ 2,2,2,2,2,2,2,2, # 40 - 4742+ 2,2,2,2,2,2,2,2, # 48 - 4f43+ 2,2,2,2,2,2,2,2, # 50 - 5744+ 2,2,2,2,2,2,2,2, # 58 - 5f45+ 2,2,2,2,2,2,2,2, # 60 - 6746+ 2,2,2,2,2,2,2,2, # 68 - 6f47+ 2,2,2,2,2,2,2,2, # 70 - 7748+ 2,2,2,2,2,2,2,1, # 78 - 7f49+ 4,4,4,4,4,4,4,4, # 80 - 8750+ 4,4,4,4,4,4,4,4, # 88 - 8f51+ 4,4,4,4,4,4,4,4, # 90 - 9752+ 4,4,4,4,4,4,4,4, # 98 - 9f53+ 4,3,3,3,3,3,3,3, # a0 - a754+ 3,3,3,3,3,3,3,3, # a8 - af55+ 3,3,3,3,3,3,3,3, # b0 - b756+ 3,3,3,3,3,3,3,3, # b8 - bf57+ 3,3,3,3,3,3,3,3, # c0 - c758+ 3,3,3,3,3,3,3,3, # c8 - cf59+ 3,3,3,3,3,3,3,3, # d0 - d760+ 3,3,3,3,3,3,3,3, # d8 - df61+ 3,3,3,3,3,3,3,3, # e0 - e762+ 3,3,3,3,3,3,3,3, # e8 - ef63+ 3,3,3,3,3,3,3,3, # f0 - f764+ 3,3,3,3,3,3,3,0 # f8 - ff65+)66+67+BIG5_st = (68+ eError,eStart,eStart, 3,eError,eError,eError,eError,#00-0769+ eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,#08-0f70+ eError,eStart,eStart,eStart,eStart,eStart,eStart,eStart#10-1771+)72+73+Big5CharLenTable = (0, 1, 1, 2, 0)74+75+Big5SMModel = {'classTable': BIG5_cls,76+ 'classFactor': 5,77+ 'stateTable': BIG5_st,78+ 'charLenTable': Big5CharLenTable,79+ 'name': 'Big5'}80+81+# EUC-JP82+83+EUCJP_cls = (84+ 4,4,4,4,4,4,4,4, # 00 - 0785+ 4,4,4,4,4,4,5,5, # 08 - 0f86+ 4,4,4,4,4,4,4,4, # 10 - 1787+ 4,4,4,5,4,4,4,4, # 18 - 1f88+ 4,4,4,4,4,4,4,4, # 20 - 2789+ 4,4,4,4,4,4,4,4, # 28 - 2f90+ 4,4,4,4,4,4,4,4, # 30 - 3791+ 4,4,4,4,4,4,4,4, # 38 - 3f92+ 4,4,4,4,4,4,4,4, # 40 - 4793+ 4,4,4,4,4,4,4,4, # 48 - 4f94+ 4,4,4,4,4,4,4,4, # 50 - 5795+ 4,4,4,4,4,4,4,4, # 58 - 5f96+ 4,4,4,4,4,4,4,4, # 60 - 6797+ 4,4,4,4,4,4,4,4, # 68 - 6f98+ 4,4,4,4,4,4,4,4, # 70 - 7799+ 4,4,4,4,4,4,4,4, # 78 - 7f100+ 5,5,5,5,5,5,5,5, # 80 - 87101+ 5,5,5,5,5,5,1,3, # 88 - 8f102+ 5,5,5,5,5,5,5,5, # 90 - 97103+ 5,5,5,5,5,5,5,5, # 98 - 9f104+ 5,2,2,2,2,2,2,2, # a0 - a7105+ 2,2,2,2,2,2,2,2, # a8 - af106+ 2,2,2,2,2,2,2,2, # b0 - b7107+ 2,2,2,2,2,2,2,2, # b8 - bf108+ 2,2,2,2,2,2,2,2, # c0 - c7109+ 2,2,2,2,2,2,2,2, # c8 - cf110+ 2,2,2,2,2,2,2,2, # d0 - d7111+ 2,2,2,2,2,2,2,2, # d8 - df112+ 0,0,0,0,0,0,0,0, # e0 - e7113+ 0,0,0,0,0,0,0,0, # e8 - ef114+ 0,0,0,0,0,0,0,0, # f0 - f7115+ 0,0,0,0,0,0,0,5 # f8 - ff116+)117+118+EUCJP_st = (119+ 3, 4, 3, 5,eStart,eError,eError,eError,#00-07120+ eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f121+ eItsMe,eItsMe,eStart,eError,eStart,eError,eError,eError,#10-17122+ eError,eError,eStart,eError,eError,eError, 3,eError,#18-1f123+ 3,eError,eError,eError,eStart,eStart,eStart,eStart#20-27124+)125+126+EUCJPCharLenTable = (2, 2, 2, 3, 1, 0)127+128+EUCJPSMModel = {'classTable': EUCJP_cls,129+ 'classFactor': 6,130+ 'stateTable': EUCJP_st,131+ 'charLenTable': EUCJPCharLenTable,132+ 'name': 'EUC-JP'}133+134+# EUC-KR135+136+EUCKR_cls = (137+ 1,1,1,1,1,1,1,1, # 00 - 07138+ 1,1,1,1,1,1,0,0, # 08 - 0f139+ 1,1,1,1,1,1,1,1, # 10 - 17140+ 1,1,1,0,1,1,1,1, # 18 - 1f141+ 1,1,1,1,1,1,1,1, # 20 - 27142+ 1,1,1,1,1,1,1,1, # 28 - 2f143+ 1,1,1,1,1,1,1,1, # 30 - 37144+ 1,1,1,1,1,1,1,1, # 38 - 3f145+ 1,1,1,1,1,1,1,1, # 40 - 47146+ 1,1,1,1,1,1,1,1, # 48 - 4f147+ 1,1,1,1,1,1,1,1, # 50 - 57148+ 1,1,1,1,1,1,1,1, # 58 - 5f149+ 1,1,1,1,1,1,1,1, # 60 - 67150+ 1,1,1,1,1,1,1,1, # 68 - 6f151+ 1,1,1,1,1,1,1,1, # 70 - 77152+ 1,1,1,1,1,1,1,1, # 78 - 7f153+ 0,0,0,0,0,0,0,0, # 80 - 87154+ 0,0,0,0,0,0,0,0, # 88 - 8f155+ 0,0,0,0,0,0,0,0, # 90 - 97156+ 0,0,0,0,0,0,0,0, # 98 - 9f157+ 0,2,2,2,2,2,2,2, # a0 - a7158+ 2,2,2,2,2,3,3,3, # a8 - af159+ 2,2,2,2,2,2,2,2, # b0 - b7160+ 2,2,2,2,2,2,2,2, # b8 - bf161+ 2,2,2,2,2,2,2,2, # c0 - c7162+ 2,3,2,2,2,2,2,2, # c8 - cf163+ 2,2,2,2,2,2,2,2, # d0 - d7164+ 2,2,2,2,2,2,2,2, # d8 - df165+ 2,2,2,2,2,2,2,2, # e0 - e7166+ 2,2,2,2,2,2,2,2, # e8 - ef167+ 2,2,2,2,2,2,2,2, # f0 - f7168+ 2,2,2,2,2,2,2,0 # f8 - ff169+)170+171+EUCKR_st = (172+ eError,eStart, 3,eError,eError,eError,eError,eError,#00-07173+ eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,eStart,eStart #08-0f174+)175+176+EUCKRCharLenTable = (0, 1, 2, 0)177+178+EUCKRSMModel = {'classTable': EUCKR_cls,179+ 'classFactor': 4,180+ 'stateTable': EUCKR_st,181+ 'charLenTable': EUCKRCharLenTable,182+ 'name': 'EUC-KR'}183+184+# EUC-TW185+186+EUCTW_cls = (187+ 2,2,2,2,2,2,2,2, # 00 - 07188+ 2,2,2,2,2,2,0,0, # 08 - 0f189+ 2,2,2,2,2,2,2,2, # 10 - 17190+ 2,2,2,0,2,2,2,2, # 18 - 1f191+ 2,2,2,2,2,2,2,2, # 20 - 27192+ 2,2,2,2,2,2,2,2, # 28 - 2f193+ 2,2,2,2,2,2,2,2, # 30 - 37194+ 2,2,2,2,2,2,2,2, # 38 - 3f195+ 2,2,2,2,2,2,2,2, # 40 - 47196+ 2,2,2,2,2,2,2,2, # 48 - 4f197+ 2,2,2,2,2,2,2,2, # 50 - 57198+ 2,2,2,2,2,2,2,2, # 58 - 5f199+ 2,2,2,2,2,2,2,2, # 60 - 67200+ 2,2,2,2,2,2,2,2, # 68 - 6f201+ 2,2,2,2,2,2,2,2, # 70 - 77202+ 2,2,2,2,2,2,2,2, # 78 - 7f203+ 0,0,0,0,0,0,0,0, # 80 - 87204+ 0,0,0,0,0,0,6,0, # 88 - 8f205+ 0,0,0,0,0,0,0,0, # 90 - 97206+ 0,0,0,0,0,0,0,0, # 98 - 9f207+ 0,3,4,4,4,4,4,4, # a0 - a7208+ 5,5,1,1,1,1,1,1, # a8 - af209+ 1,1,1,1,1,1,1,1, # b0 - b7210+ 1,1,1,1,1,1,1,1, # b8 - bf211+ 1,1,3,1,3,3,3,3, # c0 - c7212+ 3,3,3,3,3,3,3,3, # c8 - cf213+ 3,3,3,3,3,3,3,3, # d0 - d7214+ 3,3,3,3,3,3,3,3, # d8 - df215+ 3,3,3,3,3,3,3,3, # e0 - e7216+ 3,3,3,3,3,3,3,3, # e8 - ef217+ 3,3,3,3,3,3,3,3, # f0 - f7218+ 3,3,3,3,3,3,3,0 # f8 - ff219+)220+221+EUCTW_st = (222+ eError,eError,eStart, 3, 3, 3, 4,eError,#00-07223+ eError,eError,eError,eError,eError,eError,eItsMe,eItsMe,#08-0f224+ eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eStart,eError,#10-17225+ eStart,eStart,eStart,eError,eError,eError,eError,eError,#18-1f226+ 5,eError,eError,eError,eStart,eError,eStart,eStart,#20-27227+ eStart,eError,eStart,eStart,eStart,eStart,eStart,eStart #28-2f228+)229+230+EUCTWCharLenTable = (0, 0, 1, 2, 2, 2, 3)231+232+EUCTWSMModel = {'classTable': EUCTW_cls,233+ 'classFactor': 7,234+ 'stateTable': EUCTW_st,235+ 'charLenTable': EUCTWCharLenTable,236+ 'name': 'x-euc-tw'}237+238+# GB2312239+240+GB2312_cls = (241+ 1,1,1,1,1,1,1,1, # 00 - 07242+ 1,1,1,1,1,1,0,0, # 08 - 0f243+ 1,1,1,1,1,1,1,1, # 10 - 17244+ 1,1,1,0,1,1,1,1, # 18 - 1f245+ 1,1,1,1,1,1,1,1, # 20 - 27246+ 1,1,1,1,1,1,1,1, # 28 - 2f247+ 3,3,3,3,3,3,3,3, # 30 - 37248+ 3,3,1,1,1,1,1,1, # 38 - 3f249+ 2,2,2,2,2,2,2,2, # 40 - 47250+ 2,2,2,2,2,2,2,2, # 48 - 4f251+ 2,2,2,2,2,2,2,2, # 50 - 57252+ 2,2,2,2,2,2,2,2, # 58 - 5f253+ 2,2,2,2,2,2,2,2, # 60 - 67254+ 2,2,2,2,2,2,2,2, # 68 - 6f255+ 2,2,2,2,2,2,2,2, # 70 - 77256+ 2,2,2,2,2,2,2,4, # 78 - 7f257+ 5,6,6,6,6,6,6,6, # 80 - 87258+ 6,6,6,6,6,6,6,6, # 88 - 8f259+ 6,6,6,6,6,6,6,6, # 90 - 97260+ 6,6,6,6,6,6,6,6, # 98 - 9f261+ 6,6,6,6,6,6,6,6, # a0 - a7262+ 6,6,6,6,6,6,6,6, # a8 - af263+ 6,6,6,6,6,6,6,6, # b0 - b7264+ 6,6,6,6,6,6,6,6, # b8 - bf265+ 6,6,6,6,6,6,6,6, # c0 - c7266+ 6,6,6,6,6,6,6,6, # c8 - cf267+ 6,6,6,6,6,6,6,6, # d0 - d7268+ 6,6,6,6,6,6,6,6, # d8 - df269+ 6,6,6,6,6,6,6,6, # e0 - e7270+ 6,6,6,6,6,6,6,6, # e8 - ef271+ 6,6,6,6,6,6,6,6, # f0 - f7272+ 6,6,6,6,6,6,6,0 # f8 - ff273+)274+275+GB2312_st = (276+ eError,eStart,eStart,eStart,eStart,eStart, 3,eError,#00-07277+ eError,eError,eError,eError,eError,eError,eItsMe,eItsMe,#08-0f278+ eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,eStart,#10-17279+ 4,eError,eStart,eStart,eError,eError,eError,eError,#18-1f280+ eError,eError, 5,eError,eError,eError,eItsMe,eError,#20-27281+ eError,eError,eStart,eStart,eStart,eStart,eStart,eStart #28-2f282+)283+284+# To be accurate, the length of class 6 can be either 2 or 4.285+# But it is not necessary to discriminate between the two since286+# it is used for frequency analysis only, and we are validing287+# each code range there as well. So it is safe to set it to be288+# 2 here.289+GB2312CharLenTable = (0, 1, 1, 1, 1, 1, 2)290+291+GB2312SMModel = {'classTable': GB2312_cls,292+ 'classFactor': 7,293+ 'stateTable': GB2312_st,294+ 'charLenTable': GB2312CharLenTable,295+ 'name': 'GB2312'}296+297+# Shift_JIS298+299+SJIS_cls = (300+ 1,1,1,1,1,1,1,1, # 00 - 07301+ 1,1,1,1,1,1,0,0, # 08 - 0f302+ 1,1,1,1,1,1,1,1, # 10 - 17303+ 1,1,1,0,1,1,1,1, # 18 - 1f304+ 1,1,1,1,1,1,1,1, # 20 - 27305+ 1,1,1,1,1,1,1,1, # 28 - 2f306+ 1,1,1,1,1,1,1,1, # 30 - 37307+ 1,1,1,1,1,1,1,1, # 38 - 3f308+ 2,2,2,2,2,2,2,2, # 40 - 47309+ 2,2,2,2,2,2,2,2, # 48 - 4f310+ 2,2,2,2,2,2,2,2, # 50 - 57311+ 2,2,2,2,2,2,2,2, # 58 - 5f312+ 2,2,2,2,2,2,2,2, # 60 - 67313+ 2,2,2,2,2,2,2,2, # 68 - 6f314+ 2,2,2,2,2,2,2,2, # 70 - 77315+ 2,2,2,2,2,2,2,1, # 78 - 7f316+ 3,3,3,3,3,3,3,3, # 80 - 87317+ 3,3,3,3,3,3,3,3, # 88 - 8f318+ 3,3,3,3,3,3,3,3, # 90 - 97319+ 3,3,3,3,3,3,3,3, # 98 - 9f320+ #0xa0 is illegal in sjis encoding, but some pages does321+ #contain such byte. We need to be more error forgiven.322+ 2,2,2,2,2,2,2,2, # a0 - a7323+ 2,2,2,2,2,2,2,2, # a8 - af324+ 2,2,2,2,2,2,2,2, # b0 - b7325+ 2,2,2,2,2,2,2,2, # b8 - bf326+ 2,2,2,2,2,2,2,2, # c0 - c7327+ 2,2,2,2,2,2,2,2, # c8 - cf328+ 2,2,2,2,2,2,2,2, # d0 - d7329+ 2,2,2,2,2,2,2,2, # d8 - df330+ 3,3,3,3,3,3,3,3, # e0 - e7331+ 3,3,3,3,3,4,4,4, # e8 - ef332+ 4,4,4,4,4,4,4,4, # f0 - f7333+ 4,4,4,4,4,0,0,0 # f8 - ff334+)335+336+337+SJIS_st = (338+ eError,eStart,eStart, 3,eError,eError,eError,eError,#00-07339+ eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f340+ eItsMe,eItsMe,eError,eError,eStart,eStart,eStart,eStart #10-17341+)342+343+SJISCharLenTable = (0, 1, 1, 2, 0, 0)344+345+SJISSMModel = {'classTable': SJIS_cls,346+ 'classFactor': 6,347+ 'stateTable': SJIS_st,348+ 'charLenTable': SJISCharLenTable,349+ 'name': 'Shift_JIS'}350+351+# UCS2-BE352+353+UCS2BE_cls = (354+ 0,0,0,0,0,0,0,0, # 00 - 07355+ 0,0,1,0,0,2,0,0, # 08 - 0f356+ 0,0,0,0,0,0,0,0, # 10 - 17357+ 0,0,0,3,0,0,0,0, # 18 - 1f358+ 0,0,0,0,0,0,0,0, # 20 - 27359+ 0,3,3,3,3,3,0,0, # 28 - 2f360+ 0,0,0,0,0,0,0,0, # 30 - 37361+ 0,0,0,0,0,0,0,0, # 38 - 3f362+ 0,0,0,0,0,0,0,0, # 40 - 47363+ 0,0,0,0,0,0,0,0, # 48 - 4f364+ 0,0,0,0,0,0,0,0, # 50 - 57365+ 0,0,0,0,0,0,0,0, # 58 - 5f366+ 0,0,0,0,0,0,0,0, # 60 - 67367+ 0,0,0,0,0,0,0,0, # 68 - 6f368+ 0,0,0,0,0,0,0,0, # 70 - 77369+ 0,0,0,0,0,0,0,0, # 78 - 7f370+ 0,0,0,0,0,0,0,0, # 80 - 87371+ 0,0,0,0,0,0,0,0, # 88 - 8f372+ 0,0,0,0,0,0,0,0, # 90 - 97373+ 0,0,0,0,0,0,0,0, # 98 - 9f374+ 0,0,0,0,0,0,0,0, # a0 - a7375+ 0,0,0,0,0,0,0,0, # a8 - af376+ 0,0,0,0,0,0,0,0, # b0 - b7377+ 0,0,0,0,0,0,0,0, # b8 - bf378+ 0,0,0,0,0,0,0,0, # c0 - c7379+ 0,0,0,0,0,0,0,0, # c8 - cf380+ 0,0,0,0,0,0,0,0, # d0 - d7381+ 0,0,0,0,0,0,0,0, # d8 - df382+ 0,0,0,0,0,0,0,0, # e0 - e7383+ 0,0,0,0,0,0,0,0, # e8 - ef384+ 0,0,0,0,0,0,0,0, # f0 - f7385+ 0,0,0,0,0,0,4,5 # f8 - ff386+)387+388+UCS2BE_st = (389+ 5, 7, 7,eError, 4, 3,eError,eError,#00-07390+ eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f391+ eItsMe,eItsMe, 6, 6, 6, 6,eError,eError,#10-17392+ 6, 6, 6, 6, 6,eItsMe, 6, 6,#18-1f393+ 6, 6, 6, 6, 5, 7, 7,eError,#20-27394+ 5, 8, 6, 6,eError, 6, 6, 6,#28-2f395+ 6, 6, 6, 6,eError,eError,eStart,eStart #30-37396+)397+398+UCS2BECharLenTable = (2, 2, 2, 0, 2, 2)399+400+UCS2BESMModel = {'classTable': UCS2BE_cls,401+ 'classFactor': 6,402+ 'stateTable': UCS2BE_st,403+ 'charLenTable': UCS2BECharLenTable,404+ 'name': 'UTF-16BE'}405+406+# UCS2-LE407+408+UCS2LE_cls = (409+ 0,0,0,0,0,0,0,0, # 00 - 07410+ 0,0,1,0,0,2,0,0, # 08 - 0f411+ 0,0,0,0,0,0,0,0, # 10 - 17412+ 0,0,0,3,0,0,0,0, # 18 - 1f413+ 0,0,0,0,0,0,0,0, # 20 - 27414+ 0,3,3,3,3,3,0,0, # 28 - 2f415+ 0,0,0,0,0,0,0,0, # 30 - 37416+ 0,0,0,0,0,0,0,0, # 38 - 3f417+ 0,0,0,0,0,0,0,0, # 40 - 47418+ 0,0,0,0,0,0,0,0, # 48 - 4f419+ 0,0,0,0,0,0,0,0, # 50 - 57420+ 0,0,0,0,0,0,0,0, # 58 - 5f421+ 0,0,0,0,0,0,0,0, # 60 - 67422+ 0,0,0,0,0,0,0,0, # 68 - 6f423+ 0,0,0,0,0,0,0,0, # 70 - 77424+ 0,0,0,0,0,0,0,0, # 78 - 7f425+ 0,0,0,0,0,0,0,0, # 80 - 87426+ 0,0,0,0,0,0,0,0, # 88 - 8f427+ 0,0,0,0,0,0,0,0, # 90 - 97428+ 0,0,0,0,0,0,0,0, # 98 - 9f429+ 0,0,0,0,0,0,0,0, # a0 - a7430+ 0,0,0,0,0,0,0,0, # a8 - af431+ 0,0,0,0,0,0,0,0, # b0 - b7432+ 0,0,0,0,0,0,0,0, # b8 - bf433+ 0,0,0,0,0,0,0,0, # c0 - c7434+ 0,0,0,0,0,0,0,0, # c8 - cf435+ 0,0,0,0,0,0,0,0, # d0 - d7436+ 0,0,0,0,0,0,0,0, # d8 - df437+ 0,0,0,0,0,0,0,0, # e0 - e7438+ 0,0,0,0,0,0,0,0, # e8 - ef439+ 0,0,0,0,0,0,0,0, # f0 - f7440+ 0,0,0,0,0,0,4,5 # f8 - ff441+)442+443+UCS2LE_st = (444+ 6, 6, 7, 6, 4, 3,eError,eError,#00-07445+ eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f446+ eItsMe,eItsMe, 5, 5, 5,eError,eItsMe,eError,#10-17447+ 5, 5, 5,eError, 5,eError, 6, 6,#18-1f448+ 7, 6, 8, 8, 5, 5, 5,eError,#20-27449+ 5, 5, 5,eError,eError,eError, 5, 5,#28-2f450+ 5, 5, 5,eError, 5,eError,eStart,eStart #30-37451+)452+453+UCS2LECharLenTable = (2, 2, 2, 2, 2, 2)454+455+UCS2LESMModel = {'classTable': UCS2LE_cls,456+ 'classFactor': 6,457+ 'stateTable': UCS2LE_st,458+ 'charLenTable': UCS2LECharLenTable,459+ 'name': 'UTF-16LE'}460+461+# UTF-8462+463+UTF8_cls = (464+ 1,1,1,1,1,1,1,1, # 00 - 07 #allow 0x00 as a legal value465+ 1,1,1,1,1,1,0,0, # 08 - 0f466+ 1,1,1,1,1,1,1,1, # 10 - 17467+ 1,1,1,0,1,1,1,1, # 18 - 1f468+ 1,1,1,1,1,1,1,1, # 20 - 27469+ 1,1,1,1,1,1,1,1, # 28 - 2f470+ 1,1,1,1,1,1,1,1, # 30 - 37471+ 1,1,1,1,1,1,1,1, # 38 - 3f472+ 1,1,1,1,1,1,1,1, # 40 - 47473+ 1,1,1,1,1,1,1,1, # 48 - 4f474+ 1,1,1,1,1,1,1,1, # 50 - 57475+ 1,1,1,1,1,1,1,1, # 58 - 5f476+ 1,1,1,1,1,1,1,1, # 60 - 67477+ 1,1,1,1,1,1,1,1, # 68 - 6f478+ 1,1,1,1,1,1,1,1, # 70 - 77479+ 1,1,1,1,1,1,1,1, # 78 - 7f480+ 2,2,2,2,3,3,3,3, # 80 - 87481+ 4,4,4,4,4,4,4,4, # 88 - 8f482+ 4,4,4,4,4,4,4,4, # 90 - 97483+ 4,4,4,4,4,4,4,4, # 98 - 9f484+ 5,5,5,5,5,5,5,5, # a0 - a7485+ 5,5,5,5,5,5,5,5, # a8 - af486+ 5,5,5,5,5,5,5,5, # b0 - b7487+ 5,5,5,5,5,5,5,5, # b8 - bf488+ 0,0,6,6,6,6,6,6, # c0 - c7489+ 6,6,6,6,6,6,6,6, # c8 - cf490+ 6,6,6,6,6,6,6,6, # d0 - d7491+ 6,6,6,6,6,6,6,6, # d8 - df492+ 7,8,8,8,8,8,8,8, # e0 - e7493+ 8,8,8,8,8,9,8,8, # e8 - ef494+ 10,11,11,11,11,11,11,11, # f0 - f7495+ 12,13,13,13,14,15,0,0 # f8 - ff496+)497+498+UTF8_st = (499+ eError,eStart,eError,eError,eError,eError, 12, 10,#00-07500+ 9, 11, 8, 7, 6, 5, 4, 3,#08-0f501+ eError,eError,eError,eError,eError,eError,eError,eError,#10-17502+ eError,eError,eError,eError,eError,eError,eError,eError,#18-1f503+ eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,#20-27504+ eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,#28-2f505+ eError,eError, 5, 5, 5, 5,eError,eError,#30-37506+ eError,eError,eError,eError,eError,eError,eError,eError,#38-3f507+ eError,eError,eError, 5, 5, 5,eError,eError,#40-47508+ eError,eError,eError,eError,eError,eError,eError,eError,#48-4f509+ eError,eError, 7, 7, 7, 7,eError,eError,#50-57510+ eError,eError,eError,eError,eError,eError,eError,eError,#58-5f511+ eError,eError,eError,eError, 7, 7,eError,eError,#60-67512+ eError,eError,eError,eError,eError,eError,eError,eError,#68-6f513+ eError,eError, 9, 9, 9, 9,eError,eError,#70-77514+ eError,eError,eError,eError,eError,eError,eError,eError,#78-7f515+ eError,eError,eError,eError,eError, 9,eError,eError,#80-87516+ eError,eError,eError,eError,eError,eError,eError,eError,#88-8f517+ eError,eError, 12, 12, 12, 12,eError,eError,#90-97518+ eError,eError,eError,eError,eError,eError,eError,eError,#98-9f519+ eError,eError,eError,eError,eError, 12,eError,eError,#a0-a7520+ eError,eError,eError,eError,eError,eError,eError,eError,#a8-af521+ eError,eError, 12, 12, 12,eError,eError,eError,#b0-b7522+ eError,eError,eError,eError,eError,eError,eError,eError,#b8-bf523+ eError,eError,eStart,eStart,eStart,eStart,eError,eError,#c0-c7524+ eError,eError,eError,eError,eError,eError,eError,eError #c8-cf525+)526+527+UTF8CharLenTable = (0, 1, 0, 0, 0, 0, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6)528+529+UTF8SMModel = {'classTable': UTF8_cls,530+ 'classFactor': 16,531+ 'stateTable': UTF8_st,532+ 'charLenTable': UTF8CharLenTable,533+ 'name': 'UTF-8'}534+535+# flake8: noqamodified:requests/packages/charade/sbcharsetprober.py+120 added-124 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Universal charset detector code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 20017-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-# Shy Shalom - original C code12-#13-# This library is free software; you can redistribute it and/or14-# modify it under the terms of the GNU Lesser General Public15-# License as published by the Free Software Foundation; either16-# version 2.1 of the License, or (at your option) any later version.17-#18-# This library is distributed in the hope that it will be useful,19-# but WITHOUT ANY WARRANTY; without even the implied warranty of20-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21-# Lesser General Public License for more details.22-#23-# You should have received a copy of the GNU Lesser General Public24-# License along with this library; if not, write to the Free Software25-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26-# 02110-1301 USA27-######################### END LICENSE BLOCK #########################28-29-import sys30-from . import constants31-from .charsetprober import CharSetProber32-from .compat import wrap_ord33-34-SAMPLE_SIZE = 6435-SB_ENOUGH_REL_THRESHOLD = 102436-POSITIVE_SHORTCUT_THRESHOLD = 0.9537-NEGATIVE_SHORTCUT_THRESHOLD = 0.0538-SYMBOL_CAT_ORDER = 25039-NUMBER_OF_SEQ_CAT = 440-POSITIVE_CAT = NUMBER_OF_SEQ_CAT - 141-#NEGATIVE_CAT = 042-43-44-class SingleByteCharSetProber(CharSetProber):45- def __init__(self, model, reversed=False, nameProber=None):46- CharSetProber.__init__(self)47- self._mModel = model48- # TRUE if we need to reverse every pair in the model lookup49- self._mReversed = reversed50- # Optional auxiliary prober for name decision51- self._mNameProber = nameProber52- self.reset()53-54- def reset(self):55- CharSetProber.reset(self)56- self._mLastOrder = 255 # char order of last character57- self._mSeqCounters = [0] * NUMBER_OF_SEQ_CAT58- self._mTotalSeqs = 059- self._mTotalChar = 060- self._mFreqChar = 0 # characters that fall in our sampling range61-62- def get_charset_name(self):63- if self._mNameProber:64- return self._mNameProber.get_charset_name()65- else:66- return self._mModel['charsetName']67-68- def feed(self, aBuf):69- if not self._mModel['keepEnglishLetter']:70- aBuf = self.filter_without_english_letters(aBuf)71- aLen = len(aBuf)72- if not aLen:73- return self.get_state()74- for c in aBuf:75- try:76- order = self._mModel['charToOrderMap'][wrap_ord(c)]77- except IndexError:78- return constants.eError79- if order < SYMBOL_CAT_ORDER:80- self._mTotalChar += 181- if order < SAMPLE_SIZE:82- self._mFreqChar += 183- if self._mLastOrder < SAMPLE_SIZE:84- self._mTotalSeqs += 185- if not self._mReversed:86- i = (self._mLastOrder * SAMPLE_SIZE) + order87- else: # reverse the order of the letters in the lookup88- i = (order * SAMPLE_SIZE) + self._mLastOrder89- model = self._mModel['precedenceMatrix'][i]90- self._mSeqCounters[model] += 191- self._mLastOrder = order92-93- if self.get_state() == constants.eDetecting:94- if self._mTotalSeqs > SB_ENOUGH_REL_THRESHOLD:95- cf = self.get_confidence()96- if cf > POSITIVE_SHORTCUT_THRESHOLD:97- if constants._debug:98- sys.stderr.write('%s confidence = %s, we have a'99- ' winner\n' %100- (self._mModel['charsetName'],101- cf))102- self._mState = constants.eFoundIt103- elif cf < NEGATIVE_SHORTCUT_THRESHOLD:104- if constants._debug:105- sys.stderr.write('%s confidence = %s, below negative'106- ' shortcut threshhold %s\n' %107- (self._mModel['charsetName'], cf,108- NEGATIVE_SHORTCUT_THRESHOLD))109- self._mState = constants.eNotMe110-111- return self.get_state()112-113- def get_confidence(self):114- r = 0.01115- if self._mTotalSeqs > 0:116- #print(self._mSeqCounters[POSITIVE_CAT], self._mTotalSeqs,117- # self._mModel['mTypicalPositiveRatio'])118- r = ((1.0 * self._mSeqCounters[POSITIVE_CAT]) / self._mTotalSeqs119- / self._mModel['mTypicalPositiveRatio'])120- #print(r, self._mFreqChar, self._mTotalChar)121- r = r * self._mFreqChar / self._mTotalChar122- if r >= 1.0:123- r = 0.99124- return r1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Universal charset detector code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 20017+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+# Shy Shalom - original C code12+#13+# This library is free software; you can redistribute it and/or14+# modify it under the terms of the GNU Lesser General Public15+# License as published by the Free Software Foundation; either16+# version 2.1 of the License, or (at your option) any later version.17+#18+# This library is distributed in the hope that it will be useful,19+# but WITHOUT ANY WARRANTY; without even the implied warranty of20+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21+# Lesser General Public License for more details.22+#23+# You should have received a copy of the GNU Lesser General Public24+# License along with this library; if not, write to the Free Software25+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26+# 02110-1301 USA27+######################### END LICENSE BLOCK #########################28+29+import sys30+from . import constants31+from .charsetprober import CharSetProber32+from .compat import wrap_ord33+34+SAMPLE_SIZE = 6435+SB_ENOUGH_REL_THRESHOLD = 102436+POSITIVE_SHORTCUT_THRESHOLD = 0.9537+NEGATIVE_SHORTCUT_THRESHOLD = 0.0538+SYMBOL_CAT_ORDER = 25039+NUMBER_OF_SEQ_CAT = 440+POSITIVE_CAT = NUMBER_OF_SEQ_CAT - 141+#NEGATIVE_CAT = 042+43+44+class SingleByteCharSetProber(CharSetProber):45+ def __init__(self, model, reversed=False, nameProber=None):46+ CharSetProber.__init__(self)47+ self._mModel = model48+ # TRUE if we need to reverse every pair in the model lookup49+ self._mReversed = reversed50+ # Optional auxiliary prober for name decision51+ self._mNameProber = nameProber52+ self.reset()53+54+ def reset(self):55+ CharSetProber.reset(self)56+ # char order of last character57+ self._mLastOrder = 25558+ self._mSeqCounters = [0] * NUMBER_OF_SEQ_CAT59+ self._mTotalSeqs = 060+ self._mTotalChar = 061+ # characters that fall in our sampling range62+ self._mFreqChar = 063+64+ def get_charset_name(self):65+ if self._mNameProber:66+ return self._mNameProber.get_charset_name()67+ else:68+ return self._mModel['charsetName']69+70+ def feed(self, aBuf):71+ if not self._mModel['keepEnglishLetter']:72+ aBuf = self.filter_without_english_letters(aBuf)73+ aLen = len(aBuf)74+ if not aLen:75+ return self.get_state()76+ for c in aBuf:77+ order = self._mModel['charToOrderMap'][wrap_ord(c)]78+ if order < SYMBOL_CAT_ORDER:79+ self._mTotalChar += 180+ if order < SAMPLE_SIZE:81+ self._mFreqChar += 182+ if self._mLastOrder < SAMPLE_SIZE:83+ self._mTotalSeqs += 184+ if not self._mReversed:85+ i = (self._mLastOrder * SAMPLE_SIZE) + order86+ model = self._mModel['precedenceMatrix'][i]87+ else: # reverse the order of the letters in the lookup88+ i = (order * SAMPLE_SIZE) + self._mLastOrder89+ model = self._mModel['precedenceMatrix'][i]90+ self._mSeqCounters[model] += 191+ self._mLastOrder = order92+93+ if self.get_state() == constants.eDetecting:94+ if self._mTotalSeqs > SB_ENOUGH_REL_THRESHOLD:95+ cf = self.get_confidence()96+ if cf > POSITIVE_SHORTCUT_THRESHOLD:97+ if constants._debug:98+ sys.stderr.write('%s confidence = %s, we have a'99+ 'winner\n' %100+ (self._mModel['charsetName'], cf))101+ self._mState = constants.eFoundIt102+ elif cf < NEGATIVE_SHORTCUT_THRESHOLD:103+ if constants._debug:104+ sys.stderr.write('%s confidence = %s, below negative'105+ 'shortcut threshhold %s\n' %106+ (self._mModel['charsetName'], cf,107+ NEGATIVE_SHORTCUT_THRESHOLD))108+ self._mState = constants.eNotMe109+110+ return self.get_state()111+112+ def get_confidence(self):113+ r = 0.01114+ if self._mTotalSeqs > 0:115+ r = ((1.0 * self._mSeqCounters[POSITIVE_CAT]) / self._mTotalSeqs116+ / self._mModel['mTypicalPositiveRatio'])117+ r = r * self._mFreqChar / self._mTotalChar118+ if r >= 1.0:119+ r = 0.99120+ return rmodified:requests/packages/charade/sbcsgroupprober.py+69 added-69 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Universal charset detector code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 20017-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-# Shy Shalom - original C code12-#13-# This library is free software; you can redistribute it and/or14-# modify it under the terms of the GNU Lesser General Public15-# License as published by the Free Software Foundation; either16-# version 2.1 of the License, or (at your option) any later version.17-#18-# This library is distributed in the hope that it will be useful,19-# but WITHOUT ANY WARRANTY; without even the implied warranty of20-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21-# Lesser General Public License for more details.22-#23-# You should have received a copy of the GNU Lesser General Public24-# License along with this library; if not, write to the Free Software25-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26-# 02110-1301 USA27-######################### END LICENSE BLOCK #########################28-29-from .charsetgroupprober import CharSetGroupProber30-from .sbcharsetprober import SingleByteCharSetProber31-from .langcyrillicmodel import (Win1251CyrillicModel, Koi8rModel,32- Latin5CyrillicModel, MacCyrillicModel,33- Ibm866Model, Ibm855Model)34-from .langgreekmodel import Latin7GreekModel, Win1253GreekModel35-from .langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel36-from .langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel37-from .langthaimodel import TIS620ThaiModel38-from .langhebrewmodel import Win1255HebrewModel39-from .hebrewprober import HebrewProber40-41-42-class SBCSGroupProber(CharSetGroupProber):43- def __init__(self):44- CharSetGroupProber.__init__(self)45- self._mProbers = [46- SingleByteCharSetProber(Win1251CyrillicModel),47- SingleByteCharSetProber(Koi8rModel),48- SingleByteCharSetProber(Latin5CyrillicModel),49- SingleByteCharSetProber(MacCyrillicModel),50- SingleByteCharSetProber(Ibm866Model),51- SingleByteCharSetProber(Ibm855Model),52- SingleByteCharSetProber(Latin7GreekModel),53- SingleByteCharSetProber(Win1253GreekModel),54- SingleByteCharSetProber(Latin5BulgarianModel),55- SingleByteCharSetProber(Win1251BulgarianModel),56- SingleByteCharSetProber(Latin2HungarianModel),57- SingleByteCharSetProber(Win1250HungarianModel),58- SingleByteCharSetProber(TIS620ThaiModel),59- ]60- hebrewProber = HebrewProber()61- logicalHebrewProber = SingleByteCharSetProber(Win1255HebrewModel,62- False, hebrewProber)63- visualHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, True,64- hebrewProber)65- hebrewProber.set_model_probers(logicalHebrewProber, visualHebrewProber)66- self._mProbers.extend([hebrewProber, logicalHebrewProber,67- visualHebrewProber])68-69- self.reset()1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Universal charset detector code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 20017+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+# Shy Shalom - original C code12+#13+# This library is free software; you can redistribute it and/or14+# modify it under the terms of the GNU Lesser General Public15+# License as published by the Free Software Foundation; either16+# version 2.1 of the License, or (at your option) any later version.17+#18+# This library is distributed in the hope that it will be useful,19+# but WITHOUT ANY WARRANTY; without even the implied warranty of20+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21+# Lesser General Public License for more details.22+#23+# You should have received a copy of the GNU Lesser General Public24+# License along with this library; if not, write to the Free Software25+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26+# 02110-1301 USA27+######################### END LICENSE BLOCK #########################28+29+from .charsetgroupprober import CharSetGroupProber30+from .sbcharsetprober import SingleByteCharSetProber31+from .langcyrillicmodel import (Win1251CyrillicModel, Koi8rModel,32+ Latin5CyrillicModel, MacCyrillicModel,33+ Ibm866Model, Ibm855Model)34+from .langgreekmodel import Latin7GreekModel, Win1253GreekModel35+from .langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel36+from .langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel37+from .langthaimodel import TIS620ThaiModel38+from .langhebrewmodel import Win1255HebrewModel39+from .hebrewprober import HebrewProber40+41+42+class SBCSGroupProber(CharSetGroupProber):43+ def __init__(self):44+ CharSetGroupProber.__init__(self)45+ self._mProbers = [46+ SingleByteCharSetProber(Win1251CyrillicModel),47+ SingleByteCharSetProber(Koi8rModel),48+ SingleByteCharSetProber(Latin5CyrillicModel),49+ SingleByteCharSetProber(MacCyrillicModel),50+ SingleByteCharSetProber(Ibm866Model),51+ SingleByteCharSetProber(Ibm855Model),52+ SingleByteCharSetProber(Latin7GreekModel),53+ SingleByteCharSetProber(Win1253GreekModel),54+ SingleByteCharSetProber(Latin5BulgarianModel),55+ SingleByteCharSetProber(Win1251BulgarianModel),56+ SingleByteCharSetProber(Latin2HungarianModel),57+ SingleByteCharSetProber(Win1250HungarianModel),58+ SingleByteCharSetProber(TIS620ThaiModel),59+ ]60+ hebrewProber = HebrewProber()61+ logicalHebrewProber = SingleByteCharSetProber(Win1255HebrewModel,62+ False, hebrewProber)63+ visualHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, True,64+ hebrewProber)65+ hebrewProber.set_model_probers(logicalHebrewProber, visualHebrewProber)66+ self._mProbers.extend([hebrewProber, logicalHebrewProber,67+ visualHebrewProber])68+69+ self.reset()modified:requests/packages/charade/sjisprober.py+91 added-90 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is mozilla.org code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-#22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-import sys29-from .mbcharsetprober import MultiByteCharSetProber30-from .codingstatemachine import CodingStateMachine31-from .chardistribution import SJISDistributionAnalysis32-from .jpcntx import SJISContextAnalysis33-from .mbcssm import SJISSMModel34-from . import constants35-36-37-class SJISProber(MultiByteCharSetProber):38- def __init__(self):39- MultiByteCharSetProber.__init__(self)40- self._mCodingSM = CodingStateMachine(SJISSMModel)41- self._mDistributionAnalyzer = SJISDistributionAnalysis()42- self._mContextAnalyzer = SJISContextAnalysis()43- self.reset()44-45- def reset(self):46- MultiByteCharSetProber.reset(self)47- self._mContextAnalyzer.reset()48-49- def get_charset_name(self):50- return "SHIFT_JIS"51-52- def feed(self, aBuf):53- aLen = len(aBuf)54- for i in range(0, aLen):55- codingState = self._mCodingSM.next_state(aBuf[i])56- if codingState == constants.eError:57- if constants._debug:58- sys.stderr.write(self.get_charset_name() + ' prober hit'59- 'error at byte ' + str(i) + '\n')60- self._mState = constants.eNotMe61- break62- elif codingState == constants.eItsMe:63- self._mState = constants.eFoundIt64- break65- elif codingState == constants.eStart:66- charLen = self._mCodingSM.get_current_charlen()67- if i == 0:68- self._mLastChar[1] = aBuf[0]69- self._mContextAnalyzer.feed(self._mLastChar[2 - charLen:],70- charLen)71- self._mDistributionAnalyzer.feed(self._mLastChar, charLen)72- else:73- self._mContextAnalyzer.feed(aBuf[i + 1 - charLen:i + 3 -74- charLen], charLen)75- self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],76- charLen)77-78- self._mLastChar[0] = aBuf[aLen - 1]79-80- if self.get_state() == constants.eDetecting:81- if (self._mContextAnalyzer.got_enough_data() and82- (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):83- self._mState = constants.eFoundIt84-85- return self.get_state()86-87- def get_confidence(self):88- contxtCf = self._mContextAnalyzer.get_confidence()89- distribCf = self._mDistributionAnalyzer.get_confidence()90- return max(contxtCf, distribCf)1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is mozilla.org code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+#22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+import sys29+from .mbcharsetprober import MultiByteCharSetProber30+from .codingstatemachine import CodingStateMachine31+from .chardistribution import SJISDistributionAnalysis32+from .jpcntx import SJISContextAnalysis33+from .mbcssm import SJISSMModel34+from . import constants35+36+37+class SJISProber(MultiByteCharSetProber):38+ def __init__(self):39+ MultiByteCharSetProber.__init__(self)40+ self._mCodingSM = CodingStateMachine(SJISSMModel)41+ self._mDistributionAnalyzer = SJISDistributionAnalysis()42+ self._mContextAnalyzer = SJISContextAnalysis()43+ self.reset()44+45+ def reset(self):46+ MultiByteCharSetProber.reset(self)47+ self._mContextAnalyzer.reset()48+49+ def get_charset_name(self):50+ return "SHIFT_JIS"51+52+ def feed(self, aBuf):53+ aLen = len(aBuf)54+ for i in range(0, aLen):55+ codingState = self._mCodingSM.next_state(aBuf[i])56+ if codingState == constants.eError:57+ if constants._debug:58+ sys.stderr.write(self.get_charset_name()59+ + ' prober hit error at byte ' + str(i)60+ + '\n')61+ self._mState = constants.eNotMe62+ break63+ elif codingState == constants.eItsMe:64+ self._mState = constants.eFoundIt65+ break66+ elif codingState == constants.eStart:67+ charLen = self._mCodingSM.get_current_charlen()68+ if i == 0:69+ self._mLastChar[1] = aBuf[0]70+ self._mContextAnalyzer.feed(self._mLastChar[2 - charLen:],71+ charLen)72+ self._mDistributionAnalyzer.feed(self._mLastChar, charLen)73+ else:74+ self._mContextAnalyzer.feed(aBuf[i + 1 - charLen:i + 375+ - charLen], charLen)76+ self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],77+ charLen)78+79+ self._mLastChar[0] = aBuf[aLen - 1]80+81+ if self.get_state() == constants.eDetecting:82+ if (self._mContextAnalyzer.got_enough_data() and83+ (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):84+ self._mState = constants.eFoundIt85+86+ return self.get_state()87+88+ def get_confidence(self):89+ contxtCf = self._mContextAnalyzer.get_confidence()90+ distribCf = self._mDistributionAnalyzer.get_confidence()91+ return max(contxtCf, distribCf)modified:requests/packages/charade/universaldetector.py+171 added-173 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is Mozilla Universal charset detector code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 20017-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-# Shy Shalom - original C code12-#13-# This library is free software; you can redistribute it and/or14-# modify it under the terms of the GNU Lesser General Public15-# License as published by the Free Software Foundation; either16-# version 2.1 of the License, or (at your option) any later version.17-#18-# This library is distributed in the hope that it will be useful,19-# but WITHOUT ANY WARRANTY; without even the implied warranty of20-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21-# Lesser General Public License for more details.22-#23-# You should have received a copy of the GNU Lesser General Public24-# License along with this library; if not, write to the Free Software25-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26-# 02110-1301 USA27-######################### END LICENSE BLOCK #########################28-29-import sys30-from . import constants31-from .latin1prober import Latin1Prober # windows-125232-from .mbcsgroupprober import MBCSGroupProber # multi-byte character sets33-from .sbcsgroupprober import SBCSGroupProber # single-byte character sets34-from .escprober import EscCharSetProber # ISO-2122, etc.35-import re36-import logging37-38-logger = logging.getLogger(__name__)39-40-MINIMUM_THRESHOLD = 0.2041-ePureAscii = 042-eEscAscii = 143-eHighbyte = 244-45-46-class UniversalDetector:47- def __init__(self):48- self._highBitDetector = re.compile(b'[\x80-\xFF]')49- self._escDetector = re.compile(b'(\033|~{)')50- self._mEscCharSetProber = None51- self._mCharSetProbers = []52- self.reset()53-54- def reset(self):55- self.result = {'encoding': None, 'confidence': 0.0}56- self.done = False57- self._mStart = True58- self._mGotData = False59- self._mInputState = ePureAscii60- self._mLastChar = b''61- if self._mEscCharSetProber:62- self._mEscCharSetProber.reset()63- for prober in self._mCharSetProbers:64- prober.reset()65-66- def feed(self, aBuf):67- if self.done:68- return69-70- charmap = (71- # EF BB BF UTF-8 with BOM72- ('\xEF\xBB\xBF', {'encoding': "UTF-8", 'confidence': 1.0}),73- # FF FE 00 00 UTF-32, little-endian BOM74- ('\xFF\xFE\x00\x00', {'encoding': "UTF-32LE", 'confidence': 1.0}),75- # 00 00 FE FF UTF-32, big-endian BOM76- ('\x00\x00\xFE\xFF', {'encoding': "UTF-32BE", 'confidence': 1.0}),77- # FE FF 00 00 UCS-4, unusual octet order BOM (3412)78- ('\xFE\xFF\x00\x00', {'encoding': "X-ISO-10646-UCS-4-3412",79- 'confidence': 1.0}),80- # 00 00 FF FE UCS-4, unusual octet order BOM (2143)81- ('\x00\x00\xFF\xFE', {'encoding': "X-ISO-10646-UCS-4-2143",82- 'confidence': 1.0}),83- # FF FE UTF-16, little endian BOM84- ('\xFF\xFE', {'encoding': "UTF-16LE", 'confidence': 1.0}),85- # FE FF UTF-16, big endian BOM86- ('\xFE\xFF', {'encoding': "UTF-16BE", 'confidence': 1.0}),87- )88-89- aLen = len(aBuf)90- if not aLen:91- return92-93- if not self._mGotData:94- # If the data starts with BOM, we know it is UTF95- for chunk, result in charmap:96- if aBuf[:len(chunk)] == chunk:97- self.result = result98- break99-100- self._mGotData = True101- if self.result['encoding'] and (self.result['confidence'] > 0.0):102- self.done = True103- return104-105- if self._mInputState == ePureAscii:106- if self._highBitDetector.search(aBuf):107- self._mInputState = eHighbyte108- elif ((self._mInputState == ePureAscii) and109- self._escDetector.search(self._mLastChar + aBuf)):110- self._mInputState = eEscAscii111-112- self._mLastChar = aBuf[-1:]113-114- if self._mInputState == eEscAscii:115- if not self._mEscCharSetProber:116- self._mEscCharSetProber = EscCharSetProber()117- if self._mEscCharSetProber.feed(aBuf) == constants.eFoundIt:118- self.result = {119- 'encoding': self._mEscCharSetProber.get_charset_name(),120- 'confidence': self._mEscCharSetProber.get_confidence(),121- }122- self.done = True123- elif self._mInputState == eHighbyte:124- if not self._mCharSetProbers:125- self._mCharSetProbers = [MBCSGroupProber(), SBCSGroupProber(),126- Latin1Prober()]127- for prober in self._mCharSetProbers:128- try:129- if prober.feed(aBuf) == constants.eFoundIt:130- self.result = {'encoding': prober.get_charset_name(),131- 'confidence': prober.get_confidence()}132- self.done = True133- break134- except (UnicodeDecodeError, UnicodeEncodeError) as e:135- logger.exception(e)136-137- def close(self):138- if self.done:139- return140- if not self._mGotData:141- if constants._debug:142- sys.stderr.write('no data received!\n')143- return144- self.done = True145-146- if self._mInputState == ePureAscii:147- self.result = {'encoding': 'ascii', 'confidence': 1.0}148- return self.result149-150- if self._mInputState == eHighbyte:151- proberConfidence = None152- maxProberConfidence = 0.0153- maxProber = None154- for prober in self._mCharSetProbers:155- if not prober:156- continue157- proberConfidence = prober.get_confidence()158- if proberConfidence > maxProberConfidence:159- maxProberConfidence = proberConfidence160- maxProber = prober161- if maxProber and (maxProberConfidence > MINIMUM_THRESHOLD):162- self.result = {'encoding': maxProber.get_charset_name(),163- 'confidence': maxProber.get_confidence()}164- return self.result165-166- if constants._debug:167- sys.stderr.write('no probers hit minimum threshhold\n')168- for prober in self._mCharSetProbers[0].mProbers:169- if not prober:170- continue171- sys.stderr.write('%s confidence = %s\n' %172- (prober.get_charset_name(),173- prober.get_confidence()))1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is Mozilla Universal charset detector code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 20017+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+# Shy Shalom - original C code12+#13+# This library is free software; you can redistribute it and/or14+# modify it under the terms of the GNU Lesser General Public15+# License as published by the Free Software Foundation; either16+# version 2.1 of the License, or (at your option) any later version.17+#18+# This library is distributed in the hope that it will be useful,19+# but WITHOUT ANY WARRANTY; without even the implied warranty of20+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21+# Lesser General Public License for more details.22+#23+# You should have received a copy of the GNU Lesser General Public24+# License along with this library; if not, write to the Free Software25+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26+# 02110-1301 USA27+######################### END LICENSE BLOCK #########################28+29+from . import constants30+import sys31+from .latin1prober import Latin1Prober # windows-125232+from .mbcsgroupprober import MBCSGroupProber # multi-byte character sets33+from .sbcsgroupprober import SBCSGroupProber # single-byte character sets34+from .escprober import EscCharSetProber # ISO-2122, etc.35+import re36+37+MINIMUM_THRESHOLD = 0.2038+ePureAscii = 039+eEscAscii = 140+eHighbyte = 241+42+43+class UniversalDetector:44+ def __init__(self):45+ self._highBitDetector = re.compile(b'[\x80-\xFF]')46+ self._escDetector = re.compile(b'(\033|~{)')47+ self._mEscCharSetProber = None48+ self._mCharSetProbers = []49+ self.reset()50+51+ def reset(self):52+ self.result = {'encoding': None, 'confidence': 0.0}53+ self.done = False54+ self._mStart = True55+ self._mGotData = False56+ self._mInputState = ePureAscii57+ self._mLastChar = b''58+ if self._mEscCharSetProber:59+ self._mEscCharSetProber.reset()60+ for prober in self._mCharSetProbers:61+ prober.reset()62+63+ def feed(self, aBuf):64+ if self.done:65+ return66+67+ aLen = len(aBuf)68+ if not aLen:69+ return70+71+ if not self._mGotData:72+ # If the data starts with BOM, we know it is UTF73+ if aBuf[:3] == '\xEF\xBB\xBF':74+ # EF BB BF UTF-8 with BOM75+ self.result = {'encoding': "UTF-8", 'confidence': 1.0}76+ elif aBuf[:4] == '\xFF\xFE\x00\x00':77+ # FF FE 00 00 UTF-32, little-endian BOM78+ self.result = {'encoding': "UTF-32LE", 'confidence': 1.0}79+ elif aBuf[:4] == '\x00\x00\xFE\xFF':80+ # 00 00 FE FF UTF-32, big-endian BOM81+ self.result = {'encoding': "UTF-32BE", 'confidence': 1.0}82+ elif aBuf[:4] == '\xFE\xFF\x00\x00':83+ # FE FF 00 00 UCS-4, unusual octet order BOM (3412)84+ self.result = {85+ 'encoding': "X-ISO-10646-UCS-4-3412",86+ 'confidence': 1.087+ }88+ elif aBuf[:4] == '\x00\x00\xFF\xFE':89+ # 00 00 FF FE UCS-4, unusual octet order BOM (2143)90+ self.result = {91+ 'encoding': "X-ISO-10646-UCS-4-2143",92+ 'confidence': 1.093+ }94+ elif aBuf[:2] == '\xFF\xFE':95+ # FF FE UTF-16, little endian BOM96+ self.result = {'encoding': "UTF-16LE", 'confidence': 1.0}97+ elif aBuf[:2] == '\xFE\xFF':98+ # FE FF UTF-16, big endian BOM99+ self.result = {'encoding': "UTF-16BE", 'confidence': 1.0}100+101+ self._mGotData = True102+ if self.result['encoding'] and (self.result['confidence'] > 0.0):103+ self.done = True104+ return105+106+ if self._mInputState == ePureAscii:107+ if self._highBitDetector.search(aBuf):108+ self._mInputState = eHighbyte109+ elif ((self._mInputState == ePureAscii) and110+ self._escDetector.search(self._mLastChar + aBuf)):111+ self._mInputState = eEscAscii112+113+ self._mLastChar = aBuf[-1:]114+115+ if self._mInputState == eEscAscii:116+ if not self._mEscCharSetProber:117+ self._mEscCharSetProber = EscCharSetProber()118+ if self._mEscCharSetProber.feed(aBuf) == constants.eFoundIt:119+ self.result = {120+ 'encoding': self._mEscCharSetProber.get_charset_name(),121+ 'confidence': self._mEscCharSetProber.get_confidence()122+ }123+ self.done = True124+ elif self._mInputState == eHighbyte:125+ if not self._mCharSetProbers:126+ self._mCharSetProbers = [MBCSGroupProber(), SBCSGroupProber(),127+ Latin1Prober()]128+ for prober in self._mCharSetProbers:129+ if prober.feed(aBuf) == constants.eFoundIt:130+ self.result = {'encoding': prober.get_charset_name(),131+ 'confidence': prober.get_confidence()}132+ self.done = True133+ break134+135+ def close(self):136+ if self.done:137+ return138+ if not self._mGotData:139+ if constants._debug:140+ sys.stderr.write('no data received!\n')141+ return142+ self.done = True143+144+ if self._mInputState == ePureAscii:145+ self.result = {'encoding': 'ascii', 'confidence': 1.0}146+ return self.result147+148+ if self._mInputState == eHighbyte:149+ proberConfidence = None150+ maxProberConfidence = 0.0151+ maxProber = None152+ for prober in self._mCharSetProbers:153+ if not prober:154+ continue155+ proberConfidence = prober.get_confidence()156+ if proberConfidence > maxProberConfidence:157+ maxProberConfidence = proberConfidence158+ maxProber = prober159+ if maxProber and (maxProberConfidence > MINIMUM_THRESHOLD):160+ self.result = {'encoding': maxProber.get_charset_name(),161+ 'confidence': maxProber.get_confidence()}162+ return self.result163+164+ if constants._debug:165+ sys.stderr.write('no probers hit minimum threshhold\n')166+ for prober in self._mCharSetProbers[0].mProbers:167+ if not prober:168+ continue169+ sys.stderr.write('%s confidence = %s\n' %170+ (prober.get_charset_name(),171+ prober.get_confidence()))modified:requests/packages/charade/utf8prober.py+76 added-76 removed
1-######################## BEGIN LICENSE BLOCK ########################2-# The Original Code is mozilla.org code.3-#4-# The Initial Developer of the Original Code is5-# Netscape Communications Corporation.6-# Portions created by the Initial Developer are Copyright (C) 19987-# the Initial Developer. All Rights Reserved.8-#9-# Contributor(s):10-# Mark Pilgrim - port to Python11-#12-# This library is free software; you can redistribute it and/or13-# modify it under the terms of the GNU Lesser General Public14-# License as published by the Free Software Foundation; either15-# 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 of19-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20-# Lesser General Public License for more details.21-#22-# You should have received a copy of the GNU Lesser General Public23-# License along with this library; if not, write to the Free Software24-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25-# 02110-1301 USA26-######################### END LICENSE BLOCK #########################27-28-from . import constants29-from .charsetprober import CharSetProber30-from .codingstatemachine import CodingStateMachine31-from .mbcssm import UTF8SMModel32-33-ONE_CHAR_PROB = 0.534-35-36-class UTF8Prober(CharSetProber):37- def __init__(self):38- CharSetProber.__init__(self)39- self._mCodingSM = CodingStateMachine(UTF8SMModel)40- self.reset()41-42- def reset(self):43- CharSetProber.reset(self)44- self._mCodingSM.reset()45- self._mNumOfMBChar = 046-47- def get_charset_name(self):48- return "utf-8"49-50- def feed(self, aBuf):51- for c in aBuf:52- codingState = self._mCodingSM.next_state(c)53- if codingState == constants.eError:54- self._mState = constants.eNotMe55- break56- elif codingState == constants.eItsMe:57- self._mState = constants.eFoundIt58- break59- elif codingState == constants.eStart:60- if self._mCodingSM.get_current_charlen() >= 2:61- self._mNumOfMBChar += 162-63- if self.get_state() == constants.eDetecting:64- if self.get_confidence() > constants.SHORTCUT_THRESHOLD:65- self._mState = constants.eFoundIt66-67- return self.get_state()68-69- def get_confidence(self):70- unlike = 0.9971- if self._mNumOfMBChar < 6:72- for i in range(0, self._mNumOfMBChar):73- unlike = unlike * ONE_CHAR_PROB74- return 1.0 - unlike75- else:76- return unlike1+######################## BEGIN LICENSE BLOCK ########################2+# The Original Code is mozilla.org code.3+#4+# The Initial Developer of the Original Code is5+# Netscape Communications Corporation.6+# Portions created by the Initial Developer are Copyright (C) 19987+# the Initial Developer. All Rights Reserved.8+#9+# Contributor(s):10+# Mark Pilgrim - port to Python11+#12+# This library is free software; you can redistribute it and/or13+# modify it under the terms of the GNU Lesser General Public14+# License as published by the Free Software Foundation; either15+# 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 of19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20+# Lesser General Public License for more details.21+#22+# You should have received a copy of the GNU Lesser General Public23+# License along with this library; if not, write to the Free Software24+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25+# 02110-1301 USA26+######################### END LICENSE BLOCK #########################27+28+from . import constants29+from .charsetprober import CharSetProber30+from .codingstatemachine import CodingStateMachine31+from .mbcssm import UTF8SMModel32+33+ONE_CHAR_PROB = 0.534+35+36+class UTF8Prober(CharSetProber):37+ def __init__(self):38+ CharSetProber.__init__(self)39+ self._mCodingSM = CodingStateMachine(UTF8SMModel)40+ self.reset()41+42+ def reset(self):43+ CharSetProber.reset(self)44+ self._mCodingSM.reset()45+ self._mNumOfMBChar = 046+47+ def get_charset_name(self):48+ return "utf-8"49+50+ def feed(self, aBuf):51+ for c in aBuf:52+ codingState = self._mCodingSM.next_state(c)53+ if codingState == constants.eError:54+ self._mState = constants.eNotMe55+ break56+ elif codingState == constants.eItsMe:57+ self._mState = constants.eFoundIt58+ break59+ elif codingState == constants.eStart:60+ if self._mCodingSM.get_current_charlen() >= 2:61+ self._mNumOfMBChar += 162+63+ if self.get_state() == constants.eDetecting:64+ if self.get_confidence() > constants.SHORTCUT_THRESHOLD:65+ self._mState = constants.eFoundIt66+67+ return self.get_state()68+69+ def get_confidence(self):70+ unlike = 0.9971+ if self._mNumOfMBChar < 6:72+ for i in range(0, self._mNumOfMBChar):73+ unlike = unlike * ONE_CHAR_PROB74+ return 1.0 - unlike75+ else:76+ return unlikeadded:requests/packages/t.py
added:requests/compat.py.orig+123 added
1+# -*- coding: utf-8 -*-2+3+"""4+pythoncompat5+"""6+7+8+import sys9+10+# -------11+# Pythons12+# -------13+14+# Syntax sugar.15+_ver = sys.version_info16+17+#: Python 2.x?18+is_py2 = (_ver[0] == 2)19+20+#: Python 3.x?21+is_py3 = (_ver[0] == 3)22+23+#: Python 3.0.x24+is_py30 = (is_py3 and _ver[1] == 0)25+26+#: Python 3.1.x27+is_py31 = (is_py3 and _ver[1] == 1)28+29+#: Python 3.2.x30+is_py32 = (is_py3 and _ver[1] == 2)31+32+#: Python 3.3.x33+is_py33 = (is_py3 and _ver[1] == 3)34+35+#: Python 3.4.x36+is_py34 = (is_py3 and _ver[1] == 4)37+38+#: Python 2.7.x39+is_py27 = (is_py2 and _ver[1] == 7)40+41+#: Python 2.6.x42+is_py26 = (is_py2 and _ver[1] == 6)43+44+#: Python 2.5.x45+is_py25 = (is_py2 and _ver[1] == 5)46+47+#: Python 2.4.x48+is_py24 = (is_py2 and _ver[1] == 4) # I'm assuming this is not by choice.49+50+51+# ---------52+# Platforms53+# ---------54+55+56+# Syntax sugar.57+_ver = sys.version.lower()58+59+is_pypy = ('pypy' in _ver)60+is_jython = ('jython' in _ver)61+is_ironpython = ('iron' in _ver)62+63+# Assume CPython, if nothing else.64+is_cpython = not any((is_pypy, is_jython, is_ironpython))65+66+# Windows-based system.67+is_windows = 'win32' in str(sys.platform).lower()68+69+# Standard Linux 2+ system.70+is_linux = ('linux' in str(sys.platform).lower())71+is_osx = ('darwin' in str(sys.platform).lower())72+is_hpux = ('hpux' in str(sys.platform).lower()) # Complete guess.73+is_solaris = ('solar==' in str(sys.platform).lower()) # Complete guess.74+75+try:76+ import simplejson as json77+except ImportError:78+ import json79+80+# ---------81+# Specifics82+# ---------83+84+try:85+ import cchardet as chardet86+except ImportError:87+ from .packages import chardet88+89+90+if is_py2:91+ from urllib import quote, unquote, quote_plus, unquote_plus, urlencode92+ from urlparse import urlparse, urlunparse, urljoin, urlsplit, urldefrag93+ from urllib2 import parse_http_list94+ import cookielib95+ from Cookie import Morsel96+ from StringIO import StringIO97+ from .packages.urllib3.packages.ordered_dict import OrderedDict98+99+ builtin_str = str100+ bytes = str101+ str = unicode102+ basestring = basestring103+ numeric_types = (int, long, float)104+105+106+107+elif is_py3:108+ from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag109+ from urllib.request import parse_http_list110+ from http import cookiejar as cookielib111+ from http.cookies import Morsel112+ from io import StringIO113+<<<<<<< HEAD114+=======115+ from .packages import chardet116+>>>>>>> 8f86ff633a2646442f2d8976046b5c0025e772c1117+ from collections import OrderedDict118+119+ builtin_str = str120+ str = str121+ bytes = bytes122+ basestring = (str, bytes)123+ numeric_types = (int, float)added:t.py+4 added
1+from requests.packages import chardet2+3+with open('test', 'rb') as f:4+ print(chardet.detect(f.read()))added:t2.py+6 added
1+import requests2+3+r = requests.get('http://readability.com')4+r.encoding = None5+6+print(r.text)added:test+13 added
1+{2+ "url": "http://httpbin.org/get",3+ "headers": {4+ "Content-Length": "",5+ "Connection": "keep-alive",6+ "Accept": "*/*",7+ "User-Agent": "curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5",8+ "Host": "httpbin.org",9+ "Content-Type": ""10+ },11+ "args": {},12+ "origin": "184.72.18.219"13+}