~anna-g/micronaet/anna

« back to all changes in this revision

Viewing changes to mws_amazon/mws/requests/packages/chardet2/charsetprober.py

  • Committer: Anna Micronaet
  • Date: 2013-07-18 09:08:36 UTC
  • Revision ID: anna@micronaet.it-20130718090836-ssmst48rrnvcd69w
Tolti tutti i moduli

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
######################## BEGIN LICENSE BLOCK ########################
2
 
# The Original Code is Mozilla Universal charset detector code.
3
 
4
 
# The Initial Developer of the Original Code is
5
 
# Netscape Communications Corporation.
6
 
# Portions created by the Initial Developer are Copyright (C) 2001
7
 
# the Initial Developer. All Rights Reserved.
8
 
9
 
# Contributor(s):
10
 
#   Mark Pilgrim - port to Python
11
 
#   Shy Shalom - original C code
12
 
#
13
 
# This library is free software; you can redistribute it and/or
14
 
# modify it under the terms of the GNU Lesser General Public
15
 
# License as published by the Free Software Foundation; either
16
 
# 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 of
20
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21
 
# Lesser General Public License for more details.
22
 
23
 
# You should have received a copy of the GNU Lesser General Public
24
 
# License along with this library; if not, write to the Free Software
25
 
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26
 
# 02110-1301  USA
27
 
######################### END LICENSE BLOCK #########################
28
 
 
29
 
from . import constants
30
 
import re
31
 
 
32
 
class CharSetProber:
33
 
    def __init__(self):
34
 
        pass
35
 
        
36
 
    def reset(self):
37
 
        self._mState = constants.eDetecting
38
 
    
39
 
    def get_charset_name(self):
40
 
        return None
41
 
 
42
 
    def feed(self, aBuf):
43
 
        pass
44
 
 
45
 
    def get_state(self):
46
 
        return self._mState
47
 
 
48
 
    def get_confidence(self):
49
 
        return 0.0
50
 
 
51
 
    def filter_high_bit_only(self, aBuf):
52
 
        aBuf = re.sub(b'([\x00-\x7F])+', b' ', aBuf)
53
 
        return aBuf
54
 
    
55
 
    def filter_without_english_letters(self, aBuf):
56
 
        aBuf = re.sub(b'([A-Za-z])+', b' ', aBuf)
57
 
        return aBuf
58
 
        
59
 
    def filter_with_english_letters(self, aBuf):
60
 
        # TODO
61
 
        return aBuf