textmate-grammar-python 0.3.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/PKG-INFO +4 -18
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/README.md +0 -16
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/pyproject.toml +3 -3
- textmate_grammar_python-0.4.0/src/textmate_grammar/__init__.py +1 -0
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/elements.py +3 -0
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/grammars/markdown/__init__.py +2 -0
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/grammars/matlab/__init__.py +2 -0
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/language.py +2 -0
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/utils/cache.py +10 -7
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/utils/exceptions.py +3 -0
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/utils/handler.py +2 -0
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/utils/logger.py +5 -3
- textmate_grammar_python-0.3.0/src/textmate_grammar/__init__.py +0 -1
- textmate_grammar_python-0.3.0/src/textmate_grammar/grammars/__pycache__/__init__.cpython-312.pyc +0 -0
- textmate_grammar_python-0.3.0/src/textmate_grammar/grammars/markdown/__pycache__/__init__.cpython-312.pyc +0 -0
- textmate_grammar_python-0.3.0/src/textmate_grammar/grammars/matlab/__pycache__/__init__.cpython-312.pyc +0 -0
- textmate_grammar_python-0.3.0/src/textmate_grammar/utils/__pycache__/__init__.cpython-312.pyc +0 -0
- textmate_grammar_python-0.3.0/src/textmate_grammar/utils/__pycache__/cache.cpython-312.pyc +0 -0
- textmate_grammar_python-0.3.0/src/textmate_grammar/utils/__pycache__/exceptions.cpython-312.pyc +0 -0
- textmate_grammar_python-0.3.0/src/textmate_grammar/utils/__pycache__/handler.cpython-312.pyc +0 -0
- textmate_grammar_python-0.3.0/src/textmate_grammar/utils/__pycache__/logger.cpython-312.pyc +0 -0
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/LICENSE +0 -0
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/grammars/__init__.py +0 -0
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/grammars/markdown/LICENSE.txt +0 -0
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/grammars/markdown/grammar.yaml +0 -0
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/grammars/matlab/grammar.yaml +0 -0
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/grammars/matlab/license.txt +0 -0
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/parser.py +0 -0
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/py.typed +0 -0
- {textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/utils/__init__.py +0 -0
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: textmate-grammar-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: A lexer and tokenizer for grammar files as defined by TextMate and used in VSCode, implemented in Python.
|
|
5
5
|
Home-page: https://github.com/watermarkhu/textmate-grammar-python
|
|
6
6
|
License: MIT
|
|
7
7
|
Keywords: textmate,tokenization
|
|
8
8
|
Author: Mark Shui Hu
|
|
9
9
|
Author-email: watermarkhu@gmail.com
|
|
10
|
-
Requires-Python: >=3.
|
|
10
|
+
Requires-Python: >=3.9,<4.0
|
|
11
11
|
Classifier: License :: OSI Approved :: MIT License
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
17
|
Requires-Dist: PyYAML (>=6.0.1,<7.0.0)
|
|
@@ -33,22 +35,6 @@ A lexer and tokenizer for grammar files as defined by TextMate and used in VSCod
|
|
|
33
35
|
|
|
34
36
|
Textmate grammars are made for [vscode-texmate](https://github.com/microsoft/vscode-textmate), allowing for syntax highlighting in VSCode after tokenization. This presents textmate-grammar-python with a large list of potentially supported languages.
|
|
35
37
|
|
|
36
|
-
```mermaid
|
|
37
|
-
flowchart TD
|
|
38
|
-
A[grammar file]
|
|
39
|
-
Z[code]
|
|
40
|
-
B("`vscode-textmate **js**`")
|
|
41
|
-
C("`textmate-grammar-**python**`")
|
|
42
|
-
D[tokens]
|
|
43
|
-
|
|
44
|
-
click C "https://github.com/microsoft/vscode-textmate"
|
|
45
|
-
|
|
46
|
-
Z --> B
|
|
47
|
-
Z --> C
|
|
48
|
-
A -.-> B --> D
|
|
49
|
-
A -.-> C --> D
|
|
50
|
-
```
|
|
51
|
-
|
|
52
38
|
## Usage
|
|
53
39
|
Install the module with:
|
|
54
40
|
```bash
|
|
@@ -13,22 +13,6 @@ A lexer and tokenizer for grammar files as defined by TextMate and used in VSCod
|
|
|
13
13
|
|
|
14
14
|
Textmate grammars are made for [vscode-texmate](https://github.com/microsoft/vscode-textmate), allowing for syntax highlighting in VSCode after tokenization. This presents textmate-grammar-python with a large list of potentially supported languages.
|
|
15
15
|
|
|
16
|
-
```mermaid
|
|
17
|
-
flowchart TD
|
|
18
|
-
A[grammar file]
|
|
19
|
-
Z[code]
|
|
20
|
-
B("`vscode-textmate **js**`")
|
|
21
|
-
C("`textmate-grammar-**python**`")
|
|
22
|
-
D[tokens]
|
|
23
|
-
|
|
24
|
-
click C "https://github.com/microsoft/vscode-textmate"
|
|
25
|
-
|
|
26
|
-
Z --> B
|
|
27
|
-
Z --> C
|
|
28
|
-
A -.-> B --> D
|
|
29
|
-
A -.-> C --> D
|
|
30
|
-
```
|
|
31
|
-
|
|
32
16
|
## Usage
|
|
33
17
|
Install the module with:
|
|
34
18
|
```bash
|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "textmate-grammar-python"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.0"
|
|
8
8
|
description = "A lexer and tokenizer for grammar files as defined by TextMate and used in VSCode, implemented in Python."
|
|
9
9
|
authors = ["Mark Shui Hu <watermarkhu@gmail.com>"]
|
|
10
10
|
license = "MIT"
|
|
@@ -15,7 +15,7 @@ keywords = ["textmate", "tokenization"]
|
|
|
15
15
|
packages = [{include = "textmate_grammar", from = "src"}]
|
|
16
16
|
|
|
17
17
|
[tool.poetry.dependencies]
|
|
18
|
-
python = "^3.
|
|
18
|
+
python = "^3.9"
|
|
19
19
|
onigurumacffi = "^1.3.0"
|
|
20
20
|
PyYAML = "^6.0.1"
|
|
21
21
|
|
|
@@ -80,7 +80,7 @@ legacy_tox_ini = """
|
|
|
80
80
|
[testenv:mypy]
|
|
81
81
|
skip_install = true
|
|
82
82
|
allowlist_externals = mypy
|
|
83
|
-
commands =
|
|
83
|
+
commands =
|
|
84
84
|
mypy .
|
|
85
85
|
|
|
86
86
|
[testenv:regression]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.4.0"
|
{textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/elements.py
RENAMED
|
@@ -130,6 +130,8 @@ def _dispatch_list(
|
|
|
130
130
|
elements.extend(captured_elements)
|
|
131
131
|
elif item != parent:
|
|
132
132
|
elements.append(item)
|
|
133
|
+
for element in elements:
|
|
134
|
+
element.parent = parent
|
|
133
135
|
return elements
|
|
134
136
|
|
|
135
137
|
|
|
@@ -168,6 +170,7 @@ class ContentElement:
|
|
|
168
170
|
self.characters = characters
|
|
169
171
|
self._children_captures = children
|
|
170
172
|
self._dispatched: bool = False
|
|
173
|
+
self.parent: ContentElement | None = None
|
|
171
174
|
|
|
172
175
|
@property
|
|
173
176
|
def _subelements(self) -> list[ContentElement]:
|
{textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/utils/cache.py
RENAMED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import atexit
|
|
2
4
|
from pathlib import Path
|
|
3
5
|
from pickle import UnpicklingError
|
|
@@ -141,10 +143,10 @@ class ShelveCache(TextmateCache):
|
|
|
141
143
|
self._database[key] = (timestamp, element)
|
|
142
144
|
|
|
143
145
|
|
|
144
|
-
CACHE:
|
|
146
|
+
CACHE: TextmateCache = SimpleCache()
|
|
145
147
|
|
|
146
148
|
|
|
147
|
-
def init_cache(type: str = "simple") ->
|
|
149
|
+
def init_cache(type: str = "simple") -> TextmateCache:
|
|
148
150
|
"""
|
|
149
151
|
Initialize the cache based on the given type.
|
|
150
152
|
|
|
@@ -152,9 +154,10 @@ def init_cache(type: str = "simple") -> "TextmateCache":
|
|
|
152
154
|
:return: The initialized cache object.
|
|
153
155
|
"""
|
|
154
156
|
global CACHE
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
if type == "shelve":
|
|
158
|
+
CACHE = ShelveCache()
|
|
159
|
+
elif type == "simple":
|
|
160
|
+
CACHE = SimpleCache()
|
|
161
|
+
else:
|
|
162
|
+
raise NotImplementedError(f"Cache type {type} not implemented.")
|
|
160
163
|
return CACHE
|
{textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/utils/logger.py
RENAMED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import logging
|
|
2
4
|
from functools import wraps
|
|
3
|
-
from typing import TYPE_CHECKING
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
4
6
|
|
|
5
7
|
if TYPE_CHECKING:
|
|
6
8
|
from ..parser import GrammarParser
|
|
@@ -70,7 +72,7 @@ class Logger:
|
|
|
70
72
|
channel.setFormatter(LogFormatter())
|
|
71
73
|
self.logger.addHandler(channel)
|
|
72
74
|
|
|
73
|
-
def configure(self, parser:
|
|
75
|
+
def configure(self, parser: GrammarParser, height: int, width: int, **kwargs) -> None:
|
|
74
76
|
"""Configures the logger to a specific grammar and content length"""
|
|
75
77
|
self.line_decimals = len(str(height))
|
|
76
78
|
self.position_decimals = len(str(width))
|
|
@@ -84,7 +86,7 @@ class Logger:
|
|
|
84
86
|
def format_message(
|
|
85
87
|
self,
|
|
86
88
|
message: str,
|
|
87
|
-
parser:
|
|
89
|
+
parser: GrammarParser | None = None,
|
|
88
90
|
position: tuple[int, int] | None = None,
|
|
89
91
|
depth: int = 0,
|
|
90
92
|
) -> str:
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.3.0"
|
textmate_grammar_python-0.3.0/src/textmate_grammar/grammars/__pycache__/__init__.cpython-312.pyc
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
textmate_grammar_python-0.3.0/src/textmate_grammar/utils/__pycache__/__init__.cpython-312.pyc
DELETED
|
Binary file
|
|
Binary file
|
textmate_grammar_python-0.3.0/src/textmate_grammar/utils/__pycache__/exceptions.cpython-312.pyc
DELETED
|
Binary file
|
textmate_grammar_python-0.3.0/src/textmate_grammar/utils/__pycache__/handler.cpython-312.pyc
DELETED
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/parser.py
RENAMED
|
File without changes
|
{textmate_grammar_python-0.3.0 → textmate_grammar_python-0.4.0}/src/textmate_grammar/py.typed
RENAMED
|
File without changes
|
|
File without changes
|