Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #36514
| References | (6 earlier) <50eafb00$0$287$14726298@news.sunsite.dk> <mailman.280.1357659111.2939.python-list@python.org> <50ed336f$0$284$14726298@news.sunsite.dk> <mailman.310.1357726998.2939.python-list@python.org> <50ed4eaf$0$284$14726298@news.sunsite.dk> |
|---|---|
| Date | 2013-01-09 10:25 -0800 |
| From | chaouche yacine <yacinechaouche@yahoo.com> |
| Subject | Re: How to modify this script? |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.333.1357756068.2939.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
Indeed, the console shows a traceback where data is misinterpreted, maybe due to my triple protective quotes around $GEDIT_SELECTED_TEXT. Try without them, like so (it worked for me) :
$<
def addline(line):
return "<tr\>%s</tr\>\n" % line
def addcolumn(item,nb_columns):
if nb_columns != 3:
return "<td colspan='%s'\>%s</td\>" % (3 - nb_columns + 1, item)
return "<td\>%s</td\>" % item
output = "<table\>\n"
selected_text = $GEDIT_SELECTED_TEXT
for line in selected_text.split("\n"):
items = line.strip().split("\t")
columns = ""
for item in items :
columns += addcolumn(item,len(items))
output += addline(columns)
output += "</table\>"
return output>
________________________________
From: Kurt Hansen <kurt@ugyldig.invalid>
To: python-list@python.org
Sent: Wednesday, January 9, 2013 12:04 PM
Subject: Re: How to modify this script?
Den 09/01/13 11.23, chaouche yacine skrev:
> I figrued it out. Copy/paste exactly these lines in the snippets tool.
> You can bind it to a key as you may know, I bound it to Ctrl-E. So paste
> it in a new snippet (keep the original in a safe place), bind to a key,
> select the text you want to html-tableize and hit the key binding. In my
> case it worked.
>
> $<
[cut]
> def addline(line):
Spooky behavior. Yes, the green-apple-example also works for me with your new script, BUT ...!
Try to copy the table content on this page:
http://www.danacord.dk/frmsets/records/732-r.html
which is a realistic scenario. That's whar I am doing these days.
Pasting it into Gedit and running the snippet blanks the edit area (on MY Mac at least).
And yes: I have pasted your code excatly and I've double-checked for linewraps. Everything is okay.
For your cenvenience I have put borders on the table online (see link above). You may ommit the rows after track 14. Not that it makes any differerence, but that block is surposed to be formatted differerent. I do that manually afterwards ... if not ... ;-)
-- Regards
Kurt Hansen
-- http://mail.python.org/mailman/listinfo/python-list
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 13:42 +0100
Re: How to modify this script? Chris Angelico <rosuav@gmail.com> - 2013-01-06 23:52 +1100
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 14:34 +0100
Re: How to modify this script? Chris Angelico <rosuav@gmail.com> - 2013-01-07 00:44 +1100
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 15:03 +0100
Re: How to modify this script? Chris Angelico <rosuav@gmail.com> - 2013-01-07 01:20 +1100
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 15:30 +0100
Re: How to modify this script? Chris Angelico <rosuav@gmail.com> - 2013-01-07 01:41 +1100
Re: How to modify this script? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-01-08 15:18 +0100
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-09 10:21 +0100
Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-06 04:58 -0800
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 14:38 +0100
Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-06 06:01 -0800
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 15:21 +0100
Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-06 07:12 -0800
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-07 17:42 +0100
Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-08 07:31 -0800
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-09 10:07 +0100
Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-09 02:23 -0800
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-09 12:04 +0100
Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-09 10:25 -0800
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-11 05:35 +0100
Re: How to modify this script? Subimal Deb <subimal.deb@gmail.com> - 2013-01-06 06:22 -0800
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 15:40 +0100
Re: How to modify this script? Chris Angelico <rosuav@gmail.com> - 2013-01-07 01:52 +1100
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 16:05 +0100
Re: How to modify this script? Gertjan Klein <gklein@xs4all.nl> - 2013-01-07 18:56 +0100
Re: How to modify this script? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-01-08 15:22 +0100
Re: How to modify this script? Gertjan Klein <gklein@xs4all.nl> - 2013-01-08 17:22 +0100
csiph-web