dbrownell-parserlib 0.1.0__tar.gz → 0.2.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.
- {dbrownell_parserlib-0.1.0 → dbrownell_parserlib-0.2.0}/PKG-INFO +1 -1
- {dbrownell_parserlib-0.1.0 → dbrownell_parserlib-0.2.0}/pyproject.toml +2 -1
- dbrownell_parserlib-0.2.0/src/dbrownell_ParserLib/__init__.py +15 -0
- dbrownell_parserlib-0.2.0/src/dbrownell_ParserLib/location.py +74 -0
- dbrownell_parserlib-0.1.0/src/dbrownell_ParserLib/UvScaffolding_sample_file.py +0 -11
- dbrownell_parserlib-0.1.0/src/dbrownell_ParserLib/__init__.py +0 -6
- {dbrownell_parserlib-0.1.0 → dbrownell_parserlib-0.2.0}/README.md +0 -0
- {dbrownell_parserlib-0.1.0 → dbrownell_parserlib-0.2.0}/src/dbrownell_ParserLib/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "dbrownell-parserlib"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.2.0"
|
|
4
4
|
# ^^^^^
|
|
5
5
|
# Wheel names will be generated according to this value. Do not manually modify this value; instead
|
|
6
6
|
# update it according to committed changes by running this command from the root of the repository:
|
|
@@ -47,6 +47,7 @@ dev = [
|
|
|
47
47
|
|
|
48
48
|
[tool.pytest.ini_options]
|
|
49
49
|
addopts = "--verbose -vv --capture=no --cov=dbrownell_ParserLib --cov-report html --cov-report term --cov-report xml:coverage.xml --cov-fail-under=95.0"
|
|
50
|
+
python_files = ["tests/*Tests.py"]
|
|
50
51
|
|
|
51
52
|
[tool.ruff]
|
|
52
53
|
line-length = 110
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# noqa: D104
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import version
|
|
4
|
+
|
|
5
|
+
from dbrownell_ParserLib.location import Location
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# ----------------------------------------------------------------------
|
|
9
|
+
__all__ = [
|
|
10
|
+
"Location",
|
|
11
|
+
"__version__",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
__version__ = version("dbrownell_ParserLib")
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# noqa: D100
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from functools import cached_property
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# ----------------------------------------------------------------------
|
|
7
|
+
@dataclass(frozen=True)
|
|
8
|
+
class Location:
|
|
9
|
+
"""Location within a source file."""
|
|
10
|
+
|
|
11
|
+
# ----------------------------------------------------------------------
|
|
12
|
+
line: int
|
|
13
|
+
column: int
|
|
14
|
+
|
|
15
|
+
# ----------------------------------------------------------------------
|
|
16
|
+
def __post_init__(self) -> None:
|
|
17
|
+
if self.line < 1:
|
|
18
|
+
msg = "Invalid line"
|
|
19
|
+
raise ValueError(msg)
|
|
20
|
+
|
|
21
|
+
if self.column < 1:
|
|
22
|
+
msg = "Invalid column"
|
|
23
|
+
raise ValueError(msg)
|
|
24
|
+
|
|
25
|
+
# ----------------------------------------------------------------------
|
|
26
|
+
def __str__(self) -> str:
|
|
27
|
+
return self._string
|
|
28
|
+
|
|
29
|
+
# ----------------------------------------------------------------------
|
|
30
|
+
@staticmethod
|
|
31
|
+
def Compare(
|
|
32
|
+
this: Location,
|
|
33
|
+
that: Location,
|
|
34
|
+
) -> int:
|
|
35
|
+
"""Compare two `Location` objects."""
|
|
36
|
+
|
|
37
|
+
result = this.line - that.line
|
|
38
|
+
if result != 0:
|
|
39
|
+
return result
|
|
40
|
+
|
|
41
|
+
result = this.column - that.column
|
|
42
|
+
if result != 0:
|
|
43
|
+
return result
|
|
44
|
+
|
|
45
|
+
return 0
|
|
46
|
+
|
|
47
|
+
# ----------------------------------------------------------------------
|
|
48
|
+
def __hash__(self) -> int:
|
|
49
|
+
return hash((self.line, self.column))
|
|
50
|
+
|
|
51
|
+
def __eq__(self, other: object) -> bool:
|
|
52
|
+
return isinstance(other, Location) and self.__class__.Compare(self, other) == 0
|
|
53
|
+
|
|
54
|
+
def __ne__(self, other: object) -> bool:
|
|
55
|
+
return not isinstance(other, Location) or self.__class__.Compare(self, other) != 0
|
|
56
|
+
|
|
57
|
+
def __lt__(self, other: object) -> bool:
|
|
58
|
+
return isinstance(other, Location) and self.__class__.Compare(self, other) < 0
|
|
59
|
+
|
|
60
|
+
def __le__(self, other: object) -> bool:
|
|
61
|
+
return isinstance(other, Location) and self.__class__.Compare(self, other) <= 0
|
|
62
|
+
|
|
63
|
+
def __gt__(self, other: object) -> bool:
|
|
64
|
+
return isinstance(other, Location) and self.__class__.Compare(self, other) > 0
|
|
65
|
+
|
|
66
|
+
def __ge__(self, other: object) -> bool:
|
|
67
|
+
return isinstance(other, Location) and self.__class__.Compare(self, other) >= 0
|
|
68
|
+
|
|
69
|
+
# ----------------------------------------------------------------------
|
|
70
|
+
# ----------------------------------------------------------------------
|
|
71
|
+
# ----------------------------------------------------------------------
|
|
72
|
+
@cached_property
|
|
73
|
+
def _string(self) -> str:
|
|
74
|
+
return f"Ln {self.line} Col {self.column}"
|
|
File without changes
|
|
File without changes
|