More MicroPython related fixes.

Sat, 24 Aug 2019 18:25:37 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 24 Aug 2019 18:25:37 +0200
changeset 7166
5a184952ba77
parent 7165
375c077ef7e2
child 7167
b3557e77314a

More MicroPython related fixes.

eric6/Project/Project.py file | annotate | diff | comparison | revisions
eric6/Project/PropertiesDialog.py file | annotate | diff | comparison | revisions
--- a/eric6/Project/Project.py	Sat Aug 24 18:24:33 2019 +0200
+++ b/eric6/Project/Project.py	Sat Aug 24 18:25:37 2019 +0200
@@ -168,6 +168,7 @@
         self.__progLanguages = [
             "Python2",
             "Python3",
+            "MicroPython",
             "Ruby",
             "JavaScript",
         ]
@@ -227,6 +228,13 @@
                 if ext not in extensions:
                     extensions.append(ext)
             return extensions
+        elif language == "MicroPython":
+            extensions = Preferences.getPython("Python3Extensions")
+            # *.py should always be associated with source files
+            for ext in [".py"]:
+                if ext not in extensions:
+                    extensions.append(ext)
+            return extensions
         elif language == "Ruby":
             return ['.rb']
         elif language == "JavaScript":
@@ -2321,6 +2329,12 @@
                 encoding="utf-8")
             self.pdata["HASH"] = hashStr
             
+            if self.pdata["PROGLANGUAGE"] == "MicroPython":
+                # change the lexer association for *.py files
+                self.pdata["LEXERASSOCS"] = {
+                    "*.py": "MicroPython",
+                }
+            
             # create the project directory if it doesn't exist already
             if not os.path.isdir(self.ppath):
                 try:
@@ -2339,7 +2353,7 @@
                 # create an empty __init__.py file to make it a Python package
                 # (only for Python and Python3)
                 if self.pdata["PROGLANGUAGE"] in \
-                        ["Python", "Python2", "Python3"]:
+                        ["Python", "Python2", "Python3", "MicroPython"]:
                     fn = os.path.join(self.ppath, "__init__.py")
                     f = open(fn, "w", encoding="utf-8")
                     f.close()
@@ -2382,6 +2396,7 @@
                 self.createProjectManagementDir()
                 
                 self.saveProject()
+                addAllToVcs = True
             else:
                 try:
                     # create management directory if not present
@@ -2447,10 +2462,11 @@
                     yesDefault=True)
                 if res:
                     self.newProjectAddFiles(ms)
+                addAllToVcs = res
                 # create an empty __init__.py file to make it a Python package
                 # if none exists (only for Python and Python3)
                 if self.pdata["PROGLANGUAGE"] in \
-                        ["Python", "Python2", "Python3"]:
+                        ["Python", "Python2", "Python3", "MicroPython"]:
                     fn = os.path.join(self.ppath, "__init__.py")
                     if not os.path.exists(fn):
                         f = open(fn, "w", encoding="utf-8")
@@ -2577,7 +2593,8 @@
                     # create the project in the VCS
                     self.vcs.vcsSetDataFromDict(vcsDataDict)
                     self.saveProject()
-                    self.vcs.vcsConvertProject(vcsDataDict, self)
+                    self.vcs.vcsConvertProject(vcsDataDict, self,
+                                               addAll=addAllToVcs)
                 else:
                     self.newProjectHooks.emit()
                     self.newProject.emit()
@@ -3378,7 +3395,7 @@
         @return flag indicating a Python project (boolean)
         """
         return self.pdata["PROGLANGUAGE"] in ["Python", "Python2",
-                                              "Python3"]
+                                              "Python3", "MicroPython"]
         
     def isPy3Project(self):
         """
@@ -3396,6 +3413,15 @@
         """
         return self.pdata["PROGLANGUAGE"] in ["Python", "Python2"]
         
+    def isMicroPythonProject(self):
+        """
+        Public method to check, if this project is a MicroPython project.
+        
+        @return flag indicating a MicroPython project
+        @rtype bool
+        """
+        return self.pdata["PROGLANGUAGE"] == "MicroPython"
+        
     def isRubyProject(self):
         """
         Public method to check, if this project is a Ruby project.
--- a/eric6/Project/PropertiesDialog.py	Sat Aug 24 18:24:33 2019 +0200
+++ b/eric6/Project/PropertiesDialog.py	Sat Aug 24 18:25:37 2019 +0200
@@ -146,7 +146,7 @@
         curProjectType = self.getProjectType()
         
         projectTypes = []
-        for projectTypeItem in self.project.getProjectTypes().items():
+        for projectTypeItem in self.project.getProjectTypes(language).items():
             projectTypes.append((projectTypeItem[1], projectTypeItem[0]))
         self.projectTypeComboBox.clear()
         for projectType in sorted(projectTypes):

eric ide

mercurial