Try importing text_unidecode before unidecode

Issue #77 new
Former user created an issue

For our usages, we cannot use GPL packages so we must use alternatives like text_unidecode. To get this working, we have to monkey patch our code. Would it be possible to have WebHelpers attempt to import text_unidecode before it tries to load unidecode?

Comments (1)

  1. Sam Park

    I believe the core change would just be:

    diff --git a/webhelpers/text.py b/webhelpers/text.py
    index 8ec56a9..0e26501 100644
    --- a/webhelpers/text.py
    +++ b/webhelpers/text.py
    @@ -10,10 +10,14 @@ import urllib
    
     from webhelpers.html.tools import strip_tags
    
    +
     try:
    -    from unidecode import unidecode
    +    from text_unidecode import unidecode
     except ImportError:
    -    unidecode = None
    +    try:
    +        from unidecode import unidecode
    +    except ImportError:
    +        unidecode = None
    
     __all__ = [
         "chop_at",
    
  2. Log in to comment