[Python-modules-commits] [pyenchant] 01/05: Import pyenchant_1.6.7.orig.tar.gz

Piotr Ożarowski piotr at moszumanska.debian.org
Sat Aug 6 08:51:02 UTC 2016


This is an automated email from the git hooks/post-receive script.

piotr pushed a commit to branch master
in repository pyenchant.

commit 651192e97d5b5dc8fa37c505d9fb0790bcd0a310
Author: Piotr Ożarowski <piotr at debian.org>
Date:   Sat Aug 6 10:42:12 2016 +0200

    Import pyenchant_1.6.7.orig.tar.gz
---
 PKG-INFO                                 |   2 +-
 README.txt                               |  48 ++-------
 enchant/__init__.py                      | 165 +++++++++++++++++--------------
 enchant/_enchant.py                      |   6 +-
 enchant/checker/GtkSpellCheckerDialog.py |   6 +-
 enchant/checker/tests.py                 |   4 +-
 enchant/errors.py                        |   2 +-
 enchant/tests.py                         |  24 ++---
 enchant/tokenize/__init__.py             |  38 +++----
 enchant/tokenize/en.py                   |   2 +-
 enchant/utils.py                         |  74 +++++++++-----
 pyenchant.egg-info/PKG-INFO              |   2 +-
 pyenchant.egg-info/eager_resources.txt   |  12 ++-
 setup.cfg                                |   2 +-
 setup.py                                 |   6 +-
 tools/shootout.py                        |   4 +-
 tools/wx_example.py                      |   4 +-
 17 files changed, 211 insertions(+), 190 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index b3cc51f..2f57d0e 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pyenchant
-Version: 1.6.6
+Version: 1.6.7
 Summary: Python bindings for the Enchant spellchecking system
 Home-page: https://pythonhosted.org/pyenchant/
 Author: Ryan Kelly
diff --git a/README.txt b/README.txt
index 8ba489e..cfa8c22 100644
--- a/README.txt
+++ b/README.txt
@@ -24,9 +24,15 @@ More information is available on the Enchant website:
 How do I use it?
 ----------------
 
-For Windows users, there is an executable installer program which can be
-used to install the software with a minimum of effort.  Other users will
-need to install from source.
+For Windows and OSX users, install the pre-built binary packages using
+pip::
+
+    pip install pyenchant
+
+
+These packages bundle a pre-built copy of the underlying enchant library.
+Users on other platforms will need to install "enchant" using their system
+package manager.
 
 Once the software is installed, python's on-line help facilities can
 get you started.  Launch python and issue the following commands:
@@ -35,40 +41,6 @@ get you started.  Launch python and issue the following commands:
     >>> help(enchant)
 
 
-Installing with the Windows Installer
--------------------------------------
-
-Download and run the windows installer program.  It will automatically
-detect your python installation and set up pyenchant accordingly.
-
-The windows installer version provides a pre-compiled enchant library
-as well as several supporting libraries.  Several commonly-used
-dictionaries are installed into:
-
-    <YOUR_PYTHON_ROOT>\Lib\site-packages\enchant\share\enchant\myspell.
-
-Additional language dictionaries are available from the OpenOffice.org
-project, and are available at:
-
-    http://wiki.services.openoffice.org/wiki/Dictionaries
-    
-Download the appropriate zip for for the language of interest, and
-unzip its contents into the "myspell" directory mentioned above.
-
-
-Installing from Source
-----------------------
-
-First, you must already have the enchant library installed on our system.
-You will also need access to a C compiler.
-
-This package is distributed using the Python 'setuptools' framework.
-If you have the necessary prerequisites, all that should be required to
-install is to execute the following command in the current directory:
-
-    python setup.py install
-
-
 
 Who is responsible for all this?
 --------------------------------
@@ -86,7 +58,7 @@ about SWIG, ctypes, and even a little bit of the Python/C API.
 
 Bugs can be filed on the project's github page:
 
-    http://github.com/rfk/pyenchant/issues
+    https://github.com/rfk/pyenchant/issues
 
 Comments, suggestions, other feedback can be directed to the pyenchant-users
 mailing list:
diff --git a/enchant/__init__.py b/enchant/__init__.py
index f8cf64c..0f5ee89 100644
--- a/enchant/__init__.py
+++ b/enchant/__init__.py
@@ -9,7 +9,7 @@
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPsE.  See the GNU
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # Lesser General Public License for more details.
 #
 # You should have received a copy of the GNU Lesser General Public
@@ -62,10 +62,10 @@ function 'request_dict'.
 A finer degree of control over the dictionaries and how they are created
 can be obtained using one or more 'Broker' objects.  These objects are
 responsible for locating dictionaries for a specific language.
-    
+
 In Python 2.x, unicode strings are supported transparently in the
 standard manner - if a unicode string is given as an argument, the
-result will be a unicode string. Note that Enchant works in UTF-8 
+result will be a unicode string. Note that Enchant works in UTF-8
 internally, so passing an ASCII string to a dictionary for a language
 requiring Unicode may result in UTF-8 strings being returned.
 
@@ -81,7 +81,7 @@ _DOC_ERRORS = ['enchnt','enchnt','incant','fr']
 # Make version info available
 __ver_major__ = 1
 __ver_minor__ = 6
-__ver_patch__ = 6
+__ver_patch__ = 7
 __ver_sub__ = ""
 __version__ = "%d.%d.%d%s" % (__ver_major__,__ver_minor__,
                               __ver_patch__,__ver_sub__)
@@ -96,7 +96,7 @@ except ImportError:
     _e = None
 
 from enchant.errors import *
-from enchant.utils import EnchantStr, get_default_language
+from enchant.utils import EnchantStr, get_default_language, UTF16EnchantStr
 from enchant.pypwl import PyPWL
 
 #  Due to the unfortunate name collision between the enchant "tokenize" module
@@ -140,7 +140,7 @@ class ProviderDesc(object):
         return (self.name == pd.name and \
                 self.desc == pd.desc and \
                 self.file == pd.file)
-                
+
     def __hash__(self):
         """Hash operator on ProviderDesc objects."""
         return hash(self.name + self.desc + self.file)
@@ -148,11 +148,11 @@ class ProviderDesc(object):
 
 class _EnchantObject(object):
     """Base class for enchant objects.
-    
+
     This class implements some general functionality for interfacing with
     the '_enchant' C-library in a consistent way.  All public objects
     from the 'enchant' module are subclasses of this class.
-    
+
     All enchant objects have an attribute '_this' which contains the
     pointer to the underlying C-library object.  The method '_check_this'
     can be called to ensure that this point is not None, raising an
@@ -166,7 +166,7 @@ class _EnchantObject(object):
         #  to create a dummy default broker.
         if _e is not None:
             self._init_this()
-        
+
     def _check_this(self,msg=None):
         """Check that self._this is set to a pointer, rather than None."""
         if self._this is None:
@@ -219,14 +219,14 @@ class Broker(_EnchantObject):
 
         * dict_exists:   check existence of a specific language dictionary
         * request_dict:  obtain a dictionary for specific language
-        * set_ordering:  specify which dictionaries to try for for a
+        * set_ordering:  specify which dictionaries to try for a
                          given language.
 
     """
 
     def __init__(self):
         """Broker object constructor.
-        
+
         This method is the constructor for the 'Broker' object.  No
         arguments are required.
         """
@@ -240,8 +240,11 @@ class Broker(_EnchantObject):
 
     def __del__(self):
         """Broker object destructor."""
-        if _e is not None:
+        # Calling free() might fail if python is shutting down
+        try:
             self._free()
+        except (AttributeError, TypeError):
+            pass
 
     def __getstate__(self):
         state = super(Broker,self).__getstate__()
@@ -253,11 +256,11 @@ class Broker(_EnchantObject):
         err = _e.broker_get_error(self._this)
         if err == "" or err is None:
             raise eclass(default)
-        raise eclass(err)
+        raise eclass(EnchantStr("").decode(err))
 
     def _free(self):
         """Free system resource associated with a Broker object.
-        
+
         This method can be called to free the underlying system resources
         associated with a Broker object.  It is called automatically when
         the object is garbage collected.  If called explicitly, the
@@ -272,23 +275,23 @@ class Broker(_EnchantObject):
                     count -= 1
             _e.broker_free(self._this)
             self._this = None
-            
+
     def request_dict(self,tag=None):
         """Request a Dict object for the language specified by <tag>.
-        
+
         This method constructs and returns a Dict object for the
         requested language.  'tag' should be a string of the appropriate
         form for specifying a language, such as "fr" (French) or "en_AU"
         (Australian English).  The existence of a specific language can
         be tested using the 'dict_exists' method.
-        
+
         If <tag> is not given or is None, an attempt is made to determine
         the current language in use.  If this cannot be determined, Error
         is raised.
-        
+
         NOTE:  this method is functionally equivalent to calling the Dict()
                constructor and passing in the <broker> argument.
-               
+
         """
         return Dict(tag,self)
     request_dict._DOC_ERRORS = ["fr"]
@@ -313,7 +316,7 @@ class Broker(_EnchantObject):
 
     def request_pwl_dict(self,pwl):
         """Request a Dict object for a personal word list.
-        
+
         This method behaves as 'request_dict' but rather than returning
         a dictionary for a specific language, it returns a dictionary
         referencing a personal word list.  A personal word list is a file
@@ -335,7 +338,7 @@ class Broker(_EnchantObject):
 
     def _free_dict(self,dict):
         """Free memory associated with a dictionary.
-        
+
         This method frees system resources associated with a Dict object.
         It is equivalent to calling the object's 'free' method.  Once this
         method has been called on a dictionary, it must not be used again.
@@ -354,7 +357,7 @@ class Broker(_EnchantObject):
 
     def dict_exists(self,tag):
         """Check availability of a dictionary.
-        
+
         This method checks whether there is a dictionary available for
         the language specified by 'tag'.  It returns True if a dictionary
         is available, and False otherwise.
@@ -366,7 +369,7 @@ class Broker(_EnchantObject):
 
     def set_ordering(self,tag,ordering):
         """Set dictionary preferences for a language.
-        
+
         The Enchant library supports the use of multiple dictionary programs
         and multiple languages.  This method specifies which dictionaries
         the broker should prefer when dealing with a given language.  'tag'
@@ -383,9 +386,9 @@ class Broker(_EnchantObject):
 
     def describe(self):
         """Return list of provider descriptions.
-        
+
         This method returns a list of descriptions of each of the
-        dictionary providers available.  Each entry in the list is a 
+        dictionary providers available.  Each entry in the list is a
         ProviderDesc object.
         """
         self._check_this()
@@ -395,7 +398,7 @@ class Broker(_EnchantObject):
 
     def __describe_callback(self,name,desc,file):
         """Collector callback for dictionary description.
-        
+
         This method is used as a callback into the _enchant function
         'enchant_broker_describe'.  It collects the given arguments in
         a tuple and appends them to the list '__describe_result'.
@@ -405,15 +408,15 @@ class Broker(_EnchantObject):
         desc = s.decode(desc)
         file = s.decode(file)
         self.__describe_result.append((name,desc,file))
-        
+
     def list_dicts(self):
         """Return list of available dictionaries.
-        
+
         This method returns a list of dictionaries available to the
         broker.  Each entry in the list is a two-tuple of the form:
-            
+
             (tag,provider)
-        
+
         where <tag> is the language lag for the dictionary and
         <provider> is a ProviderDesc object describing the provider
         through which that dictionary can be obtained.
@@ -422,10 +425,10 @@ class Broker(_EnchantObject):
         self.__list_dicts_result = []
         _e.broker_list_dicts(self._this,self.__list_dicts_callback)
         return [ (r[0],ProviderDesc(*r[1])) for r in self.__list_dicts_result]
-    
+
     def __list_dicts_callback(self,tag,name,desc,file):
         """Collector callback for listing dictionaries.
-        
+
         This method is used as a callback into the _enchant function
         'enchant_broker_list_dicts'.  It collects the given arguments into
         an appropriate tuple and appends them to '__list_dicts_result'.
@@ -436,10 +439,10 @@ class Broker(_EnchantObject):
         desc = s.decode(desc)
         file = s.decode(file)
         self.__list_dicts_result.append((tag,(name,desc,file)))
- 
+
     def list_languages(self):
         """List languages for which dictionaries are available.
-        
+
         This function returns a list of language tags for which a
         dictionary is available.
         """
@@ -448,7 +451,7 @@ class Broker(_EnchantObject):
             if tag not in langs:
                 langs.append(tag)
         return langs
-        
+
     def __describe_dict(self,dict_data):
         """Get the description tuple for a dict data object.
         <dict_data> must be a C-library pointer to an enchant dictionary.
@@ -490,7 +493,7 @@ class Broker(_EnchantObject):
         name = EnchantStr(name)
         value = EnchantStr(value)
         _e.broker_set_param(self._this,name.encode(),value.encode())
-        
+
 
 
 class Dict(_EnchantObject):
@@ -516,12 +519,12 @@ class Dict(_EnchantObject):
 
         * tag:        the language tag of the dictionary
         * provider:   a ProviderDesc object for the dictionary provider
-    
+
     """
 
     def __init__(self,tag=None,broker=None):
         """Dict object constructor.
-        
+
         A dictionary belongs to a specific language, identified by the
         string <tag>.  If the tag is not given or is None, an attempt to
         determine the language currently in use is made using the 'locale'
@@ -531,7 +534,7 @@ class Dict(_EnchantObject):
         is created without any reference to a language.  This is typically
         only useful within PyEnchant itself.  Any other non-string value
         for <tag> raises Error.
-        
+
         Each dictionary must also have an associated Broker object which
         obtains the dictionary information from the underlying system. This
         may be specified using <broker>.  If not given, the default broker
@@ -572,13 +575,13 @@ class Dict(_EnchantObject):
 
     def _switch_this(self,this,broker):
         """Switch the underlying C-library pointer for this object.
-        
+
         As all useful state for a Dict is stored by the underlying C-library
         pointer, it is very convenient to allow this to be switched at
         run-time.  Pass a new dict data object into this method to affect
         the necessary changes.  The creating Broker object (at the Python
         level) must also be provided.
-                
+
         This should *never* *ever* be used by application code.  It's
         a convenience for developers only, replacing the clunkier <data>
         parameter to __init__ from earlier versions.
@@ -592,11 +595,16 @@ class Dict(_EnchantObject):
         desc = self.__describe(check_this=False)
         self.tag = desc[0]
         self.provider = ProviderDesc(*desc[1:])
+        if self.provider.name == "myspell":
+            self._StringClass = UTF16EnchantStr
+        else:
+            self._StringClass = EnchantStr
+
     _switch_this._DOC_ERRORS = ["init"]
-            
+
     def _check_this(self,msg=None):
         """Extend _EnchantObject._check_this() to check Broker validity.
-        
+
         It is possible for the managing Broker object to be freed without
         freeing the Dict.  Thus validity checking must take into account
         self._broker._this as well as self._this.
@@ -610,11 +618,11 @@ class Dict(_EnchantObject):
         err = _e.dict_get_error(self._this)
         if err == "" or err is None:
             raise eclass(default)
-        raise eclass(err)
+        raise eclass(EnchantStr("").decode(err))
 
     def _free(self):
         """Free the system resources associated with a Dict object.
-        
+
         This method frees underlying system resources for a Dict object.
         Once it has been called, the Dict object must no longer be used.
         It is called automatically when the object is garbage collected.
@@ -627,12 +635,16 @@ class Dict(_EnchantObject):
 
     def check(self,word):
         """Check spelling of a word.
-        
+
         This method takes a word in the dictionary language and returns
         True if it is correctly spelled, and false otherwise.
         """
         self._check_this()
-        word = EnchantStr(word)
+        word = self._StringClass(word)
+        # Enchant asserts that the word is non-empty.
+        # Check it up-front to avoid nasty warnings on stderr.
+        if len(word) == 0:
+            raise ValueError("can't check spelling of empty string")
         val = _e.dict_check(self._this,word.encode())
         if val == 0:
             return True
@@ -642,25 +654,29 @@ class Dict(_EnchantObject):
 
     def suggest(self,word):
         """Suggest possible spellings for a word.
-        
+
         This method tries to guess the correct spelling for a given
         word, returning the possibilities in a list.
         """
         self._check_this()
-        word = EnchantStr(word)
+        word = self._StringClass(word)
+        # Enchant asserts that the word is non-empty.
+        # Check it up-front to avoid nasty warnings on stderr.
+        if len(word) == 0:
+            raise ValueError("can't suggest spellings for empty string")
         suggs = _e.dict_suggest(self._this,word.encode())
         return [word.decode(w) for w in suggs]
 
     def add(self,word):
         """Add a word to the user's personal word list."""
         self._check_this()
-        word = EnchantStr(word)
+        word = self._StringClass(word)
         _e.dict_add(self._this,word.encode())
 
     def remove(self,word):
         """Add a word to the user's personal exclude list."""
         self._check_this()
-        word = EnchantStr(word)
+        word = self._StringClass(word)
         _e.dict_remove(self._this,word.encode())
 
     def add_to_pwl(self,word):
@@ -668,31 +684,31 @@ class Dict(_EnchantObject):
         warnings.warn("Dict.add_to_pwl is deprecated, please use Dict.add",
                       category=DeprecationWarning,stacklevel=2)
         self._check_this()
-        word = EnchantStr(word)
+        word = self._StringClass(word)
         _e.dict_add_to_pwl(self._this,word.encode())
 
     def add_to_session(self,word):
         """Add a word to the session personal list."""
         self._check_this()
-        word = EnchantStr(word)
+        word = self._StringClass(word)
         _e.dict_add_to_session(self._this,word.encode())
 
     def remove_from_session(self,word):
         """Add a word to the session exclude list."""
         self._check_this()
-        word = EnchantStr(word)
+        word = self._StringClass(word)
         _e.dict_remove_from_session(self._this,word.encode())
 
     def is_added(self,word):
         """Check whether a word is in the personal word list."""
         self._check_this()
-        word = EnchantStr(word)
+        word = self._StringClass(word)
         return _e.dict_is_added(self._this,word.encode())
 
     def is_removed(self,word):
         """Check whether a word is in the personal exclude list."""
         self._check_this()
-        word = EnchantStr(word)
+        word = self._StringClass(word)
         return _e.dict_is_removed(self._this,word.encode())
 
     def is_in_session(self,word):
@@ -701,13 +717,13 @@ class Dict(_EnchantObject):
                       "please use Dict.is_added",
                       category=DeprecationWarning,stacklevel=2)
         self._check_this()
-        word = EnchantStr(word)
+        word = self._StringClass(word)
         return _e.dict_is_in_session(self._this,word.encode())
 
     def store_replacement(self,mis,cor):
         """Store a replacement spelling for a miss-spelled word.
-        
-        This method makes a suggestion to the spellchecking engine that the 
+
+        This method makes a suggestion to the spellchecking engine that the
         miss-spelled word <mis> is in fact correctly spelled as <cor>.  Such
         a suggestion will typically mean that <cor> appears early in the
         list of suggested spellings offered for later instances of <mis>.
@@ -717,14 +733,14 @@ class Dict(_EnchantObject):
         if not cor:
             raise ValueError("can't store empty string as a replacement")
         self._check_this()
-        mis = EnchantStr(mis)
-        cor = EnchantStr(cor)
+        mis = self._StringClass(mis)
+        cor = self._StringClass(cor)
         _e.dict_store_replacement(self._this,mis.encode(),cor.encode())
     store_replacement._DOC_ERRORS = ["mis","mis"]
 
     def __describe(self,check_this=True):
         """Return a tuple describing the dictionary.
-        
+
         This method returns a four-element tuple describing the underlying
         spellchecker system providing the dictionary.  It will contain the
         following strings:
@@ -744,7 +760,7 @@ class Dict(_EnchantObject):
 
     def __describe_callback(self,tag,name,desc,file):
         """Collector callback for dictionary description.
-        
+
         This method is used as a callback into the _enchant function
         'enchant_dict_describe'.  It collects the given arguments in
         a tuple and stores them in the attribute '__describe_result'.
@@ -764,7 +780,7 @@ class DictWithPWL(Dict):
            exclude list.  This class is now only needed if you want
            to explicitly maintain a separate word list in addition to
            the default one.
-    
+
     This class behaves as the standard Dict class, but also manages a
     personal word list stored in a separate file.  The file must be
     specified at creation time by the 'pwl' argument to the constructor.
@@ -777,15 +793,15 @@ class DictWithPWL(Dict):
     If either 'pwl' or 'pel' are None, an in-memory word list is used.
     This will prevent calls to add() and remove() from affecting the user's
     default word lists.
-    
+
     The Dict object managing the PWL is available as the 'pwl' attribute.
     The Dict object managing the PEL is available as the 'pel' attribute.
-    
+
     To create a DictWithPWL from the user's default language, use None
     as the 'tag' argument.
     """
     _DOC_ERRORS = ["pel","pel","PEL","pel"]
-    
+
     def __init__(self,tag,pwl=None,pel=None,broker=None):
         """DictWithPWL constructor.
 
@@ -814,7 +830,7 @@ class DictWithPWL(Dict):
             self.pel = self._broker.request_pwl_dict(pel)
         else:
             self.pel = PyPWL()
-     
+
     def _check_this(self,msg=None):
        """Extend Dict._check_this() to check PWL validity."""
        if self.pwl is None:
@@ -834,10 +850,10 @@ class DictWithPWL(Dict):
             self.pel._free()
             self.pel = None
         Dict._free(self)
-        
+
     def check(self,word):
         """Check spelling of a word.
-        
+
         This method takes a word in the dictionary language and returns
         True if it is correctly spelled, and false otherwise.  It checks
         both the dictionary and the personal word list.
@@ -852,7 +868,7 @@ class DictWithPWL(Dict):
 
     def suggest(self,word):
         """Suggest possible spellings for a word.
-        
+
         This method tries to guess the correct spelling for a given
         word, returning the possibilities in a list.
         """
@@ -865,7 +881,7 @@ class DictWithPWL(Dict):
 
     def add(self,word):
         """Add a word to the associated personal word list.
-        
+
         This method adds the given word to the personal word list, and
         automatically saves the list to disk.
         """
@@ -881,7 +897,7 @@ class DictWithPWL(Dict):
 
     def add_to_pwl(self,word):
         """Add a word to the associated personal word list.
-        
+
         This method adds the given word to the personal word list, and
         automatically saves the list to disk.
         """
@@ -917,7 +933,7 @@ def get_enchant_version():
     return _e.get_version()
 
 
-# Run unit tests when called from comand-line
+# Run unit tests when called from command-line
 if __name__ == "__main__":
     import sys
     import enchant.tests
@@ -925,4 +941,3 @@ if __name__ == "__main__":
     if len(res.errors) > 0 or len(res.failures) > 0:
         sys.exit(1)
     sys.exit(0)
-
diff --git a/enchant/_enchant.py b/enchant/_enchant.py
index 5f047bb..a07058d 100644
--- a/enchant/_enchant.py
+++ b/enchant/_enchant.py
@@ -9,7 +9,7 @@
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPsE.  See the GNU
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # Lesser General Public License for more details.
 #
 # You should have received a copy of the GNU Lesser General Public
@@ -113,10 +113,12 @@ if e is None and sys.platform == "darwin":
   else:
       # Enchant doesn't natively support relocatable binaries on OSX.
       # We fake it by patching the enchant source to expose a char**, which
-      # we can write the runtime path into ourelves.
+      # we can write the runtime path into ourselves.
       e = CDLL(e_path)
       try:
           e_dir = os.path.dirname(os.path.dirname(e_path))
+          if isinstance(e_dir,unicode):
+              e_dir = e_dir.encode(sys.getfilesystemencoding())
           prefix_dir = POINTER(c_char_p).in_dll(e,"enchant_prefix_dir_p")
           prefix_dir.contents = c_char_p(e_dir)
       except AttributeError:
diff --git a/enchant/checker/GtkSpellCheckerDialog.py b/enchant/checker/GtkSpellCheckerDialog.py
index 3c3b5b9..afd1948 100644
--- a/enchant/checker/GtkSpellCheckerDialog.py
+++ b/enchant/checker/GtkSpellCheckerDialog.py
@@ -79,8 +79,8 @@ class GtkSpellCheckerDialog(gtk.Window):
         hbox.pack_start(box1,padding=5)
         conditional(box1)
 
-        # unreconized word
-        text_view_lable = gtk.Label('Unreconized word')
+        # unrecognized word
+        text_view_lable = gtk.Label('Unrecognized word')
         text_view_lable.set_justify(gtk.JUSTIFY_LEFT)
         box1.pack_start(text_view_lable,False,False)
 
@@ -222,7 +222,7 @@ class GtkSpellCheckerDialog(gtk.Window):
             model.append([value,])
 
     def setSpellChecker(self,checker):
-        assert checker,'checker cant be None'
+        assert checker, "checker can't be None"
         self._checker = checker
         self._dict_lable.set_text('Dictionary:%s'%(checker.dict.tag,))
 
diff --git a/enchant/checker/tests.py b/enchant/checker/tests.py
index ac0c683..45b9d12 100644
--- a/enchant/checker/tests.py
+++ b/enchant/checker/tests.py
@@ -234,7 +234,7 @@ class TestChecker(unittest.TestCase):
         for i,err in enumerate(chkr):
             err.replace("SPAM")
             assert i < 3
-        self.assertEquals(chkr.get_text(),". I SPAM SPAM SPAM.")
+        self.assertEqual(chkr.get_text(),". I SPAM SPAM SPAM.")
 
     def test_replace_with_empty_string(self):
         """Testcase for replacing with an empty string (bug #10)"""
@@ -243,7 +243,7 @@ class TestChecker(unittest.TestCase):
         for i,err in enumerate(chkr):
             err.replace("")
             assert i < 3
-        self.assertEquals(chkr.get_text(),". I   .")
+        self.assertEqual(chkr.get_text(),". I   .")
 
 
  
diff --git a/enchant/errors.py b/enchant/errors.py
index 8b8aaf1..c38209c 100644
--- a/enchant/errors.py
+++ b/enchant/errors.py
@@ -9,7 +9,7 @@
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPsE.  See the GNU
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # Lesser General Public License for more details.
 #
 # You should have received a copy of the GNU Lesser General Public
diff --git a/enchant/tests.py b/enchant/tests.py
index 7085cf1..737c013 100644
--- a/enchant/tests.py
+++ b/enchant/tests.py
@@ -9,7 +9,7 @@
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPsE.  See the GNU
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # Lesser General Public License for more details.
 #
 # You should have received a copy of the GNU Lesser General Public
@@ -130,7 +130,7 @@ class TestBroker(unittest.TestCase):
                 self.assertEqual((d.provider,tag),(prov,tag))
                 del d
                 del b2
-        # Place providers that dont have the language in the ordering
+        # Place providers that don't have the language in the ordering
         for tag in langs:
             for prov in langs[tag]:
                 order = prov.name
@@ -185,6 +185,7 @@ class TestDict(unittest.TestCase):
         self.assertTrue(self.dict.check("test"))
         self.assertFalse(self.dict.check("helo"))
         self.assertFalse(self.dict.check("testt"))
+        self.assertRaises(ValueError, self.dict.check, "")
         
     def test_broker(self):
         """Test that the dict's broker is set correctly."""
@@ -198,6 +199,7 @@ class TestDict(unittest.TestCase):
         """Test that suggest() gets simple suggestions right."""
         self.assertTrue(self.dict.check("hello"))
         self.assertTrue("hello" in self.dict.suggest("helo"))
+        self.assertRaises(ValueError, self.dict.suggest, "")
 
     def test_suggestHang1(self):
         """Test whether suggest() hangs on some inputs (Bug #1404196)"""
@@ -250,7 +252,7 @@ class TestDict(unittest.TestCase):
         """Test behaviour of default language selection."""
         defLang = utils.get_default_language()
         if defLang is None:
-            # If no default language, shouldnt work
+            # If no default language, shouldn't work
             self.assertRaises(Error,Dict)
         else:
             # If there is a default language, should use it
@@ -262,7 +264,7 @@ class TestDict(unittest.TestCase):
                 pass
 
     def test_pickling(self):
-        """Test that pickling doensn't corrupt internal state."""
+        """Test that pickling doesn't corrupt internal state."""
         d1 = Dict("en")
         self.assertTrue(d1.check("hello"))
         d2 = pickle.loads(pickle.dumps(d1))
@@ -413,12 +415,12 @@ class TestUtils(unittest.TestCase):
     def test_trim_suggestions(self):
         word = "gud"
         suggs = ["good","god","bad+"]
-        self.assertEquals(trim_suggestions(word,suggs,40),["god","good","bad+"])
-        self.assertEquals(trim_suggestions(word,suggs,4),["god","good","bad+"])
-        self.assertEquals(trim_suggestions(word,suggs,3),["god","good","bad+"])
-        self.assertEquals(trim_suggestions(word,suggs,2),["god","good"])
-        self.assertEquals(trim_suggestions(word,suggs,1),["god"])
-        self.assertEquals(trim_suggestions(word,suggs,0),[])
+        self.assertEqual(trim_suggestions(word,suggs,40),["god","good","bad+"])
+        self.assertEqual(trim_suggestions(word,suggs,4),["god","good","bad+"])
+        self.assertEqual(trim_suggestions(word,suggs,3),["god","good","bad+"])
+        self.assertEqual(trim_suggestions(word,suggs,2),["god","good"])
+        self.assertEqual(trim_suggestions(word,suggs,1),["god"])
+        self.assertEqual(trim_suggestions(word,suggs,0),[])
 
 
 class TestDocStrings(unittest.TestCase):
@@ -436,7 +438,7 @@ class TestDocStrings(unittest.TestCase):
              "spellchecker","dialog","urls","wikiwords","enchantobject",
              "providerdesc", "spellcheck", "pwl", "aspell", "myspell",
              "docstring", "docstrings", "stopiteration", "pwls","pypwl",
-             "dictwithpwl","skippable","dicts","dict's","filenames",
+             "dictwithpwl","skippable","dicts","dict's","filenames","fr",
              "trie","api","ctypes","wxspellcheckerdialog","stateful",
              "cmdlinechecker","spellchecks","callback","clunkier","iterator",
              "ispell","cor","backends","subclasses","initialise","runtime"]
diff --git a/enchant/tokenize/__init__.py b/enchant/tokenize/__init__.py
index 4e65be4..9a09871 100644
--- a/enchant/tokenize/__init__.py
+++ b/enchant/tokenize/__init__.py
@@ -76,7 +76,7 @@ be at least partially suitable for other languages.
 
 This module also provides various implementations of "Chunkers" and
 "Filters".  These classes are designed to make it easy to work with
-text in a vareity of common formats, by detecting and excluding parts
+text in a variety of common formats, by detecting and excluding parts
 of the text that don't need to be checked.
 
 A Chunker is a class designed to break a body of text into large chunks
@@ -86,11 +86,11 @@ A Filter is a class designed to skip individual words during the checking
 process; for example the URLFilter class skips over any words that
 have the format of a URL.
 
-For exmaple, to spellcheck an HTML document it is necessary to split the
+For example, to spellcheck an HTML document it is necessary to split the
 text into chunks based on HTML tags, and to filter out common word forms
 such as URLs and WikiWords.  This would look something like the following::
 
-    tknzr = get_tokenier("en_US",(HTMLChunker,),(URLFilter,WikiWordFilter)))
+    tknzr = get_tokenizer("en_US",(HTMLChunker,),(URLFilter,WikiWordFilter)))
 
     text = "<html><body>the url is http://example.com</body></html>"
     for (word,pos) in tknzer(text):
@@ -108,7 +108,7 @@ import enchant
 from enchant.utils import next, xrange
 from enchant.errors import *
 
-#  For backwards-compatability.  This will eventually be removed, but how
+#  For backwards-compatibility.  This will eventually be removed, but how
 #  does one mark a module-level constant as deprecated?
 Error = TokenizerNotFoundError
 
@@ -166,7 +166,7 @@ def get_tokenizer(tag=None,chunkers=None,filters=None):
     If a suitable function cannot be found, raises TokenizerNotFoundError.
     
     If given and not None, 'chunkers' and 'filters' must be lists of chunker
-    classes and filter classes resectively.  These will be applied to the
+    classes and filter classes respectively.  These will be applied to the
     tokenizer during creation.
     """
     if tag is None:
@@ -276,7 +276,7 @@ class basic_tokenize(tokenize):
                 sPos += 1
             while 0 < ePos and text[ePos-1] in self.strip_from_end:
                     ePos -= 1
-            # Return if word isnt empty
+            # Return if word isn't empty
             if(sPos < ePos):
                 return (text[sPos:ePos],sPos)
         raise StopIteration()
@@ -395,17 +395,17 @@ class Filter(object):
         def next(self):
             # Try to get the next sub-token from word currently being split.
             # If unavailable, move on to the next word and try again.
-            try:
-                (word,pos) = next(self._curtok)
-                return (word,pos + self._curpos)
-            except StopIteration:
-                (word,pos) = next(self._tokenizer)
-                while self._skip(self._to_string(word)):
+            while True:
+                try:
+                    (word,pos) = next(self._curtok)
+                    return (word,pos + self._curpos)
+                except StopIteration:
                     (word,pos) = next(self._tokenizer)
-                self._curword = word
-                self._curpos = pos
-                self._curtok = self._split(word)
-                return self.next()
+                    while self._skip(self._to_string(word)):
+                        (word,pos) = next(self._tokenizer)
+                    self._curword = word
+                    self._curpos = pos
+                    self._curtok = self._split(word)
 
         def _to_string(self, word):
             if type(word) is array.array:
@@ -452,12 +452,12 @@ class URLFilter(Filter):
     """Filter skipping over URLs.
     This filter skips any words matching the following regular expression:
        
-           ^[a-zA-z]+:\/\/[^\s].*
+           ^[a-zA-Z]+:\/\/[^\s].*
         
     That is, any words that are URLs.
     """
     _DOC_ERRORS = ["zA"]
-    _pattern = re.compile(r"^[a-zA-z]+:\/\/[^\s].*")
+    _pattern = re.compile(r"^[a-zA-Z]+:\/\/[^\s].*")
     def _skip(self,word):
         if self._pattern.match(word):
             return True
@@ -525,7 +525,7 @@ class HTMLChunker(Chunker):
                 offset += 1
             ePos = offset
             self._offset = offset
-            # Return if chunk isnt empty
+            # Return if chunk isn't empty
             if(sPos < offset):
                 return (text[sPos:offset],sPos)
         raise StopIteration()
diff --git a/enchant/tokenize/en.py b/enchant/tokenize/en.py
index 1354c43..a849162 100644
--- a/enchant/tokenize/en.py
+++ b/enchant/tokenize/en.py
@@ -161,7 +161,7 @@ class tokenize(enchant.tokenize.tokenize):
                     else:
                         break
                 offset += incr
-            # Return if word isnt empty
+            # Return if word isn't empty
             if(curPos != offset):
                 # Make sure word doesn't end with a valid_char
                 while text[offset-1] in self._valid_chars:
diff --git a/enchant/utils.py b/enchant/utils.py
index aa2c8fb..2a05c76 100644
--- a/enchant/utils.py
+++ b/enchant/utils.py
@@ -31,21 +31,21 @@
 
 enchant.utils:    Misc utilities for the enchant package
 ========================================================
-    
+
 This module provides miscellaneous utilities for use with the
 enchant spellchecking package.  Currently available functionality
 includes:
-        
+
     * string/unicode compatibility wrappers
     * functions for dealing with locale/language settings
     * ability to list supporting data files (win32 only)
     * functions for bundling supporting data files from a build
-      
+
 """
 
+import codecs
 import os
 import sys
-import codecs
 
 from enchant.errors import *
 
@@ -57,7 +57,7 @@ except ImportError:
 
 
... 282 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pyenchant.git



More information about the Python-modules-commits mailing list