pydev-code Mailing List for PyDev for Eclipse (Page 39)
Brought to you by:
fabioz
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
(14) |
Apr
(18) |
May
(12) |
Jun
(34) |
Jul
(31) |
Aug
(37) |
Sep
(22) |
Oct
(2) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(1) |
Feb
(4) |
Mar
(9) |
Apr
(1) |
May
|
Jun
(2) |
Jul
(24) |
Aug
(3) |
Sep
(5) |
Oct
(3) |
Nov
(3) |
Dec
(5) |
2006 |
Jan
(5) |
Feb
(23) |
Mar
(5) |
Apr
(80) |
May
(26) |
Jun
(13) |
Jul
(13) |
Aug
(4) |
Sep
(31) |
Oct
(24) |
Nov
(6) |
Dec
(2) |
2007 |
Jan
(7) |
Feb
|
Mar
(26) |
Apr
(3) |
May
(8) |
Jun
(6) |
Jul
(11) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
(9) |
Dec
(3) |
2008 |
Jan
(7) |
Feb
(1) |
Mar
(6) |
Apr
(7) |
May
(9) |
Jun
(14) |
Jul
(9) |
Aug
(6) |
Sep
(10) |
Oct
(5) |
Nov
(8) |
Dec
(5) |
2009 |
Jan
(8) |
Feb
(10) |
Mar
(10) |
Apr
(1) |
May
(3) |
Jun
(5) |
Jul
(10) |
Aug
(3) |
Sep
(12) |
Oct
(6) |
Nov
(22) |
Dec
(12) |
2010 |
Jan
(10) |
Feb
(17) |
Mar
(5) |
Apr
(9) |
May
(8) |
Jun
(2) |
Jul
(4) |
Aug
(12) |
Sep
(1) |
Oct
(1) |
Nov
(8) |
Dec
|
2011 |
Jan
(14) |
Feb
(8) |
Mar
(3) |
Apr
(11) |
May
(6) |
Jun
(5) |
Jul
(10) |
Aug
(7) |
Sep
|
Oct
(4) |
Nov
(4) |
Dec
(8) |
2012 |
Jan
|
Feb
(8) |
Mar
(10) |
Apr
(5) |
May
(4) |
Jun
(10) |
Jul
|
Aug
(2) |
Sep
(2) |
Oct
(11) |
Nov
(1) |
Dec
|
2013 |
Jan
(1) |
Feb
(2) |
Mar
(11) |
Apr
(10) |
May
(7) |
Jun
(9) |
Jul
(13) |
Aug
(20) |
Sep
(4) |
Oct
(18) |
Nov
(5) |
Dec
(7) |
2014 |
Jan
(3) |
Feb
(5) |
Mar
(7) |
Apr
(5) |
May
(10) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(7) |
Oct
(1) |
Nov
(1) |
Dec
(1) |
2015 |
Jan
(1) |
Feb
(1) |
Mar
(8) |
Apr
(3) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
(2) |
Sep
(1) |
Oct
(3) |
Nov
(5) |
Dec
(1) |
2016 |
Jan
(26) |
Feb
(10) |
Mar
(4) |
Apr
|
May
(4) |
Jun
(3) |
Jul
|
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(4) |
Dec
(3) |
2017 |
Jan
(3) |
Feb
|
Mar
(9) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
(9) |
Sep
(1) |
Oct
|
Nov
(2) |
Dec
|
2018 |
Jan
|
Feb
(2) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(4) |
Oct
(2) |
Nov
(1) |
Dec
(3) |
2019 |
Jan
(4) |
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
(4) |
Aug
|
Sep
|
Oct
(3) |
Nov
|
Dec
|
2020 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(4) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
(11) |
2021 |
Jan
(3) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2024 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(3) |
Oct
|
Nov
|
Dec
|
From: Don T. <nos...@gm...> - 2006-04-15 01:08:47
|
Don Taylor wrote: > if False: > from org.python.pydev.editor import PyEdit #@UnresolvedImport > cmd = 'command string' > editor = PyEdit > > sorts out cmd and editor, but at the expense of another False failure. One way of getting rid of all of the True/False warnings in Pydev extensions is to use: if False: #@UndefinedVariable # None of this code will be executed, but it will stop Pydev # extensions from complaining about undefined variables. from org.python.pydev.editor import PyEdit #@UnresolvedImport cmd = 'command string' editor = PyEdit False = False #@UndefinedVariable True = True #@UndefinedVariable any further uses of True or False will not cause undefined variable errors because of these bogus assignments. Don. |
From: Joel H. <yo...@if...> - 2006-04-14 01:36:34
|
> Well, remind that things are in a 'shared' interpreter for all scripts > for an editor, Yes. Will keep that in mind. > If you got it within an Eclipse project, just right-click it, and then > export > javadoc. Handy. Thanks! I have it that way now. I used the eclipse CVS support to pull down the pydev source to my XP machine, and it worked like a dream. Also very handy. :-) Take care! /Joel |
From: Joel H. <yo...@if...> - 2006-04-14 01:32:40
|
> mostly because you want to do that even on other syntax errors Yes that's what I had in mind, really. Something that lets the script say "woah, clean up your code before running me!". > I wouldn't worry about this one, as the user would see the syntax > error on that line anyway. I think an IDE gives a more reliable impression if it refuses to propagate errors, but I can just as well leave it as it is if you think that's better. >> 2) Is there a bug in getInsideParentesisToks? > > Fixed for 1.0.6 Snappy! Me like :-) > And who decides is the script author ;-) Heh... Then I'll set it to False. I've got the power, yeah! ;-) > Also, the script has 1 minor 'quirk': if your def line is the last > line of the document (without any new-line in the end) -- fault of > PySelection.addLine (which I just fixed, so, should work without this > problem on 1.0.6). Oh. Forgot to fix that one. I'll do that (and some other things I noticed just now) and repost with a new version. Cheers! /Joel |
From: Fabio Z. <fa...@gm...> - 2006-04-13 16:38:08
|
On 4/13/06, Don Taylor <nos...@gm...> wrote: > > Fabio Zadrozny wrote: > > > Well, remind that things are in a 'shared' interpreter for all scripts > > for an editor, so, if you had made some from java.lang import * in one > > script, all would have access to it (not something you'd like to rely > on). > > > > Fabio: > > As I understand it importing something that has already been imported > does not really do anything, unlike reload. > > So, is there really any harm in having duplicate imports, and do you > really need the guard around this import? No, no harm in it... Should be safe, so, no real need to do it. Cheers, Fabio |
From: Don T. <nos...@gm...> - 2006-04-13 16:13:44
|
Fabio Zadrozny wrote: > Well, remind that things are in a 'shared' interpreter for all scripts > for an editor, so, if you had made some from java.lang import * in one > script, all would have access to it (not something you'd like to rely on). > Fabio: As I understand it importing something that has already been imported does not really do anything, unlike reload. So, is there really any harm in having duplicate imports, and do you really need the guard around this import? if False: from org.python.pydev.editor import PyEdit #@UnresolvedImport cmd = 'command string' editor = PyEdit Don. |
From: Fabio Z. <fa...@gm...> - 2006-04-13 15:32:43
|
> > > > It is a java thing -- comes from java.lang... Actually you should impor= t > it > > into your scope: from java.lang import StringBuffer. > > Yes. On Ubuntulinux 5.10, eclipse 3.1.1 and pydev 1.0.4 I do have to > import it. > Under WinXP, eclipse <newest> and pydev 1.0.5 I didn't need to import > it... > Seems weird though. I must have imported it by mistake somewhere. I'll > investigate some more and get bact to you if I can't track it down to som= e > strangeness on my part. Well, remind that things are in a 'shared' interpreter for all scripts for an editor, so, if you had made some from java.lang import * in one script, all would have access to it (not something you'd like to rely on). > Well, actually most code has javadocs, so, probably doing at least a > javadoc > > from pydev code and making it available > > If you got it within an Eclipse project, just right-click it, and then export > javadoc. Cheers, Fabio |
From: Fabio Z. <fa...@gm...> - 2006-04-13 15:28:44
|
> > > 1) > Is there some way of detecting whether or not there's a syntax error on > the > current line at sript execution? In the current form my script will > happily > propagate syntax errors from the def line, e.g: > > class moo: > def cow(self, 1): > > (gives self.1 =3D 1 on execution) Well, actually, you could, but that would be harder, mostly because you wan= t to do that even on other syntax errors (because you could do: editor.getAST= () and check its return for the abstract syntax tree with the results of the parsing, but it might fail in other errors, and not only in the current one), so, I wouldn't worry about this one, as the user would see the syntax error on that line anyway. 2) Is there a bug in getInsideParentesisToks? > If called with the string "(foo,)" then (the equivalent of) ['foo'] is > returned. If called with the string "(foo, )" then (the equivalent of) > ['foo', > ''] is returned. The input values are equivalent in python, so shouldn't > the > returned values be equal? Well, yes, I think so too ;-) Fixed for 1.0.6 The reason I ask is related to my comment at line 71 in my attached script: > # This can happen with legal def lines such as "def moo(self, ):" > > > 3) > Right now my script activates on "Ctrl-2" followed by "a<Enter>". I think > what > we initially discussed was having this as "Ctrl-2" followed by "a", which > just > requires swapping the True at the final line for a False. > > Which one should I use? The latter seems more convenient for me right now= , > but > using it makes it impossible to execute other scripts whose names begin > with > "a". Is there an easy way for users to rebind script names to their needs= ? > Who > decides which script should have what name? You can let it with True... If later something else appears it can be changed. The only way to rebind it currently is changing the script itself. And who decides is the script author ;-) Also, the script has 1 minor 'quirk': if your def line is the last line of the document (without any new-line in the end) -- fault of PySelection.addLine (which I just fixed, so, should work without this problem on 1.0.6). Cheers, Fabio |
From: Joel H. <yo...@if...> - 2006-04-13 13:39:39
|
Hi! I beg to withdraw my previous statement about thin documentation. The source is definitely adequately documented for my tastes. And by the way... I can see from the source that there's a lot of work invested in this baby. Way to go, and keep up the good work! > It is a java thing -- comes from java.lang... Actually you should import it > into your scope: from java.lang import StringBuffer. Yes. On Ubuntulinux 5.10, eclipse 3.1.1 and pydev 1.0.4 I do have to import it. Under WinXP, eclipse <newest> and pydev 1.0.5 I didn't need to import it... Seems weird though. I must have imported it by mistake somewhere. I'll investigate some more and get bact to you if I can't track it down to some strangeness on my part. > Well, actually most code has javadocs, so, probably doing at least a javadoc > from pydev code and making it available Sorry. Don't know how to do that. > As for the cvs stuff, that developers manual would surely help -- It > should be pretty easy getting the pydev code in Eclipse. I pulled it down using command line cvs. If you're planning to put something about that in the developer manual maybe you're interested to know that the instructions at the CVS part of pydev@sourceforge didn't work for me. http://sourceforge.net/cvs/?group_id=85796 The login failed with this error message: $ cvs -d:pserver:ano...@cv...:/cvsroot/pydev login Logging in to :pserver:ano...@cv...:2401/cvsroot/pydev CVS password: cvs login: warning: failed to open /home/bioinfo/yohell/.cvspass for reading: No such file or directory However this did work: $ cvs -d:pserver:ano...@cv...:/cvsroot/pydev checkout . Cheers! /Joel |
From: Joel H. <yo...@if...> - 2006-04-13 13:38:55
|
Hi! I've cooked up a new version of my 'Assign method parameters to attributes of self' script. This one should be saner, neater, more helpful, and respectful of indent. I'm still very thankful for any hints or comments regarding anything in this code. I also have a few questions: 1) Is there some way of detecting whether or not there's a syntax error on the current line at sript execution? In the current form my script will happily propagate syntax errors from the def line, e.g: class moo: def cow(self, 1): (gives self.1 = 1 on execution) 2) Is there a bug in getInsideParentesisToks? If called with the string "(foo,)" then (the equivalent of) ['foo'] is returned. If called with the string "(foo, )" then (the equivalent of) ['foo', ''] is returned. The input values are equivalent in python, so shouldn't the returned values be equal? The reason I ask is related to my comment at line 71 in my attached script: # This can happen with legal def lines such as "def moo(self, ):" 3) Right now my script activates on "Ctrl-2" followed by "a<Enter>". I think what we initially discussed was having this as "Ctrl-2" followed by "a", which just requires swapping the True at the final line for a False. Which one should I use? The latter seems more convenient for me right now, but using it makes it impossible to execute other scripts whose names begin with "a". Is there an easy way for users to rebind script names to their needs? Who decides which script should have what name? Anyway, I'm really starting to like this pydev scripting thing. This'll be good, I'm sure. :-) Take care! /Joel Hedlund |
From: Joel H. <yo...@if...> - 2006-04-13 13:37:01
|
Hi! I've cooked up a new version of my 'Assign method parameters to attributes of self' script. This one should be saner, neater, more helpful, and respectful of indent. I'm still very thankful for any hints or comments regarding anything in this code. I also have a few questions: 1) Is there some way of detecting whether or not there's a syntax error on the current line at sript execution? In the current form my script will happily propagate syntax errors from the def line, e.g: class moo: def cow(self, 1): (gives self.1 = 1 on execution) 2) Is there a bug in getInsideParentesisToks? If called with the string "(foo,)" then (the equivalent of) ['foo'] is returned. If called with the string "(foo, )" then (the equivalent of) ['foo', ''] is returned. The input values are equivalent in python, so shouldn't the returned values be equal? The reason I ask is related to my comment at line 71 in my attached script: # This can happen with legal def lines such as "def moo(self, ):" 3) Right now my script activates on "Ctrl-2" followed by "a<Enter>". I think what we initially discussed was having this as "Ctrl-2" followed by "a", which just requires swapping the True at the final line for a False. Which one should I use? The latter seems more convenient for me right now, but using it makes it impossible to execute other scripts whose names begin with "a". Is there an easy way for users to rebind script names to their needs? Who decides which script should have what name? Anyway, I'm really starting to like this pydev scripting thing. This'll be good, I'm sure. :-) Take care! /Joel Hedlund |
From: Fabio Z. <fa...@gm...> - 2006-04-13 10:48:11
|
> > > from org.python.pydev.core.docutils import ParsingUtils > > ParsingUtils.eatLiterals(document, > > StringBuffer(), > > initialOffsetOfLiteral) > > Who put StringBuffer in my scope? I can see it's there but I didn't > declare it? Is it a Jython thing? Where can I read up on this? It is a java thing -- comes from java.lang... Actually you should import it into your scope: from java.lang import StringBuffer. You can check its javadocs at: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StringBuffer.html Oh, and is there something similar for retrieving the contents of > parantheses? I tried: > > iOffset =3D oSelection.absoluteCursorOffset > oStrBuf =3D StringBuffer() > print iOffset > print ParsingUtils.eatPar(document, iOffset, oStrBuf) > print oStrBuf > > which returns offset of the paranthesis that closes the closest nested > paranthesised expression in which the cursor currently is placed, but > oStrBuf is left empty. I was thinking maybe I should use this to detect > parameters instead, since that might be an easy way of dealing with line > continuations, comments and code directly after the scope opening colon > on def lines. What do you think? Actually, the current version seems nice to me... It actually uses the ParsingUtils to get the parents, so, it should be ok. Also, in the tuple you have in the return, 'tuple.o2' will give you the parenthesis end -- You can check that function at: http://cvs.sourceforge.net/viewcvs.py/pydev/org.python.pydev.core/src/org/p= ython/pydev/core/docutils/PySelection.java?view=3Dmarkup > So, what were your first impressions on pydev scripting? > > It's great. It gives me great opportunity for customisations, which > otherwise would be impossible (since I don't Java :-). It's all still a > little bewildering since I'm not yet used to how the internals of > neither eclipse or pydev work. The learning curve seems steep (but not > vertical). The dir utils you posted proved to be life savers. It's a > pity the code is cropped when viewed in the html repository at > sourceforge, so maybe you could put it somewhere accessible so that > people not currently on this list also can benefit from them? Sure... Actually, I have in my 'todo-list' doing a developers manual, on ho= w to get the code, so, I guess I'll put this there too. One impression is that there seem to be very little documentation. Maybe > I've got myself to blame since I must admit I still haven't pulled down > the pydev source. To my defense, I've been confined to WinXP the last > couple of days and I don't really know how to cvs from that... On the > other hand, this list has been a great help with speedy and constructive > responses. Well, actually most code has javadocs, so, probably doing at least a javado= c from pydev code and making it available would be a good addition to that. A= s for the cvs stuff, that developers manual would surely help -- It should be pretty easy getting the pydev code in Eclipse. > I'd really like to know ways to improve it... > > It's too early for me to tell, I think. I need to mess around with it > for a while first, but I'll get back to you once I come up with > something solid. Should I post those feature requests to this list or to > the tracker at sourceforge? If you want to elaborate on them, you can put it in this list (and put it later in the tracker), now, if you're sure of what you want, just toss it i= n the tracker . Cheers, Fabio |
From: Joel H. <yo...@if...> - 2006-04-13 08:24:05
|
Hi! > Nicely done, works very well for me (asside from the docstring issue > you mentioned), so... congratulations!!! Thanks! > The only thing that I saw that you shouldn't do is storing another > editor reference in your class (self._oEditor), you should just use > the editor variable directly (it will always be available in your > namespace). Right. > from org.python.pydev.core.docutils import ParsingUtils > ParsingUtils.eatLiterals(document, > StringBuffer(), > initialOffsetOfLiteral) Who put StringBuffer in my scope? I can see it's there but I didn't declare it? Is it a Jython thing? Where can I read up on this? Oh, and is there something similar for retrieving the contents of parantheses? I tried: iOffset = oSelection.absoluteCursorOffset oStrBuf = StringBuffer() print iOffset print ParsingUtils.eatPar(document, iOffset, oStrBuf) print oStrBuf which returns offset of the paranthesis that closes the closest nested paranthesised expression in which the cursor currently is placed, but oStrBuf is left empty. I was thinking maybe I should use this to detect parameters instead, since that might be an easy way of dealing with line continuations, comments and code directly after the scope opening colon on def lines. What do you think? > So, what were your first impressions on pydev scripting? It's great. It gives me great opportunity for customisations, which otherwise would be impossible (since I don't Java :-). It's all still a little bewildering since I'm not yet used to how the internals of neither eclipse or pydev work. The learning curve seems steep (but not vertical). The dir utils you posted proved to be life savers. It's a pity the code is cropped when viewed in the html repository at sourceforge, so maybe you could put it somewhere accessible so that people not currently on this list also can benefit from them? One impression is that there seem to be very little documentation. Maybe I've got myself to blame since I must admit I still haven't pulled down the pydev source. To my defense, I've been confined to WinXP the last couple of days and I don't really know how to cvs from that... On the other hand, this list has been a great help with speedy and constructive responses. > I'd really like to know ways to improve it... It's too early for me to tell, I think. I need to mess around with it for a while first, but I'll get back to you once I come up with something solid. Should I post those feature requests to this list or to the tracker at sourceforge? Now, back into the fray... :-) /Joel |
From: Joel H. <yo...@if...> - 2006-04-13 07:20:39
|
Hi! > I tried a one-liner: > > def fun(fred): foo = fred > > and still get the same result. Oh. Guess that was a bit ambiguous. By "method def one-liner" I mean a method def statement where the def keyword, parameters, and scope opening colon all live on the same line. I.e: no line continuations either using brackets or backslashes. Good: def moo(self, cow): (code here) Bad: def \ moo(self, cow): (code here) and I guess assuming no code after scope opening colon isn't such a great idea either. But anyway all this will be corrected once I learn how to script pydev properly. > Adding #@UnresolvedImport to the ends of a couple of from lines > fixes PySelection and PyAction. Oh. I didn't understand what it was at first (running plain pydev) but I'll fix it. > I don't think that True/False appeared in Python until 2.3 or 2.4 and > Jython is 2.1. Jython 2.2alpha1 is out if you're interested. Downloaded it yesterday. Thanks for the tips! /Joel |
From: Fabio Z. <fa...@gm...> - 2006-04-13 02:07:56
|
Hi Don, I have just installed your script and I guess I do not understand the > use case. The use case is: class Foo: def m1(self, a,b): <-- it will create self.a =3D a, self.b =3D b > Fabio: > > I am pretty uneasy about these tricks to kill undefined symbols. I > don't understand what is going on here, but it seems to work. It looks > too much like magic. Well, that's just untill I make the scripting environment recognize all those tokens. You could actually create a jython project in your scripts an= d add all the eclipse jars to it, but I'd rather wait a little and have some check where you could say 'ok, I want to recognize as valid imports all the jars from Eclipse'. I don't understand why we have to lie on the from lines, or is this > always the case with Jython and Pydev extensions? As I said, you could configure your project with all that, but it would tak= e to much work to be good for using, so, given some time, I'll make it recognize that. I don't think that True/False appeared in Python until 2.3 or 2.4 and > Jython is 2.1. > > So, what is going on here? Do these scripts already have a bunch of > things defined that is not apparant until they are executed, but the > compiler cannot be told about them? Actually... sort of... False and True are only 2.3 onwards, but I add 2 tokens: False=3D0 and True=3D1 to the globals (in the same way I add the cm= d and the editor tokens). That's mostly because I was tired of always having to declare those in the top of a jython script, so, good thing I don't have to do that anymore ;-) Cheers, Fabio |
From: Don T. <nos...@gm...> - 2006-04-13 00:44:43
|
Joel Hedlund wrote: > Alright... These are my first stumbling steps into the glorious realm of > pydev scripting. > > It's supposed to be a little helper for assigning the values of method > parameters to attributes of self with the same names, and it's activated > through "Ctrl-2" followed by "a<Enter>" ("a" for "assign"). Today it > quite happily displaces docstrings and probably also behaves badly by > other fascinating means which I still haven't discovered. > > I'd appreciate any and all pointers I can get on all this, so I can > continue in the right direction. > Hi Joel: I have just installed your script and I guess I do not understand the use case. I place my mouse pointer in a function definition, hit ctrl-2, a, <enter> and I always get the message: "So far, only one-liner method def lines are recognised by this script. The current line is not such a line." I tried a one-liner: def fun(fred): foo = fred and still get the same result. In addition, Pydev extensions on my machine complains about lots of undefined symbols (cmd, editor, PySelection, PyAction, True and False). Sticking Fabio's trick if False: from org.python.pydev.editor import PyEdit #@UnresolvedImport cmd = 'command string' editor = PyEdit sorts out cmd and editor, but at the expense of another False failure. Adding #@UnresolvedImport to the ends of a couple of from lines fixes PySelection and PyAction. Fabio: I am pretty uneasy about these tricks to kill undefined symbols. I don't understand what is going on here, but it seems to work. It looks too much like magic. I don't understand why we have to lie on the from lines, or is this always the case with Jython and Pydev extensions? I don't think that True/False appeared in Python until 2.3 or 2.4 and Jython is 2.1. So, what is going on here? Do these scripts already have a bunch of things defined that is not apparant until they are executed, but the compiler cannot be told about them? Don. |
From: Fabio Z. <fa...@gm...> - 2006-04-12 23:54:52
|
Hi Joel, Nicely done, works very well for me (asside from the docstring issue you mentioned), so... congratulations!!! The only thing that I saw that you shouldn't do is storing another editor reference in your class (self._oEditor), you should just use the editor variable directly (it will always be available in your namespace). Now the only thing missing is checking if there is some docstring. You can do that in the following way: Check if there is some ' or ", get its absolute position in the document and then you can use: from org.python.pydev.core.docutils import ParsingUtils ParsingUtils.eatLiterals(document, StringBuffer(), initialOffsetOfLiteral) The contents of the docstring will be on the passed StringBuffer and the returned value will be the absolute offset to the docstring end. So, what were your first impressions on pydev scripting? I'd really like to know ways to improve it... Probably creating a more 'pythonic' interface fo= r some common operations will be in that list, but this will come with time, so, aside from that, what do you think? Cheers, Fabio On 4/12/06, Joel Hedlund <yo...@if...> wrote: > > Alright... These are my first stumbling steps into the glorious realm of > pydev scripting. > > It's supposed to be a little helper for assigning the values of method > parameters to attributes of self with the same names, and it's activated > through "Ctrl-2" followed by "a<Enter>" ("a" for "assign"). Today it > quite happily displaces docstrings and probably also behaves badly by > other fascinating means which I still haven't discovered. > > I'd appreciate any and all pointers I can get on all this, so I can > continue in the right direction. > > Take care everybody! > /Joel Hedlund > > > assert cmd is not None > assert editor is not None > > if cmd =3D=3D 'onCreateActions': > import re > from org.eclipse.jface.action import Action #@UnresolvedImport > from org.eclipse.jface.dialogs import MessageDialog #@UnresolvedImport > from org.python.pydev.core.docutils import PySelection > from org.python.pydev.editor.actions import PyAction > > class ScriptUnapplicableError(Exception): > """Raised when the script is unapplicable to the current line.""" > def __init__(self, msg): > self.msg =3D msg > def __str__(self): > return self.msg > > class AssignToAttribsOfSelf(Action): > _oEditor =3D editor > _rOK =3D re.compile(r'^\s+def\s+\w+\(self.*\)\s*:\s*$') > def run(self): > oSelection =3D PySelection(self._oEditor) > sCurrentLine =3D oSelection.getCursorLineContents() > try: > if not self._rOK.match(sCurrentLine): > msg =3D "So far, only one-liner method def lines are > recognised by this script. The current line is not such a line." > raise ScriptUnapplicableError(msg) > oParamInfo =3D oSelection.getInsideParentesisToks(False) > lsParams =3D oParamInfo.o1 > iOffset =3D oParamInfo.o2 > if len(lsParams) =3D=3D 0: > msg =3D "This method def has no parameters, so > consequently there is nothing to assign to atributes." > raise ScriptUnapplicableError(msg) > sPreviousIndent =3D PySelection.getIndentationFromLine > (sCurrentLine) > sIndent =3D PyAction.getStaticIndentationString() > sTotalIndent =3D sPreviousIndent + sIndent > sTemplate =3D sTotalIndent + "self.%s =3D %s" > sNewLine =3D PyAction.getDelimiter(oSelection.getDoc()) > sAssignments =3D sNewLine.join([sTemplate % (s,s) for s in > lsParams]) > iLine =3D oSelection.getLineOfOffset(iOffset) > oSelection.addLine(sAssignments, iLine) > except ScriptUnapplicableError, e: > title =3D "Script Unapplicable" > header =3D "Script: Assign Method Parameters to Attributes= of > self\r\n\r\n" > MessageDialog.openInformation(editor.getSite().getShell(), > title, header + str(e)) > > editor.addOfflineActionListener("a", AssignToAttribsOfSelf(), 'Assign > method parameters to attributes of self', True) #the user can activate th= is > action with: Ctrl+2 ex2<ENTER> > > > |
From: Joel H. <yo...@if...> - 2006-04-12 22:07:36
|
Alright... These are my first stumbling steps into the glorious realm of pydev scripting. It's supposed to be a little helper for assigning the values of method parameters to attributes of self with the same names, and it's activated through "Ctrl-2" followed by "a<Enter>" ("a" for "assign"). Today it quite happily displaces docstrings and probably also behaves badly by other fascinating means which I still haven't discovered. I'd appreciate any and all pointers I can get on all this, so I can continue in the right direction. Take care everybody! /Joel Hedlund |
From: Don T. <nos...@gm...> - 2006-04-10 23:48:58
|
Fabio Zadrozny wrote: > I guess you could do it with some tool to embed cpython in java... > > There are some projects that say they support this (note that I never > tried any of those): > http://jepp.sourceforge.net/ > http://jpe.sourceforge.net/ > http://jpype.sourceforge.net/roadmap.html > Fabio: I had another look at these projects and you may be interested in using Jepp in Pydev as I believe that you ould use it to execute inline CPython from inside a Java program. Jep uses the Jni to allow Java to call CPython. As I understand it, you currently spawn separate processes for CPython components of Pydev, I think Jepp would let you run these components synchronously or inside a Java task. But Jep (presumably jep.dll) presently does seem to require a custom build for each pair (JRE version, Python version). I have not tried Jep because it will require some (difficult for me) build work to get it running on my machine. Don. |
From: Fabio Z. <fa...@gm...> - 2006-04-10 10:50:29
|
Hi Gunter, Actually, I believe there is no such option... If this would be implemented= , it should be on Eclipse itself, as this is more like a 'general' behaviour than what pydev should provide (like the write in overwrite mode), so, if you would like this behaviour, you should submit a feature request to the Eclipse guys (at eclipse.org). Cheers, Fabio On 4/10/06, Gunter Bach <gun...@a3...> wrote: > > > Hello! > > Is there a way to have "unix-style" selection in PyDev? > > To be more specific: When I have selected a region in PyDev, it will be > overwritten when I start typing (the normal Windows-Like behaviour). Is i= t > possible to have only the selection deselected when typing? > > If this is not specialy related to PyDev, how could I archive such a > behaviour? > > Many thanks in advance... > > Gunter > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting > language > that extends applications into web and mobile media. Attend the live > webcast > and join the prime developer group breaking into this new coding > territory! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 > _______________________________________________ > pydev-code mailing list > pyd...@li... > https://lists.sourceforge.net/lists/listinfo/pydev-code > |
From: Gunter B. <gun...@a3...> - 2006-04-10 08:17:55
|
Hello! Is there a way to have "unix-style" selection in PyDev? To be more specific: When I have selected a region in PyDev, it will be overwritten when I start typing (the normal Windows-Like behaviour). Is it possible to have only the selection deselected when typing? If this is not specialy related to PyDev, how could I archive such a behaviour? Many thanks in advance... Gunter |
From: Fabio Z. <fa...@gm...> - 2006-04-05 18:31:10
|
Hi All, Pydev and Pydev Extensions 1.0.5 have been released Check http://www.fabioz.com/pydev for details on Pydev Extensions and http://pydev.sf.net for details on Pydev Release Highlights in Pydev Extensions: ----------------------------------------------------------------- - The pop-up does not pop as much for unlicensed versions Release Highlights in Pydev: ---------------------------------------------- - Another batch of things to improve indentation: * Indent does not try to make auto-indentation when pasting * When smart-indent is not selected, it will still add an indentation level after ':' * It will keep the indent of the previous line on new-lines if the current line is empty * Other little things - Added a place to specify vm arguments (for jython or python) -- thanks to Rudi de Andrade for this patch - Added a way to kill the underlying python/jython shells (Ctrl+2+kill) What is PyDev? --------------------------- PyDev is a plugin that enables users to use Eclipse for Python and Jython development -- making Eclipse a first class Python IDE -- It comes with man= y goodies such as code completion, syntax highlighting, syntax analysis, refactor, debug and many others. Cheers, -- Fabio Zadrozny ------------------------------------------------------ Software Developer ESSS - Engineering Simulation and Scientific Software http://www.esss.com.br Pydev Extensions http://www.fabioz.com/pydev Pydev - Python Development Enviroment for Eclipse http://pydev.sf.net http://pydev.blogspot.com |
From: Fabio Z. <fa...@gm...> - 2006-04-04 22:01:32
|
> > None of these seem to be ready for prime time and they are not really > what I have in mind. I was wondering how to invoke existing CPython > stuff from a Jython script in Pydev. Actually, if you're meaning in the same process, you'd need something that exposed the CPython api to java (as those projects try to do), but I agree, none seems to be in production... Given that there does not seem to be anything worth using I am assuming > that you run at least some of Pydev's Python code in a separate process > rather that in-process? For stuff like BRM which I doubt you would have > ported that to Jython. I wonder what else is in straight Python? Yes, BRM, code-completion (for builtins), debugging, code-coverage, etc. ar= e all in Python. Did you develop a standard protocol for this that could be exposed to > the scripting interface? Or would it be straightforward to do this > directly in Jython. Actually, there is not an actual protocol for everything... In the debugger it uses xml-rpc, in code-completion it just write messages directly (to try reducing the communication penalty). BRM uses the same thing code-completio= n does... Actually, thinking about it, that's the most 'standard' approach. The server at the cpython side is at org.python.pydev/pysrc/pycompletionserver.py (altough it is used for BRM too). Anyway, I'm not sure that would be a good way to go, as you'd have to pass all the objects you need to know about to the python side, so, the communication could make things VERY slow... Besides, you wouldn't have acess to the Eclipse internals. So, it does not appear such a good solution to me (if one of those projects could take care of that in the same process= , then it might be worth it, but otherwise, I think jython would be the best way to go). In more general terms, it would be very interesting to read an > architectural overview of the design of Pydev. > I'll try to write about it as I do a 'developers manual'. Cheers, Fabio |
From: Don T. <nos...@gm...> - 2006-04-04 21:21:10
|
Fabio Zadrozny wrote: > I guess you could do it with some tool to embed cpython in java... > > There are some projects that say they support this (note that I never > tried any of those): > http://jepp.sourceforge.net/ > http://jpe.sourceforge.net/ > http://jpype.sourceforge.net/roadmap.html > Thanks for this. None of these seem to be ready for prime time and they are not really what I have in mind. I was wondering how to invoke existing CPython stuff from a Jython script in Pydev. Given that there does not seem to be anything worth using I am assuming that you run at least some of Pydev's Python code in a separate process rather that in-process? For stuff like BRM which I doubt you would have ported that to Jython. I wonder what else is in straight Python? Did you develop a standard protocol for this that could be exposed to the scripting interface? Or would it be straightforward to do this directly in Jython. In more general terms, it would be very interesting to read an architectural overview of the design of Pydev. Don. |
From: Fabio Z. <fa...@gm...> - 2006-04-04 17:03:51
|
import java def dirObj(obj): ret = [] found = java.util.HashMap() original = obj if hasattr(obj, '__class__') and obj.__class__ == java.lang.Class: #get info about superclasses classes = [] classes.append(obj) c = obj.getSuperclass() while c != None: classes.append(c) c = c.getSuperclass() #get info about interfaces interfs = [] for obj in classes: interfs.extend(obj.getInterfaces()) classes.extend(interfs) #now is the time when we actually get info on the declared methods and fields for obj in classes: declaredMethods = obj.getDeclaredMethods() declaredFields = obj.getDeclaredFields() for i in range(len(declaredMethods)): name = declaredMethods[i].getName() ret.append(name) found.put(name, 1) for i in range(len(declaredFields)): name = declaredFields[i].getName() ret.append(name) found.put(name, 1) #this simple dir does not always get all the info, that's why we have the part before #(e.g.: if we do a dir on String, some methods that are from other interfaces such as #charAt don't appear) d = dir(original) for name in d: if found.get(name) is not 1: ret.append(name) return ret for p in dirObj(editor.__class__): print p |
From: Fabio Z. <fa...@gm...> - 2006-04-04 17:02:54
|
I guess you could do it with some tool to embed cpython in java... There are some projects that say they support this (note that I never tried any of those): http://jepp.sourceforge.net/ http://jpe.sourceforge.net/ http://jpype.sourceforge.net/roadmap.html Cheers, Fabio On 4/4/06, Don Taylor <nos...@gm...> wrote: > > Fabio: > > Do you know if it is possible to interface Jython to CPython? > > I was wondering if it would be possible to simply use Jython to write a > bunch of adapters between Java and CPython so that CPython 2.4 could be > used as the scripting language. > > I guess it could be done in separate processes, but I was wondering > about the possibility of having both in the same process. > > Don. > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting > language > that extends applications into web and mobile media. Attend the live > webcast > and join the prime developer group breaking into this new coding > territory! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 > _______________________________________________ > pydev-code mailing list > pyd...@li... > https://lists.sourceforge.net/lists/listinfo/pydev-code > |