diff options
author | DasIch <dasdasich@gmail.com> | 2010-08-16 08:18:10 +0200 |
---|---|---|
committer | DasIch <dasdasich@gmail.com> | 2010-08-16 08:18:10 +0200 |
commit | cf29a28446dd017193f509c8ca6403fc25995164 (patch) | |
tree | 3fb26b5c32a707ccdc0fa9edcece0d84026cb946 /sphinx/versioning.py | |
parent | 7707a73959b896eb496d4d45cb6431c35a6e2bec (diff) | |
download | sphinx-cf29a28446dd017193f509c8ca6403fc25995164.tar.gz |
Fix get_ratio for empty strings
Diffstat (limited to 'sphinx/versioning.py')
-rw-r--r-- | sphinx/versioning.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sphinx/versioning.py b/sphinx/versioning.py index 9a7cb2da..06acc63d 100644 --- a/sphinx/versioning.py +++ b/sphinx/versioning.py @@ -20,6 +20,9 @@ except ImportError: from sphinx.util import PeekableIterator +# anything below that ratio is considered equal/changed +VERSIONING_RATIO = 65 + def add_uids(doctree, condition): """ Adds a unique id to every node in the `doctree` which matches the condition @@ -88,7 +91,7 @@ def merge_doctrees(old, new, condition): continue else: seen.add(new_node) - if ratio < 65: + if ratio < VERSIONING_RATIO: new_node.uid = old_node.uid else: new_node.uid = uuid4().hex @@ -104,6 +107,8 @@ def get_ratio(old, new): Returns a "similiarity ratio" representing the similarity between the two strings where 0 is equal and anything above less than equal. """ + if not all([old, new]): + return VERSIONING_RATIO return levenshtein_distance(old, new) / (len(old) / 100.0) def levenshtein_distance(a, b): |