|
1 |
| -import importlib |
2 |
| - |
3 | 1 | import sublime
|
4 | 2 |
|
5 |
| -from docblockr_python.formatters.registry import registry |
| 3 | +from docblockr_python.formatters.registry import populate_registry |
6 | 4 |
|
7 | 5 | plugin_is_loaded = False
|
8 | 6 |
|
9 |
| -def get_formatter(formatter): |
10 |
| - try: |
11 |
| - temp = importlib.import_module('docblockr_python.formatters.{}'.format(formatter)) |
12 |
| - Formatter = getattr(temp, '{}Formatter'.format(formatter.capitalize())) |
13 |
| - return Formatter |
14 |
| - except ImportError as exception: |
15 |
| - print(exception) |
16 |
| - except AttributeError as exception: |
17 |
| - raise ValueError('Formatter {} doesn\'t exist'.format(formatter)) from exception |
18 |
| - |
19 |
| - |
20 |
| -def get_setting(key, default=None): |
21 |
| - """Gets the passed setting from the aggregated settings files. |
22 |
| -
|
23 |
| - Merges up settings as specified in Sublime's docs. |
24 |
| - https://www.sublimetext.com/docs/3/settings.html |
25 |
| -
|
26 |
| - Arguments: |
27 |
| - key {str} -- String of the key to get |
28 |
| -
|
29 |
| - Keyword Arguments: |
30 |
| - default {str} -- default value in case the setting is not found (default: None) |
31 |
| -
|
32 |
| - Returns: |
33 |
| - {str} or {None} -- value of the setting |
34 |
| - """ |
35 |
| - settings = sublime.load_settings('DocblockrPython.sublime-settings') |
36 |
| - os_specific_settings = {} |
37 |
| - |
38 |
| - os_name = sublime.platform() |
39 |
| - if os_name == 'osx': |
40 |
| - os_specific_settings = sublime.load_settings('DocblockrPython (OSX).sublime-settings') |
41 |
| - elif os_name == 'windows': |
42 |
| - os_specific_settings = sublime.load_settings('DocblockrPython (Windows).sublime-settings') |
43 |
| - else: |
44 |
| - os_specific_settings = sublime.load_settings('DocblockrPython (Linux).sublime-settings') |
45 |
| - |
46 |
| - return os_specific_settings.get(key, settings.get(key, default)) |
47 |
| - |
48 | 7 |
|
49 | 8 | def plugin_loaded():
|
50 |
| - """The ST3 entry point for plugins.""" |
| 9 | + """The Sublime Text 3 entry point for plugins.""" |
| 10 | + populate_registry() |
| 11 | + |
51 | 12 | global plugin_is_loaded
|
52 | 13 | plugin_is_loaded = True
|
53 | 14 |
|
|
0 commit comments