Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feed.xsnews.nl!border-2.ams.xsnews.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'output': 0.04; 'debug': 0.05; 'debugging': 0.05; 'modify': 0.05; 'default.': 0.07; 'subject:How': 0.09; 'python': 0.09; '"%s"': 0.09; 'homepage.': 0.09; 'inserted': 0.09; 'snippet': 0.09; 'subject:script': 0.09; 'texts.': 0.09; 'worked.': 0.09; 'def': 0.10; 'kurt': 0.11; '.app': 0.16; 'bind': 0.16; 'binding.': 0.16; 'buggy': 0.16; 'columns': 0.16; 'item)': 0.16; 'script?': 0.16; 'snippets': 0.16; 'tabs': 0.16; 'tool.': 0.16; 'url:records': 0.16; 'copied': 0.17; 'skip:" 30': 0.20; 'to:name:python- list@python.org': 0.20; 'wednesday,': 0.22; '>': 0.23; 'to:2**1': 0.23; 'feature': 0.24; 'script': 0.24; 'header:In- Reply-To:1': 0.25; 'select': 0.26; 'skip:" 20': 0.26; 'separate': 0.27; "doesn't": 0.28; 'lines': 0.28; 'went': 0.28; 'key,': 0.29; 'received:98.138.87': 0.29; 'yes.': 0.29; 'url:mailman': 0.29; 'included': 0.29; 'source': 0.29; 'figure': 0.30; 'code': 0.31; 'url:python': 0.32; 'mac': 0.32; 'structure': 0.32; 'skip:_ 30': 0.32; 'url:listinfo': 0.32; 'text,': 0.33; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'know.': 0.33; 'text': 0.34; 'reply- to:addr:yahoo.com': 0.34; 'wrong': 0.34; 'adds': 0.35; 'open': 0.35; 'table': 0.35; 'subject:?': 0.35; 'there': 0.35; 'list.': 0.35; 'add': 0.36; 'subject:': 0.36; 'ability': 0.36; 'but': 0.36; 'url:org': 0.36; 'email addr:python.org': 0.36; 'item': 0.37; 'sent:': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'from:': 0.38; 'skip:l 20': 0.38; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'url:mail': 0.40; 'your': 0.60; 'easy': 0.60; 'email name:python- list': 0.62; 'safe': 0.63; 'url:png': 0.63; 'here': 0.65; 'header :Reply-To:1': 0.68; 'received:41': 0.73; 'click': 0.76; 'subject:this': 0.84; '2013': 0.84; 'console,': 0.84; 'organize,': 0.84; 'url:dk': 0.84; 'activated': 0.91; 'received:98.138.226': 0.91 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 931616.20902.bm@omp1008.mail.ne1.yahoo.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1357726988; bh=lQ1thkSgdxJWLB+r3GXglGjgDDzK0Iaab9uu6jRhBoo=; 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=ZuVFHsMWTA2Q3yA3+Cz/QushyPy2WaTBylxlRO3G8MJ9g0QqCHuXq7pKx5nQqT99eGTPRh46ZN5IDHySaiRWezFaSwmNrB8MIgdNqhIk6uybjCg9r64W/HXGDsrZk3d8TBaTB4jAgjilMCvf0ivr5UPdeCEb6GtBEhqHrVlgNBE= 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=epBvRJa0aTdEsKUsmS6bnIIaqsj4YdqXgdkcPFHicznqHSQ+qb/whvs49e4mhVpRfRPzQHUZRWkZA3YAkSAXmYfj90LOZ6JCR7fI2+KFL3eIvTXjAO0BltO4ej8Pei5i603rxXdsNyd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SwgYmluZCB0byBhIGtleSwgc2VsZWN0IHRoZSB0ZXh0IHlvdSB3YW50IHRvIGh0bWwtdGFibGVpemUgYW5kIGhpdCB0aGUga2V5IGJpbmRpbmcuIEluIG15IGMBMAEBAQE- 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> Date: Wed, 9 Jan 2013 02:23:08 -0800 (PST) From: chaouche yacine Subject: Re: How to modify this script? To: Kurt Hansen , "python-list@python.org" In-Reply-To: <50ed336f$0$284$14726298@news.sunsite.dk> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="329289550-1982634150-1357726988=:24875" 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: 116 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1357726998 news.xs4all.nl 6954 [2001:888:2000:d::a6]:59225 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36484 --329289550-1982634150-1357726988=:24875 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable 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 th= e text you want to html-tableize and hit the key binding. In my case it wor= ked.=0A=0A$<=0Adef addline(line):=0A=A0=A0=A0 return "%s\n" % li= ne=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_co= lumns + 1, item)=0A=A0=A0=A0 return "%s" % item=0A=0Aoutput =3D = "\n"=0Afor line in """$GEDIT_SELECTED_TEXT""".split("\n"):=0A=A0=A0= =A0 items =3D line.strip().split("\t")=0A=A0=A0=A0 columns =3D ""=0A=A0=A0= =A0 for item in items :=0A=A0=A0=A0=A0=A0=A0=A0 columns +=3D addcolumn(item= ,len(items))=0A=A0=A0=A0 output=A0 +=3D addline(columns)=0A=0A=0Aoutput += =3D ""=0Areturn output>=0A=0A=0AHere's a screenshit, sorry screens= hot :) http://h.dropcanvas.com/521xc/gedit.png=0A=0A=0AThe python support i= n gedit snippets is very poor when it comes to debugging because there are = traceback printed in the console, that means gedit actually breaks without = even noticing the user about what went wrong (ex. : your snippet is malform= ed or has errors). I had to debug it using pdb.set_trace directly inside it= s source code to figure out what was wrong in the snippet.=0A=0AIf this doe= sn't work for you, please let me know.=0A=0A=0A=0A=0A=0A___________________= _____________=0A From: Kurt Hansen =0ATo: python-list= @python.org =0ASent: Wednesday, January 9, 2013 10:07 AM=0ASubject: Re: How= to modify this script?=0A =0ADen 08/01/13 16.31, chaouche yacine skrev:=0A= > Well tell me how do you use this script in gedit, are you using it as a= =0A> plugin ?=0A=0A"Snippets" is a plugin, yes. It's included in the .app f= or Mac (v. 2.30.2), but not activated af default.=0A=0AOpen "Tools" in the = menu line and click "Manage snippets...". Here you can organize, add and ed= it snippets of texts. The feature ols=E5 has the ability to work with Pytho= n code inside the snippet content.=0A=0AI am re-building a 15 years old hom= epage. The HTML code is handmade over the years and very varying, buggy etc= ., s=E5 I would like to renew the HTML for the table structure in an easy w= ay.=0A=0AExample: On this page: http://www.danacord.dk/frmsets/records/732-= r.html I mark the content of the CD, copy it to the clipboard and paste it = into the editing area in Gedit. cmd-a marks it all again and then I "run" t= he snippet upon the text, either using my self-defined hotkey or by pushing= ctrl+space and select my snippet from a list.=0A=0AThe copied text is inse= rted as clean text without any HTML. The Python-snippet we are discussing r= ecognizes tabs to separate the columns and adds the apprpriate HTML-code to= it.=0A-- Regards=0AKurt Hansen=0A-- http://mail.python.org/mailman/listinf= o/python-list --329289550-1982634150-1357726988=:24875 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
I figrued it out. Cop= y/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 t= he original in a safe place), bind to a key, select the text you want to ht= ml-tableize and hit the key binding. In my case it worked.

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

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

output =3D = "<table\>\n"
for line in """$GEDIT_SELECTED_TEXT""".split("\n"):    items =3D line.strip().split("\t")
  &nbs= p; columns =3D ""
    for item in items :
  &n= bsp;     columns +=3D addcolumn(item,len(items))
&nb= sp;   output  +=3D addline(columns)


output +=3D "= </table\>"
return output>

H= ere's a screenshit, sorry screenshot :) http://h.dropcanvas.com/521xc/gedit= .png


The python support in gedit sn= ippets is very poor when it comes to debugging because there are traceback = printed in the console, that means gedit actually breaks without even notic= ing the user about what went wrong (ex. : your snippet is malformed or has errors). I had to debug it using pdb.set_trace directly inside its source = code to figure out what was wrong in the snippet.

= If this doesn't work for you, please let me know.

<= div style=3D"color: rgb(0, 0, 0); font-size: 16px; font-family: times new r= oman,new york,times,serif; background-color: transparent; font-style: norma= l;">

=
From: Kurt Hansen <kurt@ugyldig.invalid>
= To: python-list@python.org=
Sent: Wednesday, Jan= uary 9, 2013 10:07 AM
Subject: Re: How to modify this script?

=0ADen 08/01= /13 16.31, chaouche yacine skrev:
> Well tell me how do you use this = script in gedit, are you using it as a
> plugin ?

"Snippets" i= s a plugin, yes. It's included in the .app for Mac (v. 2.30.2), but not act= ivated af default.

Open "Tools" in the menu line and click "Manage s= nippets...". Here you can organize, add and edit snippets of texts. The fea= ture ols=E5 has the ability to work with Python code inside the snippet con= tent.

I am re-building a 15 years old homepage. The HTML code is han= dmade over the years and very varying, buggy etc., s=E5 I would like to ren= ew the HTML for the table structure in an easy way.

Example: On this= page: http://www.danacord.dk/frmsets/records/732-r.html I mark the content= of the CD, copy it to the clipboard and paste it into the editing area in = Gedit. cmd-a marks it all again and then I "run" the snippet upon the text,= either using my self-defined hotkey or by pushing ctrl+space and select my snippet from a list.

The copied text is inserted as c= lean text without any HTML. The Python-snippet we are discussing recognizes= tabs to separate the columns and adds the apprpriate HTML-code to it.
-= - Regards
Kurt Hansen
-- http://mail.python.org/mailman/listinfo/pyth= on-list


--329289550-1982634150-1357726988=:24875--