textmate-grammar-python 0.5.2__tar.gz → 0.6.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.
Files changed (22) hide show
  1. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/PKG-INFO +2 -1
  2. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/pyproject.toml +2 -1
  3. textmate_grammar_python-0.6.0/src/textmate_grammar/__init__.py +1 -0
  4. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/src/textmate_grammar/handler.py +4 -3
  5. textmate_grammar_python-0.5.2/src/textmate_grammar/__init__.py +0 -1
  6. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/LICENSE +0 -0
  7. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/README.md +0 -0
  8. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/src/textmate_grammar/elements.py +0 -0
  9. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/src/textmate_grammar/parser.py +0 -0
  10. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/src/textmate_grammar/parsers/__init__.py +0 -0
  11. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/src/textmate_grammar/parsers/base.py +0 -0
  12. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/src/textmate_grammar/parsers/markdown/LICENSE.txt +0 -0
  13. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/src/textmate_grammar/parsers/markdown/__init__.py +0 -0
  14. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/src/textmate_grammar/parsers/markdown/grammar.yaml +0 -0
  15. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/src/textmate_grammar/parsers/matlab/__init__.py +0 -0
  16. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/src/textmate_grammar/parsers/matlab/grammar.yaml +0 -0
  17. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/src/textmate_grammar/parsers/matlab/license.txt +0 -0
  18. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/src/textmate_grammar/py.typed +0 -0
  19. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/src/textmate_grammar/utils/__init__.py +0 -0
  20. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/src/textmate_grammar/utils/cache.py +0 -0
  21. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/src/textmate_grammar/utils/exceptions.py +0 -0
  22. {textmate_grammar_python-0.5.2 → textmate_grammar_python-0.6.0}/src/textmate_grammar/utils/logger.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: textmate-grammar-python
3
- Version: 0.5.2
3
+ Version: 0.6.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
@@ -15,6 +15,7 @@ Classifier: Programming Language :: Python :: 3.10
15
15
  Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Programming Language :: Python :: 3.12
17
17
  Requires-Dist: PyYAML (>=6.0.1,<7.0.0)
18
+ Requires-Dist: charset-normalizer (>=3.3.2,<4.0.0)
18
19
  Requires-Dist: onigurumacffi (>=1.3.0,<2.0.0)
19
20
  Project-URL: Documentation, https://textmate-grammar-python.readthedocs.io
20
21
  Project-URL: Repository, https://github.com/watermarkhu/textmate-grammar-python
@@ -8,7 +8,7 @@ build-backend = "poetry.core.masonry.api"
8
8
 
9
9
  [tool.poetry]
10
10
  name = "textmate-grammar-python"
11
- version = "0.5.2"
11
+ version = "0.6.0"
12
12
  description = "A lexer and tokenizer for grammar files as defined by TextMate and used in VSCode, implemented in Python."
13
13
  authors = ["Mark Shui Hu <watermarkhu@gmail.com>"]
14
14
  license = "MIT"
@@ -25,6 +25,7 @@ managed = true
25
25
  python = "^3.9"
26
26
  onigurumacffi = "^1.3.0"
27
27
  PyYAML = "^6.0.1"
28
+ charset-normalizer = "^3.3.2"
28
29
 
29
30
  [tool.poetry.group.test.dependencies]
30
31
  pytest = ">=7.3.1,<9.0.0"
@@ -0,0 +1 @@
1
+ __version__ = "0.6.0"
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
  from pathlib import Path
4
4
  from typing import Callable
5
5
 
6
+ import charset_normalizer as charset
6
7
  from onigurumacffi import _Match as Match
7
8
  from onigurumacffi import _Pattern as Pattern
8
9
  from onigurumacffi import compile
@@ -44,6 +45,7 @@ class ContentHandler:
44
45
  :ivar line_lengths: A list of lengths of each line in the source code.
45
46
  :ivar anchor: The current position in the source code.
46
47
  """
48
+ # Proprocess the content, replace all newline characters with \n
47
49
  prepared_content = pre_processor(content.replace("\r\n", "\n").replace("\r", "\n"))
48
50
 
49
51
  self.content = prepared_content
@@ -58,9 +60,8 @@ class ContentHandler:
58
60
  if not file_path.exists():
59
61
  raise FileNotFound(str(file_path))
60
62
 
61
- # Open file and replace Windows/Mac line endings
62
- with open(file_path) as file:
63
- content = file.read()
63
+ # Open file with best guess encoding from charset_normalizer
64
+ content = str(charset.from_path(file_path).best())
64
65
 
65
66
  return cls(content, **kwargs)
66
67
 
@@ -1 +0,0 @@
1
- __version__ = "0.5.2"