Mercurial > hg
comparison hgext/releasenotes.py @ 34812:bc2caa4b4480
releasenotes: move import of fuzzywuzzy to import level
This will help us in determining easily that whether fuzzywuzzy is loaded or not
loaded in any of the function.
Differential Revision: https://phab.mercurial-scm.org/D1120
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Mon, 16 Oct 2017 22:46:11 +0530 |
parents | a542ad320adb |
children | 288fad8c55f9 |
comparison
equal
deleted
inserted
replaced
34811:a542ad320adb | 34812:bc2caa4b4480 |
---|---|
30 util, | 30 util, |
31 ) | 31 ) |
32 | 32 |
33 cmdtable = {} | 33 cmdtable = {} |
34 command = registrar.command(cmdtable) | 34 command = registrar.command(cmdtable) |
35 | |
36 try: | |
37 import fuzzywuzzy.fuzz as fuzz | |
38 fuzz.token_set_ratio | |
39 except ImportError: | |
40 fuzz = None | |
35 | 41 |
36 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | 42 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
37 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | 43 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
38 # be specifying the version(s) of Mercurial they are tested with, or | 44 # be specifying the version(s) of Mercurial they are tested with, or |
39 # leave the attribute unspecified. | 45 # leave the attribute unspecified. |
217 | 223 |
218 def similaritycheck(incoming_str, existingnotes): | 224 def similaritycheck(incoming_str, existingnotes): |
219 """ | 225 """ |
220 Returns false when note fragment can be merged to existing notes. | 226 Returns false when note fragment can be merged to existing notes. |
221 """ | 227 """ |
222 try: | 228 # fuzzywuzzy not present |
223 import fuzzywuzzy.fuzz as fuzz | 229 if not fuzz: |
224 fuzz.token_set_ratio | |
225 except ImportError: | |
226 return True | 230 return True |
227 | 231 |
228 merge = True | 232 merge = True |
229 for bullet in existingnotes: | 233 for bullet in existingnotes: |
230 score = fuzz.token_set_ratio(incoming_str, bullet) | 234 score = fuzz.token_set_ratio(incoming_str, bullet) |