rennat / pynliner

Python CSS-to-inline-styles conversion tool for HTML using BeautifulSoup and cssutils
http://pythonhosted.org/pynliner/
181 stars 93 forks source link

Can't use pynliner - some errors #47

Open aktywnitu opened 8 years ago

aktywnitu commented 8 years ago

I have some code:

from pynliner import Pynliner
p=Pynliner().from_url('https://saturn.pl/')
p.run()

In Python 3:

"venv3/lib/python3.5/site-packages/pynliner/__init__.py", line 179, in _get_external_styles
    self.style_string += self._get_url(url)
TypeError: Can't convert 'bytes' object to str implicitly

In Python 2:

"venv2/local/lib/python2.7/site-packages/pynliner/__init__.py", line 179, in _get_external_styles
    self.style_string += self._get_url(url)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)
>>> pynliner.__version__
'0.7.1'

Please help me achieve result.

aktywnitu commented 8 years ago

Some errors corrected: self.style_string += self._get_url(url).decode('utf-8')

, but still new:

File "venv3/lib/python3.5/site-packages/pynliner/soupselect.py", line 110, in select
    raise Exception("No match was found. We're done or something is broken")
Exception: No match was found. We're done or something is broken
aktywnitu commented 8 years ago

ok, i see that pynliner not support some css selectors (for example "audio:not([controls])". Why pylinter don't continue after comming with unrecognized token - it raises exception, which make this library useless for many cases.

estevopaz commented 8 years ago

Why this patch: self._get_url(url).decode('utf-8') Is not applied to source code ?

utapyngo commented 7 years ago

@aktywnitu: does this PR fix your issue? https://github.com/rennat/pynliner/pull/55

utapyngo commented 7 years ago

@rennat We can't migrate to Python 3 because of this error. Is pynliner unmaintained?

rennat commented 7 years ago

Howdy @utapyngo , I do maintain pynliner but I don't actively use it on any projects anymore. This means I only get around to merging in PRs and making releases a few times a year. PR #55 looks fine. I hope to get to this before the new year. Thanks for being involved and making a pull request!

emiviada commented 7 years ago

Hey @rennat we need PR #55 merged to have Python 3 compatibility, are you planning to merge it soon? Thanks @utapyngo

rennat commented 7 years ago

PR #55 is merged and released in 0.8.0 @utapyngo @emiviada

@aktywnitu can you confirm if your issue is still happening on version 0.8.0?

vkrytpo commented 5 years ago

you can use any online cssinliner, if you wan't to use this for email. there are lot of option, just google it.