QuickGotoAnythingOpenFileCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
dl 0
loc 25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A is_visible() 0 4 1
A run() 0 14 1
1
# coding=utf-8
2
import sublime
3
import sublime_plugin
4
5
STVER = int(sublime.version())
6
ST3 = STVER >= 3000
7
8
9
class QuickGotoAnythingOpenFileCommand(sublime_plugin.ApplicationCommand):
10
    """This is a wrapper class for SublimeText's `open_file` command.
11
12
    The task is to hide the command in menu if `edit_settings` is available.
13
    """
14
15
    @staticmethod
16
    def run(file):
17
        """Expand variables and open the resulting file.
18
19
        NOTE: For some unknown reason the `open_file` command doesn't expand
20
              ${platform} when called by `run_command`, so it is expanded here.
21
        """
22
        platform_name = {
23
            'osx': 'OSX',
24
            'windows': 'Windows',
25
            'linux': 'Linux',
26
        }[sublime.platform()]
27
        file = file.replace('${platform}', platform_name)
28
        sublime.run_command('open_file', {'file': file})
29
30
    @staticmethod
31
    def is_visible():
32
        """Return True to to show the command in command pallet and menu."""
33
        return STVER < 3124
34
35
36
class QuickGotoAnythingEditSettingsCommand(sublime_plugin.ApplicationCommand):
37
    """This is a wrapper class for SublimeText's `open_file` command.
38
39
    Hides the command in menu if `edit_settings` is not available.
40
    """
41
42
    @staticmethod
43
    def run(**kwargs):
44
        """Expand variables and open the resulting file."""
45
        sublime.run_command('edit_settings', kwargs)
46
47
    @staticmethod
48
    def is_visible():
49
        """Return True to to show the command in command pallet and menu."""
50
        return STVER >= 3124
51
52