Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.

Fri, 31 Dec 2010 15:19:02 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 31 Dec 2010 15:19:02 +0100
changeset 788
5b1b59777460
parent 786
06290d4db8ab
child 789
c190cd71b097

Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.

APIs/Python3/eric5.api file | annotate | diff | comparison | revisions
Debugger/DebugServer.py file | annotate | diff | comparison | revisions
Debugger/DebugUI.py file | annotate | diff | comparison | revisions
Debugger/DebuggerInterfacePython.py file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Project.ProjectSourcesBrowser.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.QScintilla.Editor.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.UI.BrowserModel.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Utilities.__init__.html file | annotate | diff | comparison | revisions
DocumentationTools/__init__.py file | annotate | diff | comparison | revisions
E5XML/ProjectReader.py file | annotate | diff | comparison | revisions
Plugins/DocumentationPlugins/Ericapi/EricapiConfigDialog.py file | annotate | diff | comparison | revisions
Plugins/PluginEricapi.py file | annotate | diff | comparison | revisions
Plugins/PluginEricdoc.py file | annotate | diff | comparison | revisions
Project/DebuggerPropertiesDialog.py file | annotate | diff | comparison | revisions
Project/Project.py file | annotate | diff | comparison | revisions
Project/ProjectBrowser.py file | annotate | diff | comparison | revisions
Project/ProjectFormsBrowser.py file | annotate | diff | comparison | revisions
Project/ProjectResourcesBrowser.py file | annotate | diff | comparison | revisions
Project/ProjectSourcesBrowser.py file | annotate | diff | comparison | revisions
Project/ProjectTranslationsBrowser.py file | annotate | diff | comparison | revisions
PyUnit/UnittestDialog.py file | annotate | diff | comparison | revisions
QScintilla/Editor.py file | annotate | diff | comparison | revisions
QScintilla/Lexers/__init__.py file | annotate | diff | comparison | revisions
QScintilla/MiniEditor.py file | annotate | diff | comparison | revisions
UI/Browser.py file | annotate | diff | comparison | revisions
UI/BrowserModel.py file | annotate | diff | comparison | revisions
UI/UserInterface.py file | annotate | diff | comparison | revisions
Utilities/ClassBrowsers/__init__.py file | annotate | diff | comparison | revisions
Utilities/__init__.py file | annotate | diff | comparison | revisions
changelog file | annotate | diff | comparison | revisions
eric5-api.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric5.api	Mon Dec 27 19:49:16 2010 +0100
+++ b/APIs/Python3/eric5.api	Fri Dec 31 15:19:02 2010 +0100
@@ -4919,8 +4919,8 @@
 eric5.QScintilla.Editor.Editor.highlight?4(line = None, error = False, syntaxError = False)
 eric5.QScintilla.Editor.Editor.highlightVisible?4()
 eric5.QScintilla.Editor.Editor.indentLineOrSelection?4()
+eric5.QScintilla.Editor.Editor.isPy2File?4()
 eric5.QScintilla.Editor.Editor.isPy3File?4()
-eric5.QScintilla.Editor.Editor.isPyFile?4()
 eric5.QScintilla.Editor.Editor.isRubyFile?4()
 eric5.QScintilla.Editor.Editor.isSpellCheckRegion?4(pos)
 eric5.QScintilla.Editor.Editor.joinLines?4()
@@ -5693,8 +5693,8 @@
 eric5.UI.BrowserModel.BrowserFileItem.isMultiProjectFile?4()
 eric5.UI.BrowserModel.BrowserFileItem.isPixmapFile?4()
 eric5.UI.BrowserModel.BrowserFileItem.isProjectFile?4()
+eric5.UI.BrowserModel.BrowserFileItem.isPython2File?4()
 eric5.UI.BrowserModel.BrowserFileItem.isPython3File?4()
-eric5.UI.BrowserModel.BrowserFileItem.isPythonFile?4()
 eric5.UI.BrowserModel.BrowserFileItem.isResourcesFile?4()
 eric5.UI.BrowserModel.BrowserFileItem.isRubyFile?4()
 eric5.UI.BrowserModel.BrowserFileItem.isSvgFile?4()
@@ -6106,6 +6106,7 @@
 eric5.Utilities.encode?4(text, orig_coding)
 eric5.Utilities.escape_entities?4(m, map=_escape_map)
 eric5.Utilities.escape_uentities?4(m)
+eric5.Utilities.extractFlags?4(text)
 eric5.Utilities.fromNativeSeparators?4(path)
 eric5.Utilities.generateDistroInfo?4(linesep = '\n')
 eric5.Utilities.generatePluginsVersionInfo?4(linesep = '\n')
--- a/Debugger/DebugServer.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/Debugger/DebugServer.py	Fri Dec 31 15:19:02 2010 +0100
@@ -268,7 +268,7 @@
         if self.lastClientType != self.clientType or clientType is not None:
             if clientType is None:
                 clientType = self.clientType
-            if clientType == "Python":
+            if clientType == "Python2":
                 from .DebuggerInterfacePython import DebuggerInterfacePython
                 self.debuggerInterface = DebuggerInterfacePython(self, self.passive)
             elif clientType == "Python3":
@@ -654,7 +654,7 @@
         try:
             self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]])
         except KeyError:
-            self.__setClientType('Python')    # assume it is a Python file
+            self.__setClientType('Python3')    # assume it is a Python3 file
         self.startClient(False, forProject = forProject, runInConsole = runInConsole)
         
         self.remoteEnvironment(env)
@@ -689,7 +689,7 @@
         try:
             self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]])
         except KeyError:
-            self.__setClientType('Python')    # assume it is a Python file
+            self.__setClientType('Python3')    # assume it is a Python3 file
         self.startClient(False, forProject = forProject, runInConsole = runInConsole)
         
         self.remoteEnvironment(env)
@@ -720,7 +720,7 @@
         try:
             self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]])
         except KeyError:
-            self.__setClientType('Python')    # assume it is a Python file
+            self.__setClientType('Python3')    # assume it is a Python3 file
         self.startClient(False, forProject = forProject, runInConsole = runInConsole)
         
         self.remoteEnvironment(env)
@@ -751,7 +751,7 @@
         try:
             self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]])
         except KeyError:
-            self.__setClientType('Python')    # assume it is a Python file
+            self.__setClientType('Python3')    # assume it is a Python3 file
         self.startClient(False, forProject = forProject, runInConsole = runInConsole)
         
         self.remoteEnvironment(env)
@@ -969,7 +969,7 @@
         try:
             self.__setClientType(self.__clientAssociations[os.path.splitext(fn)[1]])
         except KeyError:
-            self.__setClientType('Python')    # assume it is a Python file
+            self.__setClientType('Python3')    # assume it is a Python3 file
         self.startClient(False)
         
         self.debuggerInterface.remoteUTPrepare(fn, tn, tfn, cov, covname, coverase)
--- a/Debugger/DebugUI.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/Debugger/DebugUI.py	Fri Dec 31 15:19:02 2010 +0100
@@ -766,7 +766,7 @@
                     cap = self.debugServer.getClientCapabilities(language)
                     break
             else:
-                if editor.isPyFile():
+                if editor.isPy2File():
                     cap = self.debugServer.getClientCapabilities('Python')
                 elif editor.isPy3File():
                     cap = self.debugServer.getClientCapabilities('Python3')
@@ -805,7 +805,7 @@
         if editor is None:
             return
         
-        if editor.isPyFile() or editor.isPy3File() or editor.isRubyFile():
+        if editor.isPy2File() or editor.isPy3File() or editor.isRubyFile():
             if editor.curLineHasBreakpoint():
                 self.dbgEditBpAct.setEnabled(True)
             else:
--- a/Debugger/DebuggerInterfacePython.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/Debugger/DebuggerInterfacePython.py	Fri Dec 31 15:19:02 2010 +0100
@@ -43,7 +43,7 @@
             exts.append(".{0}".format(ext))
     
     if exts and Preferences.getDebugger("PythonInterpreter"):
-        return ["Python", ClientDefaultCapabilities, exts]
+        return ["Python2", ClientDefaultCapabilities, exts]
     else:
         return ["", 0, []]
 
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Mon Dec 27 19:49:16 2010 +0100
+++ b/Documentation/Help/source.qhp	Fri Dec 31 15:19:02 2010 +0100
@@ -2337,6 +2337,7 @@
       <keyword name="encode" id="encode" ref="eric5.Utilities.__init__.html#encode" />
       <keyword name="escape_entities" id="escape_entities" ref="eric5.Utilities.__init__.html#escape_entities" />
       <keyword name="escape_uentities" id="escape_uentities" ref="eric5.Utilities.__init__.html#escape_uentities" />
+      <keyword name="extractFlags" id="extractFlags" ref="eric5.Utilities.__init__.html#extractFlags" />
       <keyword name="fromNativeSeparators" id="fromNativeSeparators" ref="eric5.Utilities.__init__.html#fromNativeSeparators" />
       <keyword name="generateDistroInfo" id="generateDistroInfo" ref="eric5.Utilities.__init__.html#generateDistroInfo" />
       <keyword name="generatePluginsVersionInfo" id="generatePluginsVersionInfo" ref="eric5.Utilities.__init__.html#generatePluginsVersionInfo" />
@@ -3824,8 +3825,8 @@
       <keyword name="BrowserFileItem.isMultiProjectFile" id="BrowserFileItem.isMultiProjectFile" ref="eric5.UI.BrowserModel.html#BrowserFileItem.isMultiProjectFile" />
       <keyword name="BrowserFileItem.isPixmapFile" id="BrowserFileItem.isPixmapFile" ref="eric5.UI.BrowserModel.html#BrowserFileItem.isPixmapFile" />
       <keyword name="BrowserFileItem.isProjectFile" id="BrowserFileItem.isProjectFile" ref="eric5.UI.BrowserModel.html#BrowserFileItem.isProjectFile" />
+      <keyword name="BrowserFileItem.isPython2File" id="BrowserFileItem.isPython2File" ref="eric5.UI.BrowserModel.html#BrowserFileItem.isPython2File" />
       <keyword name="BrowserFileItem.isPython3File" id="BrowserFileItem.isPython3File" ref="eric5.UI.BrowserModel.html#BrowserFileItem.isPython3File" />
-      <keyword name="BrowserFileItem.isPythonFile" id="BrowserFileItem.isPythonFile" ref="eric5.UI.BrowserModel.html#BrowserFileItem.isPythonFile" />
       <keyword name="BrowserFileItem.isResourcesFile" id="BrowserFileItem.isResourcesFile" ref="eric5.UI.BrowserModel.html#BrowserFileItem.isResourcesFile" />
       <keyword name="BrowserFileItem.isRubyFile" id="BrowserFileItem.isRubyFile" ref="eric5.UI.BrowserModel.html#BrowserFileItem.isRubyFile" />
       <keyword name="BrowserFileItem.isSvgFile" id="BrowserFileItem.isSvgFile" ref="eric5.UI.BrowserModel.html#BrowserFileItem.isSvgFile" />
@@ -5703,6 +5704,7 @@
       <keyword name="Editor.__normalizedEncoding" id="Editor.__normalizedEncoding" ref="eric5.QScintilla.Editor.html#Editor.__normalizedEncoding" />
       <keyword name="Editor.__printPreview" id="Editor.__printPreview" ref="eric5.QScintilla.Editor.html#Editor.__printPreview" />
       <keyword name="Editor.__processEndEditCommand" id="Editor.__processEndEditCommand" ref="eric5.QScintilla.Editor.html#Editor.__processEndEditCommand" />
+      <keyword name="Editor.__processFlags" id="Editor.__processFlags" ref="eric5.QScintilla.Editor.html#Editor.__processFlags" />
       <keyword name="Editor.__processRequestSyncCommand" id="Editor.__processRequestSyncCommand" ref="eric5.QScintilla.Editor.html#Editor.__processRequestSyncCommand" />
       <keyword name="Editor.__processStartEditCommand" id="Editor.__processStartEditCommand" ref="eric5.QScintilla.Editor.html#Editor.__processStartEditCommand" />
       <keyword name="Editor.__processSyncCommand" id="Editor.__processSyncCommand" ref="eric5.QScintilla.Editor.html#Editor.__processSyncCommand" />
@@ -5826,8 +5828,8 @@
       <keyword name="Editor.highlight" id="Editor.highlight" ref="eric5.QScintilla.Editor.html#Editor.highlight" />
       <keyword name="Editor.highlightVisible" id="Editor.highlightVisible" ref="eric5.QScintilla.Editor.html#Editor.highlightVisible" />
       <keyword name="Editor.indentLineOrSelection" id="Editor.indentLineOrSelection" ref="eric5.QScintilla.Editor.html#Editor.indentLineOrSelection" />
+      <keyword name="Editor.isPy2File" id="Editor.isPy2File" ref="eric5.QScintilla.Editor.html#Editor.isPy2File" />
       <keyword name="Editor.isPy3File" id="Editor.isPy3File" ref="eric5.QScintilla.Editor.html#Editor.isPy3File" />
-      <keyword name="Editor.isPyFile" id="Editor.isPyFile" ref="eric5.QScintilla.Editor.html#Editor.isPyFile" />
       <keyword name="Editor.isRubyFile" id="Editor.isRubyFile" ref="eric5.QScintilla.Editor.html#Editor.isRubyFile" />
       <keyword name="Editor.isSpellCheckRegion" id="Editor.isSpellCheckRegion" ref="eric5.QScintilla.Editor.html#Editor.isSpellCheckRegion" />
       <keyword name="Editor.joinLines" id="Editor.joinLines" ref="eric5.QScintilla.Editor.html#Editor.joinLines" />
--- a/Documentation/Source/eric5.Project.ProjectSourcesBrowser.html	Mon Dec 27 19:49:16 2010 +0100
+++ b/Documentation/Source/eric5.Project.ProjectSourcesBrowser.html	Fri Dec 31 15:19:02 2010 +0100
@@ -54,6 +54,16 @@
 <dd>
 emitted when a menu is about to be shown. The name
             of the menu and a reference to the menu are given.
+</dd><dt>sourceFile(str)</dt>
+<dd>
+emitted to open the given file.
+</dd><dt>sourceFile(str, int)</dt>
+<dd>
+emitted to open the given file at the given line.
+</dd><dt>sourceFile(str, int, str)</dt>
+<dd>
+emitted to open the given file as the given type
+            at the given line.
 </dd>
 </dl>
 <h3>Derived from</h3>
--- a/Documentation/Source/eric5.QScintilla.Editor.html	Mon Dec 27 19:49:16 2010 +0100
+++ b/Documentation/Source/eric5.QScintilla.Editor.html	Fri Dec 31 15:19:02 2010 +0100
@@ -367,6 +367,9 @@
 <td><a href="#Editor.__processEndEditCommand">__processEndEditCommand</a></td>
 <td>Private slot to process a remote EndEdit command</td>
 </tr><tr>
+<td><a href="#Editor.__processFlags">__processFlags</a></td>
+<td>Private method to extract flags and process them.</td>
+</tr><tr>
 <td><a href="#Editor.__processRequestSyncCommand">__processRequestSyncCommand</a></td>
 <td>Private slot to process a remote RequestSync command</td>
 </tr><tr>
@@ -736,12 +739,12 @@
 <td><a href="#Editor.indentLineOrSelection">indentLineOrSelection</a></td>
 <td>Public slot to indent the current line or current selection</td>
 </tr><tr>
+<td><a href="#Editor.isPy2File">isPy2File</a></td>
+<td>Public method to return a flag indicating a Python file.</td>
+</tr><tr>
 <td><a href="#Editor.isPy3File">isPy3File</a></td>
 <td>Public method to return a flag indicating a Python3 file.</td>
 </tr><tr>
-<td><a href="#Editor.isPyFile">isPyFile</a></td>
-<td>Public method to return a flag indicating a Python file.</td>
-</tr><tr>
 <td><a href="#Editor.isRubyFile">isRubyFile</a></td>
 <td>Public method to return a flag indicating a Ruby file.</td>
 </tr><tr>
@@ -1631,7 +1634,12 @@
 <dd>
 string containing the command parameters (string)
 </dd>
-</dl><a NAME="Editor.__processRequestSyncCommand" ID="Editor.__processRequestSyncCommand"></a>
+</dl><a NAME="Editor.__processFlags" ID="Editor.__processFlags"></a>
+<h4>Editor.__processFlags</h4>
+<b>__processFlags</b>(<i></i>)
+<p>
+        Private method to extract flags and process them.
+</p><a NAME="Editor.__processRequestSyncCommand" ID="Editor.__processRequestSyncCommand"></a>
 <h4>Editor.__processRequestSyncCommand</h4>
 <b>__processRequestSyncCommand</b>(<i>argsString</i>)
 <p>
@@ -2693,7 +2701,17 @@
 <b>indentLineOrSelection</b>(<i></i>)
 <p>
         Public slot to indent the current line or current selection
-</p><a NAME="Editor.isPy3File" ID="Editor.isPy3File"></a>
+</p><a NAME="Editor.isPy2File" ID="Editor.isPy2File"></a>
+<h4>Editor.isPy2File</h4>
+<b>isPy2File</b>(<i></i>)
+<p>
+        Public method to return a flag indicating a Python file.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+flag indicating a Python file (boolean)
+</dd>
+</dl><a NAME="Editor.isPy3File" ID="Editor.isPy3File"></a>
 <h4>Editor.isPy3File</h4>
 <b>isPy3File</b>(<i></i>)
 <p>
@@ -2703,16 +2721,6 @@
 <dd>
 flag indicating a Python3 file (boolean)
 </dd>
-</dl><a NAME="Editor.isPyFile" ID="Editor.isPyFile"></a>
-<h4>Editor.isPyFile</h4>
-<b>isPyFile</b>(<i></i>)
-<p>
-        Public method to return a flag indicating a Python file.
-</p><dl>
-<dt>Returns:</dt>
-<dd>
-flag indicating a Python file (boolean)
-</dd>
 </dl><a NAME="Editor.isRubyFile" ID="Editor.isRubyFile"></a>
 <h4>Editor.isRubyFile</h4>
 <b>isRubyFile</b>(<i></i>)
--- a/Documentation/Source/eric5.UI.BrowserModel.html	Mon Dec 27 19:49:16 2010 +0100
+++ b/Documentation/Source/eric5.UI.BrowserModel.html	Fri Dec 31 15:19:02 2010 +0100
@@ -566,12 +566,12 @@
 <td><a href="#BrowserFileItem.isProjectFile">isProjectFile</a></td>
 <td>Public method to check, if this file is an eric project file.</td>
 </tr><tr>
+<td><a href="#BrowserFileItem.isPython2File">isPython2File</a></td>
+<td>Public method to check, if this file is a Python script.</td>
+</tr><tr>
 <td><a href="#BrowserFileItem.isPython3File">isPython3File</a></td>
 <td>Public method to check, if this file is a Python3 script.</td>
 </tr><tr>
-<td><a href="#BrowserFileItem.isPythonFile">isPythonFile</a></td>
-<td>Public method to check, if this file is a Python script.</td>
-</tr><tr>
 <td><a href="#BrowserFileItem.isResourcesFile">isResourcesFile</a></td>
 <td>Public method to check, if this file is a Qt-Resources file.</td>
 </tr><tr>
@@ -713,6 +713,16 @@
 <dd>
 flag indicating an eric project file (boolean)
 </dd>
+</dl><a NAME="BrowserFileItem.isPython2File" ID="BrowserFileItem.isPython2File"></a>
+<h4>BrowserFileItem.isPython2File</h4>
+<b>isPython2File</b>(<i></i>)
+<p>
+        Public method to check, if this file is a Python script.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+flag indicating a Python file (boolean)
+</dd>
 </dl><a NAME="BrowserFileItem.isPython3File" ID="BrowserFileItem.isPython3File"></a>
 <h4>BrowserFileItem.isPython3File</h4>
 <b>isPython3File</b>(<i></i>)
@@ -723,16 +733,6 @@
 <dd>
 flag indicating a Python file (boolean)
 </dd>
-</dl><a NAME="BrowserFileItem.isPythonFile" ID="BrowserFileItem.isPythonFile"></a>
-<h4>BrowserFileItem.isPythonFile</h4>
-<b>isPythonFile</b>(<i></i>)
-<p>
-        Public method to check, if this file is a Python script.
-</p><dl>
-<dt>Returns:</dt>
-<dd>
-flag indicating a Python file (boolean)
-</dd>
 </dl><a NAME="BrowserFileItem.isResourcesFile" ID="BrowserFileItem.isResourcesFile"></a>
 <h4>BrowserFileItem.isResourcesFile</h4>
 <b>isResourcesFile</b>(<i></i>)
--- a/Documentation/Source/eric5.Utilities.__init__.html	Mon Dec 27 19:49:16 2010 +0100
+++ b/Documentation/Source/eric5.Utilities.__init__.html	Fri Dec 31 15:19:02 2010 +0100
@@ -74,6 +74,9 @@
 <td><a href="#escape_uentities">escape_uentities</a></td>
 <td>Function to encode html entities.</td>
 </tr><tr>
+<td><a href="#extractFlags">extractFlags</a></td>
+<td>Function to extract eric specific flags out of the given text.</td>
+</tr><tr>
 <td><a href="#fromNativeSeparators">fromNativeSeparators</a></td>
 <td>Function returning a path, that is using "/" separator characters.</td>
 </tr><tr>
@@ -530,6 +533,32 @@
 </dl>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
+<a NAME="extractFlags" ID="extractFlags"></a>
+<h2>extractFlags</h2>
+<b>extractFlags</b>(<i>text</i>)
+<p>
+    Function to extract eric specific flags out of the given text.
+</p><p>
+    Flags are contained in comments and are introduced by 'eflag:'.
+    The rest of the line is interpreted as 'key = value'. value is
+    analyzed for being an integer or float value. If that fails, it
+    is assumed to be a string. If a key does not contain a '=' 
+    character, it is assumed to be a boolean flag. Flags are expected
+    at the very end of a file. The search is ended, if a line without
+    the 'eflag:' marker is found.
+</p><dl>
+<dt><i>text</i></dt>
+<dd>
+text to be scanned (string)
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+dictionary of string, boolean, complex, float and int
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr /><hr />
 <a NAME="fromNativeSeparators" ID="fromNativeSeparators"></a>
 <h2>fromNativeSeparators</h2>
 <b>fromNativeSeparators</b>(<i>path</i>)
--- a/DocumentationTools/__init__.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/DocumentationTools/__init__.py	Fri Dec 31 15:19:02 2010 +0100
@@ -8,7 +8,7 @@
 """
 
 supportedExtensionsDictForApis = {
-    "Python"  : [".py2", ".pyw2", ".ptl"], 
+    "Python2"  : [".py2", ".pyw2", ".ptl"], 
     "Python3" : [".py", ".pyw", ".py3", ".pyw3"], 
     "Ruby"    : [".rb"]
 }
--- a/E5XML/ProjectReader.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/E5XML/ProjectReader.py	Fri Dec 31 15:19:02 2010 +0100
@@ -58,6 +58,9 @@
                     self.project.pdata["MIXEDLANGUAGE"] = \
                         [int(self.attribute("mixed", "0"))]
                     self.project.pdata["PROGLANGUAGE"] = [self.readElementText()]
+                    if self.project.pdata["PROGLANGUAGE"][0] == "Python":
+                        # convert Python to the more specific Python2
+                        self.project.pdata["PROGLANGUAGE"][0] = "Python2"
                 elif self.name() == "ProjectType":
                     self.project.pdata["PROJECTTYPE"] = [self.readElementText()]
                 elif self.name() == "Description":
--- a/Plugins/DocumentationPlugins/Ericapi/EricapiConfigDialog.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/Plugins/DocumentationPlugins/Ericapi/EricapiConfigDialog.py	Fri Dec 31 15:19:02 2010 +0100
@@ -69,8 +69,11 @@
         self.sourceExtEdit.setText(", ".join(self.parameters['sourceExtensions']))
         self.excludeFilesEdit.setText(", ".join(self.parameters['ignoreFilePatterns']))
         for language in self.parameters['languages']:
+            if language == "Python":
+                # convert Python to the more specific Python2
+                language = "Python2"
             items = self.languagesList.findItems(language, Qt.MatchFlags(Qt.MatchExactly))
-            items[0].setSelected(True)
+            items and items[0].setSelected(True)
     
     def __initializeDefaults(self):
         """
@@ -93,7 +96,7 @@
         if lang in DocumentationTools.supportedExtensionsDictForApis:
             self.defaults['languages'] = [lang]
         else:
-            self.defaults['languages'] = ["Python"]
+            self.defaults['languages'] = ["Python3"]
     
     def generateParameters(self):
         """
@@ -255,4 +258,4 @@
             self.parameters['languages'].append(itm.text())
         
         # call the accept slot of the base class
-        QDialog.accept(self)
\ No newline at end of file
+        QDialog.accept(self)
--- a/Plugins/PluginEricapi.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/Plugins/PluginEricapi.py	Fri Dec 31 15:19:02 2010 +0100
@@ -133,7 +133,7 @@
             if self.__projectAct is not None:
                 self.__projectAct.setEnabled(
                     e5App().getObject("Project").getProjectLanguage() in \
-                        ["Python", "Python3", "Ruby"])
+                        ["Python", "Python2", "Python3", "Ruby"])
     
     def __doEricapi(self):
         """
@@ -178,4 +178,4 @@
                 if outfile not in project.pdata['OTHERS']:
                     project.pdata['OTHERS'].append(outfile)
                     project.setDirty(True)
-                    project.othersAdded(outfile)
\ No newline at end of file
+                    project.othersAdded(outfile)
--- a/Plugins/PluginEricdoc.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/Plugins/PluginEricdoc.py	Fri Dec 31 15:19:02 2010 +0100
@@ -169,7 +169,7 @@
             if self.__projectAct is not None:
                 self.__projectAct.setEnabled(
                     e5App().getObject("Project").getProjectLanguage() in \
-                        ["Python", "Python3", "Ruby"])
+                        ["Python", "Python2", "Python3", "Ruby"])
     
     def __doEricdoc(self):
         """
@@ -218,4 +218,4 @@
                 if outdir not in project.pdata['OTHERS']:
                     project.pdata['OTHERS'].append(outdir)
                     project.setDirty(True)
-                    project.othersAdded(outdir)
\ No newline at end of file
+                    project.othersAdded(outdir)
--- a/Project/DebuggerPropertiesDialog.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/Project/DebuggerPropertiesDialog.py	Fri Dec 31 15:19:02 2010 +0100
@@ -48,14 +48,14 @@
         if self.project.debugProperties["INTERPRETER"]:
             self.interpreterEdit.setText(self.project.debugProperties["INTERPRETER"])
         else:
-            if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python3"]:
+            if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]:
                 self.interpreterEdit.setText(sys.executable)
             elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby":
                 self.interpreterEdit.setText("/usr/bin/ruby")
         if self.project.debugProperties["DEBUGCLIENT"]:
             self.debugClientEdit.setText(self.project.debugProperties["DEBUGCLIENT"])
         else:
-            if self.project.pdata["PROGLANGUAGE"][0] == "Python":
+            if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2"]:
                 debugClient = os.path.join(getConfig('ericDir'), 
                                            "DebugClients", "Python", "DebugClient.py")
             elif self.project.pdata["PROGLANGUAGE"][0] == "Python3":
@@ -129,7 +129,7 @@
         self.project.debugProperties["INTERPRETER"] = \
             self.interpreterEdit.text()
         if not self.project.debugProperties["INTERPRETER"]:
-            if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python3"]:
+            if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]:
                 self.project.debugProperties["INTERPRETER"] = sys.executable
             elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby":
                 self.project.debugProperties["INTERPRETER"] = "/usr/bin/ruby"
@@ -137,7 +137,7 @@
         self.project.debugProperties["DEBUGCLIENT"] = \
             self.debugClientEdit.text()
         if not self.project.debugProperties["DEBUGCLIENT"]:
-            if self.project.pdata["PROGLANGUAGE"][0] == "Python":
+            if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2"]:
                 debugClient = os.path.join(getConfig('ericDir'), 
                                            "DebugClients", "Python", "DebugClient.py")
             elif self.project.pdata["PROGLANGUAGE"][0] == "Python3":
@@ -174,4 +174,4 @@
             self.redirectCheckBox.isChecked()
         self.project.debugProperties["NOENCODING"] = \
             self.noEncodingCheckBox.isChecked()
-        self.project.debugPropertiesLoaded = True
\ No newline at end of file
+        self.project.debugPropertiesLoaded = True
--- a/Project/Project.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/Project/Project.py	Fri Dec 31 15:19:02 2010 +0100
@@ -192,16 +192,16 @@
         self.ui = parent
         
         self.sourceExtensions = {
-            "Python"  : Preferences.getPython("PythonExtensions"),
+            "Python2"  : Preferences.getPython("PythonExtensions"),
             "Python3" : Preferences.getPython("Python3Extensions"),
             "Ruby"    : ['.rb'],
             "Mixed"   : ['.py', '.ptl', '.rb']
         }
         
         self.dbgFilters = {
-            "Python"  : self.trUtf8(
-                         "Python Files (*.py2);;"
-                         "Python GUI Files (*.pyw2);;"),
+            "Python2"  : self.trUtf8(
+                         "Python2 Files (*.py2);;"
+                         "Python2 GUI Files (*.pyw2);;"),
             "Python3" : self.trUtf8(
                          "Python3 Files (*.py *.py3);;"
                          "Python3 GUI Files (*.pyw *.pyw3);;"),
@@ -1823,7 +1823,7 @@
                     return
                 # create an empty __init__.py file to make it a Python package
                 # (only for Python and Python3)
-                if self.pdata["PROGLANGUAGE"][0] in ["Python", "Python3"]:
+                if self.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]:
                     fn = os.path.join(self.ppath, "__init__.py")
                     f = open(fn, "w", encoding = "utf-8")
                     f.close()
@@ -1877,7 +1877,7 @@
                     self.newProjectAddFiles(ms)
                 # create an empty __init__.py file to make it a Python package
                 # if none exists (only for Python and Python3)
-                if self.pdata["PROGLANGUAGE"][0] in ["Python", "Python3"]:
+                if self.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]:
                     fn = os.path.join(self.ppath, "__init__.py")
                     if not os.path.exists(fn):
                         f = open(fn, "w", encoding = "utf-8")
@@ -2060,7 +2060,7 @@
                     self.projectLanguageAdded.emit(ts)
             if len(self.pdata["MAINSCRIPT"]) == 0 or \
                len(self.pdata["MAINSCRIPT"][0]) == 0:
-                if self.pdata["PROGLANGUAGE"][0] in ["Python", "Python3"]:
+                if self.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]:
                     self.pdata["MAINSCRIPT"] = ['{0}.py'.format(mainscriptname)]
                 elif self.pdata["PROGLANGUAGE"][0] == "Ruby":
                     self.pdata["MAINSCRIPT"] = ['{0}.rb'.format(mainscriptname)]
--- a/Project/ProjectBrowser.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/Project/ProjectBrowser.py	Fri Dec 31 15:19:02 2010 +0100
@@ -272,7 +272,7 @@
         if not self.project.isOpen():
             icon = UI.PixmapCache.getIcon("projectSources.png")
         else:
-            if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python3"]:
+            if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]:
                 if self.project.pdata["MIXEDLANGUAGE"][0]:
                     icon = UI.PixmapCache.getIcon("projectSourcesPyMixed.png")
                 else:
@@ -352,4 +352,4 @@
         else:
             self.vcsStatusIndicator.setColor(
                 Preferences.getProjectBrowserColour(self.vcsStatusColorNames[state]))
-        self.vcsStatusIndicator.setToolTip(self.vcsStatusText[state])
\ No newline at end of file
+        self.vcsStatusIndicator.setToolTip(self.vcsStatusText[state])
--- a/Project/ProjectFormsBrowser.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/Project/ProjectFormsBrowser.py	Fri Dec 31 15:19:02 2010 +0100
@@ -644,7 +644,7 @@
         args = []
         self.buf = ""
         
-        if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python3"]:
+        if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]:
             if self.project.getProjectType() in ["Qt4", "E4Plugin"]:
                 self.uicompiler = 'pyuic4'
                 if Utilities.isWindowsPlatform():
@@ -674,7 +674,7 @@
         ofn, ext = os.path.splitext(fn)
         fn = os.path.join(self.project.ppath, fn)
         
-        if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python3"]:
+        if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]:
             dirname, filename = os.path.split(ofn)
             self.compiledFile = os.path.join(dirname, "Ui_" + filename + ".py")
             args.append("-x")
@@ -834,7 +834,8 @@
                 QApplication.processEvents()
                 
                 ifn = os.path.join(self.project.ppath, fn)
-                if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python3"]:
+                if self.project.pdata["PROGLANGUAGE"][0] in \
+                   ["Python", "Python2", "Python3"]:
                     dirname, filename = os.path.split(os.path.splitext(ifn)[0])
                     ofn = os.path.join(dirname, "Ui_" + filename + ".py")
                 elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby":
@@ -900,4 +901,4 @@
             "compileSelectedForms"  : None, 
             "generateDialogCode"    : None, 
             "newForm"               : None, 
-        }
\ No newline at end of file
+        }
--- a/Project/ProjectResourcesBrowser.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/Project/ProjectResourcesBrowser.py	Fri Dec 31 15:19:02 2010 +0100
@@ -549,17 +549,17 @@
         args = []
         self.buf = ""
         
-        if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python3"]:
+        if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]:
             if self.project.getProjectType() in ["Qt4", "E4Plugin"]:
                 self.rccCompiler = 'pyrcc4'
                 if PYQT_VERSION >= 0x040500:
-                    if self.project.pdata["PROGLANGUAGE"][0] == "Python":
+                    if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2"]:
                         args.append("-py2")
                     else:
                         args.append("-py3")
             elif self.project.getProjectType() == "PySide":
                 self.rccCompiler = 'pyside-rcc4'
-                if self.project.pdata["PROGLANGUAGE"][0] == "Python":
+                if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2"]:
                     args.append("-py2")
                 else:
                     args.append("-py3")
@@ -581,7 +581,7 @@
         fn = os.path.join(self.project.ppath, fn)
         
         dirname, filename = os.path.split(ofn)
-        if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python3"]:
+        if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]:
             self.compiledFile = os.path.join(dirname, 
                                 self.RCFilenameFormatPython.format(filename))
         elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby":
@@ -743,7 +743,8 @@
                 progress.setValue(i)
                 QApplication.processEvents()
                 ifn = os.path.join(self.project.ppath, fn)
-                if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python3"]:
+                if self.project.pdata["PROGLANGUAGE"][0] in \
+                   ["Python", "Python2", "Python3"]:
                     dirname, filename = os.path.split(os.path.splitext(ifn)[0])
                     ofn = os.path.join(dirname, 
                                        self.RCFilenameFormatPython.format(filename))
@@ -814,4 +815,4 @@
             "compileChangedResources"   : None, 
             "compileSelectedResources"  : None, 
             "newResource"               : None, 
-        }
\ No newline at end of file
+        }
--- a/Project/ProjectSourcesBrowser.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/Project/ProjectSourcesBrowser.py	Fri Dec 31 15:19:02 2010 +0100
@@ -43,6 +43,10 @@
             from the project
     @signal showMenu(str, QMenu) emitted when a menu is about to be shown. The name
             of the menu and a reference to the menu are given.
+    @signal sourceFile(str) emitted to open the given file.
+    @signal sourceFile(str, int) emitted to open the given file at the given line.
+    @signal sourceFile(str, int, str) emitted to open the given file as the given type
+            at the given line.
     """
     closeSourceWindow = pyqtSignal(str)
     showMenu = pyqtSignal(str, QMenu)
@@ -105,7 +109,7 @@
         ProjectBaseBrowser._createPopupMenus(self)
         self.sourceMenuActions = {}
         
-        if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python3"]:
+        if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]:
             self.__createPythonPopupMenus()
         elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby":
             self.__createRubyPopupMenus()
@@ -400,7 +404,7 @@
                         if isinstance(itm, ProjectBrowserFileItem):
                             fn = itm.fileName()
                             if self.project.pdata["PROGLANGUAGE"][0] in \
-                               ["Python", "Python3"]:
+                               ["Python", "Python2", "Python3"]:
                                 if fn.endswith('.ptl'):
                                     for act in list(self.sourceMenuActions.values()):
                                         act.setEnabled(False)
@@ -524,8 +528,8 @@
         
         for itm in itmList:
             if isinstance(itm, BrowserFileItem):
-                if itm.isPythonFile():
-                    self.sourceFile[str, int, str].emit(itm.fileName(), 1, "Python")
+                if itm.isPython2File():
+                    self.sourceFile[str, int, str].emit(itm.fileName(), 1, "Python2")
                 elif itm.isPython3File():
                     self.sourceFile[str, int, str].emit(itm.fileName(), 1, "Python3")
                 elif itm.isRubyFile():
@@ -854,4 +858,4 @@
             yesDefault = True)
         self.applicationDiagram = ApplicationDiagram(self.project, self, 
             noModules = not res)
-        self.applicationDiagram.show()
\ No newline at end of file
+        self.applicationDiagram.show()
--- a/Project/ProjectTranslationsBrowser.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/Project/ProjectTranslationsBrowser.py	Fri Dec 31 15:19:02 2010 +0100
@@ -887,7 +887,7 @@
                     return
         
         # generate a minimal temporary projectfile suitable for pylupdate
-        if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python3"]:
+        if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]:
             ok = self.__writeTempProjectFile(langs, [".py"])
         else:
             ok = False
@@ -1020,7 +1020,7 @@
                 return
         
         # generate a minimal temporary projectfile suitable for lrelease
-        if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python3"]:
+        if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]:
             ok = self.__writeTempProjectFile(langs, [".py"])
         else:
             ok = False
@@ -1098,4 +1098,4 @@
             "generateSelectedWithObsolete"  : None, 
             "releaseAll"                    : None, 
             "releaseSelected"               : None, 
-        }
\ No newline at end of file
+        }
--- a/PyUnit/UnittestDialog.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/PyUnit/UnittestDialog.py	Fri Dec 31 15:19:02 2010 +0100
@@ -149,15 +149,15 @@
         Private slot to open a file dialog.
         """
         if self.dbs:
-            pyExtensions = \
+            py2Extensions = \
                 ' '.join(["*{0}".format(ext) 
-                          for ext in self.dbs.getExtensions('Python')])
+                          for ext in self.dbs.getExtensions('Python2')])
             py3Extensions = \
                 ' '.join(["*{0}".format(ext) 
                           for ext in self.dbs.getExtensions('Python3')])
             filter = self.trUtf8(
                 "Python3 Files ({1});;Python2 Files ({0});;All Files (*)")\
-                .format(pyExtensions, py3Extensions)
+                .format(py2Extensions, py3Extensions)
         else:
             filter = self.trUtf8("Python Files (*.py);;All Files (*)")
         prog = QFileDialog.getOpenFileName(
@@ -179,7 +179,7 @@
         @param txt name of the test file (string)
         """
         if self.dbs:
-            exts = self.dbs.getExtensions("Python")
+            exts = self.dbs.getExtensions("Python3")
             if txt.endswith(exts):
                 self.coverageCheckBox.setChecked(False)
                 self.coverageCheckBox.setEnabled(False)
@@ -591,4 +591,4 @@
             QApplication.exit()
             return True
         
-        return False
\ No newline at end of file
+        return False
--- a/QScintilla/Editor.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/QScintilla/Editor.py	Fri Dec 31 15:19:02 2010 +0100
@@ -152,6 +152,7 @@
         self.fileName = fn
         self.vm = vm
         self.filetype = filetype
+        self.filetypeByFlag = False
         self.noName = ""
         self.project = e5App().getObject("Project")
         
@@ -464,30 +465,33 @@
         
         @param line0 first line of text to use in the generation process (string)
         """
-        bindName = self.fileName
+        bindName = ""
         
         if line0.startswith("<?xml"):
             # override extension for XML files
             bindName = "dummy.xml"
         
         # check filetype
-        if self.filetype == "Python":
-            bindName = "dummy.py"
-        elif self.filetype == "Ruby":
-            bindName = "dummy.rb"
-        elif self.filetype == "D":
-            bindName = "dummy.d"
-        elif self.filetype == "Properties":
-            bindName = "dummy.ini"
+        if not bindName and self.filetype:
+            if self.filetype in ["Python", "Python2"]:
+                bindName = "dummy.py"
+            elif self.filetype == "Python3":
+                bindName = "dummy.py"
+            elif self.filetype == "Ruby":
+                bindName = "dummy.rb"
+            elif self.filetype == "D":
+                bindName = "dummy.d"
+            elif self.filetype == "Properties":
+                bindName = "dummy.ini"
         
         # #! marker detection
-        if line0.startswith("#!"):
+        if not bindName and line0.startswith("#!"):
             if "python3" in line0:
                 bindName = "dummy.py"
                 self.filetype = "Python3"
             elif "python2" in line0:
                 bindName = "dummy.py"
-                self.filetype = "Python"
+                self.filetype = "Python2"
             elif "python" in line0:
                 bindName = "dummy.py"
                 self.filetype = "Python"
@@ -503,6 +507,10 @@
             elif "dmd" in line0:
                 bindName = "dummy.d"
                 self.filetype = "D"
+        
+        if not bindName:
+            bindName = self.fileName
+        
         return bindName
         
     def getMenu(self, menuName):
@@ -1543,15 +1551,16 @@
             line += 1
         return folds
         
-    def isPyFile(self):
+    def isPy2File(self):
         """
         Public method to return a flag indicating a Python file.
         
         @return flag indicating a Python file (boolean)
         """
-        return self.filetype == "Python" or \
-            (self.fileName is not None and \
-             os.path.splitext(self.fileName)[1] in self.dbs.getExtensions('Python'))
+        return self.filetype in ["Python", "Python2"] or \
+            (self.filetype == "" and \
+             self.fileName is not None and \
+             os.path.splitext(self.fileName)[1] in self.dbs.getExtensions('Python2'))
 
     def isPy3File(self):
         """
@@ -1560,7 +1569,8 @@
         @return flag indicating a Python3 file (boolean)
         """
         return self.filetype == "Python3" or \
-            (self.fileName is not None and \
+            (self.filetype == "" and \
+             self.fileName is not None and \
              os.path.splitext(self.fileName)[1] in self.dbs.getExtensions('Python3'))
 
     def isRubyFile(self):
@@ -1570,7 +1580,8 @@
         @return flag indicating a Ruby file (boolean)
         """
         return self.filetype == "Ruby" or \
-            (self.fileName is not None and \
+            (self.filetype == "" and \
+             self.fileName is not None and \
              os.path.splitext(self.fileName)[1] in self.dbs.getExtensions('Ruby'))
         
     def highlightVisible(self):
@@ -1766,7 +1777,7 @@
         @param temporary flag indicating a temporary breakpoint (boolean)
         """
         if self.fileName and \
-           (self.isPyFile() or self.isPy3File() or self.isRubyFile()):
+           (self.isPy2File() or self.isPy3File() or self.isRubyFile()):
             self.breakpointModel.addBreakPoint(self.fileName, line,
                 ('', temporary, True, 0))
             self.breakpointToggled.emit(self)
@@ -2168,9 +2179,31 @@
         self.taskMarkersUpdated.emit(self)
     
     ############################################################################
+    ## Flags handling methods below
+    ############################################################################
+    
+    def __processFlags(self):
+        """
+        Private method to extract flags and process them.
+        """
+        txt = self.text()
+        flags = Utilities.extractFlags(txt)
+        
+        # Flag 1: FileType
+        if "FileType" in flags:
+            if isinstance(flags["FileType"], str):
+                self.filetype = flags["FileType"]
+                self.filetypeByFlag = True
+        else:
+            if self.filetype != "" and self.filetypeByFlag:
+                self.filetype = ""
+                self.filetypeByFlag = False
+                self.__bindName(txt.splitlines()[0])
+    
+    ############################################################################
     ## File handling methods below
     ############################################################################
-
+    
     def checkDirty(self):
         """
         Public method to check dirty status and open a message window.
@@ -2250,6 +2283,9 @@
         
         self.setText(txt)
         
+        # get eric specific flags
+        self.__processFlags()
+        
         # perform automatic eol conversion
         if Preferences.getEditor("AutomaticEOLConversion"):
             self.convertEols(self.eolMode())
@@ -2405,6 +2441,8 @@
             self.editorSaved.emit(self.fileName)
             self.__autoSyntaxCheck()
             self.extractTasks()
+            # get eric specific flags
+            self.__processFlags()
             return True
         else:
             self.lastModified = QFileInfo(fn).lastModified()
@@ -3780,12 +3818,12 @@
             self.menuActs["Copy"].setEnabled(self.hasSelectedText())
         if not self.isResourcesFile:
             if self.fileName and \
-               (self.isPyFile() or self.isPy3File()):
+               (self.isPy2File() or self.isPy3File()):
                 self.menuActs["Show"].setEnabled(True)
             else:
                 self.menuActs["Show"].setEnabled(False)
             if self.fileName and \
-               (self.isPyFile() or self.isPy3File() or self.isRubyFile()):
+               (self.isPy2File() or self.isPy3File() or self.isRubyFile()):
                 self.menuActs["Diagrams"].setEnabled(True)
             else:
                 self.menuActs["Diagrams"].setEnabled(False)
@@ -3889,7 +3927,7 @@
         Private slot handling the aboutToShow signal of the margins context menu.
         """
         if self.fileName and \
-           (self.isPyFile() or self.isPy3File() or self.isRubyFile()):
+           (self.isPy2File() or self.isPy3File() or self.isRubyFile()):
             self.marginMenuActs["Breakpoint"].setEnabled(True)
             self.marginMenuActs["TempBreakpoint"].setEnabled(True)
             if self.markersAtLine(self.line) & self.breakpointMask:
--- a/QScintilla/Lexers/__init__.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/QScintilla/Lexers/__init__.py	Fri Dec 31 15:19:02 2010 +0100
@@ -117,7 +117,7 @@
     """
     if not pyname:
         try:
-            if language in ["Python", "Python3"]:
+            if language in ["Python", "Python2", "Python3"]:
                 from .LexerPython import LexerPython
                 return LexerPython(parent)
             elif language == "C++":
@@ -349,11 +349,11 @@
     """
     saveFileFiltersList = [
         QApplication.translate('Lexers', 
-            "Python Files (*.py2)"), 
+            "Python2 Files (*.py2)"), 
         QApplication.translate('Lexers', 
             "Python3 Files (*.py)"), 
         QApplication.translate('Lexers', 
-            "Python GUI Files (*.pyw2)"), 
+            "Python2 GUI Files (*.pyw2)"), 
         QApplication.translate('Lexers', 
             "Python3 GUI Files (*.pyw)"), 
         QApplication.translate('Lexers', 
@@ -531,6 +531,10 @@
         "*.rc"              : "Properties",
         '*.py'              : "Python",
         '*.pyw'             : "Python",
+        '*.py2'             : "Python",
+        '*.pyw2'            : "Python",
+        '*.py3'             : "Python",
+        '*.pyw3'            : "Python",
         '*.pyx'             : "Python",
         '*.ptl'             : "Python",
         '*.rb'              : "Ruby",
--- a/QScintilla/MiniEditor.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/QScintilla/MiniEditor.py	Fri Dec 31 15:19:02 2010 +0100
@@ -2083,7 +2083,7 @@
             bindName = "dummy.xml"
         
         # check filetype
-        if self.filetype == "Python":
+        if self.filetype in ["Python", "Python3"]:
             bindName = "dummy.py"
         elif self.filetype == "Ruby":
             bindName = "dummy.rb"
--- a/UI/Browser.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/UI/Browser.py	Fri Dec 31 15:19:02 2010 +0100
@@ -323,7 +323,7 @@
         
         for itm in itmList:
             if isinstance(itm, BrowserFileItem):
-                if itm.isPythonFile():
+                if itm.isPython2File():
                     self.sourceFile[str, int, str].emit(itm.fileName(), 1, "Python")
                 elif itm.isPython3File():
                     self.sourceFile[str, int, str].emit(itm.fileName(), 1, "Python3")
@@ -567,4 +567,4 @@
         if self.__embeddedBrowser == 1:
             e5App().getObject("UserInterface").showPreferences("debuggerGeneralPage")
         elif self.__embeddedBrowser == 2:
-            e5App().getObject("UserInterface").showPreferences("projectBrowserPage")
\ No newline at end of file
+            e5App().getObject("UserInterface").showPreferences("projectBrowserPage")
--- a/UI/BrowserModel.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/UI/BrowserModel.py	Fri Dec 31 15:19:02 2010 +0100
@@ -525,7 +525,7 @@
         try:
             dict = Utilities.ClassBrowsers.readmodule(
                 moduleName, [parentItem.dirName()], 
-                parentItem.isPythonFile() or parentItem.isPython3File())
+                parentItem.isPython2File() or parentItem.isPython3File())
         except ImportError:
             return
         
@@ -950,7 +950,7 @@
         self._moduleName = ''
         
         pixName = ""
-        if self.isPythonFile():
+        if self.isPython2File():
             if self.fileext == '.py':
                 pixName = "filePython.png"
             else:
@@ -1010,7 +1010,7 @@
         """
         self._filename = os.path.abspath(finfo)
         self.itemData[0] = os.path.basename(finfo)
-        if self.isPythonFile() or self.isPython3File() or \
+        if self.isPython2File() or self.isPython3File() or \
            self.isRubyFile() or self.isIdlFile():
             self._dirName = os.path.dirname(finfo)
             self._moduleName = os.path.basename(finfo)
@@ -1055,14 +1055,14 @@
         """
         return self._moduleName
     
-    def isPythonFile(self):
+    def isPython2File(self):
         """
         Public method to check, if this file is a Python script.
         
         @return flag indicating a Python file (boolean)
         """
         return self.fileext in Preferences.getPython("PythonExtensions") or \
-               (self.fileext == "" and self.sourceLanguage == "Python")
+               (self.fileext == "" and self.sourceLanguage in ["Python", "Python2"])
     
     def isPython3File(self):
         """
--- a/UI/UserInterface.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/UI/UserInterface.py	Fri Dec 31 15:19:02 2010 +0100
@@ -4984,7 +4984,7 @@
                     self.utEditorOpen = cap & HasUnittest
                     return
             
-            if self.viewmanager.getOpenEditor(fn).isPyFile() or \
+            if self.viewmanager.getOpenEditor(fn).isPy2File() or \
                self.viewmanager.getOpenEditor(fn).isPy3File():
                 self.utScriptAct.setEnabled(True)
                 self.utEditorOpen = True
@@ -5010,7 +5010,7 @@
                     self.utEditorOpen = cap & HasUnittest
                     return
             
-            if editor.isPyFile() or editor.isPy3File():
+            if editor.isPy2File() or editor.isPy3File():
                 self.utScriptAct.setEnabled(True)
                 self.utEditorOpen = True
                 return
--- a/Utilities/ClassBrowsers/__init__.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/Utilities/ClassBrowsers/__init__.py	Fri Dec 31 15:19:02 2010 +0100
@@ -30,7 +30,7 @@
 
 __extensions = {
     "IDL"       : [".idl"],
-    "Python"    : [".py", ".pyw", ".ptl"],
+    "Python"    : [".py", ".pyw", ".ptl"],  # currently not used
     "Ruby"      : [".rb"],
 }
 
--- a/Utilities/__init__.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/Utilities/__init__.py	Fri Dec 31 15:19:02 2010 +0100
@@ -435,6 +435,57 @@
     else:
         return "\r\n"
 
+def extractFlags(text):
+    """
+    Function to extract eric specific flags out of the given text.
+    
+    Flags are contained in comments and are introduced by 'eflag:'.
+    The rest of the line is interpreted as 'key = value'. value is
+    analyzed for being an integer or float value. If that fails, it
+    is assumed to be a string. If a key does not contain a '=' 
+    character, it is assumed to be a boolean flag. Flags are expected
+    at the very end of a file. The search is ended, if a line without
+    the 'eflag:' marker is found.
+    
+    @param text text to be scanned (string)
+    @return dictionary of string, boolean, complex, float and int
+    """
+    flags = {}
+    lines = text.splitlines()
+    for line in reversed(lines):
+        index = line.find("eflag:")
+        if index == -1:
+            # no flag found, don't look any further
+            break
+        
+        flag = line[index + 6:].strip()
+        if "=" in flag:
+            key, value = flag.split("=", 1)
+            key = key.strip()
+            value = value.strip()
+            
+            if value.lower() in ["true", "false", "yes", "no", "ok"]:
+                # it is a flag
+                flags[key] = value.lower() in ["true", "yes", "ok"]
+                continue
+            
+            try:
+                # interpret as int first
+                value = int(value)
+            except ValueError:
+                try:
+                    # interpret as float next
+                    value = float(value)
+                except ValueError:
+                    pass
+            
+            flags[key] = value
+        else:
+            # treat it as a boolean
+            flags[flag] = True
+    
+    return flags
+
 def toNativeSeparators(path):
     """
     Function returning a path, that is using native separator characters.
--- a/changelog	Mon Dec 27 19:49:16 2010 +0100
+++ b/changelog	Fri Dec 31 15:19:02 2010 +0100
@@ -9,6 +9,9 @@
 - added display of suppressed client termination messages
 - changed the Mercurial log browser to show incoming/outgoing changesets
   with the current log (by pressing the next button)
+- added a feature where flags can be given at the end of a source file.
+  The only flag supported is 'FileType' to overwrite the filetype detection
+  mechanism.
 
 Version 5.1-snapshot-20101029:
 - bug fixes
--- a/eric5-api.py	Mon Dec 27 19:49:16 2010 +0100
+++ b/eric5-api.py	Fri Dec 31 15:19:02 2010 +0100
@@ -73,7 +73,7 @@
     print("        This option may be repeated multiple times.")
     for lang in sorted(DocumentationTools.supportedExtensionsDictForApis.keys()):
         print("            * {0}".format(lang))
-    print("        The default is 'Python'.")
+    print("        The default is 'Python3'.")
     print("        This option may be repeated multiple times.")
     sys.exit(1)
 
@@ -217,7 +217,7 @@
                             inpackage = True
                             files.remove(initFile)
                             files.insert(0, initFile)
-                        elif progLanguage != "Python":
+                        elif progLanguage != "Python3":
                             # assume package
                             inpackage = True
                 else:

eric ide

mercurial