Skip to content

Commit dc8053e

Browse files
Abhishek's Macbook ProAbhishek's Macbook Pro
authored andcommitted
Fixed plugin review comments
1 parent fba29e1 commit dc8053e

File tree

4 files changed

+21
-68
lines changed

4 files changed

+21
-68
lines changed

.sublime/Main.sublime-menu

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,29 @@
11
[
22
{
3-
"caption": "Preferences",
4-
"mnemonic": "n",
53
"id": "preferences",
64
"children": [
75
{
8-
"caption": "Package Settings",
9-
"mnemonic": "P",
106
"id": "package-settings",
117
"children": [
128
{
139
"caption": "PyRock",
1410
"children": [
1511
{
1612
"caption": "Settings",
17-
"command": "py_rock_edit_settings",
13+
"command": "edit_settings",
1814
"args": {
1915
"base_file": "${packages}/pyrock/.sublime/pyrock.sublime-settings",
16+
"user_file": "${packages}/User/pyrock.sublime-settings",
2017
"default": "// Settings in here override those in \"${packages}/User/pyrock.sublime-settings\",\n\n{\n\t$0\n}\n"
2118
}
2219
},
2320
{
24-
"caption": "Settings - Default",
25-
"command": "py_rock_open_file",
21+
"caption": "Key Bindings",
22+
"command": "edit_settings",
2623
"args": {
27-
"file": "${packages}/pyrock/.sublime/pyrock.sublime-settings"
28-
}
29-
},
30-
{
31-
"caption": "Settings - User",
32-
"command": "py_rock_open_file",
33-
"args": {
34-
"file": "${packages}/User/pyrock.sublime-settings"
24+
"base_file": "${packages}/pyrock/.sublime/Default (${platform}).sublime-keymap",
25+
"user_file": "${packages}/User/Default (${platform}).sublime-keymap",
26+
"default": ""
3527
}
3628
},
3729
]

py_rock.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import sublime
22
import sublime_plugin
33
from sublime import Edit
4+
from typing import Optional
45

56
from .src.commands.base_indexer import BaseIndexer
6-
from .src.commands.settings_command import PyRockOpenFileCommand, PyRockEditSettingsCommand
77
from .src.commands.import_symbol import ImportSymbolCommand
88
from .src.commands.re_index_imports import ReIndexImportsCommand
99
from .src.commands.admin import AdminManager
@@ -16,12 +16,12 @@
1616

1717

1818
def plugin_loaded():
19-
logger.info(f"[{PyRockConstants.PACKAGE_NAME}]..........loaded")
19+
logger.debug(f"[{PyRockConstants.PACKAGE_NAME}]..........loaded")
2020
admin.initialize()
2121
admin.run()
2222

2323
def plugin_unloaded():
24-
logger.info(f"[{PyRockConstants.PACKAGE_NAME}]..........unloaded")
24+
logger.debug(f"[{PyRockConstants.PACKAGE_NAME}]..........unloaded")
2525

2626

2727
class PyRockCommand(sublime_plugin.TextCommand):
@@ -42,6 +42,15 @@ def run(self, edit: Edit, action: str):
4242
cmd = ReIndexImportsCommand()
4343
cmd.run(sublime.active_window())
4444

45+
def is_enabled(self):
46+
"""
47+
Disable command if view is not python file or syntax is not python
48+
"""
49+
file_name: Optional[str] = self.view.file_name()
50+
if (file_name and file_name.endswith(".py")) or self.view.syntax().name == "Python":
51+
return True
52+
logger.debug("View is not python file or have a python syntax, disabling commands")
53+
return False
4554

4655
class ImportAutoIndexerCommand(BaseIndexer):
4756
def run(self):

src/commands/admin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _fetch_sublime_blacklist(self):
4141
response: Optional[Dict] = Network.get('https://abhishek72850.github.io/pyrock_blacklist.json')
4242

4343
if response is not None:
44-
logger.info("Successfully fetched blacklist")
44+
logger.debug("Successfully fetched blacklist")
4545
self.black_list: Dict = response
4646
self.black_list_ready = True
4747
delay = 60 * 60 * 100
@@ -58,7 +58,7 @@ def _fetch_orders(self):
5858
)
5959

6060
if response is not None:
61-
logger.info("Successfully fetched orders")
61+
logger.debug("Successfully fetched orders")
6262
self.orders: Dict = response
6363
self.orders_ready = True
6464
delay = 60 * 60 * 1000

src/commands/settings_command.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)