154 @rtype str |
154 @rtype str |
155 """ |
155 """ |
156 idString = "" |
156 idString = "" |
157 |
157 |
158 language = editor.getLanguage() |
158 language = editor.getLanguage() |
159 if self.__e5project.isOpen() and \ |
159 if ( |
160 self.__e5project.getProjectLanguage() == language: |
160 self.__e5project.isOpen() and |
|
161 self.__e5project.getProjectLanguage() == language |
|
162 ): |
161 filename = editor.getFileName() |
163 filename = editor.getFileName() |
162 if self.__e5project.isProjectSource(filename): |
164 if self.__e5project.isProjectSource(filename): |
163 idString = CodeAssistServer.IdProject |
165 idString = CodeAssistServer.IdProject |
164 |
166 |
165 if not idString and language in self.__editorLanguageMapping: |
167 if not idString and language in self.__editorLanguageMapping: |
429 idString = self.__idString(editor) |
431 idString = self.__idString(editor) |
430 |
432 |
431 if not idString: |
433 if not idString: |
432 language = editor.getLanguage() |
434 language = editor.getLanguage() |
433 if Preferences.getDocuViewer("ShowInfoAsRichText"): |
435 if Preferences.getDocuViewer("ShowInfoAsRichText"): |
434 warning = self.tr("Language <b>{0}</b> is not supported.")\ |
436 warning = self.tr( |
435 .format(language) |
437 "Language <b>{0}</b> is not supported." |
|
438 ).format(language) |
436 else: |
439 else: |
437 warning = self.tr("Language '{0}' is not supported.")\ |
440 warning = self.tr( |
438 .format(language) |
441 "Language '{0}' is not supported." |
|
442 ).format(language) |
439 self.__documentationViewer.documentationReady( |
443 self.__documentationViewer.documentationReady( |
440 warning, isWarning=True) |
444 warning, isWarning=True) |
441 return |
445 return |
442 |
446 |
443 filename = editor.getFileName() |
447 filename = editor.getFileName() |
475 documentationDict = result["DocumentationDict"] |
479 documentationDict = result["DocumentationDict"] |
476 if documentationDict: |
480 if documentationDict: |
477 if "module" in documentationDict: |
481 if "module" in documentationDict: |
478 if documentationDict["module"]: |
482 if documentationDict["module"]: |
479 if Preferences.getDocuViewer("ShowInfoAsRichText"): |
483 if Preferences.getDocuViewer("ShowInfoAsRichText"): |
480 documentationDict["note"] = \ |
484 documentationDict["note"] = self.tr( |
481 self.tr("Present in <i>{0}</i> module")\ |
485 "Present in <i>{0}</i> module" |
482 .format(documentationDict["module"]) |
486 ).format(documentationDict["module"]) |
483 else: |
487 else: |
484 documentationDict["note"] = \ |
488 documentationDict["note"] = self.tr( |
485 self.tr("Present in '{0}' module")\ |
489 "Present in '{0}' module" |
486 .format(documentationDict["module"]) |
490 ).format(documentationDict["module"]) |
487 del documentationDict["module"] |
491 del documentationDict["module"] |
488 |
492 |
489 if "typ" in documentationDict: |
493 if "typ" in documentationDict: |
490 if documentationDict["typ"] not in self.__typeMapping: |
494 if documentationDict["typ"] not in self.__typeMapping: |
491 del documentationDict["typ"] |
495 del documentationDict["typ"] |
492 else: |
496 else: |
493 documentationDict["typ"] = \ |
497 documentationDict["typ"] = self.__typeMapping[ |
494 self.__typeMapping[documentationDict["typ"]] |
498 documentationDict["typ"]] |
495 |
499 |
496 if "note" not in documentationDict: |
500 if "note" not in documentationDict: |
497 documentationDict["note"] = "" |
501 documentationDict["note"] = "" |
498 |
502 |
499 docu = documentationDict |
503 docu = documentationDict |
677 if idString == "Python2": |
681 if idString == "Python2": |
678 # Python 2 |
682 # Python 2 |
679 venvName = Preferences.getDebugger("Python2VirtualEnv") |
683 venvName = Preferences.getDebugger("Python2VirtualEnv") |
680 if not venvName and sys.version_info[0] == 2: |
684 if not venvName and sys.version_info[0] == 2: |
681 try: |
685 try: |
682 venvName, _ = \ |
686 venvName, _ = ( |
683 venvManager.getDefaultEnvironment() |
687 venvManager.getDefaultEnvironment() |
|
688 ) |
684 except AttributeError: |
689 except AttributeError: |
685 # ignore for eric6 < 18.10 |
690 # ignore for eric6 < 18.10 |
686 pass |
691 pass |
687 elif idString == "Python3": |
692 elif idString == "Python3": |
688 # Python 3 |
693 # Python 3 |
689 venvName = Preferences.getDebugger("Python3VirtualEnv") |
694 venvName = Preferences.getDebugger("Python3VirtualEnv") |
690 if not venvName and sys.version_info[0] == 3: |
695 if not venvName and sys.version_info[0] >= 3: |
691 try: |
696 try: |
692 venvName, _ = \ |
697 venvName, _ = ( |
693 venvManager.getDefaultEnvironment() |
698 venvManager.getDefaultEnvironment() |
|
699 ) |
694 except AttributeError: |
700 except AttributeError: |
695 # ignore for eric6 < 18.10 |
701 # ignore for eric6 < 18.10 |
696 pass |
702 pass |
697 if venvName: |
703 if venvName: |
698 interpreter = \ |
704 interpreter = venvManager.getVirtualenvInterpreter( |
699 venvManager.getVirtualenvInterpreter(venvName) |
705 venvName) |
700 |
706 |
701 try: |
707 try: |
702 execPath = \ |
708 execPath = venvManager.getVirtualenvExecPath( |
703 venvManager.getVirtualenvExecPath(venvName) |
709 venvName) |
704 except AttributeError: |
710 except AttributeError: |
705 # eric6 < 18.12 |
711 # eric6 < 18.12 |
706 execPath = "" |
712 execPath = "" |
707 |
713 |
708 # build a suitable environment |
714 # build a suitable environment |
714 clientEnv["PATH"] = execPath |
720 clientEnv["PATH"] = execPath |
715 except KeyError: |
721 except KeyError: |
716 # backward compatibility (eric <18.07) |
722 # backward compatibility (eric <18.07) |
717 if idString == "Python2": |
723 if idString == "Python2": |
718 # Python 2 |
724 # Python 2 |
719 interpreter = \ |
725 interpreter = Preferences.getDebugger( |
720 Preferences.getDebugger("PythonInterpreter") |
726 "PythonInterpreter") |
721 elif idString == "Python3": |
727 elif idString == "Python3": |
722 # Python 3 |
728 # Python 3 |
723 interpreter = \ |
729 interpreter = Preferences.getDebugger( |
724 Preferences.getDebugger("Python3Interpreter") |
730 "Python3Interpreter") |
725 if interpreter: |
731 if interpreter: |
726 ok = self.__startCodeAssistClient(interpreter, idString, |
732 ok = self.__startCodeAssistClient(interpreter, idString, |
727 clientEnv) |
733 clientEnv) |
728 else: |
734 else: |
729 ok = False |
735 ok = False |
760 if projectLanguage == "Python2": |
766 if projectLanguage == "Python2": |
761 # Python 2 |
767 # Python 2 |
762 venvName = Preferences.getDebugger("Python2VirtualEnv") |
768 venvName = Preferences.getDebugger("Python2VirtualEnv") |
763 if not venvName and sys.version_info[0] == 2: |
769 if not venvName and sys.version_info[0] == 2: |
764 try: |
770 try: |
765 venvName, _ = \ |
771 venvName, _ = ( |
766 venvManager.getDefaultEnvironment() |
772 venvManager.getDefaultEnvironment() |
|
773 ) |
767 except AttributeError: |
774 except AttributeError: |
768 # ignore for eric6 < 18.10 |
775 # ignore for eric6 < 18.10 |
769 pass |
776 pass |
770 elif projectLanguage == "Python3": |
777 elif projectLanguage == "Python3": |
771 # Python 3 |
778 # Python 3 |
772 venvName = Preferences.getDebugger("Python3VirtualEnv") |
779 venvName = Preferences.getDebugger("Python3VirtualEnv") |
773 if not venvName and sys.version_info[0] == 3: |
780 if not venvName and sys.version_info[0] >= 3: |
774 try: |
781 try: |
775 venvName, _ = \ |
782 venvName, _ = ( |
776 venvManager.getDefaultEnvironment() |
783 venvManager.getDefaultEnvironment() |
|
784 ) |
777 except AttributeError: |
785 except AttributeError: |
778 # ignore for eric6 < 18.10 |
786 # ignore for eric6 < 18.10 |
779 pass |
787 pass |
780 else: |
788 else: |
781 venvName = "" |
789 venvName = "" |
782 if venvName: |
790 if venvName: |
783 interpreter = \ |
791 interpreter = venvManager.getVirtualenvInterpreter( |
784 venvManager.getVirtualenvInterpreter(venvName) |
792 venvName |
|
793 ) |
785 |
794 |
786 try: |
795 try: |
787 execPath = venvManager.getVirtualenvExecPath(venvName) |
796 execPath = venvManager.getVirtualenvExecPath(venvName) |
788 except AttributeError: |
797 except AttributeError: |
789 # eric6 < 18.12 |
798 # eric6 < 18.12 |