Skip to content

Commit

Permalink
Merge pull request #8 from abhishek72850/patch-102-20230827
Browse files Browse the repository at this point in the history
Fixed plugin review comments
  • Loading branch information
abhishek72850 authored Aug 27, 2023
2 parents fba29e1 + dc8053e commit 9aaac33
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 68 deletions.
22 changes: 7 additions & 15 deletions .sublime/Main.sublime-menu
Original file line number Diff line number Diff line change
@@ -1,37 +1,29 @@
[
{
"caption": "Preferences",
"mnemonic": "n",
"id": "preferences",
"children": [
{
"caption": "Package Settings",
"mnemonic": "P",
"id": "package-settings",
"children": [
{
"caption": "PyRock",
"children": [
{
"caption": "Settings",
"command": "py_rock_edit_settings",
"command": "edit_settings",
"args": {
"base_file": "${packages}/pyrock/.sublime/pyrock.sublime-settings",
"user_file": "${packages}/User/pyrock.sublime-settings",
"default": "// Settings in here override those in \"${packages}/User/pyrock.sublime-settings\",\n\n{\n\t$0\n}\n"
}
},
{
"caption": "Settings - Default",
"command": "py_rock_open_file",
"caption": "Key Bindings",
"command": "edit_settings",
"args": {
"file": "${packages}/pyrock/.sublime/pyrock.sublime-settings"
}
},
{
"caption": "Settings - User",
"command": "py_rock_open_file",
"args": {
"file": "${packages}/User/pyrock.sublime-settings"
"base_file": "${packages}/pyrock/.sublime/Default (${platform}).sublime-keymap",
"user_file": "${packages}/User/Default (${platform}).sublime-keymap",
"default": ""
}
},
]
Expand Down
15 changes: 12 additions & 3 deletions py_rock.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import sublime
import sublime_plugin
from sublime import Edit
from typing import Optional

from .src.commands.base_indexer import BaseIndexer
from .src.commands.settings_command import PyRockOpenFileCommand, PyRockEditSettingsCommand
from .src.commands.import_symbol import ImportSymbolCommand
from .src.commands.re_index_imports import ReIndexImportsCommand
from .src.commands.admin import AdminManager
Expand All @@ -16,12 +16,12 @@


def plugin_loaded():
logger.info(f"[{PyRockConstants.PACKAGE_NAME}]..........loaded")
logger.debug(f"[{PyRockConstants.PACKAGE_NAME}]..........loaded")
admin.initialize()
admin.run()

def plugin_unloaded():
logger.info(f"[{PyRockConstants.PACKAGE_NAME}]..........unloaded")
logger.debug(f"[{PyRockConstants.PACKAGE_NAME}]..........unloaded")


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

def is_enabled(self):
"""
Disable command if view is not python file or syntax is not python
"""
file_name: Optional[str] = self.view.file_name()
if (file_name and file_name.endswith(".py")) or self.view.syntax().name == "Python":
return True
logger.debug("View is not python file or have a python syntax, disabling commands")
return False

class ImportAutoIndexerCommand(BaseIndexer):
def run(self):
Expand Down
4 changes: 2 additions & 2 deletions src/commands/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _fetch_sublime_blacklist(self):
response: Optional[Dict] = Network.get('https://abhishek72850.github.io/pyrock_blacklist.json')

if response is not None:
logger.info("Successfully fetched blacklist")
logger.debug("Successfully fetched blacklist")
self.black_list: Dict = response
self.black_list_ready = True
delay = 60 * 60 * 100
Expand All @@ -58,7 +58,7 @@ def _fetch_orders(self):
)

if response is not None:
logger.info("Successfully fetched orders")
logger.debug("Successfully fetched orders")
self.orders: Dict = response
self.orders_ready = True
delay = 60 * 60 * 1000
Expand Down
48 changes: 0 additions & 48 deletions src/commands/settings_command.py

This file was deleted.

0 comments on commit 9aaac33

Please sign in to comment.