Skip to content

Commit

Permalink
Version 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek's Macbook Pro authored and Abhishek's Macbook Pro committed May 11, 2024
1 parent 480f183 commit d0453d5
Show file tree
Hide file tree
Showing 23 changed files with 1,482 additions and 14 deletions.
Binary file added assets/beaker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/debug-start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions assets/run_test_annotation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<html>
<body id='pyrock-run-test'>
<style>

* {
margin: 0;
padding: 0;
}
body {
/* display: inline; */
}
.ref-link {
display: inline-block;
text-decoration: none;
position: relative;
/* margin: auto 0; */
}
.run-test-icon {
position: relative;
width: 1rem;
height: 1rem;
top: 10%;
}
.run-test-label {
display: inline-block;
}

</style>

<a href='$run_test_region_index' class='ref-link'>
<img src='file://$image_file' class='run-test-icon'>
<p class='run-test-label'>Run as test</p>
</a>
</body>
</html>
86 changes: 86 additions & 0 deletions assets/test_output.sublime-syntax
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
%YAML 1.2
---
name: PyRock Test Result
scope: text.test-result
hidden: true
contexts:
main:
- match: 'cd'
captures:
1: support.command.shell
scope: source.shell

# verbosity <= 1
- match: '(?=^[\\.sEF]+$)'
push:
- match: $
pop: true
- match: s
scope: markup.changed
- match: E|F
scope: markup.deleted

# verbosity >= 2
- match: .+(\.\.\.)
captures:
1: markup.ignored
push:
- match: $
pop: true
- match: ok
scope: markup.inserted
- match: ERROR|FAIL
scope: markup.deleted
- match: "skipped.*"
scope: markup.changed

- match: ^OK.*
scope: markup.inserted

- match: ^FAILED.*
scope: markup.deleted

- match: '======================================================================'
scope: markup.ignored
push:
- match: '----------------------------------------------------------------------'
scope: markup.ignored
pop: true
- match: ^ERROR|FAIL
scope: markup.deleted

- match: ^----------------------------------------------------------------------$
scope: markup.ignored

- include: scope:source.diff

- match: 'File "(.*)"(?:, line ([0-9]+)(?:, in (.*))?)?'
captures:
1: markup.underline.link
2: constant.numeric
3: entity.name

- match: 'Running Command:'
scope: markup.heading

# New patterns for datetime and logger level
- match: '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}'
scope: markup.changed

- match: 'INFO|DEBUG|WARN|WARNING|ERROR|CRITICAL'
scope: keyword.control.logger-level

# New patterns for Python errors
- match: 'Traceback \(most recent call last\):'
scope: keyword.control.python-error
push:
- match: 'File "(.*)"(?:, line ([0-9]+)(?:, in (.*))?)?'
captures:
1: markup.underline.link
2: constant.numeric
3: entity.name
- match: '^([^:]+): (.+)$'
captures:
1: variable.language.python
2: string.quoted.single.python
scope: keyword.control.python-error
58 changes: 58 additions & 0 deletions assets/test_output_color_scheme.tmTheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Custom Theme</string>
<key>settings</key>
<array>
<!-- Background color -->
<dict>
<key>settings</key>
<dict>
<key>background</key>
<string>#000000</string>
<key>foreground</key>
<string>#FFFFFF</string>
</dict>
</dict>

<!-- Datetime color -->
<dict>
<key>name</key>
<string>Constant - Datetime</string>
<key>scope</key>
<string>constant.other.datetime</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#FF0000</string> <!-- Adjust the color here -->
</dict>
</dict>
<dict>
<key>name</key>
<string>Constant - Logger Level</string>
<key>scope</key>
<string>keyword.control.logger-level</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#FF0000</string> <!-- Adjust the color here -->
</dict>
</dict>
<dict>
<key>name</key>
<string>Constant - Python Error</string>
<key>scope</key>
<string>keyword.control.python-error</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#FF0000</string> <!-- Adjust the color here -->
<key>underline</key>
<true/>
</dict>
</dict>
</array>
</dict>
</plist>
1 change: 1 addition & 0 deletions package-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"sublime_text": ">=3000", "description": "Sublime plugin to generate python import statements", "platforms": ["*"], "version": "1.1.0", "url": "https://github.com/abhishek72850/pyrock", "dependencies": []}
41 changes: 39 additions & 2 deletions py_rock.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import importlib
import sublime
import sublime_plugin
from sublime import Edit
from typing import Optional

# Reloads the submodules
# import importlib
# from .src import reloader
# importlib.reload(reloader)
# reloader.reload()
Expand All @@ -15,16 +15,23 @@
from .src.commands.admin import AdminManager
from .src.logger import Logger
from .src.constants import PyRockConstants
from .src.commands.copy_test_path import CopyTestPathCommand
from .src.commands.annotate_and_test_runner import AnnotateAndTestRunnerCommand


logger = Logger(__name__)
admin = AdminManager(window=sublime.active_window())
test_runner_cmd = AnnotateAndTestRunnerCommand()


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

settings = sublime.load_settings(PyRockConstants.PACKAGE_SETTING_NAME)
logger.debug(f"[{PyRockConstants.PACKAGE_NAME}] Settings: {settings}")

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

Expand All @@ -44,9 +51,25 @@ def run(self, edit: Edit, action: str, test: bool = False):
test=test,
)
cmd.run()
if action == "re_index_imports":
elif action == "copy_import_symbol":
cmd = ImportSymbolCommand(
window=sublime.active_window(),
edit=edit,
view=self.view,
test=test,
)
cmd.run(copy=True)
elif action == "re_index_imports":
cmd = ReIndexImportsCommand(test=test)
cmd.run(sublime.active_window())
elif action == "copy_test_path":
cmd = CopyTestPathCommand(
view=self.view,
test=test,
)
cmd.run()
else:
logger.debug("Inavlid command recieved")

def is_enabled(self, action: str, test: bool = False):
"""
Expand Down Expand Up @@ -92,3 +115,17 @@ def run(self, edit: Edit, start: int, end: int, text: str):
"""
region = sublime.Region(start, end)
self.view.replace(edit, region, text)


class PyRockAnnotateAndTestRunnerCommand(sublime_plugin.ViewEventListener):
def on_load_async(self):
logger.debug("View loaded")
test_runner_cmd.run(self.view)

def on_activated_async(self):
logger.debug("View reloaded")
test_runner_cmd.run(self.view)

def on_post_save_async(self):
logger.debug("View saved")
test_runner_cmd.run(self.view)
Loading

0 comments on commit d0453d5

Please sign in to comment.