textmate-grammar-python 0.5.2__py3-none-any.whl → 0.6.0__py3-none-any.whl

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.
@@ -1 +1 @@
1
- __version__ = "0.5.2"
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,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
@@ -1,6 +1,6 @@
1
- textmate_grammar/__init__.py,sha256=isJrmDBLRag7Zc2UK9ZovWGOv7ji1Oh-zJtJMNJFkXw,22
1
+ textmate_grammar/__init__.py,sha256=cID1jLnC_vj48GgMN6Yb1FA3JsQ95zNmCHmRYE8TFhY,22
2
2
  textmate_grammar/elements.py,sha256=HL591LujcK1M8F5VAR8_tDnHboYnfISIBvnOitEFG3g,20035
3
- textmate_grammar/handler.py,sha256=WhWSn-mFF3LUl679uAHTbgAeaFCwr5BRMKZ8Xa5MmXM,12051
3
+ textmate_grammar/handler.py,sha256=1Si9Bcv-w04FWPsvrDe8W0DZ0aNQVXJ76f2J66F_vIU,12160
4
4
  textmate_grammar/parser.py,sha256=jSibbq9JxRoma_L0v-6MrfwmZNP6xNJa3P6TNwXFpAw,35912
5
5
  textmate_grammar/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  textmate_grammar/parsers/base.py,sha256=hKqmFsfth6D-M3Syv50DWfwaPYX-luVc5FYTKugRbFg,6930
@@ -15,7 +15,7 @@ textmate_grammar/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
15
15
  textmate_grammar/utils/cache.py,sha256=Rh93Dvd83VUxuVk1Wu1aQff0QnjbcJTVxVMYtxuwUn0,5107
16
16
  textmate_grammar/utils/exceptions.py,sha256=4xhmXRYAWZ76zrvEKYcn4duAInl8mN5ib_4b9wCdnD8,2133
17
17
  textmate_grammar/utils/logger.py,sha256=KC0pwjGLHmMp5-9NXBZBGJdQXlW8VzlZQZGrakFlNPs,5673
18
- textmate_grammar_python-0.5.2.dist-info/LICENSE,sha256=z_od-h3J1gcHgjNlVmcr6pGweBAkZUxQTzbrTK1GMhI,1069
19
- textmate_grammar_python-0.5.2.dist-info/METADATA,sha256=K-nhgfuo219B6Z-SHExbuu_gIYnAYuCJMxsL0TOc_0M,5990
20
- textmate_grammar_python-0.5.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
21
- textmate_grammar_python-0.5.2.dist-info/RECORD,,
18
+ textmate_grammar_python-0.6.0.dist-info/LICENSE,sha256=z_od-h3J1gcHgjNlVmcr6pGweBAkZUxQTzbrTK1GMhI,1069
19
+ textmate_grammar_python-0.6.0.dist-info/METADATA,sha256=DsOtxReSJwoKYj1d2c6eHI-k6zvhgSm2e1OfLQ3TveE,6041
20
+ textmate_grammar_python-0.6.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
21
+ textmate_grammar_python-0.6.0.dist-info/RECORD,,