[Python-modules-commits] [fuzzywuzzy] 01/03: Import fuzzywuzzy_0.7.0.orig.tar.gz

Edward Betts edward at moszumanska.debian.org
Mon Oct 19 13:11:31 UTC 2015


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

edward pushed a commit to branch master
in repository fuzzywuzzy.

commit a512e645dde321132c1ca6025bf4a30983f0090c
Author: Edward Betts <edward at 4angle.com>
Date:   Mon Oct 19 14:00:19 2015 +0100

    Import fuzzywuzzy_0.7.0.orig.tar.gz
---
 CHANGES.rst                     | 20 ++++++++++++++++++++
 PKG-INFO                        |  8 ++++----
 README                          |  6 +++---
 README.rst                      |  6 +++---
 fuzzywuzzy.egg-info/PKG-INFO    |  8 ++++----
 fuzzywuzzy.egg-info/SOURCES.txt |  1 +
 fuzzywuzzy.egg-info/pbr.json    |  1 +
 fuzzywuzzy/__init__.py          |  2 +-
 fuzzywuzzy/fuzz.py              | 33 ++++++---------------------------
 fuzzywuzzy/process.py           |  4 ++--
 fuzzywuzzy/utils.py             | 19 +++++++++++++++++++
 test_fuzzywuzzy.py              | 34 ++++++++++++++++++++++++++++++++++
 12 files changed, 98 insertions(+), 44 deletions(-)

diff --git a/CHANGES.rst b/CHANGES.rst
index 8918615..37cfdb5 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,6 +1,26 @@
 Changelog
 =========
 
+0.7.0 (2015-10-02)
+------------------
+
+- Use portable syntax for catching exception on tests. [Luis Madrigal]
+
+- [Fix] test against correct variable. [Luis Madrigal]
+
+- Add unit tests for validator decorators. [Luis Madrigal]
+
+- Move validators to decorator functions. [Luis Madrigal]
+
+  This allows easier composition and IMO makes the functions more readable
+
+
+- Fix typo: dictionery -> dictionary. [shale]
+
+- FizzyWuzzy -> FuzzyWuzzy typo correction. [shale]
+
+- Add check for gitchangelog. [Jose Diaz-Gonzalez]
+
 0.6.2 (2015-09-03)
 ------------------
 
diff --git a/PKG-INFO b/PKG-INFO
index 0bfa877..44c44cb 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: fuzzywuzzy
-Version: 0.6.2
+Version: 0.7.0
 Summary: Fuzzy string matching in python
 Home-page: https://github.com/seatgeek/fuzzywuzzy
 Author: Adam Cohen
@@ -54,13 +54,13 @@ Description: |Build Status|
         
         .. code:: bash
         
-            pip install git+git://github.com/seatgeek/fuzzywuzzy.git@0.6.2#egg=fuzzywuzzy
+            pip install git+git://github.com/seatgeek/fuzzywuzzy.git@0.7.0#egg=fuzzywuzzy
         
         Adding to your ``requirements.txt`` file (run ``pip install -r requirements.txt`` afterwards)
         
         .. code:: bash
         
-            git+ssh://git@github.com/seatgeek/fuzzywuzzy.git@0.6.2#egg=fuzzywuzzy
+            git+ssh://git@github.com/seatgeek/fuzzywuzzy.git@0.7.0#egg=fuzzywuzzy
             
         Manually via GIT
         
@@ -131,7 +131,7 @@ Description: |Build Status|
         
         Known Ports
         ============
-        Some people are porting FizzyWuzzy to other languages. Here is one port we know about:
+        Some people are porting FuzzyWuzzy to other languages. Here is one port we know about:
         
         -  Java: https://github.com/WantedTechnologies/xpresso/wiki/Approximate-string-comparison-and-pattern-matching-in-Java
         
diff --git a/README b/README
index 9ad27f6..2044a24 100644
--- a/README
+++ b/README
@@ -26,13 +26,13 @@ Using PIP via Github
 
 .. code:: bash
 
-    pip install git+git://github.com/seatgeek/fuzzywuzzy.git@0.6.2#egg=fuzzywuzzy
+    pip install git+git://github.com/seatgeek/fuzzywuzzy.git@0.7.0#egg=fuzzywuzzy
 
 Adding to your ``requirements.txt`` file (run ``pip install -r requirements.txt`` afterwards)
 
 .. code:: bash
 
-    git+ssh://git@github.com/seatgeek/fuzzywuzzy.git@0.6.2#egg=fuzzywuzzy
+    git+ssh://git@github.com/seatgeek/fuzzywuzzy.git@0.7.0#egg=fuzzywuzzy
     
 Manually via GIT
 
@@ -103,6 +103,6 @@ Process
 
 Known Ports
 ============
-Some people are porting FizzyWuzzy to other languages. Here is one port we know about:
+Some people are porting FuzzyWuzzy to other languages. Here is one port we know about:
 
 -  Java: https://github.com/WantedTechnologies/xpresso/wiki/Approximate-string-comparison-and-pattern-matching-in-Java
diff --git a/README.rst b/README.rst
index 9ad27f6..2044a24 100644
--- a/README.rst
+++ b/README.rst
@@ -26,13 +26,13 @@ Using PIP via Github
 
 .. code:: bash
 
-    pip install git+git://github.com/seatgeek/fuzzywuzzy.git@0.6.2#egg=fuzzywuzzy
+    pip install git+git://github.com/seatgeek/fuzzywuzzy.git@0.7.0#egg=fuzzywuzzy
 
 Adding to your ``requirements.txt`` file (run ``pip install -r requirements.txt`` afterwards)
 
 .. code:: bash
 
-    git+ssh://git@github.com/seatgeek/fuzzywuzzy.git@0.6.2#egg=fuzzywuzzy
+    git+ssh://git@github.com/seatgeek/fuzzywuzzy.git@0.7.0#egg=fuzzywuzzy
     
 Manually via GIT
 
@@ -103,6 +103,6 @@ Process
 
 Known Ports
 ============
-Some people are porting FizzyWuzzy to other languages. Here is one port we know about:
+Some people are porting FuzzyWuzzy to other languages. Here is one port we know about:
 
 -  Java: https://github.com/WantedTechnologies/xpresso/wiki/Approximate-string-comparison-and-pattern-matching-in-Java
diff --git a/fuzzywuzzy.egg-info/PKG-INFO b/fuzzywuzzy.egg-info/PKG-INFO
index 0bfa877..44c44cb 100644
--- a/fuzzywuzzy.egg-info/PKG-INFO
+++ b/fuzzywuzzy.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: fuzzywuzzy
-Version: 0.6.2
+Version: 0.7.0
 Summary: Fuzzy string matching in python
 Home-page: https://github.com/seatgeek/fuzzywuzzy
 Author: Adam Cohen
@@ -54,13 +54,13 @@ Description: |Build Status|
         
         .. code:: bash
         
-            pip install git+git://github.com/seatgeek/fuzzywuzzy.git@0.6.2#egg=fuzzywuzzy
+            pip install git+git://github.com/seatgeek/fuzzywuzzy.git@0.7.0#egg=fuzzywuzzy
         
         Adding to your ``requirements.txt`` file (run ``pip install -r requirements.txt`` afterwards)
         
         .. code:: bash
         
-            git+ssh://git@github.com/seatgeek/fuzzywuzzy.git@0.6.2#egg=fuzzywuzzy
+            git+ssh://git@github.com/seatgeek/fuzzywuzzy.git@0.7.0#egg=fuzzywuzzy
             
         Manually via GIT
         
@@ -131,7 +131,7 @@ Description: |Build Status|
         
         Known Ports
         ============
-        Some people are porting FizzyWuzzy to other languages. Here is one port we know about:
+        Some people are porting FuzzyWuzzy to other languages. Here is one port we know about:
         
         -  Java: https://github.com/WantedTechnologies/xpresso/wiki/Approximate-string-comparison-and-pattern-matching-in-Java
         
diff --git a/fuzzywuzzy.egg-info/SOURCES.txt b/fuzzywuzzy.egg-info/SOURCES.txt
index 14ac5fb..165a540 100644
--- a/fuzzywuzzy.egg-info/SOURCES.txt
+++ b/fuzzywuzzy.egg-info/SOURCES.txt
@@ -15,5 +15,6 @@ fuzzywuzzy/utils.py
 fuzzywuzzy.egg-info/PKG-INFO
 fuzzywuzzy.egg-info/SOURCES.txt
 fuzzywuzzy.egg-info/dependency_links.txt
+fuzzywuzzy.egg-info/pbr.json
 fuzzywuzzy.egg-info/top_level.txt
 fuzzywuzzy.egg-info/zip-safe
\ No newline at end of file
diff --git a/fuzzywuzzy.egg-info/pbr.json b/fuzzywuzzy.egg-info/pbr.json
new file mode 100644
index 0000000..7bebd3d
--- /dev/null
+++ b/fuzzywuzzy.egg-info/pbr.json
@@ -0,0 +1 @@
+{"is_release": true, "git_version": "11d2b58"}
\ No newline at end of file
diff --git a/fuzzywuzzy/__init__.py b/fuzzywuzzy/__init__.py
index 6e2b168..28b1b2f 100644
--- a/fuzzywuzzy/__init__.py
+++ b/fuzzywuzzy/__init__.py
@@ -1,2 +1,2 @@
 # -*- coding: utf-8 -*-
-__version__ = '0.6.2'
+__version__ = '0.7.0'
diff --git a/fuzzywuzzy/fuzz.py b/fuzzywuzzy/fuzz.py
index 19926c4..e7560e1 100644
--- a/fuzzywuzzy/fuzz.py
+++ b/fuzzywuzzy/fuzz.py
@@ -40,33 +40,22 @@ from . import utils
 # Basic Scoring Functions #
 ###########################
 
+ at utils.check_for_none
+ at utils.check_empty_string
 def ratio(s1, s2):
-
-    if s1 is None:
-        raise TypeError("s1 is None")
-    if s2 is None:
-        raise TypeError("s2 is None")
     s1, s2 = utils.make_type_consistent(s1, s2)
 
-    if len(s1) == 0 or len(s2) == 0:
-        return 0
-
     m = SequenceMatcher(None, s1, s2)
     return utils.intr(100 * m.ratio())
 
 
 # todo: skip duplicate indexes for a little more speed
+ at utils.check_for_none
+ at utils.check_empty_string
 def partial_ratio(s1, s2):
     """"Return the ratio of the most similar substring
     as a number between 0 and 100."""
-
-    if s1 is None:
-        raise TypeError("s1 is None")
-    if s2 is None:
-        raise TypeError("s2 is None")
     s1, s2 = utils.make_type_consistent(s1, s2)
-    if len(s1) == 0 or len(s2) == 0:
-        return 0
 
     if len(s1) <= len(s2):
         shorter = s1
@@ -118,13 +107,8 @@ def _process_and_sort(s, force_ascii):
 #   find all alphanumeric tokens in the string
 #   sort those tokens and take ratio of resulting joined strings
 #   controls for unordered string elements
+ at utils.check_for_none
 def _token_sort(s1, s2, partial=True, force_ascii=True):
-
-    if s1 is None:
-        raise TypeError("s1 is None")
-    if s2 is None:
-        raise TypeError("s2 is None")
-
     sorted1 = _process_and_sort(s1, force_ascii)
     sorted2 = _process_and_sort(s2, force_ascii)
 
@@ -147,7 +131,7 @@ def partial_token_sort_ratio(s1, s2, force_ascii=True):
     """
     return _token_sort(s1, s2, partial=True, force_ascii=force_ascii)
 
-
+ at utils.check_for_none
 def _token_set(s1, s2, partial=True, force_ascii=True):
     """Find all alphanumeric tokens in each string...
         - treat them as a set
@@ -156,11 +140,6 @@ def _token_set(s1, s2, partial=True, force_ascii=True):
         - take ratios of those two strings
         - controls for unordered partial matches"""
 
-    if s1 is None:
-        raise TypeError("s1 is None")
-    if s2 is None:
-        raise TypeError("s2 is None")
-
     p1 = utils.full_process(s1, force_ascii=force_ascii)
     p2 = utils.full_process(s2, force_ascii=force_ascii)
 
diff --git a/fuzzywuzzy/process.py b/fuzzywuzzy/process.py
index 2cba4d7..88eaa83 100644
--- a/fuzzywuzzy/process.py
+++ b/fuzzywuzzy/process.py
@@ -34,7 +34,7 @@ def extract(query, choices, processor=None, scorer=None, limit=5):
     """Select the best match in a list or dictionary of choices.
 
     Find best matches in a list or dictionary of choices, return a
-    list of tuples containing the match and it's score. If a dictionery
+    list of tuples containing the match and it's score. If a dictionary
     is used, also returns the key for each match.
 
     Arguments:
@@ -65,7 +65,7 @@ def extract(query, choices, processor=None, scorer=None, limit=5):
         List of tuples containing the match and its score.
 
         If a list is used for choices, then the result will be 2-tuples.
-        If a dictionery is used, then the result will be 3-tuples containing
+        If a dictionary is used, then the result will be 3-tuples containing
         he key for each match.
 
         For example, searching for 'bird' in the dictionary
diff --git a/fuzzywuzzy/utils.py b/fuzzywuzzy/utils.py
index 0534af0..be1baad 100644
--- a/fuzzywuzzy/utils.py
+++ b/fuzzywuzzy/utils.py
@@ -1,5 +1,6 @@
 from __future__ import unicode_literals
 import sys
+import functools
 
 from fuzzywuzzy.string_processing import StringProcessor
 
@@ -13,6 +14,24 @@ def validate_string(s):
     except TypeError:
         return False
 
+def check_for_none(func):
+    @functools.wraps(func)
+    def decorator(*args, **kwargs):
+        if args[0] is None:
+            raise TypeError("s1 is None")
+        if args[1] is None:
+            raise TypeError("s2 is None")
+        return func(*args, **kwargs)
+    return decorator
+
+def check_empty_string(func):
+    @functools.wraps(func)
+    def decorator(*args, **kwargs):
+        if len(args[0]) == 0 or len(args[1]) == 0:
+            return 0
+        return  func(*args, **kwargs)
+    return decorator
+
 bad_chars = str("").join([chr(i) for i in range(128, 256)])  # ascii dammit!
 if PY3:
     translation_table = dict((ord(c), None) for c in bad_chars)
diff --git a/test_fuzzywuzzy.py b/test_fuzzywuzzy.py
index 7abbab4..d5621ea 100644
--- a/test_fuzzywuzzy.py
+++ b/test_fuzzywuzzy.py
@@ -284,6 +284,40 @@ class RatioTest(unittest.TestCase):
         best = process.extractOne(query, self.baseball_strings)
         self.assertEqual(best[0], self.baseball_strings[0])
 
+class ValidatorTest(unittest.TestCase):
+    def setUp(self):
+        self.testFunc = lambda *args, **kwargs: (args, kwargs)
+
+    def testCheckForNone(self):
+        invalid_input = [
+            (None, None),
+            ('Some', None),
+            (None, 'Some')
+        ]
+        decorated_func = utils.check_for_none(self.testFunc)
+        for i in invalid_input:
+            self.assertRaises(TypeError, decorated_func, *i)
+
+        try:
+            valid_input = ['Some', 'Some']
+            decorated_func(*valid_input)
+        except ValueError as e:
+            self.fail('check_for_none matched non-None input', valid_input, e)
+
+    def testCheckEmptyString(self):
+        invalid_input = [
+            ('', ''),
+            ('Some', ''),
+            ('', 'Some')
+        ]
+        decorated_func = utils.check_empty_string(self.testFunc)
+        for i in invalid_input:
+            self.assertEqual(decorated_func(*i), 0)
+
+        valid_input = ('Some', 'Some')
+        actual = decorated_func(*valid_input)
+        self.assertNotEqual(actual, 0)
+
 
 class ProcessTest(unittest.TestCase):
 

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



More information about the Python-modules-commits mailing list