Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'output': 0.04; 'modify': 0.05; 'subject:How': 0.09; '"%s"': 0.09; '(it': 0.09; 'formatted': 0.09; 'indeed,': 0.09; 'rows': 0.09; 'script,': 0.09; 'snippet': 0.09; 'subject:script': 0.09; 'worked.': 0.09; 'def': 0.10; ';-)': 0.11; 'kurt': 0.11; '12:04': 0.16; 'bind': 0.16; 'binding.': 0.16; 'columns': 0.16; 'item)': 0.16; 'script?': 0.16; 'snippets': 0.16; 'tool.': 0.16; 'url:records': 0.16; 'to:name:python- list@python.org': 0.20; '(on': 0.22; 'skip:$ 20': 0.22; 'wednesday,': 0.22; '>': 0.23; 'to:2**1': 0.23; "i've": 0.23; 'header:In-Reply-To:1': 0.25; 'select': 0.26; 'skip:" 20': 0.26; '(see': 0.27; 'lines': 0.28; 'behavior.': 0.29; 'key,': 0.29; 'url:mailman': 0.29; 'maybe': 0.29; 'worked': 0.30; 'code': 0.31; 'url:python': 0.32; 'mac': 0.32; 'running': 0.32; 'skip:_ 30': 0.32; 'url:listinfo': 0.32; 'quotes': 0.33; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'text': 0.34; 'reply- to:addr:yahoo.com': 0.34; 'doing': 0.35; 'table': 0.35; 'subject:?': 0.35; 'subject:': 0.36; 'but': 0.36; 'url:org': 0.36; 'email addr:python.org': 0.36; 'item': 0.37; 'sent:': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'from:': 0.38; 'skip:l 20': 0.38; 'shows': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'skip:" 10': 0.40; 'url:mail': 0.40; 'your': 0.60; 'link': 0.60; 'email name:python-list': 0.62; 'safe': 0.63; '14.': 0.65; 'due': 0.66; 'header:Reply-To:1': 0.68; 'online': 0.70; 'subject:this': 0.84; '2013': 0.84; 'pasting': 0.84; 'url:dk': 0.84; 'realistic': 0.93 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 228513.21141.bm@omp1034.mail.ne1.yahoo.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1357755945; bh=M070e+qAiOYXZOpctGlMqRYW517Ys3u1w/AleQnBCd0=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=1dMn6kYzGs4iq1Hk8bxLpnebPr7yo8NY/VaSZxUKGBxkGCLFQcRvTJKK6/LJKFHsqnwtJXxiGBNBOcHF6NINtTOxfGNNqduBBSW2KFSQitkNTL3QGO9gCY+ivz6wLdLngfcMBT0FNiRZLzKHbFdnKs0aSnt/ClJFxQfypcxh9Q8= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=Da5CSdA72ppqmGDn62Om41caX+TYB1OigWEg3wc+pPlReL+T+qB2DI0Z5hnUY4MKIInsFjn1u6kcsngMrCjl2auwmFJmXZkEn5K74+KM/R3bEbUuNWJMrDlhQ82QJU4GpcEHVWxqKNpy92uTaph/onrmR47aYgGXKDpVn9lGHxQ=; X-YMail-OSG: eo_Fec0VM1k6KYXfo_HPQBpudc_fshpfip0JddMTDwiw9EJ 3aA7nmKHuPB1FUYn1UGcmj.4mB_O0zynC_B_wLHWiU0QRR043ht7DOr.PfVv R7vdPPzD2ektQRzohuD7R7XRAZbzf3Ri4gzz11HpCazTla4J5cSJeCIvGbBM S9x1W6W00QYOYzN86La2KYgnB1s4XAo2CvhJN.NAqPeZfdS0C_kHrkj46pLQ bNdb9nf9zSuJAcJboTtDN30x2RWeVpKH6DgX54DhVOUfCc9nQsFwcQV5_agm 9b01J8fhixk.Dt9cc..n1nLSUgfJJd_rx9Q4DLbkjMVziKXO.NtShjRNkuLd 81efQ3rJgI2JXCmUCcAVnqosIUIf4budPVrqf.jWeZDjzQQNGp0xNdVCt5DM CmjYzVs_pRZteLx4pU7WoNqPnGdGM7ehPu.mIRNNUmTiSjrKrswBSo96MbsU ApeK9opX6oK8nT10u53gviLMYDh4Qt_BLVMHPnbkKvFlWs.oofsG7GflhW_2 NYOj4_lLw_237trWPt8bPb1OZuP5ZEehm77v4N9NqhkHmby11VfmnES_uySG Q6ynA3NNPlXiF0ohzO8WVRCALFQUjr3Fs1ReTp1Y5ndsKso0MJTxhaiH4bgu KCMkimeY- X-Rocket-MIMEInfo: 001.001, SW5kZWVkLCB0aGUgY29uc29sZSBzaG93cyBhIHRyYWNlYmFjayB3aGVyZSBkYXRhIGlzIG1pc2ludGVycHJldGVkLCBtYXliZSBkdWUgdG8gbXkgdHJpcGxlIHByb3RlY3RpdmUgcXVvdGVzIGFyb3VuZCAkR0VESVRfU0VMRUNURURfVEVYVC4gVHJ5IHdpdGhvdXQgdGhlbSwgbGlrZSBzbyAoaXQgd29ya2VkIGZvciBtZSkgOiAKCiQ8CmRlZiBhZGRsaW5lKGxpbmUpOgrCoMKgwqAgcmV0dXJuICI8dHJcPiVzPC90clw.XG4iICUgbGluZQoKZGVmIGFkZGNvbHVtbihpdGVtLG5iX2NvbHVtbnMpOgrCoMKgwqAgaWYBMAEBAQE- X-Mailer: YahooMailWebService/0.8.130.494 References: <50e97123$0$294$14726298@news.sunsite.dk> <50e97e4c$0$294$14726298@news.sunsite.dk> <50e9885e$0$294$14726298@news.sunsite.dk> <50eafb00$0$287$14726298@news.sunsite.dk> <50ed336f$0$284$14726298@news.sunsite.dk> <50ed4eaf$0$284$14726298@news.sunsite.dk> Date: Wed, 9 Jan 2013 10:25:45 -0800 (PST) From: chaouche yacine Subject: Re: How to modify this script? To: Kurt Hansen , "python-list@python.org" In-Reply-To: <50ed4eaf$0$284$14726298@news.sunsite.dk> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="318864283-1556366751-1357755945=:50400" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: chaouche yacine List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 83 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1357756068 news.xs4all.nl 6867 [2001:888:2000:d::a6]:36343 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36514 --318864283-1556366751-1357755945=:50400 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Indeed, the console shows a traceback where data is misinterpreted, maybe d= ue to my triple protective quotes around $GEDIT_SELECTED_TEXT. Try without = them, like so (it worked for me) : =0A=0A$<=0Adef addline(line):=0A=A0=A0= =A0 return "%s\n" % line=0A=0Adef addcolumn(item,nb_columns):=0A= =A0=A0=A0 if nb_columns !=3D 3:=0A=A0=A0=A0=A0=A0=A0=A0 return "%s" % (3 - nb_columns + 1, item)=0A=A0=A0=A0 return "%s= " % item=0A=0Aoutput =3D "\n"=0Aselected_text =3D $GEDIT_SELE= CTED_TEXT=0Afor line in selected_text.split("\n"):=0A=A0=A0=A0 items =3D li= ne.strip().split("\t")=0A=A0=A0=A0 columns =3D ""=0A=A0=A0=A0 for item in i= tems :=0A=A0=A0=A0=A0=A0=A0=A0 columns +=3D addcolumn(item,len(items))=0A= =A0=A0=A0 output=A0 +=3D addline(columns)=0A=0Aoutput +=3D ""=0Are= turn output>=0A=0A=0A=0A________________________________=0A From: Kurt Hans= en =0ATo: python-list@python.org =0ASent: Wednesday, = January 9, 2013 12:04 PM=0ASubject: Re: How to modify this script?=0A =0ADe= n 09/01/13 11.23, chaouche yacine skrev:=0A> I figrued it out. Copy/paste e= xactly these lines in the snippets tool.=0A> You can bind it to a key as yo= u may know, I bound it to Ctrl-E. So paste=0A> it in a new snippet (keep th= e original in a safe place), bind to a key,=0A> select the text you want to= html-tableize and hit the key binding. In my=0A> case it worked.=0A> =0A> = $<=0A[cut]=0A> def addline(line):=0A=0ASpooky behavior. Yes, the green-appl= e-example also works for me with your new script, BUT ...!=0A=0ATry to copy= the table content on this page:=0Ahttp://www.danacord.dk/frmsets/records/7= 32-r.html=0Awhich is a realistic scenario. That's whar I am doing these day= s.=0A=0APasting it into Gedit and running the snippet blanks the edit area = (on MY Mac at least).=0A=0AAnd yes: I have pasted your code excatly and I'v= e double-checked for linewraps. Everything is okay.=0A=0AFor your cenvenien= ce I have put borders on the table online (see link above). You may ommit t= he 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 ... ;-)=0A-- Regards=0AKurt Hansen=0A-- http://mail.python.org/mailm= an/listinfo/python-list --318864283-1556366751-1357755945=:50400 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Indeed, the console s= hows a traceback where data is misinterpreted, maybe due to my triple prote= ctive quotes around $GEDIT_SELECTED_TEXT. Try without them, like so (it wor= ked for me) :

$<
def addline(line):
    ret= urn "<tr\>%s</tr\>\n" % line

def addcolumn(item,nb_colum= ns):
    if nb_columns !=3D 3:
    = ;    return "<td colspan=3D'%s'\>%s</td\>" % (3 = - nb_columns + 1, item)
    return "<td\>%s</td\= >" % item

output =3D "<table\>\n"
selected_text =3D $GED= IT_SELECTED_TEXT
for line in selected_text.split("\n"):
  &= nbsp; items =3D line.strip().split("\t")
    columns =3D = ""
    for item in items :
        columns +=3D addcolumn(ite= m,len(items))
    output  +=3D addline(columns)
<= br>output +=3D "</table\>"
return output>

<= div style=3D"font-family: times new roman, new york, times, serif; font-siz= e: 12pt;">
<= hr size=3D"1"> 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 scr= ipt?

=0ADen 09/01/13 11.23, chaouche yacine skrev:> I figrued it out. Copy/paste exactly these lines in the snippets too= l.
> 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), b= ind 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-ex= ample also works for me with your new script, BUT ...!

Try to copy t= he table content on this page:
http://www.danacord.dk/frmsets/records/73= 2-r.html
which is a realistic scenario. That's whar I am doing these day= s.

Pasting it into Gedit and running the snippet blanks the edit are= a (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 cen= venience 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 t= o be formatted differerent. I do that manually afterwards ... if not ... ;-= )
-- Regards
Kurt Hansen
-- http://mail.python.org/mailman/listinf= o/python-list


--318864283-1556366751-1357755945=:50400--