pydev-cvs Mailing List for PyDev for Eclipse (Page 312)
Brought to you by:
fabioz
You can subscribe to this list here.
2004 |
Jan
|
Feb
(4) |
Mar
(48) |
Apr
(56) |
May
(64) |
Jun
(27) |
Jul
(66) |
Aug
(81) |
Sep
(148) |
Oct
(194) |
Nov
(78) |
Dec
(46) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(125) |
Feb
(126) |
Mar
(163) |
Apr
(133) |
May
(115) |
Jun
(307) |
Jul
(387) |
Aug
(417) |
Sep
(283) |
Oct
(148) |
Nov
(45) |
Dec
(53) |
2006 |
Jan
(240) |
Feb
(200) |
Mar
(267) |
Apr
(231) |
May
(245) |
Jun
(361) |
Jul
(142) |
Aug
(12) |
Sep
(210) |
Oct
(99) |
Nov
(7) |
Dec
(30) |
2007 |
Jan
(161) |
Feb
(511) |
Mar
(265) |
Apr
(74) |
May
(147) |
Jun
(151) |
Jul
(94) |
Aug
(68) |
Sep
(98) |
Oct
(144) |
Nov
(26) |
Dec
(36) |
2008 |
Jan
(98) |
Feb
(107) |
Mar
(199) |
Apr
(113) |
May
(119) |
Jun
(112) |
Jul
(92) |
Aug
(71) |
Sep
(101) |
Oct
(16) |
Nov
|
Dec
|
From: Aleksandar T. <at...@us...> - 2004-06-11 21:28:29
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11687 Modified Files: plugin.xml Log Message: switched version to 0.4.2 Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** plugin.xml 11 Jun 2004 20:03:56 -0000 1.17 --- plugin.xml 11 Jun 2004 21:28:04 -0000 1.18 *************** *** 3,7 **** id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.4.0" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> --- 3,7 ---- id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.4.2" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> |
From: Parhaum T. <dre...@us...> - 2004-06-11 20:04:12
|
Update of /cvsroot/pydev/org.python.pydev.help In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6357 Modified Files: toc_main.xml Log Message: Modified in org.python.pydev: PyAddCommentBlock - Extends PyComment, works on multiple lines PyComment - Selects newly commented lines after performing action PyUnComment - Selects newly uncommented lines after performing action Plugin.xml - Added PyRemoveCommentBlock and PyStripTrailingWhitespace functionality to menu, context, and hotkey (Ctrl+5) PluginPrefs - Made block comment separator a user-defined string Modified in org.python.pydev.help: toc_main.xml - user guide structure New: PyRemoveCommentBlock - Created to undo AddCommentBlock action PyStripTrailingWhitespace - Created to strip trailing whitespace from a selection or the document Index: toc_main.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.help/toc_main.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** toc_main.xml 10 Jan 2004 03:15:28 -0000 1.2 --- toc_main.xml 11 Jun 2004 20:04:03 -0000 1.3 *************** *** 1,3 **** ! <toc label="Pydev" topic="html/index.html"> <topic label="Editor" href="html/editor.html"> <topic label="Preferences" href="html/ed_prefs.html"/> --- 1,3 ---- ! <toc label="PyDev" topic="html/index.html"> <topic label="Editor" href="html/editor.html"> <topic label="Preferences" href="html/ed_prefs.html"/> *************** *** 6,8 **** --- 6,20 ---- <topic label="Preferences" href="html/db_prefs.html"/> </topic> + <topic label="User Guide" href="html/userguide/index.html"> + <topic label="Editor"> + <topic label="Syntax Highlighting" href="html/userguide/editor_syntaxh.html"/> + <topic label="Auto-Indentation" href="html/userguide/editor_autoi.html"/> + <topic label="Comment" href="html/userguide/editor_comment.html"/> + <topic label="Block Comment" href="html/userguide/editor_blockc.html"/> + <topic label="Strip Trailing Whitespace" href="html/userguide/editor_stripw.html"/> + </topic> + <topic label="Preferences" href="html/userguide/preferences.html"/> + <topic label="Debugger"/> + <topic label="Developer Guide" href="html/devguide/index.html"/> + </topic> </toc> \ No newline at end of file |
From: Parhaum T. <dre...@us...> - 2004-06-11 20:04:06
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6185 Modified Files: plugin.xml Log Message: Modified in org.python.pydev: PyAddCommentBlock - Extends PyComment, works on multiple lines PyComment - Selects newly commented lines after performing action PyUnComment - Selects newly uncommented lines after performing action Plugin.xml - Added PyRemoveCommentBlock and PyStripTrailingWhitespace functionality to menu, context, and hotkey (Ctrl+5) PluginPrefs - Made block comment separator a user-defined string Modified in org.python.pydev.help: toc_main.xml - user guide structure New: PyRemoveCommentBlock - Created to undo AddCommentBlock action PyStripTrailingWhitespace - Created to strip trailing whitespace from a selection or the document Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** plugin.xml 25 May 2004 21:25:11 -0000 1.16 --- plugin.xml 11 Jun 2004 20:03:56 -0000 1.17 *************** *** 101,104 **** --- 101,107 ---- name="addGroup"> </separator> + <separator + name="whitespaceGroup"> + </separator> </menu> <action *************** *** 110,113 **** --- 113,123 ---- </action> <action + definitionId="org.python.pydev.editor.actions.stripTrailingWhitespace" + label="Strip trailing whitespace" + class="org.python.pydev.editor.actions.PyStripTrailingWhitespace" + menubarPath="org.python.pydev.editor.actions.sourceMenu/whitespaceGroup" + id="org.python.pydev.editor.actions.stripTrailingWhitespace"> + </action> + <action definitionId="org.python.pydev.editor.actions.uncomment" label="Uncomment" *************** *** 124,127 **** --- 134,144 ---- </action> <action + definitionId="org.python.pydev.editor.actions.removeBlockComment" + label="Remove comment block" + class="org.python.pydev.editor.actions.PyRemoveBlockComment" + menubarPath="org.python.pydev.editor.actions.sourceMenu/addGroup" + id="org.python.pydev.editor.actions.removeBlockComment"> + </action> + <action definitionId="org.python.pydev.editor.actions.addBlockComment" label="Add comment block" *************** *** 169,174 **** --- 186,200 ---- name="addGroup"> </separator> + <separator + name="whitespaceGroup"> + </separator> </menu> <action + label="Strip trailing whitespace" + class="org.python.pydev.editor.actions.PyStripTrailingWhitespace" + menubarPath="org.python.pydev.editor.actions.editorPopup/whitespaceGroup" + id="org.python.pydev.editor.actions.stripTrailingWhitespace"> + </action> + <action label="Uncomment" class="org.python.pydev.editor.actions.PyUncomment" *************** *** 183,186 **** --- 209,218 ---- </action> <action + label="Remove comment block" + class="org.python.pydev.editor.actions.PyRemoveBlockComment" + menubarPath="org.python.pydev.editor.actions.editorPopup/addGroup" + id="org.python.pydev.editor.actions.removeBlockComment"> + </action> + <action label="Add comment block" class="org.python.pydev.editor.actions.PyAddBlockComment" *************** *** 256,259 **** --- 288,317 ---- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> </keyBinding> + <!-- command: whitespace--> + <command + name="Strip trailing whitespace" + description="Strips trailing whitespace from selected region or whole document if nothing selected" + category="org.python.pydev.ui.category.source" + id="org.python.pydev.editor.actions.stripTrailingWhitespace"> + </command> + <keyBinding + string="Shift+Space" + scope="org.python.pydev.ui.editor.scope" + command="org.python.pydev.editor.actions.stripTrailingWhitespace" + configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> + </keyBinding> + <!-- command: unblock--> + <command + name="Remove Comment Block" + description="Removes a python comment block" + category="org.python.pydev.ui.category.source" + id="org.python.pydev.editor.actions.removeBlockComment"> + </command> + <keyBinding + string="Ctrl+5" + scope="org.python.pydev.ui.editor.scope" + command="org.python.pydev.editor.actions.removeBlockComment" + configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> + </keyBinding> <!-- command: block--> <command |
From: Parhaum T. <dre...@us...> - 2004-06-11 20:04:05
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6185/src/org/python/pydev/plugin Modified Files: PydevPrefs.java Log Message: Modified in org.python.pydev: PyAddCommentBlock - Extends PyComment, works on multiple lines PyComment - Selects newly commented lines after performing action PyUnComment - Selects newly uncommented lines after performing action Plugin.xml - Added PyRemoveCommentBlock and PyStripTrailingWhitespace functionality to menu, context, and hotkey (Ctrl+5) PluginPrefs - Made block comment separator a user-defined string Modified in org.python.pydev.help: toc_main.xml - user guide structure New: PyRemoveCommentBlock - Created to undo AddCommentBlock action PyStripTrailingWhitespace - Created to strip trailing whitespace from a selection or the document Index: PydevPrefs.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/PydevPrefs.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PydevPrefs.java 5 May 2004 02:05:09 -0000 1.7 --- PydevPrefs.java 11 Jun 2004 20:03:56 -0000 1.8 *************** *** 11,14 **** --- 11,15 ---- import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.IntegerFieldEditor; + import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.jface.resource.StringConverter; import org.eclipse.swt.graphics.RGB; *************** *** 50,53 **** --- 51,60 ---- public static final String HYPERLINK_COLOR = "HYPERLINK_COLOR"; private static final RGB DEFAULT_HYPERLINK_COLOR = new RGB(0, 0, 238); + // TODO Handle changes to block separator string? + // If user changes this, it needs to update all files with that in it, because the + // undo-er replaces that string, not the first and last lines of a comment block + public static final String BLOCK_COMMENT = "BLOCK_COMMENT"; + public static final String DEFAULT_BLOCK_COMMENT_STRING = "======================================="; + public static final boolean DEFAULT_BLOCK_COMMENT = true; /** *************** *** 81,87 **** GUESS_TAB_SUBSTITUTION, "Assume tab spacing when files contain tabs?", p)); IntegerFieldEditor ife = new IntegerFieldEditor(TAB_WIDTH, "Tab length", p, 1); ! ife.setValidRange(1, 8); // you can't restrict widget width on IntegerFieldEditor for now addField(ife); addField(new ColorFieldEditor( CODE_COLOR, "Code", p)); --- 88,98 ---- GUESS_TAB_SUBSTITUTION, "Assume tab spacing when files contain tabs?", p)); IntegerFieldEditor ife = new IntegerFieldEditor(TAB_WIDTH, "Tab length", p, 1); ! ife.setValidRange(1, 8); // you can't restrict widget width on IntegerFieldEditor for now addField(ife); + + StringFieldEditor sfe = new StringFieldEditor ( BLOCK_COMMENT, "Block comment separator", p ); + addField(sfe); + addField(new ColorFieldEditor( CODE_COLOR, "Code", p)); *************** *** 93,96 **** --- 104,108 ---- COMMENT_COLOR, "Comments", p)); } + /** *************** *** 101,104 **** --- 113,117 ---- prefs.setDefault(GUESS_TAB_SUBSTITUTION, DEFAULT_GUESS_TAB_SUBSTITUTION); prefs.setDefault(TAB_WIDTH, DEFAULT_TAB_WIDTH); + prefs.setDefault(BLOCK_COMMENT, DEFAULT_BLOCK_COMMENT_STRING); prefs.setDefault(CODE_COLOR,StringConverter.asString(DEFAULT_CODE_COLOR)); prefs.setDefault(KEYWORD_COLOR,StringConverter.asString(DEFAULT_KEYWORD_COLOR)); |
From: Parhaum T. <dre...@us...> - 2004-06-11 20:04:05
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6185/src/org/python/pydev/editor/actions Modified Files: PyAddBlockComment.java PyComment.java Added Files: PyRemoveBlockComment.java PyStripTrailingWhitespace.java Log Message: Modified in org.python.pydev: PyAddCommentBlock - Extends PyComment, works on multiple lines PyComment - Selects newly commented lines after performing action PyUnComment - Selects newly uncommented lines after performing action Plugin.xml - Added PyRemoveCommentBlock and PyStripTrailingWhitespace functionality to menu, context, and hotkey (Ctrl+5) PluginPrefs - Made block comment separator a user-defined string Modified in org.python.pydev.help: toc_main.xml - user guide structure New: PyRemoveCommentBlock - Created to undo AddCommentBlock action PyStripTrailingWhitespace - Created to strip trailing whitespace from a selection or the document Index: PyAddBlockComment.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyAddBlockComment.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyAddBlockComment.java 27 Apr 2004 01:06:59 -0000 1.5 --- PyAddBlockComment.java 11 Jun 2004 20:03:56 -0000 1.6 *************** *** 7,86 **** package org.python.pydev.editor.actions; ! import org.eclipse.jface.action.IAction; ! import org.eclipse.jface.text.IDocument; ! import org.eclipse.jface.text.IRegion; ! import org.eclipse.jface.text.ITextSelection; ! import org.eclipse.ui.texteditor.ITextEditor; /** ! * Creates a comment block * * @author Fabio Zadrozny */ ! public class PyAddBlockComment extends PyAction { /** ! * . ! * Insert a comment block. ! * #===... ! * # ! * #===... ! * (TODO:This could be customized somewhere...) */ ! public void run(IAction action) { ! try { ! ITextEditor textEditor = getTextEditor(); ! ! IDocument doc = ! textEditor.getDocumentProvider().getDocument( ! textEditor.getEditorInput()); ! ITextSelection selection = ! (ITextSelection) textEditor ! .getSelectionProvider() ! .getSelection(); ! ! //strange things happen when we try to get the line information on the last line of the ! //document (it doesn't return the end line delimiter correctly), so we always get on position ! //0 and check to see if we are not in the last line. ! if (doc.getNumberOfLines() <= 1) ! return; ! ! IRegion startLine = null; ! ! int startLineIndex = selection.getStartLine(); ! ! String endLineDelim = getDelimiter(doc, 0); ! startLine = doc.getLineInformation(startLineIndex); ! ! IRegion line = doc.getLineInformation(startLineIndex); ! int lineLenght = line.getLength(); ! int pos = line.getOffset(); ! ! String content = doc.get(pos, lineLenght); ! String comment = getFullCommentLine(); ! ! StringBuffer strBuf = new StringBuffer(); ! ! strBuf.append(endLineDelim); ! strBuf.append(comment); //#=========... ! strBuf.append(endLineDelim); ! ! strBuf.append("# "); ! strBuf.append(content); ! ! strBuf.append(endLineDelim); ! strBuf.append(comment); //#=========... ! strBuf.append(endLineDelim); ! ! doc.replace(pos, lineLenght, strBuf.toString()); ! textEditor.selectAndReveal(pos+strBuf.length()-comment.length()-4,0); ! ! } catch (Exception e) { ! beep(e); ! } } ! private String getFullCommentLine(){ ! return "#==============================================================================="; } } --- 7,51 ---- package org.python.pydev.editor.actions; ! import org.python.pydev.plugin.PydevPrefs; ! import org.eclipse.core.runtime.Preferences; ! import org.python.pydev.plugin.PydevPlugin; ! /** ! * Creates a comment block. Comment blocks are slightly different than regular comments ! * created in that they provide a distinguishing element at the beginning and end as a ! * separator. In this case, it is a string of <code>=======</code> symbols to strongly ! * differentiate this comment block. * * @author Fabio Zadrozny + * @author Parhaum Toofanian */ ! public class PyAddBlockComment extends PyComment { /** ! * This method is called to return the text that should be replaced ! * by the text passed as a parameter. ! * ! * The text passed as a parameter represents the text from the whole ! * lines of the selection. ! * ! * @param str the string to be replaced. ! * @param endLineDelim delimiter used. ! * @return the new string. */ ! protected String replaceStr(String str, String endLineDelim) { ! return "#" + getFullCommentLine ( ) + endLineDelim + ! "#" + str.replaceAll(endLineDelim, endLineDelim + "#") + ! endLineDelim + "#" + getFullCommentLine ( ); } ! /** ! * Currently returns a string with the comment block. ! * @return Comment line string ! */ ! protected String getFullCommentLine(){ ! Preferences prefs = PydevPlugin.getDefault().getPluginPreferences(); ! return prefs.getString(PydevPrefs.BLOCK_COMMENT); } + } --- NEW FILE: PyRemoveBlockComment.java --- /* * @author: ptoofani * Created: June 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.actions; /** * Removes a comment block. Comment blocks are slightly different than regular comments * created in that they provide a distinguishing element at the beginning and end as a * separator. In this case, it is a string of <code>=======</code> symbols to strongly * differentiate this comment block. * * This will handle regular comment blocks as well by removing the # token at the head of * each line, but will also remove the block separators if they are present * * @author Parhaum Toofanian */ public class PyRemoveBlockComment extends PyAddBlockComment { /** * This method is called to return the text that should be replaced * by the text passed as a parameter. * * The text passed as a parameter represents the text from the whole * lines of the selection. * * @param str the string to be replaced. * @param endLineDelim delimiter used. * @return the new string. */ protected String replaceStr(String str, String endLineDelim) { str = str.replaceAll(endLineDelim+"#", endLineDelim ); if (str.startsWith("#")){ str = str.substring(1); } str = str.replaceAll(getFullCommentLine()+endLineDelim, ""); str = str.replaceAll(endLineDelim+getFullCommentLine(), ""); return str; } } Index: PyComment.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyComment.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyComment.java 15 Apr 2004 23:19:21 -0000 1.2 --- PyComment.java 11 Jun 2004 20:03:56 -0000 1.3 *************** *** 51,56 **** String endLineDelim = getDelimiter(doc, startLineIndex); - startLine = doc.getLineInformation(startLineIndex); - endLine = doc.getLineInformation(endLineIndex); String str = doc.get(initialPos, length); --- 51,54 ---- *************** *** 59,62 **** --- 57,63 ---- doc.replace(initialPos, length, str); + // Select the new comment block automatically + textEditor.selectAndReveal(initialPos,str.length()); + } catch (Exception e) { beep(e); *************** *** 78,80 **** --- 79,82 ---- return "#" + str.replaceAll(endLineDelim, endLineDelim + "#"); } + } --- NEW FILE: PyStripTrailingWhitespace.java --- /* * @author: ptoofani * Created: June 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.actions; import org.eclipse.jface.action.IAction; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextSelection; import org.eclipse.ui.texteditor.ITextEditor; /** * Strips trailing whitespace on the selected lines. If no lines are selected, it performs * the action on the entire document. * * @author Parhaum Toofanian */ public class PyStripTrailingWhitespace extends PyAction { /** * Strip whitespace. */ public void run(IAction action) { try { // Grab the editor ITextEditor textEditor = getTextEditor(); // Grab the document IDocument doc = textEditor.getDocumentProvider().getDocument( textEditor.getEditorInput()); // Grab the selection ITextSelection selection = (ITextSelection) textEditor .getSelectionProvider() .getSelection(); // What we'll be modifying String str = new String ( ); // End line delimiter character String endLineDelim = new String ( ); // Get some line information int initialPos = 0; int length = 0; int startLineIndex = selection.getStartLine(); int endLineIndex = selection.getEndLine(); //special cases...first char of the editor, last char... if (endLineIndex < startLineIndex) { endLineIndex = startLineIndex; } IRegion startLine = doc.getLineInformation(startLineIndex); IRegion endLine = doc.getLineInformation(endLineIndex); // If anything is actually selected, we'll be modifying the selection only if ( selection.getLength ( ) > 0 ) { // Get offsets and lengths initialPos = startLine.getOffset(); length = (endLine.getOffset() - startLine.getOffset()) + endLine.getLength(); endLineDelim = getDelimiter(doc, startLineIndex); // Grab the selected text into our string str = doc.get(initialPos, length); } // Otherwise we'll modify the whole document else { // Grab the whole document str = doc.get ( ); endLineDelim = getDelimiter ( doc, 0 ); length = doc.getLength(); } // We can't use trim() since we only want to get rid of trailing whitespace, // so we need to go line by line. String [] lines = str.split ( endLineDelim ); // What we'll be replacing the selected text with StringBuffer strbuf = new StringBuffer ( ); // For all but the last line, trim whitespace normally for ( int i = 0; i < lines.length - 1; i++ ) { strbuf.append ( trimTrailingWhitespace ( lines[i] ) + endLineDelim ); } // Handle the last line differently, because it might not be a full line with // and ending delimiter, so we don't just want to trim whitespace (it could be // ending in the middle of a line, and this would screw up the code, which we // imagine the developer doesn't want to do if ( lines.length > 0 ) { // Check if full last line is selected or not if ( lines[lines.length - 1].length ( ) == endLine.getLength ( ) ) strbuf.append ( trimTrailingWhitespace ( lines[lines.length - 1] ) ); else strbuf.append ( lines[lines.length - 1] ); } // Replace selection with our new stripped text doc.replace(initialPos, length, strbuf.toString ( ) ); // Put cursor at the first area of the selection textEditor.selectAndReveal(endLine.getOffset(),0); } catch (Exception e) { beep(e); } } /** * This method is called to check for trailing whitespace and get rid of it * * @param str the string to be checked. * @return String the string, stripped of whitespace, or an empty string. */ private String trimTrailingWhitespace ( String str ) { // If nothing at all, just return if ( str.length ( ) == 0 ) return ""; // Find the last non-whitespace character int j; for ( j = str.length ( ) - 1; j >= 0; j-- ) { if ( ! Character.isWhitespace ( str.charAt ( j ) ) ) { break; } } // If the whole line is whitespace, return empty string if ( j < 0 ) return ""; // If the last character isn't whitespace, nothing to trim, so return the string if ( j == str.length ( ) - 1 ) { return ( str ); } // Otherwise, return a substring else { return ( str.substring ( 0, j + 1 ) ); } } } |
From: Parhaum T. <dre...@us...> - 2004-06-11 19:47:22
|
Update of /cvsroot/pydev/org.python.pydev.help/html/images In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24587/html/images Modified Files: ed_prefs.gif Log Message: Modified in org.python.pydev.help: ed_prefs.gif - New screenshot showing new preference page with block separator field ed_prefs.html - Added description of block comment separator userguide folder - contains an idea of a user guide for complete newbies Index: ed_prefs.gif =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.help/html/images/ed_prefs.gif,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvs0SDnxt and /tmp/cvsvSASGW differ |
Update of /cvsroot/pydev/org.python.pydev.help/html/userguide/images In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24587/html/userguide/images Added Files: editor_blockc_03.jpg editor_blockc_01.jpg editor_blockc_02.jpg editor_blockc_05.jpg editor_blockc_04.jpg editor_blockc_06.jpg Log Message: Modified in org.python.pydev.help: ed_prefs.gif - New screenshot showing new preference page with block separator field ed_prefs.html - Added description of block comment separator userguide folder - contains an idea of a user guide for complete newbies --- NEW FILE: editor_blockc_05.jpg --- (This appears to be a binary file; contents omitted.) --- NEW FILE: editor_blockc_04.jpg --- (This appears to be a binary file; contents omitted.) --- NEW FILE: editor_blockc_01.jpg --- (This appears to be a binary file; contents omitted.) --- NEW FILE: editor_blockc_06.jpg --- (This appears to be a binary file; contents omitted.) --- NEW FILE: editor_blockc_03.jpg --- (This appears to be a binary file; contents omitted.) --- NEW FILE: editor_blockc_02.jpg --- (This appears to be a binary file; contents omitted.) |
Update of /cvsroot/pydev/org.python.pydev.help/html/userguide In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24587/html/userguide Added Files: editor_syntaxh.html preferences.html editor_autoi.html editor_stripw.html index.html editor_comment.html editor_blockc.html Log Message: Modified in org.python.pydev.help: ed_prefs.gif - New screenshot showing new preference page with block separator field ed_prefs.html - Added description of block comment separator userguide folder - contains an idea of a user guide for complete newbies --- NEW FILE: index.html --- <h2>PyDev User Manual</h2> <p> Welcome to the PyDev Python IDE User Manual. This section of help will contain a list detailing the features available within the PyDev IDE. </p> --- NEW FILE: editor_comment.html --- <h2>PyDev User Manual</h2> <h3>Editor :: Comment</h3> <p> Besides regular commenting, PyDev allows you to comment out sections of code easily.<br> <br> From this:<br> <br> <img src="images/editor_blockc_06.jpg"><br> <br> To this:<br> <br> <img src="images/editor_blockc_05.jpg"><br> <br> In order to make bulk comments, highlight a body of text in the editor, and do one of the following:<br> <ul> <li>Source Menu -> Comment <li>Right-Click -> Source -> Comment <li>Ctrl+/ </ul> You may remove a selected bulk comment with:<br> <ul> <li>Source -> Comment <li>Right-Click -> Source -> Uncomment <li>Ctrl+\ </ul> </p> --- NEW FILE: editor_autoi.html --- <h2>PyDev User Manual</h2> <h3>Editor :: Auto Indentation</h3> --- NEW FILE: editor_syntaxh.html --- <h2>PyDev User Manual</h2> <h3>Editor :: Syntax Highlighting</h3> --- NEW FILE: editor_stripw.html --- <h2>PyDev User Manual</h2> <h3>Editor :: Strip Trailing Whitespace</h3> <p> Trailing whitespace is any tab, space, etc characters at the end of a line. <br><br> In order to strip whitespace, you can highlight a body of text in the editor, or select nothing and it will strip whitespace in the entire document. Do one of the following:<br> <ul> <li>Source Menu -> Strip Trailing Whitespace <li>Right-Click -> Source -> Strip Trailing Whitespace <li>Shift+Space </p> --- NEW FILE: editor_blockc.html --- <h2>PyDev User Manual</h2> <h3>Editor :: Block Comment</h3> <p> Block Comments are lines of code with the <strong>#</strong> token preceding them, and with separators to make them stand out.<br> <br> From this:<br> <br> <img src="images/editor_blockc_06.jpg"><br> <br> To this:<br> <br> <img src="images/editor_blockc_01.jpg"><br> <br> In order to make block comments, highlight a body of text in the editor, and do one of the following:<br> <ul> <li>Source Menu -> Add Comment Block <li>Right-Click -> Source -> Add Comment Block <li>Ctrl+4 </ul> You may remove a selected comment block with:<br> <ul> <li>Source -> Remove Comment Block <li>Right-Click -> Source -> Remove Comment Block <li>Ctrl+5 </ul> The separator string (the =====) can be changed in the <a href="preferences.html">Preferences page</a>. <br> </p> --- NEW FILE: preferences.html --- <h2>PyDev User Manual</h2> <h3>Preferences</h3> |
From: Parhaum T. <dre...@us...> - 2004-06-11 19:46:49
|
Update of /cvsroot/pydev/org.python.pydev.help/html/userguide/images In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24278/html/userguide/images Log Message: Directory /cvsroot/pydev/org.python.pydev.help/html/userguide/images added to the repository |
From: Parhaum T. <dre...@us...> - 2004-06-11 19:46:49
|
Update of /cvsroot/pydev/org.python.pydev.help/html/userguide In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24278/html/userguide Log Message: Directory /cvsroot/pydev/org.python.pydev.help/html/userguide added to the repository |
From: Dana M. <dan...@us...> - 2004-05-27 18:29:46
|
Update of /cvsroot/pydev/org.pydev.jython In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24061 Modified Files: .classpath build.properties Log Message: repaired build.properties Index: .classpath =================================================================== RCS file: /cvsroot/pydev/org.pydev.jython/.classpath,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .classpath 25 May 2004 18:01:56 -0000 1.1 --- .classpath 27 May 2004 18:29:35 -0000 1.2 *************** *** 1,5 **** <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src/"/> <classpathentry kind="src" path="/org.eclipse.core.boot"/> <classpathentry kind="src" path="/org.eclipse.core.runtime"/> --- 1,4 ---- Index: build.properties =================================================================== RCS file: /cvsroot/pydev/org.pydev.jython/build.properties,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** build.properties 25 May 2004 18:01:56 -0000 1.1 --- build.properties 27 May 2004 18:29:35 -0000 1.2 *************** *** 1,3 **** - source.jython.jar = src/ bin.includes = plugin.xml,\ *.jar,\ --- 1,2 ---- |
From: Aleksandar T. <at...@us...> - 2004-05-26 18:57:09
|
Update of /cvsroot/pydev/org.python.pydev.debug/pysrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30779/pysrc Modified Files: pydevd.py Log Message: Fix for 958736: renamed functions with pydevd prefix to avoid naming conflicts in trace_dispatch Index: pydevd.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/pysrc/pydevd.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pydevd.py 17 May 2004 20:17:16 -0000 1.6 --- pydevd.py 26 May 2004 18:56:58 -0000 1.7 *************** *** 76,89 **** __all__ = (); ! _trace = 0 ! ! def log(level, s): """ levels are: ! 0 most serious warnings/errors 1 warnings/significant events 2 informational trace """ ! if (level <= _trace): print >>sys.stderr, s --- 76,89 ---- __all__ = (); + + pydevd_trace = 0 ! def pydevd_log(level, s): """ levels are: ! 0 most serious warnings/errors 1 warnings/significant events 2 informational trace """ ! if (level <= pydevd_trace): print >>sys.stderr, s *************** *** 108,112 **** while (buffer.find('\n') != -1): [command, buffer] = buffer.split('\n', 1) ! log(1, "received command " + command) args = command.split('\t', 2) # print "the args are", args[0], " 2 ", args[1], " 3 ", args[2] --- 108,112 ---- while (buffer.find('\n') != -1): [command, buffer] = buffer.split('\n', 1) ! pydevd_log(1, "received command " + command) args = command.split('\t', 2) # print "the args are", args[0], " 2 ", args[1], " 3 ", args[2] *************** *** 136,144 **** while(True): cmd = self.cmdQueue.get(1) ! log(1, "sending cmd " + cmd.getOutgoing()) self.sock.sendall(cmd.getOutgoing()) except: ! print >>sys.stderr, "Exception in writer thread" ! raise class NetCommand: --- 136,146 ---- while(True): cmd = self.cmdQueue.get(1) ! pydevd_log(1, "sending cmd " + cmd.getOutgoing()) self.sock.sendall(cmd.getOutgoing()) + except Exception, e: + print >>sys.stderr, "Exception in writer thread", str(e) except: ! print >>sys.stderr, "Exception in writer thread" ! raise class NetCommand: *************** *** 285,289 **** def doIt(self, dbg): ! log(1, "killing " + str(self.thread_id)) cmd = dbg.cmdFactory.makeThreadKilledMessage(self.thread_id) dbg.writer.addCommand(cmd) --- 287,291 ---- def doIt(self, dbg): ! pydevd_log(1, "killing " + str(self.thread_id)) cmd = dbg.cmdFactory.makeThreadKilledMessage(self.thread_id) dbg.writer.addCommand(cmd) *************** *** 318,322 **** dbg.writer.addCommand(cmd) ! def findThreadById(thread_id): try: int_id = int(thread_id) --- 320,324 ---- dbg.writer.addCommand(cmd) ! def pydevd_findThreadById(thread_id): try: int_id = int(thread_id) *************** *** 374,378 **** # TODO untested s = socket(AF_INET, SOCK_STREAM) ! s.bind(port) s.listen(1) newSock, addr = s.accept() --- 376,380 ---- # TODO untested s = socket(AF_INET, SOCK_STREAM) ! s.bind(('', port)) s.listen(1) newSock, addr = s.accept() *************** *** 381,390 **** def startClient(self, host, port): """ connects to a host/port """ ! log(1, "Connecting to " + host + ":" + str(port)) try: s = socket(AF_INET, SOCK_STREAM); s.settimeout(10) # seconds s.connect((host, port)) ! log(1, "Connected.") self.initializeNetwork(s) except timeout, e: --- 383,392 ---- def startClient(self, host, port): """ connects to a host/port """ ! pydevd_log(1, "Connecting to " + host + ":" + str(port)) try: s = socket(AF_INET, SOCK_STREAM); s.settimeout(10) # seconds s.connect((host, port)) ! pydevd_log(1, "Connected.") self.initializeNetwork(s) except timeout, e: *************** *** 414,421 **** cmd = self.cmdFactory.makeThreadCreatedMessage(t) if (cmd): ! log(2, "found a new thread " + str(thread_id)) self.writer.addCommand(cmd) else: ! log(0, "could not find thread by id to register") return self.cmdQueue[thread_id] --- 416,423 ---- cmd = self.cmdFactory.makeThreadCreatedMessage(t) if (cmd): ! pydevd_log(2, "found a new thread " + str(thread_id)) self.writer.addCommand(cmd) else: ! pydevd_log(0, "could not find thread by id to register") return self.cmdQueue[thread_id] *************** *** 434,438 **** while (True): int_cmd = queue.get(False) ! log(2, "processign internal command " + str(int_cmd)) int_cmd.doIt(self) except Empty: --- 436,440 ---- while (True): int_cmd = queue.get(False) ! pydevd_log(2, "processign internal command " + str(int_cmd)) int_cmd.doIt(self) except Empty: *************** *** 453,466 **** elif (id == CMD_THREAD_SUSPEND): # print >>sys.stderr, "About to suspend ", text ! t = findThreadById(text) if t: self.setSuspend(t, CMD_THREAD_SUSPEND) # else: print >>sys.stderr, "Could not find thread ", t elif (id == CMD_THREAD_RUN): ! t = findThreadById(text) if t: t.pydev_state = PyDB.STATE_RUN t.pydev_step_cmd = None elif (id == CMD_STEP_INTO or id == CMD_STEP_OVER or id == CMD_STEP_RETURN): ! t = findThreadById(text) if t: t.pydev_state = PyDB.STATE_RUN --- 455,468 ---- elif (id == CMD_THREAD_SUSPEND): # print >>sys.stderr, "About to suspend ", text ! t = pydevd_findThreadById(text) if t: self.setSuspend(t, CMD_THREAD_SUSPEND) # else: print >>sys.stderr, "Could not find thread ", t elif (id == CMD_THREAD_RUN): ! t = pydevd_findThreadById(text) if t: t.pydev_state = PyDB.STATE_RUN t.pydev_step_cmd = None elif (id == CMD_STEP_INTO or id == CMD_STEP_OVER or id == CMD_STEP_RETURN): ! t = pydevd_findThreadById(text) if t: t.pydev_state = PyDB.STATE_RUN *************** *** 473,477 **** else: (scope, attrs) = (scopeattrs, None) ! t = findThreadById(thread_id) if t: int_cmd = InternalGetVariable(seq, t, frame_id, scope, attrs) --- 475,479 ---- else: (scope, attrs) = (scopeattrs, None) ! t = pydevd_findThreadById(thread_id) if t: int_cmd = InternalGetVariable(seq, t, frame_id, scope, attrs) *************** *** 488,492 **** breakDict[int(line)] = True self.breakpoints[file] = breakDict ! log(1, "Set breakpoint at " + file + " " + line) elif (id == CMD_REMOVE_BREAK): # text is file\tline. Remove from breakpoints dictionary --- 490,494 ---- breakDict[int(line)] = True self.breakpoints[file] = breakDict ! pydevd_log(1, "Set breakpoint at " + file + " " + line) elif (id == CMD_REMOVE_BREAK): # text is file\tline. Remove from breakpoints dictionary *************** *** 503,507 **** else: cmd = self.cmdFactory.makeErrorMessage(seq, "unexpected command " + str(id)) ! log( 1, "processed command " + str (id)) if cmd: self.writer.addCommand(cmd) --- 505,509 ---- else: cmd = self.cmdFactory.makeErrorMessage(seq, "unexpected command " + str(id)) ! pydevd_log(1, "processed command " + str (id)) if cmd: self.writer.addCommand(cmd) *************** *** 520,524 **** thread.pydev_notify_kill = False if not wasNotified: ! log(1, "leaving stopped thread " + str(id(thread))) cmd = self.cmdFactory.makeThreadKilledMessage(id(thread)) self.writer.addCommand(cmd) --- 522,526 ---- thread.pydev_notify_kill = False if not wasNotified: ! pydevd_log(1, "leaving stopped thread " + str(id(thread))) cmd = self.cmdFactory.makeThreadKilledMessage(id(thread)) self.writer.addCommand(cmd) *************** *** 558,562 **** pass ! log(1, "thread resumed " + thread.getName()) cmd = self.cmdFactory.makeThreadRunMessage(id(thread), thread.pydev_step_cmd) self.writer.addCommand(cmd) --- 560,564 ---- pass ! pydevd_log(1, "thread resumed " + thread.getName()) cmd = self.cmdFactory.makeThreadRunMessage(id(thread), thread.pydev_step_cmd) self.writer.addCommand(cmd) *************** *** 709,713 **** def quittingNow(): ! log(1, "Debugger exiting. Over & out....\n") if __name__ == '__main__': --- 711,715 ---- def quittingNow(): ! pydevd_log(1, "Debugger exiting. Over & out....\n") if __name__ == '__main__': *************** *** 719,724 **** print e usage(1) ! log(2, "Executing file " + setup['file']) ! log(2, "arguments:" + str(sys.argv)) import atexit --- 721,726 ---- print e usage(1) ! pydevd_log(2, "Executing file " + setup['file']) ! pydevd_log(2, "arguments:" + str(sys.argv)) import atexit |
From: Dana M. <dan...@us...> - 2004-05-25 21:42:23
|
Update of /cvsroot/pydev/org.python.pydev/PySrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2262/PySrc Modified Files: introspect.py Log Message: introspection launched from a jython wrapper Index: introspect.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/introspect.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** introspect.py 25 May 2004 21:36:56 -0000 1.1 --- introspect.py 25 May 2004 21:42:14 -0000 1.2 *************** *** 10,14 **** __cvsid__ = "$Id$" __revision__ = "$Revision$"[11:-2] ! import cStringIO --- 10,14 ---- __cvsid__ = "$Id$" __revision__ = "$Revision$"[11:-2] ! # PYDEV Wrapping by the PyDev content team import cStringIO |
From: Dana M. <dan...@us...> - 2004-05-25 21:37:06
|
Update of /cvsroot/pydev/org.python.pydev/PySrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1439/PySrc Added Files: inspect.py introspect.py jintrospect.py Log Message: content introspectors --- NEW FILE: introspect.py --- """Provides a variety of introspective-type support functions for things like call tips and command auto completion. NOTE: this file is a modification of Patrick O'Brien's version 1.62 """ from __future__ import nested_scopes __author__ = "Patrick K. O'Brien <po...@or...>" __cvsid__ = "$Id: introspect.py,v 1.1 2004/05/25 21:36:56 dana_virtual Exp $" __revision__ = "$Revision: 1.1 $"[11:-2] import cStringIO import inspect import sys import tokenize import types from debug import * try: True except NameError: True = 1==1 False = 1==0 def getAutoCompleteList(command='', locals=None, includeMagic=1, includeSingle=1, includeDouble=1): """Return list of auto-completion options for command. The list of options will be based on the locals namespace.""" attributes = [] # Get the proper chunk of code from the command. root = getRoot(command, terminator='.') debug( "getAutoCompleteList: root ", root) try: if locals is not None: object = eval(root, locals) debug( "getAutoCompleteList: object w locals ", object) else: object = eval(root) debug( "getAutoCompleteList: object ", object) except: debug( "getAutoCompleteList: could not eval object ") pass else: attributes = getAttributeNames(object, includeMagic, includeSingle, includeDouble) debug( "getAutoCompleteList: attributes ", attributes) return attributes def getAttributeNames(object, includeMagic=1, includeSingle=1, includeDouble=1): """Return list of unique attributes, including inherited, for object.""" attributes = [] dict = {} if not hasattrAlwaysReturnsTrue(object): # Add some attributes that don't always get picked up. If # they don't apply, they'll get filtered out at the end. attributes += ['__bases__', '__class__', '__dict__', '__name__', 'func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc', 'func_globals', 'func_name'] if includeMagic: try: attributes += object._getAttributeNames() except: pass # Get all attribute names. attrdict = getAllAttributeNames(object) for attrlist in attrdict.values(): attributes += attrlist # Remove duplicates from the attribute list. for item in attributes: dict[item] = None attributes = dict.keys() attributes.sort(lambda x, y: cmp(x.upper(), y.upper())) if not includeSingle: attributes = filter(lambda item: item[0]!='_' \ or item[1]=='_', attributes) if not includeDouble: attributes = filter(lambda item: item[:2]!='__', attributes) # Make sure we haven't picked up any bogus attributes somehow. attributes = [attribute for attribute in attributes \ if hasattr(object, attribute)] debug( "getAttributeNames: attributes ",attributes) return attributes def hasattrAlwaysReturnsTrue(object): return hasattr(object, 'bogu5_123_aTTri8ute') def getAllAttributeNames(object): """Return dict of all attributes, including inherited, for an object. Recursively walk through a class and all base classes. """ attrdict = {} # (object, technique, count): [list of attributes] # !!! # Do Not use hasattr() as a test anywhere in this function, # because it is unreliable with remote objects: xmlrpc, soap, etc. # They always return true for hasattr(). # !!! try: # Yes, this can fail if object is an instance of a class with # __str__ (or __repr__) having a bug or raising an # exception. :-( key = str(object) except: key = 'anonymous' # Wake up sleepy objects - a hack for ZODB objects in "ghost" state. wakeupcall = dir(object) del wakeupcall # Get attributes available through the normal convention. attributes = dir(object) attrdict[(key, 'dir', len(attributes))] = attributes # Get attributes from the object's dictionary, if it has one. try: attributes = object.__dict__.keys() attributes.sort() except: # Must catch all because object might have __getattr__. pass else: attrdict[(key, '__dict__', len(attributes))] = attributes # For a class instance, get the attributes for the class. try: klass = object.__class__ except: # Must catch all because object might have __getattr__. pass else: if klass is object: # Break a circular reference. This happens with extension # classes. pass else: attrdict.update(getAllAttributeNames(klass)) # Also get attributes from any and all parent classes. try: bases = object.__bases__ except: # Must catch all because object might have __getattr__. pass else: if isinstance(bases, types.TupleType): for base in bases: if type(base) is types.TypeType: # Break a circular reference. Happens in Python 2.2. pass else: attrdict.update(getAllAttributeNames(base)) return attrdict def getCallTip(command='', locals=None): """For a command, return a tuple of object name, argspec, tip text. The call tip information will be based on the locals namespace.""" calltip = ('', '', '') # object name, argspec, tip text. # Get the proper chunk of code from the command. root = getRoot(command, terminator='(') try: if locals is not None: object = eval(root, locals) else: object = eval(root) except: return calltip name = '' object, dropSelf = getBaseObject(object) try: name = object.__name__ except AttributeError: pass tip1 = '' argspec = '' if inspect.isbuiltin(object): # Builtin functions don't have an argspec that we can get. pass elif inspect.isfunction(object): # tip1 is a string like: "getCallTip(command='', locals=None)" argspec = apply(inspect.formatargspec, inspect.getargspec(object)) if dropSelf: # The first parameter to a method is a reference to an # instance, usually coded as "self", and is usually passed # automatically by Python; therefore we want to drop it. temp = argspec.split(',') if len(temp) == 1: # No other arguments. argspec = '()' else: # Drop the first argument. argspec = '(' + ','.join(temp[1:]).lstrip() tip1 = name + argspec doc = '' if callable(object): doc = inspect.getdoc(object) if doc: # tip2 is the first separated line of the docstring, like: # "Return call tip text for a command." # tip3 is the rest of the docstring, like: # "The call tip information will be based on ... <snip> firstline = doc.split('\n')[0].lstrip() if tip1 == firstline: tip1 = '' else: tip1 += '\n\n' docpieces = doc.split('\n\n') tip2 = docpieces[0] tip3 = '\n\n'.join(docpieces[1:]) tip = '%s%s\n\n%s' % (tip1, tip2, tip3) else: tip = tip1 calltip = (name, argspec[1:-1], tip.strip()) return calltip def getRoot(command, terminator=None): """Return the rightmost root portion of an arbitrary Python command. Return only the root portion that can be eval()'d without side effects. The command would normally terminate with a '(' or '.'. The terminator and anything after the terminator will be dropped.""" command = command.split('\n')[-1] #~ print "DBG: command", command #~ print "DBG: sys", dir(sys), ' ps2 ', sys.ps2 #~ if command.startswith(sys.ps2): #~ command = command[len(sys.ps2):] command = command.lstrip() command = rtrimTerminus(command, terminator) tokens = getTokens(command) if not tokens: return '' if tokens[-1][0] is tokenize.ENDMARKER: # Remove the end marker. del tokens[-1] if not tokens: return '' if terminator == '.' and \ (tokens[-1][1] <> '.' or tokens[-1][0] is not tokenize.OP): # Trap decimals in numbers, versus the dot operator. return '' else: # Strip off the terminator. if terminator and command.endswith(terminator): size = 0 - len(terminator) command = command[:size] command = command.rstrip() tokens = getTokens(command) tokens.reverse() line = '' start = None prefix = '' laststring = '.' emptyTypes = ('[]', '()', '{}') for token in tokens: tokentype = token[0] tokenstring = token[1] line = token[4] if tokentype is tokenize.ENDMARKER: continue if tokentype in (tokenize.NAME, tokenize.STRING, tokenize.NUMBER) \ and laststring != '.': # We've reached something that's not part of the root. if prefix and line[token[3][1]] != ' ': # If it doesn't have a space after it, remove the prefix. prefix = '' break if tokentype in (tokenize.NAME, tokenize.STRING, tokenize.NUMBER) \ or (tokentype is tokenize.OP and tokenstring == '.'): if prefix: # The prefix isn't valid because it comes after a dot. prefix = '' break else: # start represents the last known good point in the line. start = token[2][1] elif len(tokenstring) == 1 and tokenstring in ('[({])}'): # Remember, we're working backwords. # So prefix += tokenstring would be wrong. if prefix in emptyTypes and tokenstring in ('[({'): # We've already got an empty type identified so now we # are in a nested situation and we can break out with # what we've got. break else: prefix = tokenstring + prefix else: # We've reached something that's not part of the root. break laststring = tokenstring if start is None: start = len(line) root = line[start:] if prefix in emptyTypes: # Empty types are safe to be eval()'d and introspected. root = prefix + root return root def getTokens(command): """Return list of token tuples for command.""" command = str(command) # In case the command is unicode, which fails. f = cStringIO.StringIO(command) # tokens is a list of token tuples, each looking like: # (type, string, (srow, scol), (erow, ecol), line) tokens = [] # Can't use list comprehension: # tokens = [token for token in tokenize.generate_tokens(f.readline)] # because of need to append as much as possible before TokenError. try: ## This code wasn't backward compatible with Python 2.1.3. ## ## for token in tokenize.generate_tokens(f.readline): ## tokens.append(token) # This works with Python 2.1.3 (with nested_scopes). def eater(*args): tokens.append(args) tokenize.tokenize_loop(f.readline, eater) except tokenize.TokenError: # This is due to a premature EOF, which we expect since we are # feeding in fragments of Python code. pass return tokens def rtrimTerminus(command, terminator=None): """Return command minus anything that follows the final terminator.""" if terminator: pieces = command.split(terminator) if len(pieces) > 1: command = terminator.join(pieces[:-1]) + terminator return command def getBaseObject(object): """Return base object and dropSelf indicator for an object.""" if inspect.isbuiltin(object): # Builtin functions don't have an argspec that we can get. dropSelf = 0 elif inspect.ismethod(object): # Get the function from the object otherwise # inspect.getargspec() complains that the object isn't a # Python function. try: if object.im_self is None: # This is an unbound method so we do not drop self # from the argspec, since an instance must be passed # as the first arg. dropSelf = 0 else: dropSelf = 1 object = object.im_func except AttributeError: dropSelf = 0 elif inspect.isclass(object): # Get the __init__ method function for the class. constructor = getConstructor(object) if constructor is not None: object = constructor dropSelf = 1 else: dropSelf = 0 elif callable(object): # Get the __call__ method instead. try: call_method = object.__call__.im_func if call_method.__name__ == '__call__': # unbound jython method end up here, example: string.index( dropSelf = 0 else: object = call_method dropSelf = 1 except AttributeError: # unbound python methods end up here dropSelf = 0 else: dropSelf = 0 return object, dropSelf def getConstructor(object): """Return constructor for class object, or None if there isn't one.""" try: return object.__init__.im_func except AttributeError: for base in object.__bases__: constructor = getConstructor(base) if constructor is not None: return constructor return None --- NEW FILE: jintrospect.py --- """Extend introspect.py for Java based Jython classes.""" from introspect import * import string from debug import * __author__ = "Don Coleman <dco...@ch...>" __cvsid__ = "$Id: jintrospect.py,v 1.1 2004/05/25 21:36:56 dana_virtual Exp $" def getAutoCompleteList(command='', locals=None, includeMagic=1, includeSingle=1, includeDouble=1): """Return list of auto-completion options for command. The list of options will be based on the locals namespace.""" attributes = [] # Get the proper chunk of code from the command. root = getRoot(command, terminator='.') debug( "JgetAutoCompleteList: root ", root) try: if locals is not None: object = eval(root, locals) else: object = eval(root) except: return attributes debug( "JgetAutoCompleteList: object ", object) if ispython(object): # use existing code attributes = getAttributeNames(object, includeMagic, includeSingle, includeDouble) else: methods = methodsOf(object.__class__) attributes = [eachMethod.__name__ for eachMethod in methods] return attributes def methodsOf(clazz): """return a list of all the methods in a class""" classMembers = vars(clazz).values() methods = [eachMember for eachMember in classMembers if callable(eachMember)] for eachBase in clazz.__bases__: methods.extend(methodsOf(eachBase)) return methods def getCallTipJava(command='', locals=None): """For a command, return a tuple of object name, argspec, tip text. The call tip information will be based on the locals namespace.""" calltip = ('', '', '') # object name, argspec, tip text. # Get the proper chunk of code from the command. root = getRoot(command, terminator='(') try: if locals is not None: object = eval(root, locals) else: object = eval(root) except: return calltip if ispython(object): # Patrick's code handles python code # TODO fix in future because getCallTip runs eval() again return getCallTip(command, locals) name = '' try: name = object.__name__ except AttributeError: pass tipList = [] argspec = '' # not using argspec for Java if inspect.isbuiltin(object): # inspect.isbuiltin() fails for Jython # Can we get the argspec for Jython builtins? We can't in Python. pass elif inspect.isclass(object): # get the constructor(s) # TODO consider getting modifiers since jython can access private methods constructors = object.getConstructors() for constructor in constructors: paramList = [] paramTypes = constructor.getParameterTypes() # paramTypes is an array of classes, we need Strings # TODO consider list comprehension for param in paramTypes: # TODO translate [B to byte[], [C to char[] etc paramList.append(param.__name__) paramString = string.join(paramList,', ') tip = "%s(%s)" % (constructor.name, paramString) tipList.append(tip) elif inspect.ismethod(object): method = object object = method.im_class # java allows overloading so we may have more than one method methodArray = object.getMethods() for eachMethod in methodArray: if eachMethod.name == method.__name__: paramList = [] for eachParam in eachMethod.parameterTypes: paramList.append(eachParam.__name__) paramString = string.join(paramList,', ') # create a python style string a la PyCrust # we're showing the parameter type rather than the parameter name, since that's all I can get # we need to show multiple methods for overloading # TODO improve message format # do we want to show the method visibility # how about exceptions? # note: name, return type and exceptions same for EVERY overload method tip = "%s(%s) -> %s" % (eachMethod.name, paramString, eachMethod.returnType) tipList.append(tip) # else: # print "Not a java class :(" calltip = (name, argspec, string.join(tipList,"\n")) return calltip def ispython(object): """ Figure out if this is Python code or Java Code """ pyclass = 0 pycode = 0 pyinstance = 0 if inspect.isclass(object): try: object.__doc__ pyclass = 1 except AttributeError: pyclass = 0 elif inspect.ismethod(object): try: object.__dict__ pycode = 1 except AttributeError: pycode = 0 else: # I guess an instance of an object falls here try: object.__dict__ pyinstance = 1 except AttributeError: pyinstance = 0 # print "object", object, "pyclass", pyclass, "pycode", pycode, "returning", pyclass | pycode return pyclass | pycode | pyinstance --- NEW FILE: inspect.py --- """Get useful information from live Python objects. This module encapsulates the interface provided by the internal special attributes (func_*, co_*, im_*, tb_*, etc.) in a friendlier fashion. It also provides some help for examining source code and class layout. Here are some of the useful functions provided by this module: ismodule(), isclass(), ismethod(), isfunction(), istraceback(), isframe(), iscode(), isbuiltin(), isroutine() - check object types getmembers() - get members of an object that satisfy a given condition getfile(), getsourcefile(), getsource() - find an object's source code getdoc(), getcomments() - get documentation on an object getmodule() - determine the module that an object came from getclasstree() - arrange classes so as to represent their hierarchy getargspec(), getargvalues() - get info about function arguments formatargspec(), formatargvalues() - format an argument spec getouterframes(), getinnerframes() - get info about frames currentframe() - get the current stack frame stack(), trace() - get info about frames on the stack or in a traceback """ # This module is in the public domain. No warranties. __author__ = 'Ka-Ping Yee <pi...@lf...>' __date__ = '1 Jan 2001' import sys, os, types, string, re, dis, imp, tokenize # ----------------------------------------------------------- type-checking def ismodule(object): """Return true if the object is a module. Module objects provide these attributes: __doc__ documentation string __file__ filename (missing for built-in modules)""" return isinstance(object, types.ModuleType) def isclass(object): """Return true if the object is a class. Class objects provide these attributes: __doc__ documentation string __module__ name of module in which this class was defined""" return isinstance(object, types.ClassType) or hasattr(object, '__bases__') def ismethod(object): """Return true if the object is an instance method. Instance method objects provide these attributes: __doc__ documentation string __name__ name with which this method was defined im_class class object in which this method belongs im_func function object containing implementation of method im_self instance to which this method is bound, or None""" return isinstance(object, types.MethodType) def ismethoddescriptor(object): """Return true if the object is a method descriptor. But not if ismethod() or isclass() or isfunction() are true. This is new in Python 2.2, and, for example, is true of int.__add__. An object passing this test has a __get__ attribute but not a __set__ attribute, but beyond that the set of attributes varies. __name__ is usually sensible, and __doc__ often is. Methods implemented via descriptors that also pass one of the other tests return false from the ismethoddescriptor() test, simply because the other tests promise more -- you can, e.g., count on having the im_func attribute (etc) when an object passes ismethod().""" return (hasattr(object, "__get__") and not hasattr(object, "__set__") # else it's a data descriptor and not ismethod(object) # mutual exclusion and not isfunction(object) and not isclass(object)) def isfunction(object): """Return true if the object is a user-defined function. Function objects provide these attributes: __doc__ documentation string __name__ name with which this function was defined func_code code object containing compiled function bytecode func_defaults tuple of any default values for arguments func_doc (same as __doc__) func_globals global namespace in which this function was defined func_name (same as __name__)""" return isinstance(object, types.FunctionType) def istraceback(object): """Return true if the object is a traceback. Traceback objects provide these attributes: tb_frame frame object at this level tb_lasti index of last attempted instruction in bytecode tb_lineno current line number in Python source code tb_next next inner traceback object (called by this level)""" return isinstance(object, types.TracebackType) def isframe(object): """Return true if the object is a frame object. Frame objects provide these attributes: f_back next outer frame object (this frame's caller) f_builtins built-in namespace seen by this frame f_code code object being executed in this frame f_exc_traceback traceback if raised in this frame, or None f_exc_type exception type if raised in this frame, or None f_exc_value exception value if raised in this frame, or None f_globals global namespace seen by this frame f_lasti index of last attempted instruction in bytecode f_lineno current line number in Python source code f_locals local namespace seen by this frame f_restricted 0 or 1 if frame is in restricted execution mode f_trace tracing function for this frame, or None""" return isinstance(object, types.FrameType) def iscode(object): """Return true if the object is a code object. Code objects provide these attributes: co_argcount number of arguments (not including * or ** args) co_code string of raw compiled bytecode co_consts tuple of constants used in the bytecode co_filename name of file in which this code object was created co_firstlineno number of first line in Python source code co_flags bitmap: 1=optimized | 2=newlocals | 4=*arg | 8=**arg co_lnotab encoded mapping of line numbers to bytecode indices co_name name with which this code object was defined co_names tuple of names of local variables co_nlocals number of local variables co_stacksize virtual machine stack space required co_varnames tuple of names of arguments and local variables""" return isinstance(object, types.CodeType) def isbuiltin(object): """Return true if the object is a built-in function or method. Built-in functions and methods provide these attributes: __doc__ documentation string __name__ original name of this function or method __self__ instance to which a method is bound, or None""" return isinstance(object, types.BuiltinFunctionType) def isroutine(object): """Return true if the object is any kind of function or method.""" return (isbuiltin(object) or isfunction(object) or ismethod(object) or ismethoddescriptor(object)) def getmembers(object, predicate=None): """Return all members of an object as (name, value) pairs sorted by name. Optionally, only return members that satisfy a given predicate.""" results = [] for key in dir(object): value = getattr(object, key) if not predicate or predicate(value): results.append((key, value)) results.sort() return results def classify_class_attrs(cls): """Return list of attribute-descriptor tuples. For each name in dir(cls), the return list contains a 4-tuple with these elements: 0. The name (a string). 1. The kind of attribute this is, one of these strings: 'class method' created via classmethod() 'static method' created via staticmethod() 'property' created via property() 'method' any other flavor of method 'data' not a method 2. The class which defined this attribute (a class). 3. The object as obtained directly from the defining class's __dict__, not via getattr. This is especially important for data attributes: C.data is just a data object, but C.__dict__['data'] may be a data descriptor with additional info, like a __doc__ string. """ mro = getmro(cls) names = dir(cls) result = [] for name in names: # Get the object associated with the name. # Getting an obj from the __dict__ sometimes reveals more than # using getattr. Static and class methods are dramatic examples. if name in cls.__dict__: obj = cls.__dict__[name] else: obj = getattr(cls, name) # Figure out where it was defined. homecls = getattr(obj, "__objclass__", None) if homecls is None: # search the dicts. for base in mro: if name in base.__dict__: homecls = base break # Get the object again, in order to get it from the defining # __dict__ instead of via getattr (if possible). if homecls is not None and name in homecls.__dict__: obj = homecls.__dict__[name] # Also get the object via getattr. obj_via_getattr = getattr(cls, name) # Classify the object. if isinstance(obj, staticmethod): kind = "static method" elif isinstance(obj, classmethod): kind = "class method" elif isinstance(obj, property): kind = "property" elif (ismethod(obj_via_getattr) or ismethoddescriptor(obj_via_getattr)): kind = "method" else: kind = "data" result.append((name, kind, homecls, obj)) return result # ----------------------------------------------------------- class helpers def _searchbases(cls, accum): # Simulate the "classic class" search order. if cls in accum: return accum.append(cls) for base in cls.__bases__: _searchbases(base, accum) def getmro(cls): "Return tuple of base classes (including cls) in method resolution order." if hasattr(cls, "__mro__"): return cls.__mro__ else: result = [] _searchbases(cls, result) return tuple(result) # -------------------------------------------------- source code extraction def indentsize(line): """Return the indent size, in spaces, at the start of a line of text.""" expline = string.expandtabs(line) return len(expline) - len(string.lstrip(expline)) def getdoc(object): """Get the documentation string for an object. All tabs are expanded to spaces. To clean up docstrings that are indented to line up with blocks of code, any whitespace than can be uniformly removed from the second line onwards is removed.""" try: doc = object.__doc__ except AttributeError: return None # Jython doesn't like this syntax # if not isinstance(doc, (str, unicode)): # in Jython UnicodeType == StringType if not isinstance(doc, types.StringType): return None try: lines = string.split(string.expandtabs(doc), '\n') except UnicodeError: return None else: margin = None for line in lines[1:]: content = len(string.lstrip(line)) if not content: continue indent = len(line) - content if margin is None: margin = indent else: margin = min(margin, indent) if margin is not None: for i in range(1, len(lines)): lines[i] = lines[i][margin:] return string.join(lines, '\n') def getfile(object): """Work out which source or compiled file an object was defined in.""" if ismodule(object): if hasattr(object, '__file__'): return object.__file__ raise TypeError, 'arg is a built-in module' if isclass(object): object = sys.modules.get(object.__module__) if hasattr(object, '__file__'): return object.__file__ raise TypeError, 'arg is a built-in class' if ismethod(object): object = object.im_func if isfunction(object): object = object.func_code if istraceback(object): object = object.tb_frame if isframe(object): object = object.f_code if iscode(object): return object.co_filename raise TypeError, 'arg is not a module, class, method, ' \ 'function, traceback, frame, or code object' def getmoduleinfo(path): """Get the module name, suffix, mode, and module type for a given file.""" filename = os.path.basename(path) suffixes = map(lambda (suffix, mode, mtype): (-len(suffix), suffix, mode, mtype), imp.get_suffixes()) suffixes.sort() # try longest suffixes first, in case they overlap for neglen, suffix, mode, mtype in suffixes: if filename[neglen:] == suffix: return filename[:neglen], suffix, mode, mtype def getmodulename(path): """Return the module name for a given file, or None.""" info = getmoduleinfo(path) if info: return info[0] def getsourcefile(object): """Return the Python source file an object was defined in, if it exists.""" filename = getfile(object) if string.lower(filename[-4:]) in ['.pyc', '.pyo']: filename = filename[:-4] + '.py' for suffix, mode, kind in imp.get_suffixes(): if 'b' in mode and string.lower(filename[-len(suffix):]) == suffix: # Looks like a binary file. We want to only return a text file. return None if os.path.exists(filename): return filename def getabsfile(object): """Return an absolute path to the source or compiled file for an object. The idea is for each object to have a unique origin, so this routine normalizes the result as much as possible.""" return os.path.normcase( os.path.abspath(getsourcefile(object) or getfile(object))) modulesbyfile = {} def getmodule(object): """Return the module an object was defined in, or None if not found.""" if ismodule(object): return object if isclass(object): return sys.modules.get(object.__module__) try: file = getabsfile(object) except TypeError: return None if modulesbyfile.has_key(file): return sys.modules[modulesbyfile[file]] for module in sys.modules.values(): if hasattr(module, '__file__'): modulesbyfile[getabsfile(module)] = module.__name__ if modulesbyfile.has_key(file): return sys.modules[modulesbyfile[file]] main = sys.modules['__main__'] if hasattr(main, object.__name__): mainobject = getattr(main, object.__name__) if mainobject is object: return main builtin = sys.modules['__builtin__'] if hasattr(builtin, object.__name__): builtinobject = getattr(builtin, object.__name__) if builtinobject is object: return builtin def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.""" try: file = open(getsourcefile(object)) except (TypeError, IOError): raise IOError, 'could not get source code' lines = file.readlines() file.close() if ismodule(object): return lines, 0 if isclass(object): name = object.__name__ pat = re.compile(r'^\s*class\s*' + name + r'\b') for i in range(len(lines)): if pat.match(lines[i]): return lines, i else: raise IOError, 'could not find class definition' if ismethod(object): object = object.im_func if isfunction(object): object = object.func_code if istraceback(object): object = object.tb_frame if isframe(object): object = object.f_code if iscode(object): if not hasattr(object, 'co_firstlineno'): raise IOError, 'could not find function definition' lnum = object.co_firstlineno - 1 pat = re.compile(r'^\s*def\s') while lnum > 0: if pat.match(lines[lnum]): break lnum = lnum - 1 return lines, lnum raise IOError, 'could not find code object' def getcomments(object): """Get lines of comments immediately preceding an object's source code.""" try: lines, lnum = findsource(object) except IOError: return None if ismodule(object): # Look for a comment block at the top of the file. start = 0 if lines and lines[0][:2] == '#!': start = 1 while start < len(lines) and string.strip(lines[start]) in ['', '#']: start = start + 1 if start < len(lines) and lines[start][:1] == '#': comments = [] end = start while end < len(lines) and lines[end][:1] == '#': comments.append(string.expandtabs(lines[end])) end = end + 1 return string.join(comments, '') # Look for a preceding block of comments at the same indentation. elif lnum > 0: indent = indentsize(lines[lnum]) end = lnum - 1 if end >= 0 and string.lstrip(lines[end])[:1] == '#' and \ indentsize(lines[end]) == indent: comments = [string.lstrip(string.expandtabs(lines[end]))] if end > 0: end = end - 1 comment = string.lstrip(string.expandtabs(lines[end])) while comment[:1] == '#' and indentsize(lines[end]) == indent: comments[:0] = [comment] end = end - 1 if end < 0: break comment = string.lstrip(string.expandtabs(lines[end])) while comments and string.strip(comments[0]) == '#': comments[:1] = [] while comments and string.strip(comments[-1]) == '#': comments[-1:] = [] return string.join(comments, '') class ListReader: """Provide a readline() method to return lines from a list of strings.""" def __init__(self, lines): self.lines = lines self.index = 0 def readline(self): i = self.index if i < len(self.lines): self.index = i + 1 return self.lines[i] else: return '' class EndOfBlock(Exception): pass class BlockFinder: """Provide a tokeneater() method to detect the end of a code block.""" def __init__(self): self.indent = 0 self.started = 0 self.last = 0 def tokeneater(self, type, token, (srow, scol), (erow, ecol), line): if not self.started: if type == tokenize.NAME: self.started = 1 elif type == tokenize.NEWLINE: self.last = srow elif type == tokenize.INDENT: self.indent = self.indent + 1 elif type == tokenize.DEDENT: self.indent = self.indent - 1 if self.indent == 0: raise EndOfBlock, self.last def getblock(lines): """Extract the block of code at the top of the given list of lines.""" try: tokenize.tokenize(ListReader(lines).readline, BlockFinder().tokeneater) except EndOfBlock, eob: return lines[:eob.args[0]] def getsourcelines(object): """Return a list of source lines and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of the lines corresponding to the object and the line number indicates where in the original source file the first line of code was found. An IOError is raised if the source code cannot be retrieved.""" lines, lnum = findsource(object) if ismodule(object): return lines, 0 else: return getblock(lines[lnum:]), lnum + 1 def getsource(object): """Return the text of the source code for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a single string. An IOError is raised if the source code cannot be retrieved.""" lines, lnum = getsourcelines(object) return string.join(lines, '') # --------------------------------------------------- class tree extraction def walktree(classes, children, parent): """Recursive helper function for getclasstree().""" results = [] classes.sort(lambda a, b: cmp(a.__name__, b.__name__)) for c in classes: results.append((c, c.__bases__)) if children.has_key(c): results.append(walktree(children[c], children, c)) return results def getclasstree(classes, unique=0): """Arrange the given list of classes into a hierarchy of nested lists. Where a nested list appears, it contains classes derived from the class whose entry immediately precedes the list. Each entry is a 2-tuple containing a class and a tuple of its base classes. If the 'unique' argument is true, exactly one entry appears in the returned structure for each class in the given list. Otherwise, classes using multiple inheritance and their descendants will appear multiple times.""" children = {} roots = [] for c in classes: if c.__bases__: for parent in c.__bases__: if not children.has_key(parent): children[parent] = [] children[parent].append(c) if unique and parent in classes: break elif c not in roots: roots.append(c) for parent in children.keys(): if parent not in classes: roots.append(parent) return walktree(roots, children, None) # ------------------------------------------------ argument list extraction # These constants are from Python's compile.h. CO_OPTIMIZED, CO_NEWLOCALS, CO_VARARGS, CO_VARKEYWORDS = 1, 2, 4, 8 def getargs(co): """Get information about the arguments accepted by a code object. Three things are returned: (args, varargs, varkw), where 'args' is a list of argument names (possibly containing nested lists), and 'varargs' and 'varkw' are the names of the * and ** arguments or None.""" if not iscode(co): raise TypeError, 'arg is not a code object' ## #jython doesn't have co_code ## code = co.co_code nargs = co.co_argcount names = co.co_varnames args = list(names[:nargs]) step = 0 ## We don't have co_code, so skip this for now ## ## # The following acrobatics are for anonymous (tuple) arguments. ## for i in range(nargs): ## if args[i][:1] in ['', '.']: ## stack, remain, count = [], [], [] ## while step < len(code): ## op = ord(code[step]) ## step = step + 1 ## if op >= dis.HAVE_ARGUMENT: ## opname = dis.opname[op] ## value = ord(code[step]) + ord(code[step+1])*256 ## step = step + 2 ## if opname in ['UNPACK_TUPLE', 'UNPACK_SEQUENCE']: ## remain.append(value) ## count.append(value) ## elif opname == 'STORE_FAST': ## stack.append(names[value]) ## remain[-1] = remain[-1] - 1 ## while remain[-1] == 0: ## remain.pop() ## size = count.pop() ## stack[-size:] = [stack[-size:]] ## if not remain: break ## remain[-1] = remain[-1] - 1 ## if not remain: break ## args[i] = stack[0] varargs = None if co.co_flags & CO_VARARGS: varargs = co.co_varnames[nargs] nargs = nargs + 1 varkw = None if co.co_flags & CO_VARKEYWORDS: varkw = co.co_varnames[nargs] return args, varargs, varkw def getargspec(func): """Get the names and default values of a function's arguments. A tuple of four things is returned: (args, varargs, varkw, defaults). 'args' is a list of the argument names (it may contain nested lists). 'varargs' and 'varkw' are the names of the * and ** arguments or None. 'defaults' is an n-tuple of the default values of the last n arguments.""" if not isfunction(func): raise TypeError, 'arg is not a Python function' args, varargs, varkw = getargs(func.func_code) return args, varargs, varkw, func.func_defaults def getargvalues(frame): """Get information about arguments passed into a particular frame. A tuple of four things is returned: (args, varargs, varkw, locals). 'args' is a list of the argument names (it may contain nested lists). 'varargs' and 'varkw' are the names of the * and ** arguments or None. 'locals' is the locals dictionary of the given frame.""" args, varargs, varkw = getargs(frame.f_code) return args, varargs, varkw, frame.f_locals def joinseq(seq): if len(seq) == 1: return '(' + seq[0] + ',)' else: return '(' + string.join(seq, ', ') + ')' def strseq(object, convert, join=joinseq): """Recursively walk a sequence, stringifying each element.""" if type(object) in [types.ListType, types.TupleType]: return join(map(lambda o, c=convert, j=join: strseq(o, c, j), object)) else: return convert(object) def formatargspec(args, varargs=None, varkw=None, defaults=None, formatarg=str, formatvarargs=lambda name: '*' + name, formatvarkw=lambda name: '**' + name, formatvalue=lambda value: '=' + repr(value), join=joinseq): """Format an argument spec from the 4 values returned by getargspec. The first four arguments are (args, varargs, varkw, defaults). The other four arguments are the corresponding optional formatting functions that are called to turn names and values into strings. The ninth argument is an optional function to format the sequence of arguments.""" specs = [] if defaults: firstdefault = len(args) - len(defaults) for i in range(len(args)): spec = strseq(args[i], formatarg, join) if defaults and i >= firstdefault: spec = spec + formatvalue(defaults[i - firstdefault]) specs.append(spec) if varargs: specs.append(formatvarargs(varargs)) if varkw: specs.append(formatvarkw(varkw)) return '(' + string.join(specs, ', ') + ')' def formatargvalues(args, varargs, varkw, locals, formatarg=str, formatvarargs=lambda name: '*' + name, formatvarkw=lambda name: '**' + name, formatvalue=lambda value: '=' + repr(value), join=joinseq): """Format an argument spec from the 4 values returned by getargvalues. The first four arguments are (args, varargs, varkw, locals). The next four arguments are the corresponding optional formatting functions that are called to turn names and values into strings. The ninth argument is an optional function to format the sequence of arguments.""" def convert(name, locals=locals, formatarg=formatarg, formatvalue=formatvalue): return formatarg(name) + formatvalue(locals[name]) specs = [] for i in range(len(args)): specs.append(strseq(args[i], convert, join)) if varargs: specs.append(formatvarargs(varargs) + formatvalue(locals[varargs])) if varkw: specs.append(formatvarkw(varkw) + formatvalue(locals[varkw])) return '(' + string.join(specs, ', ') + ')' # -------------------------------------------------- stack frame extraction def getframeinfo(frame, context=1): """Get information about a frame or traceback object. A tuple of five things is returned: the filename, the line number of the current line, the function name, a list of lines of context from the source code, and the index of the current line within that list. The optional second argument specifies the number of lines of context to return, which are centered around the current line.""" if istraceback(frame): frame = frame.tb_frame if not isframe(frame): raise TypeError, 'arg is not a frame or traceback object' filename = getsourcefile(frame) lineno = getlineno(frame) if context > 0: ## # Jython 2.1 can't handle // ## start = lineno - 1 - context//2 start = lineno - 1 - context/2 try: lines, lnum = findsource(frame) except IOError: lines = index = None else: start = max(start, 1) start = min(start, len(lines) - context) lines = lines[start:start+context] index = lineno - 1 - start else: lines = index = None return (filename, lineno, frame.f_code.co_name, lines, index) def getlineno(frame): """ Get the line number from a frame object, allowing for optimization. """ lineno = frame.f_lineno code = frame.f_code if hasattr(code, 'co_lnotab'): table = code.co_lnotab lineno = code.co_firstlineno addr = 0 for i in range(0, len(table), 2): addr = addr + ord(table[i]) if addr > frame.f_lasti: break lineno = lineno + ord(table[i+1]) return lineno def getouterframes(frame, context=1): """Get a list of records for a frame and all higher (calling) frames. Each record contains a frame object, filename, line number, function name, a list of lines of context, and index within the context.""" framelist = [] while frame: framelist.append((frame,) + getframeinfo(frame, context)) frame = frame.f_back return framelist def getinnerframes(tb, context=1): """Get a list of records for a traceback's frame and all lower frames. Each record contains a frame object, filename, line number, function name, a list of lines of context, and index within the context.""" framelist = [] while tb: framelist.append((tb.tb_frame,) + getframeinfo(tb, context)) tb = tb.tb_next return framelist def currentframe(): """Return the frame object for the caller's stack frame.""" try: raise 'catch me' except: return sys.exc_traceback.tb_frame.f_back if hasattr(sys, '_getframe'): currentframe = sys._getframe def stack(context=1): """Return a list of records for the stack above the caller's frame.""" return getouterframes(currentframe().f_back, context) def trace(context=1): """Return a list of records for the stack below the current exception.""" return getinnerframes(sys.exc_traceback, context) |
From: Dana M. <dan...@us...> - 2004-05-25 21:36:01
|
Update of /cvsroot/pydev/org.python.pydev/PySrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1192/PySrc Log Message: Directory /cvsroot/pydev/org.python.pydev/PySrc added to the repository |
From: Dana M. <dan...@us...> - 2004-05-25 21:25:21
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31939 Modified Files: plugin.xml Log Message: added jython jar dependency Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** plugin.xml 21 May 2004 18:53:38 -0000 1.15 --- plugin.xml 25 May 2004 21:25:11 -0000 1.16 *************** *** 9,14 **** <runtime> <library name="pydev.jar"> ! <export name="*"/> ! </library> </runtime> <requires> --- 9,14 ---- <runtime> <library name="pydev.jar"> ! <export name="*"/> ! </library> </runtime> <requires> *************** *** 21,24 **** --- 21,25 ---- <import plugin="org.eclipse.jface.text"/> <import plugin="org.eclipse.jdt.ui"/> + <import plugin="org.pydev.jython"/> </requires> *************** *** 84,88 **** </page> </extension> ! <!-- Editor menus --> <extension point="org.eclipse.ui.editorActions"> --- 85,89 ---- </page> </extension> ! <!-- Editor menus --> <extension point="org.eclipse.ui.editorActions"> *************** *** 138,157 **** <action definitionId="org.python.pydev.editor.actions.navigation.previousMethod" ! label= "Goto previous method or class" ! class= "org.python.pydev.editor.actions.PyPreviousMethod" ! menubarPath= "org.python.pydev.editor.actions.sourceMenu/addGroup" ! id= "org.python.pydev.editor.actions.navigation.previousMethod"> </action> <action definitionId="org.python.pydev.editor.actions.navigation.pyGoToDefinition" ! label= "Go to Definition" ! class= "org.python.pydev.editor.actions.PyGoToDefinition" ! menubarPath= "org.python.pydev.editor.actions.sourceMenu/addGroup" ! id= "org.python.pydev.editor.actions.navigation.pyGoToDefinition"> </action> </editorContribution> </extension> - <!-- Editor popup menus--> <!-- NOTE: EditorContext part of the targetID was deduced, that is just what Eclipse expects --> <extension point="org.eclipse.ui.popupMenus"> --- 139,158 ---- <action definitionId="org.python.pydev.editor.actions.navigation.previousMethod" ! label="Goto previous method or class" ! class="org.python.pydev.editor.actions.PyPreviousMethod" ! menubarPath="org.python.pydev.editor.actions.sourceMenu/addGroup" ! id="org.python.pydev.editor.actions.navigation.previousMethod"> </action> <action definitionId="org.python.pydev.editor.actions.navigation.pyGoToDefinition" ! label="Go to Definition" ! class="org.python.pydev.editor.actions.PyGoToDefinition" ! menubarPath="org.python.pydev.editor.actions.sourceMenu/addGroup" ! id="org.python.pydev.editor.actions.navigation.pyGoToDefinition"> </action> </editorContribution> </extension> <!-- NOTE: EditorContext part of the targetID was deduced, that is just what Eclipse expects --> + <!-- Editor popup menus--> <extension point="org.eclipse.ui.popupMenus"> *************** *** 201,206 **** </viewerContribution> </extension> - <!-- Commands --> <!-- associates commands with keyboard shortcuts --> <extension point="org.eclipse.ui.commands"> --- 202,207 ---- </viewerContribution> </extension> <!-- associates commands with keyboard shortcuts --> + <!-- Commands --> <extension point="org.eclipse.ui.commands"> |
From: Aleksandar T. <at...@us...> - 2004-05-25 21:10:49
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28661/src/org/python/pydev/editor Modified Files: PyEditConfiguration.java Log Message: Fixed [ 932204 ] tab-indenting uses only spaces instead of tabs Index: PyEditConfiguration.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEditConfiguration.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PyEditConfiguration.java 22 Apr 2004 10:35:23 -0000 1.9 --- PyEditConfiguration.java 25 May 2004 21:10:40 -0000 1.10 *************** *** 106,111 **** for (int i = 0; i < tabWidth; i++) spaces.append(" "); ! boolean spacesFirst = prefs.getBoolean(PydevPrefs.SUBSTITUTE_TABS) || ! ((PyAutoIndentStrategy)getAutoIndentStrategy(null, null)).forceTabs; if (spacesFirst) { indentPrefixes[0] = spaces.toString(); --- 106,111 ---- for (int i = 0; i < tabWidth; i++) spaces.append(" "); ! boolean spacesFirst = prefs.getBoolean(PydevPrefs.SUBSTITUTE_TABS) && ! !((PyAutoIndentStrategy)getAutoIndentStrategy(null, null)).forceTabs; if (spacesFirst) { indentPrefixes[0] = spaces.toString(); *************** *** 129,132 **** --- 129,133 ---- String contentType) { resetIndentPrefixes(); + sourceViewer.setIndentPrefixes(indentPrefixes, contentType); return indentPrefixes; } |
From: Dana M. <dan...@us...> - 2004-05-25 18:02:10
|
Update of /cvsroot/pydev/org.pydev.jython In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21621 Added Files: .classpath .project build.properties jython.jar plugin.xml Log Message: support for Jython to laaunch an introspect of the content of the file currnetly being edited --- NEW FILE: .project --- <?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>org.pydev.jython</name> <comment></comment> <projects> <project>org.eclipse.core.boot</project> <project>org.eclipse.core.runtime</project> </projects> <buildSpec> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.pde.ManifestBuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.pde.SchemaBuilder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.jdt.core.javanature</nature> </natures> </projectDescription> --- NEW FILE: .classpath --- <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src/"/> <classpathentry kind="src" path="/org.eclipse.core.boot"/> <classpathentry kind="src" path="/org.eclipse.core.runtime"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin"/> </classpath> --- NEW FILE: build.properties --- source.jython.jar = src/ bin.includes = plugin.xml,\ *.jar,\ jython.jar --- NEW FILE: plugin.xml --- <?xml version="1.0" encoding="UTF-8"?> <plugin id="org.pydev.jython" name="org.pydev.jython" version="1.0.0"> <runtime> <library name="jython.jar"> <export name="*"/> <packages prefixes="org.python"/> </library> </runtime> </plugin> --- NEW FILE: jython.jar --- (This appears to be a binary file; contents omitted.) |
From: Dana M. <dan...@us...> - 2004-05-25 17:59:14
|
Update of /cvsroot/pydev/org.pydev.jython/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20605/src Log Message: Directory /cvsroot/pydev/org.pydev.jython/src added to the repository |
From: Dana M. <dan...@us...> - 2004-05-25 17:58:58
|
Update of /cvsroot/pydev/org.pydev.jython/bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20605/bin Log Message: Directory /cvsroot/pydev/org.pydev.jython/bin added to the repository |
From: Fabio Z. <fa...@us...> - 2004-05-21 18:53:47
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23376 Modified Files: plugin.xml Log Message: F3 now has the Ctrl+Click funtionality Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** plugin.xml 7 May 2004 02:07:18 -0000 1.14 --- plugin.xml 21 May 2004 18:53:38 -0000 1.15 *************** *** 138,145 **** <action definitionId="org.python.pydev.editor.actions.navigation.previousMethod" ! label="Goto previous method or class" ! class="org.python.pydev.editor.actions.PyPreviousMethod" ! menubarPath="org.python.pydev.editor.actions.sourceMenu/addGroup" ! id="org.python.pydev.editor.actions.navigation.previousMethod"> </action> </editorContribution> --- 138,152 ---- <action definitionId="org.python.pydev.editor.actions.navigation.previousMethod" ! label= "Goto previous method or class" ! class= "org.python.pydev.editor.actions.PyPreviousMethod" ! menubarPath= "org.python.pydev.editor.actions.sourceMenu/addGroup" ! id= "org.python.pydev.editor.actions.navigation.previousMethod"> ! </action> ! <action ! definitionId="org.python.pydev.editor.actions.navigation.pyGoToDefinition" ! label= "Go to Definition" ! class= "org.python.pydev.editor.actions.PyGoToDefinition" ! menubarPath= "org.python.pydev.editor.actions.sourceMenu/addGroup" ! id= "org.python.pydev.editor.actions.navigation.pyGoToDefinition"> </action> </editorContribution> *************** *** 299,302 **** --- 306,322 ---- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> </keyBinding> + <!-- command: Go To Defition--> + <command + name="Python Go To Declaration" + description="Goes to the declaration of a python element" + category="org.python.pydev.ui.category.source" + id="org.python.pydev.editor.actions.navigation.pyGoToDefinition"> + </command> + <keyBinding + string="F3" + scope="org.python.pydev.ui.editor.scope" + command="org.python.pydev.editor.actions.navigation.pyGoToDefinition" + configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> + </keyBinding> </extension> <!-- file type extensions for the team (CVS) --> |
From: Fabio Z. <fa...@us...> - 2004-05-21 18:35:40
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19268/src/org/python/pydev/editor/model Modified Files: ModelUtils.java Scope.java Log Message: Sometimes class definitions where not being gotten. Index: Scope.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/Scope.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Scope.java 5 May 2004 02:05:08 -0000 1.5 --- Scope.java 21 May 2004 18:35:30 -0000 1.6 *************** *** 11,14 **** --- 11,15 ---- import java.util.Iterator; + import org.eclipse.core.runtime.IPath; import org.python.pydev.plugin.PydevPrefs; *************** *** 72,75 **** --- 73,77 ---- } + void addFunctionDefinition(FunctionNode newDef) { if (functions == null) *************** *** 120,136 **** public ArrayList findFunctionCalls(Object token, boolean recursive, Comparator c) { ArrayList retVal = new ArrayList(); ! // traverse our definitions ! if (functions != null) { ! Iterator i = functions.iterator(); ! while (i.hasNext()) { ! Object item = i.next(); ! if (c.compare(token, item) == 0) ! retVal.add(item); } } ! if (start != null && start instanceof ClassNode && c.compare(token, start) == 0) ! // class name can also be a function call ! retVal.add(start); ! // now traverse parents ArrayList ancestors = null; if (recursive) --- 122,143 ---- public ArrayList findFunctionCalls(Object token, boolean recursive, Comparator c) { ArrayList retVal = new ArrayList(); ! ! if (start != null){ ! if (start instanceof ClassNode && c.compare(token, start) == 0){ ! ! // class name can also be a function call ! retVal.add(start); ! // now traverse parents ! } ! for( Iterator itChildren = start.children.iterator(); itChildren.hasNext();){ ! Object item = itChildren.next(); ! if(item instanceof FunctionNode || item instanceof ClassNode){ ! if (c.compare(token, item) == 0){ ! retVal.add(item); ! } ! } } } ! ArrayList ancestors = null; if (recursive) *************** *** 184,186 **** --- 191,194 ---- return parent != null ? parent.findContainingClass() : null; } + } Index: ModelUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/ModelUtils.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ModelUtils.java 5 May 2004 02:05:08 -0000 1.5 --- ModelUtils.java 21 May 2004 18:35:30 -0000 1.6 *************** *** 196,210 **** // ex: simpleCall() if (node instanceof LocalNode && ! node.getParent() instanceof FunctionCallNode) { ! ArrayList funcCalls = node.getScope().findFunctionCalls(node.getName(), true, ! new Comparator() { ! public int compare(Object token, Object funcCall) { ! return ((String)token).compareTo(((AbstractNode)funcCall).getName()); ! } ! }); for (Iterator i = funcCalls.iterator(); i.hasNext();) { AbstractNode funcNode = (AbstractNode)i.next(); retVal.add(new ItemPointer(funcNode.getPath(), funcNode.getStart(), funcNode.getEnd())); } } else if (node instanceof ImportAlias || node instanceof ImportFromNode) { // imports: --- 196,221 ---- // ex: simpleCall() if (node instanceof LocalNode && ! node.getParent() instanceof FunctionCallNode) { ! ! //here we go for function calls... that is run(), Test() ! //Note: this can be functions or Class definitions. ! Comparator c = new Comparator() { ! public int compare(Object token, Object funcCall) { ! return ((String)token).compareTo(((AbstractNode)funcCall).getName()); ! } ! }; ! ! ! ArrayList funcCalls = new ArrayList(); ! funcCalls = node.getScope().findFunctionCalls(node.getName(), true, c ); ! ! for (Iterator i = funcCalls.iterator(); i.hasNext();) { AbstractNode funcNode = (AbstractNode)i.next(); retVal.add(new ItemPointer(funcNode.getPath(), funcNode.getStart(), funcNode.getEnd())); } + + + } else if (node instanceof ImportAlias || node instanceof ImportFromNode) { // imports: |
From: Fabio Z. <fa...@us...> - 2004-05-21 18:12:41
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14052/src/org/python/pydev/editor/actions Added Files: PyGoToDefinition.java Log Message: Goes To some definition (similar to Ctrl+Click) --- NEW FILE: PyGoToDefinition.java --- /* * Created on May 21, 2004 * */ package org.python.pydev.editor.actions; import java.util.ArrayList; import org.eclipse.jface.action.IAction; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextSelection; import org.eclipse.ui.PlatformUI; import org.python.pydev.editor.PyEdit; import org.python.pydev.editor.model.AbstractNode; import org.python.pydev.editor.model.ItemPointer; import org.python.pydev.editor.model.Location; import org.python.pydev.editor.model.ModelUtils; /** * @author Fabio Zadrozny * */ public class PyGoToDefinition extends PyAction{ /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run(IAction action) { try{ PyEdit pyEdit = getPyEdit(); IDocument doc = pyEdit.getDocumentProvider().getDocument(pyEdit.getEditorInput()); ITextSelection selection = (ITextSelection) pyEdit.getSelectionProvider().getSelection(); Location loc = Location.offsetToLocation(doc, selection.getOffset()); AbstractNode node = ModelUtils.getElement(pyEdit.getPythonModel(),loc, AbstractNode.PROP_CLICKABLE); if(node == null) return; PyOpenAction openAction = (PyOpenAction)pyEdit.getAction(PyEdit.ACTION_OPEN); ArrayList where = ModelUtils.findDefinition(node); if (where.size() > 0) openAction.run((ItemPointer)where.get(0)); else PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay().beep(); }catch (Exception e) { e.printStackTrace(); } } } |
From: Aleksandar T. <at...@us...> - 2004-05-17 23:30:01
|
Update of /cvsroot/pydev/org.python.pydev.debug In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31942 Modified Files: build.properties Log Message: Removed *.jar line Index: build.properties =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/build.properties,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** build.properties 29 Mar 2004 17:04:40 -0000 1.3 --- build.properties 17 May 2004 23:29:52 -0000 1.4 *************** *** 1,4 **** bin.includes = plugin.xml,\ - *.jar,\ pydev-debug.jar,\ icons/,\ --- 1,3 ---- |
From: Aleksandar T. <at...@us...> - 2004-05-17 23:29:44
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31901 Modified Files: build.properties Log Message: Removed *.jar line Index: build.properties =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/build.properties,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** build.properties 17 Aug 2003 04:44:22 -0000 1.1 --- build.properties 17 May 2004 23:29:35 -0000 1.2 *************** *** 2,6 **** bin.includes = plugin.xml,\ - *.jar,\ pydev.jar,\ icons/ --- 2,5 ---- |