mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 23:10:17 +00:00
trimmed 2to3 output
This commit is contained in:
@@ -132,388 +132,11 @@ RefactoringTool: Skipping implicit fixer: ws_comma
|
||||
|
||||
ENOUGH_DATA_THRESHOLD = 1024
|
||||
SURE_YES = 0.99
|
||||
--- chardet\charsetgroupprober.py (original)
|
||||
+++ chardet\charsetgroupprober.py (refactored)
|
||||
@@ -26,7 +26,7 @@
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
import constants, sys
|
||||
<del>-from charsetprober import CharSetProber</del>
|
||||
<ins>+from .charsetprober import CharSetProber</ins>
|
||||
|
||||
class CharSetGroupProber(CharSetProber):
|
||||
def __init__(self):
|
||||
--- chardet\codingstatemachine.py (original)
|
||||
+++ chardet\codingstatemachine.py (refactored)
|
||||
@@ -25,7 +25,7 @@
|
||||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
<del>-from constants import eStart, eError, eItsMe</del>
|
||||
<ins>+from .constants import eStart, eError, eItsMe</ins>
|
||||
|
||||
class CodingStateMachine:
|
||||
def __init__(self, sm):
|
||||
--- chardet\constants.py (original)
|
||||
+++ chardet\constants.py (refactored)
|
||||
@@ -38,10 +38,10 @@
|
||||
|
||||
SHORTCUT_THRESHOLD = 0.95
|
||||
|
||||
<del>-import __builtin__</del>
|
||||
<ins>+import builtins</ins>
|
||||
if not hasattr(__builtin__, 'False'):
|
||||
False = 0
|
||||
True = 1
|
||||
else:
|
||||
<del>- False = __builtin__.False</del>
|
||||
<del>- True = __builtin__.True</del>
|
||||
<ins>+ False = builtins.False</ins>
|
||||
<ins>+ True = builtins.True</ins>
|
||||
--- chardet\escprober.py (original)
|
||||
+++ chardet\escprober.py (refactored)
|
||||
@@ -26,9 +26,9 @@
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
import constants, sys
|
||||
<del>-from escsm import HZSMModel, ISO2022CNSMModel, ISO2022JPSMModel, ISO2022KRSMModel</del>
|
||||
<del>-from charsetprober import CharSetProber</del>
|
||||
<del>-from codingstatemachine import CodingStateMachine</del>
|
||||
<ins>+from .escsm import HZSMModel, ISO2022CNSMModel, ISO2022JPSMModel, ISO2022KRSMModel</ins>
|
||||
<ins>+from .charsetprober import CharSetProber</ins>
|
||||
<ins>+from .codingstatemachine import CodingStateMachine</ins>
|
||||
|
||||
class EscCharSetProber(CharSetProber):
|
||||
def __init__(self):
|
||||
--- chardet\escsm.py (original)
|
||||
+++ chardet\escsm.py (refactored)
|
||||
@@ -25,7 +25,7 @@
|
||||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
<del>-from constants import eStart, eError, eItsMe</del>
|
||||
<ins>+from .constants import eStart, eError, eItsMe</ins>
|
||||
|
||||
HZ_cls = ( \
|
||||
1,0,0,0,0,0,0,0, # 00 - 07
|
||||
--- chardet\eucjpprober.py (original)
|
||||
+++ chardet\eucjpprober.py (refactored)
|
||||
@@ -26,12 +26,12 @@
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
import constants, sys
|
||||
<del>-from constants import eStart, eError, eItsMe</del>
|
||||
<del>-from mbcharsetprober import MultiByteCharSetProber</del>
|
||||
<del>-from codingstatemachine import CodingStateMachine</del>
|
||||
<del>-from chardistribution import EUCJPDistributionAnalysis</del>
|
||||
<del>-from jpcntx import EUCJPContextAnalysis</del>
|
||||
<del>-from mbcssm import EUCJPSMModel</del>
|
||||
<ins>+from .constants import eStart, eError, eItsMe</ins>
|
||||
<ins>+from .mbcharsetprober import MultiByteCharSetProber</ins>
|
||||
<ins>+from .codingstatemachine import CodingStateMachine</ins>
|
||||
<ins>+from .chardistribution import EUCJPDistributionAnalysis</ins>
|
||||
<ins>+from .jpcntx import EUCJPContextAnalysis</ins>
|
||||
<ins>+from .mbcssm import EUCJPSMModel</ins>
|
||||
|
||||
class EUCJPProber(MultiByteCharSetProber):
|
||||
def __init__(self):
|
||||
--- chardet\euckrprober.py (original)
|
||||
+++ chardet\euckrprober.py (refactored)
|
||||
@@ -25,10 +25,10 @@
|
||||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
<del>-from mbcharsetprober import MultiByteCharSetProber</del>
|
||||
<del>-from codingstatemachine import CodingStateMachine</del>
|
||||
<del>-from chardistribution import EUCKRDistributionAnalysis</del>
|
||||
<del>-from mbcssm import EUCKRSMModel</del>
|
||||
<ins>+from .mbcharsetprober import MultiByteCharSetProber</ins>
|
||||
<ins>+from .codingstatemachine import CodingStateMachine</ins>
|
||||
<ins>+from .chardistribution import EUCKRDistributionAnalysis</ins>
|
||||
<ins>+from .mbcssm import EUCKRSMModel</ins>
|
||||
|
||||
class EUCKRProber(MultiByteCharSetProber):
|
||||
def __init__(self):
|
||||
--- chardet\euctwprober.py (original)
|
||||
+++ chardet\euctwprober.py (refactored)
|
||||
@@ -25,10 +25,10 @@
|
||||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
<del>-from mbcharsetprober import MultiByteCharSetProber</del>
|
||||
<del>-from codingstatemachine import CodingStateMachine</del>
|
||||
<del>-from chardistribution import EUCTWDistributionAnalysis</del>
|
||||
<del>-from mbcssm import EUCTWSMModel</del>
|
||||
<ins>+from .mbcharsetprober import MultiByteCharSetProber</ins>
|
||||
<ins>+from .codingstatemachine import CodingStateMachine</ins>
|
||||
<ins>+from .chardistribution import EUCTWDistributionAnalysis</ins>
|
||||
<ins>+from .mbcssm import EUCTWSMModel</ins>
|
||||
|
||||
class EUCTWProber(MultiByteCharSetProber):
|
||||
def __init__(self):
|
||||
--- chardet\gb2312prober.py (original)
|
||||
+++ chardet\gb2312prober.py (refactored)
|
||||
@@ -25,10 +25,10 @@
|
||||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
<del>-from mbcharsetprober import MultiByteCharSetProber</del>
|
||||
<del>-from codingstatemachine import CodingStateMachine</del>
|
||||
<del>-from chardistribution import GB2312DistributionAnalysis</del>
|
||||
<del>-from mbcssm import GB2312SMModel</del>
|
||||
<ins>+from .mbcharsetprober import MultiByteCharSetProber</ins>
|
||||
<ins>+from .codingstatemachine import CodingStateMachine</ins>
|
||||
<ins>+from .chardistribution import GB2312DistributionAnalysis</ins>
|
||||
<ins>+from .mbcssm import GB2312SMModel</ins>
|
||||
|
||||
class GB2312Prober(MultiByteCharSetProber):
|
||||
def __init__(self):
|
||||
--- chardet\hebrewprober.py (original)
|
||||
+++ chardet\hebrewprober.py (refactored)
|
||||
@@ -25,8 +25,8 @@
|
||||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
<del>-from charsetprober import CharSetProber</del>
|
||||
<del>-import constants</del>
|
||||
<ins>+from .charsetprober import CharSetProber</ins>
|
||||
<ins>+from . import constants</ins>
|
||||
|
||||
# This prober doesn't actually recognize a language or a charset.
|
||||
# It is a helper prober for the use of the Hebrew model probers
|
||||
--- chardet\jpcntx.py (original)
|
||||
+++ chardet\jpcntx.py (refactored)
|
||||
@@ -25,7 +25,7 @@
|
||||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
<del>-import constants</del>
|
||||
<ins>+from . import constants</ins>
|
||||
|
||||
NUM_OF_CATEGORY = 6
|
||||
DONT_KNOW = -1
|
||||
--- chardet\langbulgarianmodel.py (original)
|
||||
+++ chardet\langbulgarianmodel.py (refactored)
|
||||
@@ -25,7 +25,7 @@
|
||||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
<del>-import constants</del>
|
||||
<ins>+from . import constants</ins>
|
||||
|
||||
# 255: Control characters that usually does not exist in any text
|
||||
# 254: Carriage/Return
|
||||
--- chardet\langcyrillicmodel.py (original)
|
||||
+++ chardet\langcyrillicmodel.py (refactored)
|
||||
@@ -25,7 +25,7 @@
|
||||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
<del>-import constants</del>
|
||||
<ins>+from . import constants</ins>
|
||||
|
||||
# KOI8-R language model
|
||||
# Character Mapping Table:
|
||||
--- chardet\langgreekmodel.py (original)
|
||||
+++ chardet\langgreekmodel.py (refactored)
|
||||
@@ -25,7 +25,7 @@
|
||||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
<del>-import constants</del>
|
||||
<ins>+from . import constants</ins>
|
||||
|
||||
# 255: Control characters that usually does not exist in any text
|
||||
# 254: Carriage/Return
|
||||
--- chardet\langhebrewmodel.py (original)
|
||||
+++ chardet\langhebrewmodel.py (refactored)
|
||||
@@ -27,7 +27,7 @@
|
||||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
<del>-import constants</del>
|
||||
<ins>+from . import constants</ins>
|
||||
|
||||
# 255: Control characters that usually does not exist in any text
|
||||
# 254: Carriage/Return
|
||||
--- chardet\langhungarianmodel.py (original)
|
||||
+++ chardet\langhungarianmodel.py (refactored)
|
||||
@@ -25,7 +25,7 @@
|
||||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
<del>-import constants</del>
|
||||
<ins>+from . import constants</ins>
|
||||
|
||||
# 255: Control characters that usually does not exist in any text
|
||||
# 254: Carriage/Return
|
||||
--- chardet\langthaimodel.py (original)
|
||||
+++ chardet\langthaimodel.py (refactored)
|
||||
@@ -25,7 +25,7 @@
|
||||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
<del>-import constants</del>
|
||||
<ins>+from . import constants</ins>
|
||||
|
||||
# 255: Control characters that usually does not exist in any text
|
||||
# 254: Carriage/Return
|
||||
--- chardet\latin1prober.py (original)
|
||||
+++ chardet\latin1prober.py (refactored)
|
||||
@@ -26,8 +26,8 @@
|
||||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
<del>-from charsetprober import CharSetProber</del>
|
||||
<del>-import constants</del>
|
||||
<ins>+from .charsetprober import CharSetProber</ins>
|
||||
<ins>+from . import constants</ins>
|
||||
import operator
|
||||
|
||||
FREQ_CAT_NUM = 4
|
||||
--- chardet\mbcharsetprober.py (original)
|
||||
+++ chardet\mbcharsetprober.py (refactored)
|
||||
@@ -28,8 +28,8 @@
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
import constants, sys
|
||||
<del>-from constants import eStart, eError, eItsMe</del>
|
||||
<del>-from charsetprober import CharSetProber</del>
|
||||
<ins>+from .constants import eStart, eError, eItsMe</ins>
|
||||
<ins>+from .charsetprober import CharSetProber</ins>
|
||||
|
||||
class MultiByteCharSetProber(CharSetProber):
|
||||
def __init__(self):
|
||||
--- chardet\mbcsgroupprober.py (original)
|
||||
+++ chardet\mbcsgroupprober.py (refactored)
|
||||
@@ -27,14 +27,14 @@
|
||||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
<del>-from charsetgroupprober import CharSetGroupProber</del>
|
||||
<del>-from utf8prober import UTF8Prober</del>
|
||||
<del>-from sjisprober import SJISProber</del>
|
||||
<del>-from eucjpprober import EUCJPProber</del>
|
||||
<del>-from gb2312prober import GB2312Prober</del>
|
||||
<del>-from euckrprober import EUCKRProber</del>
|
||||
<del>-from big5prober import Big5Prober</del>
|
||||
<del>-from euctwprober import EUCTWProber</del>
|
||||
<ins>+from .charsetgroupprober import CharSetGroupProber</ins>
|
||||
<ins>+from .utf8prober import UTF8Prober</ins>
|
||||
<ins>+from .sjisprober import SJISProber</ins>
|
||||
<ins>+from .eucjpprober import EUCJPProber</ins>
|
||||
<ins>+from .gb2312prober import GB2312Prober</ins>
|
||||
<ins>+from .euckrprober import EUCKRProber</ins>
|
||||
<ins>+from .big5prober import Big5Prober</ins>
|
||||
<ins>+from .euctwprober import EUCTWProber</ins>
|
||||
|
||||
class MBCSGroupProber(CharSetGroupProber):
|
||||
def __init__(self):
|
||||
--- chardet\mbcssm.py (original)
|
||||
+++ chardet\mbcssm.py (refactored)
|
||||
@@ -25,7 +25,7 @@
|
||||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
<del>-from constants import eStart, eError, eItsMe</del>
|
||||
<ins>+from .constants import eStart, eError, eItsMe</ins>
|
||||
|
||||
# BIG5
|
||||
|
||||
--- chardet\sbcharsetprober.py (original)
|
||||
+++ chardet\sbcharsetprober.py (refactored)
|
||||
@@ -27,7 +27,7 @@
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
import constants, sys
|
||||
<del>-from charsetprober import CharSetProber</del>
|
||||
<ins>+from .charsetprober import CharSetProber</ins>
|
||||
|
||||
SAMPLE_SIZE = 64
|
||||
SB_ENOUGH_REL_THRESHOLD = 1024
|
||||
--- chardet\sbcsgroupprober.py (original)
|
||||
+++ chardet\sbcsgroupprober.py (refactored)
|
||||
@@ -27,15 +27,15 @@
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
import constants, sys
|
||||
<del>-from charsetgroupprober import CharSetGroupProber</del>
|
||||
<del>-from sbcharsetprober import SingleByteCharSetProber</del>
|
||||
<del>-from langcyrillicmodel import Win1251CyrillicModel, Koi8rModel, Latin5CyrillicModel, MacCyrillicModel, Ibm866Model, Ibm855Model</del>
|
||||
<del>-from langgreekmodel import Latin7GreekModel, Win1253GreekModel</del>
|
||||
<del>-from langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel</del>
|
||||
<del>-from langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel</del>
|
||||
<del>-from langthaimodel import TIS620ThaiModel</del>
|
||||
<del>-from langhebrewmodel import Win1255HebrewModel</del>
|
||||
<del>-from hebrewprober import HebrewProber</del>
|
||||
<ins>+from .charsetgroupprober import CharSetGroupProber</ins>
|
||||
<ins>+from .sbcharsetprober import SingleByteCharSetProber</ins>
|
||||
<ins>+from .langcyrillicmodel import Win1251CyrillicModel, Koi8rModel, Latin5CyrillicModel, MacCyrillicModel, Ibm866Model, Ibm855Model</ins>
|
||||
<ins>+from .langgreekmodel import Latin7GreekModel, Win1253GreekModel</ins>
|
||||
<ins>+from .langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel</ins>
|
||||
<ins>+from .langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel</ins>
|
||||
<ins>+from .langthaimodel import TIS620ThaiModel</ins>
|
||||
<ins>+from .langhebrewmodel import Win1255HebrewModel</ins>
|
||||
<ins>+from .hebrewprober import HebrewProber</ins>
|
||||
|
||||
class SBCSGroupProber(CharSetGroupProber):
|
||||
def __init__(self):
|
||||
--- chardet\sjisprober.py (original)
|
||||
+++ chardet\sjisprober.py (refactored)
|
||||
@@ -25,13 +25,13 @@
|
||||
# 02110-1301 USA
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
<del>-from mbcharsetprober import MultiByteCharSetProber</del>
|
||||
<del>-from codingstatemachine import CodingStateMachine</del>
|
||||
<del>-from chardistribution import SJISDistributionAnalysis</del>
|
||||
<del>-from jpcntx import SJISContextAnalysis</del>
|
||||
<del>-from mbcssm import SJISSMModel</del>
|
||||
<ins>+from .mbcharsetprober import MultiByteCharSetProber</ins>
|
||||
<ins>+from .codingstatemachine import CodingStateMachine</ins>
|
||||
<ins>+from .chardistribution import SJISDistributionAnalysis</ins>
|
||||
<ins>+from .jpcntx import SJISContextAnalysis</ins>
|
||||
<ins>+from .mbcssm import SJISSMModel</ins>
|
||||
import constants, sys
|
||||
<del>-from constants import eStart, eError, eItsMe</del>
|
||||
<ins>+from .constants import eStart, eError, eItsMe</ins>
|
||||
|
||||
class SJISProber(MultiByteCharSetProber):
|
||||
def __init__(self):
|
||||
--- chardet\universaldetector.py (original)
|
||||
+++ chardet\universaldetector.py (refactored)
|
||||
@@ -27,10 +27,10 @@
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
import constants, sys
|
||||
<del>-from latin1prober import Latin1Prober # windows-1252</del>
|
||||
<del>-from mbcsgroupprober import MBCSGroupProber # multi-byte character sets</del>
|
||||
<del>-from sbcsgroupprober import SBCSGroupProber # single-byte character sets</del>
|
||||
<del>-from escprober import EscCharSetProber # ISO-2122, etc.</del>
|
||||
<ins>+from .latin1prober import Latin1Prober # windows-1252</ins>
|
||||
<ins>+from .mbcsgroupprober import MBCSGroupProber # multi-byte character sets</ins>
|
||||
<ins>+from .sbcsgroupprober import SBCSGroupProber # single-byte character sets</ins>
|
||||
<ins>+from .escprober import EscCharSetProber # ISO-2122, etc.</ins>
|
||||
import re
|
||||
|
||||
MINIMUM_THRESHOLD = 0.20
|
||||
--- chardet\utf8prober.py (original)
|
||||
+++ chardet\utf8prober.py (refactored)
|
||||
@@ -26,10 +26,10 @@
|
||||
######################### END LICENSE BLOCK #########################
|
||||
|
||||
import constants, sys
|
||||
<del>-from constants import eStart, eError, eItsMe</del>
|
||||
<del>-from charsetprober import CharSetProber</del>
|
||||
<del>-from codingstatemachine import CodingStateMachine</del>
|
||||
<del>-from mbcssm import UTF8SMModel</del>
|
||||
<ins>+from .constants import eStart, eError, eItsMe</ins>
|
||||
<ins>+from .charsetprober import CharSetProber</ins>
|
||||
<ins>+from .codingstatemachine import CodingStateMachine</ins>
|
||||
<ins>+from .mbcssm import UTF8SMModel</ins>
|
||||
|
||||
ONE_CHAR_PROB = 0.5
|
||||
|
||||
.
|
||||
.
|
||||
<mark>. (it goes on like this for a while)</mark>
|
||||
.
|
||||
.
|
||||
RefactoringTool: Files that were modified:
|
||||
RefactoringTool: chardet\__init__.py
|
||||
RefactoringTool: chardet\big5prober.py
|
||||
|
||||
Reference in New Issue
Block a user