222 return extensions |
223 return extensions |
223 elif language == "Python3": |
224 elif language == "Python3": |
224 extensions = Preferences.getPython("Python3Extensions") |
225 extensions = Preferences.getPython("Python3Extensions") |
225 # *.py and *.pyw should always be associated with source files |
226 # *.py and *.pyw should always be associated with source files |
226 for ext in [".py", ".pyw"]: |
227 for ext in [".py", ".pyw"]: |
|
228 if ext not in extensions: |
|
229 extensions.append(ext) |
|
230 return extensions |
|
231 elif language == "MicroPython": |
|
232 extensions = Preferences.getPython("Python3Extensions") |
|
233 # *.py should always be associated with source files |
|
234 for ext in [".py"]: |
227 if ext not in extensions: |
235 if ext not in extensions: |
228 extensions.append(ext) |
236 extensions.append(ext) |
229 return extensions |
237 return extensions |
230 elif language == "Ruby": |
238 elif language == "Ruby": |
231 return ['.rb'] |
239 return ['.rb'] |
2319 QByteArray(self.ppath.encode("utf-8")), |
2327 QByteArray(self.ppath.encode("utf-8")), |
2320 QCryptographicHash.Sha1).toHex(), |
2328 QCryptographicHash.Sha1).toHex(), |
2321 encoding="utf-8") |
2329 encoding="utf-8") |
2322 self.pdata["HASH"] = hashStr |
2330 self.pdata["HASH"] = hashStr |
2323 |
2331 |
|
2332 if self.pdata["PROGLANGUAGE"] == "MicroPython": |
|
2333 # change the lexer association for *.py files |
|
2334 self.pdata["LEXERASSOCS"] = { |
|
2335 "*.py": "MicroPython", |
|
2336 } |
|
2337 |
2324 # create the project directory if it doesn't exist already |
2338 # create the project directory if it doesn't exist already |
2325 if not os.path.isdir(self.ppath): |
2339 if not os.path.isdir(self.ppath): |
2326 try: |
2340 try: |
2327 os.makedirs(self.ppath) |
2341 os.makedirs(self.ppath) |
2328 except EnvironmentError: |
2342 except EnvironmentError: |
2337 return |
2351 return |
2338 |
2352 |
2339 # create an empty __init__.py file to make it a Python package |
2353 # create an empty __init__.py file to make it a Python package |
2340 # (only for Python and Python3) |
2354 # (only for Python and Python3) |
2341 if self.pdata["PROGLANGUAGE"] in \ |
2355 if self.pdata["PROGLANGUAGE"] in \ |
2342 ["Python", "Python2", "Python3"]: |
2356 ["Python", "Python2", "Python3", "MicroPython"]: |
2343 fn = os.path.join(self.ppath, "__init__.py") |
2357 fn = os.path.join(self.ppath, "__init__.py") |
2344 f = open(fn, "w", encoding="utf-8") |
2358 f = open(fn, "w", encoding="utf-8") |
2345 f.close() |
2359 f.close() |
2346 self.appendFile(fn, True) |
2360 self.appendFile(fn, True) |
2347 |
2361 |
2380 |
2394 |
2381 # create management directory if not present |
2395 # create management directory if not present |
2382 self.createProjectManagementDir() |
2396 self.createProjectManagementDir() |
2383 |
2397 |
2384 self.saveProject() |
2398 self.saveProject() |
|
2399 addAllToVcs = True |
2385 else: |
2400 else: |
2386 try: |
2401 try: |
2387 # create management directory if not present |
2402 # create management directory if not present |
2388 self.createProjectManagementDir() |
2403 self.createProjectManagementDir() |
2389 except EnvironmentError: |
2404 except EnvironmentError: |
2445 self.tr("New Project"), |
2460 self.tr("New Project"), |
2446 self.tr("""Add existing files to the project?"""), |
2461 self.tr("""Add existing files to the project?"""), |
2447 yesDefault=True) |
2462 yesDefault=True) |
2448 if res: |
2463 if res: |
2449 self.newProjectAddFiles(ms) |
2464 self.newProjectAddFiles(ms) |
|
2465 addAllToVcs = res |
2450 # create an empty __init__.py file to make it a Python package |
2466 # create an empty __init__.py file to make it a Python package |
2451 # if none exists (only for Python and Python3) |
2467 # if none exists (only for Python and Python3) |
2452 if self.pdata["PROGLANGUAGE"] in \ |
2468 if self.pdata["PROGLANGUAGE"] in \ |
2453 ["Python", "Python2", "Python3"]: |
2469 ["Python", "Python2", "Python3", "MicroPython"]: |
2454 fn = os.path.join(self.ppath, "__init__.py") |
2470 fn = os.path.join(self.ppath, "__init__.py") |
2455 if not os.path.exists(fn): |
2471 if not os.path.exists(fn): |
2456 f = open(fn, "w", encoding="utf-8") |
2472 f = open(fn, "w", encoding="utf-8") |
2457 f.close() |
2473 f.close() |
2458 self.appendFile(fn, True) |
2474 self.appendFile(fn, True) |
2575 self.vcs.vcsSetOptions(codlg.getOptions()) |
2591 self.vcs.vcsSetOptions(codlg.getOptions()) |
2576 |
2592 |
2577 # create the project in the VCS |
2593 # create the project in the VCS |
2578 self.vcs.vcsSetDataFromDict(vcsDataDict) |
2594 self.vcs.vcsSetDataFromDict(vcsDataDict) |
2579 self.saveProject() |
2595 self.saveProject() |
2580 self.vcs.vcsConvertProject(vcsDataDict, self) |
2596 self.vcs.vcsConvertProject(vcsDataDict, self, |
|
2597 addAll=addAllToVcs) |
2581 else: |
2598 else: |
2582 self.newProjectHooks.emit() |
2599 self.newProjectHooks.emit() |
2583 self.newProject.emit() |
2600 self.newProject.emit() |
2584 |
2601 |
2585 else: |
2602 else: |
3376 project. |
3393 project. |
3377 |
3394 |
3378 @return flag indicating a Python project (boolean) |
3395 @return flag indicating a Python project (boolean) |
3379 """ |
3396 """ |
3380 return self.pdata["PROGLANGUAGE"] in ["Python", "Python2", |
3397 return self.pdata["PROGLANGUAGE"] in ["Python", "Python2", |
3381 "Python3"] |
3398 "Python3", "MicroPython"] |
3382 |
3399 |
3383 def isPy3Project(self): |
3400 def isPy3Project(self): |
3384 """ |
3401 """ |
3385 Public method to check, if this project is a Python3 project. |
3402 Public method to check, if this project is a Python3 project. |
3386 |
3403 |
3393 Public method to check, if this project is a Python2 project. |
3410 Public method to check, if this project is a Python2 project. |
3394 |
3411 |
3395 @return flag indicating a Python2 project (boolean) |
3412 @return flag indicating a Python2 project (boolean) |
3396 """ |
3413 """ |
3397 return self.pdata["PROGLANGUAGE"] in ["Python", "Python2"] |
3414 return self.pdata["PROGLANGUAGE"] in ["Python", "Python2"] |
|
3415 |
|
3416 def isMicroPythonProject(self): |
|
3417 """ |
|
3418 Public method to check, if this project is a MicroPython project. |
|
3419 |
|
3420 @return flag indicating a MicroPython project |
|
3421 @rtype bool |
|
3422 """ |
|
3423 return self.pdata["PROGLANGUAGE"] == "MicroPython" |
3398 |
3424 |
3399 def isRubyProject(self): |
3425 def isRubyProject(self): |
3400 """ |
3426 """ |
3401 Public method to check, if this project is a Ruby project. |
3427 Public method to check, if this project is a Ruby project. |
3402 |
3428 |