Skip to content

Commit

Permalink
Make bodywidth kwarg overridable using config
Browse files Browse the repository at this point in the history
Default values for arguments are evaluated at import time.
This makes a problem when using html2text the following way:

    import html2text  # The default value is evaluated here
    html2text.config.BODY_WIDTH = 0
    text = html2text.html2text(html)

It is thus necessary to wait until the function runs to fetch the actual
configuration value.
  • Loading branch information
emillon committed Jun 29, 2015
1 parent b8415f8 commit 8f00e71
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion html2text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,9 @@ def optwrap(self, text):
return result


def html2text(html, baseurl='', bodywidth=config.BODY_WIDTH):
def html2text(html, baseurl='', bodywidth=None):
if bodywidth is None:
bodywidth = config.BODY_WIDTH
h = HTML2Text(baseurl=baseurl, bodywidth=bodywidth)

return h.handle(html)
Expand Down

0 comments on commit 8f00e71

Please sign in to comment.