Re: PyYAML multi-line strings
Joe Abbate <jma-ICVE9uepxrQgpMukQH3QewC/[email protected]>
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <[email protected]> |
On 28/11/12 20:37, Kirill Simonov wrote:
> PyYAML forces double-quote style on scalars with end-of-line whitespace.
> I think the rationale was that end-of-line whitespace could not be
> detected visually in block style.
>
> Here is the relevant code:
> http://pyyaml.org/browser/pyyaml/trunk/lib/yaml/emitter.py#L761
I have a slightly different problem, reported by someone who is using
Spanish accented characters. The data is stored in a UTF-8 encoded
Postgres database and fetched into Python. Under Python2, this caused
an infamous UnicodeError: ascii codec can't encode. Under Python3,
there was no error but the string wasn't shown in block style.
So I now decode the string from utf_8 into unicode under Python2 and use
a class the expects Python2 'unicode' class. Now the behavior under
Python2 is the same as Python3: no error but no block style either.
Here is some sample output, one with an accent, the other without:
view tfilm:
definition: " SELECT film.film_id, film.title,\n CASE\n
WHEN\
\ film.description IS NULL THEN 'Jur\xEDdico'::text\n
ELSE film.description\n\
\ END AS description\n FROM film;"
view tfilm_noaccent:
definition: |2-
SELECT film.film_id, film.title,
CASE
WHEN film.description IS NULL THEN 'Juridico'::text
ELSE film.description
END AS description
FROM film;
Is the problem because pyyaml can't handle the \xED embedded in the
string or is it something else? If the former, is there some workaround?
Happy 2013!
Joe
------------------------------------------------------------------------------
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612