Newlines in plot descriptions and maintaining visual structure
#1
Greetings. I am running into newline characters embedded within a plot description, which blows things up with the classic EOL seen while parsing single quoted string problem. I could always tack on a .replace('\n', ' ') on the end, but that would wreck the visual layout. I've done significant searching both in here and general python documentation but haven't found anything. How to cope with this situation or perhaps keywords I could use for more targeted searching would be greatly appreciated. Thanks!
Reply
#2
s/\n/[CR]/g

prior to passing it to the textbox/whatever
Reply
#3
I believe the appropriate word here is "doh!" followed by smacking myself in the forehead.
Reply
#4
Well, that stopped it from blowing up, but it also eliminated the overall structure of the plot listing -- it's now one big glob.
Reply
#5
if lines are too large to fit we will chop them disregarding the formatting. not much else one can do...
Reply
#6
It's not that they are too large, as the entire plot does display, but, rather, I am losing the original formatting...

Original (there are 0A's at the end of each line):
paragraph1
paragraph2
paragraph3

When run through the replace above it comes out as:
paragraph1 paragraph2 paragraph3

which while not losing any info, doesn't look quite as nice as the original. I believe the problem is passing it through something like this, and it seeing the embedded 0A's as the EOL and consequently going bang.

Code:
class _Info:
    def __init__( self, *args, **kwargs ):
        self.__dict__.update( kwargs )

exec "args = _Info(%s)" % (urllib.unquote_plus(sys.argv[2][1:].replace("&", ", ").replace('"','\'')), )
Reply
#7
Any ideas, please? Putting out the plot in a blob is just plain ugly.
Reply
#8
quote_plus(plot)

unquote_plus(plot)

both are in the urllib module
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#9
Will give that a shot. Thanks!
Reply
#10
forgot the repr()

quote_plus(repr(plot))
unquote_plus(repr(plot))
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply

Logout Mark Read Team Forum Stats Members Help
Newlines in plot descriptions and maintaining visual structure0