|
35 | 35 |
|
36 | 36 |
|
37 | 37 | def plugin_loaded():
|
38 |
| - if sys.version_info >= (3, 8): |
39 |
| - import json |
40 |
| - from textwrap import dedent |
| 38 | + if sys.version_info < (3, 8): |
| 39 | + return |
41 | 40 |
|
42 |
| - UT33_CODE = dedent( |
43 |
| - """ |
44 |
| - from UnitTesting import plugin as ut38 |
| 41 | + # python 3.3 plugin_host is optional in ST4193+ |
| 42 | + settings = sublime.load_settings("Preferences.sublime-settings") |
| 43 | + if settings.get("disable_plugin_host_3.3", False): |
| 44 | + return |
45 | 45 |
|
| 46 | + import json |
| 47 | + from textwrap import dedent |
46 | 48 |
|
47 |
| - class UnitTesting33Command(ut38.UnitTestingCommand): |
48 |
| - \"\"\"Execute unit tests for python 3.3 plugins.\"\"\" |
49 |
| - pass |
50 |
| - """ |
51 |
| - ).lstrip() |
| 49 | + UT33_CODE = dedent( |
| 50 | + """ |
| 51 | + from UnitTesting import plugin as ut38 |
52 | 52 |
|
53 |
| - UT33 = os.path.join(sublime.packages_path(), "UnitTesting33") |
54 |
| - os.makedirs(UT33, exist_ok=True) |
55 | 53 |
|
| 54 | + class UnitTesting33Command(ut38.UnitTestingCommand): |
| 55 | + \"\"\"Execute unit tests for python 3.3 plugins.\"\"\" |
| 56 | + pass |
| 57 | + """ |
| 58 | + ).lstrip() |
| 59 | + |
| 60 | + UT33 = os.path.join(sublime.packages_path(), "UnitTesting33") |
| 61 | + os.makedirs(UT33, exist_ok=True) |
| 62 | + |
| 63 | + try: |
56 | 64 | try:
|
57 |
| - try: |
58 |
| - with open(os.path.join(UT33, "plugin.py"), "x") as f: |
59 |
| - f.write(UT33_CODE) |
60 |
| - except FileExistsError: |
61 |
| - pass |
62 |
| - |
63 |
| - try: |
64 |
| - with open(os.path.join(UT33, "dependencies.json"), "x") as f: |
65 |
| - f.write( |
66 |
| - json.dumps( |
67 |
| - { |
68 |
| - "linux-x32": {">3000": ["coverage"]}, |
69 |
| - "linux-x64": {">3000": ["coverage"]}, |
70 |
| - "osx-x32": {">3000": ["coverage"]}, |
71 |
| - "osx-x64": {">3000": ["coverage"]}, |
72 |
| - "windows-x32": {">3000": ["coverage"]}, |
73 |
| - "windows-x64": {">3000": ["coverage"]}, |
74 |
| - } |
75 |
| - ) |
| 65 | + with open(os.path.join(UT33, "plugin.py"), "x") as f: |
| 66 | + f.write(UT33_CODE) |
| 67 | + except FileExistsError: |
| 68 | + pass |
| 69 | + |
| 70 | + try: |
| 71 | + with open(os.path.join(UT33, "dependencies.json"), "x") as f: |
| 72 | + f.write( |
| 73 | + json.dumps( |
| 74 | + { |
| 75 | + "linux-x32": {">3000": ["coverage"]}, |
| 76 | + "linux-x64": {">3000": ["coverage"]}, |
| 77 | + "osx-x32": {">3000": ["coverage"]}, |
| 78 | + "osx-x64": {">3000": ["coverage"]}, |
| 79 | + "windows-x32": {">3000": ["coverage"]}, |
| 80 | + "windows-x64": {">3000": ["coverage"]}, |
| 81 | + } |
76 | 82 | )
|
77 |
| - except FileExistsError: |
78 |
| - pass |
| 83 | + ) |
| 84 | + except FileExistsError: |
| 85 | + pass |
79 | 86 |
|
80 |
| - try: |
81 |
| - # hide from Package Control quick panels |
82 |
| - open(os.path.join(UT33, ".hidden-sublime-package"), "x").close() |
83 |
| - except FileExistsError: |
84 |
| - pass |
| 87 | + try: |
| 88 | + # hide from Package Control quick panels |
| 89 | + open(os.path.join(UT33, ".hidden-sublime-package"), "x").close() |
| 90 | + except FileExistsError: |
| 91 | + pass |
85 | 92 |
|
86 |
| - except OSError as e: |
87 |
| - print("UnitTesting: Error while creating python 3.3 module, since", str(e)) |
| 93 | + except OSError as e: |
| 94 | + print("UnitTesting: Error while creating python 3.3 module, since", str(e)) |
88 | 95 |
|
89 | 96 |
|
90 | 97 | def plugin_unloaded():
|
91 | 98 | if sys.version_info >= (3, 8):
|
92 | 99 | UT33 = os.path.join(sublime.packages_path(), "UnitTesting33")
|
93 | 100 | try:
|
94 | 101 | shutil.rmtree(UT33)
|
95 |
| - except Exception: |
| 102 | + except OSError: |
96 | 103 | pass
|
0 commit comments