jacobus 2.0.0.dev1__tar.gz → 2.0.2__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.
- jacobus-2.0.2/MANIFEST.in +2 -0
- {jacobus-2.0.0.dev1 → jacobus-2.0.2}/PKG-INFO +1 -1
- jacobus-2.0.2/docs/v1.0.rst +77 -0
- jacobus-2.0.2/docs/v2.0.rst +77 -0
- {jacobus-2.0.0.dev1 → jacobus-2.0.2}/pyproject.toml +1 -1
- {jacobus-2.0.0.dev1 → jacobus-2.0.2}/src/jacobus/core/__init__.py +5 -6
- {jacobus-2.0.0.dev1 → jacobus-2.0.2}/src/jacobus/tests/__init__.py +2 -0
- {jacobus-2.0.0.dev1 → jacobus-2.0.2}/src/jacobus/tests/test_jacobus_unittest.py +22 -5
- {jacobus-2.0.0.dev1 → jacobus-2.0.2}/src/jacobus.egg-info/PKG-INFO +1 -1
- {jacobus-2.0.0.dev1 → jacobus-2.0.2}/src/jacobus.egg-info/SOURCES.txt +2 -0
- jacobus-2.0.0.dev1/MANIFEST.in +0 -1
- {jacobus-2.0.0.dev1 → jacobus-2.0.2}/LICENSE.txt +0 -0
- {jacobus-2.0.0.dev1 → jacobus-2.0.2}/README.rst +0 -0
- {jacobus-2.0.0.dev1 → jacobus-2.0.2}/setup.cfg +0 -0
- {jacobus-2.0.0.dev1 → jacobus-2.0.2}/src/jacobus/__init__.py +0 -0
- {jacobus-2.0.0.dev1 → jacobus-2.0.2}/src/jacobus/__main__.py +0 -0
- {jacobus-2.0.0.dev1 → jacobus-2.0.2}/src/jacobus/py.typed +0 -0
- {jacobus-2.0.0.dev1 → jacobus-2.0.2}/src/jacobus.egg-info/dependency_links.txt +0 -0
- {jacobus-2.0.0.dev1 → jacobus-2.0.2}/src/jacobus.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Overview
|
|
2
|
+
--------
|
|
3
|
+
|
|
4
|
+
This project normalizes whitespace.
|
|
5
|
+
|
|
6
|
+
Installation
|
|
7
|
+
------------
|
|
8
|
+
|
|
9
|
+
To install this project, you can use ``pip``.
|
|
10
|
+
Open your terminal and run:
|
|
11
|
+
|
|
12
|
+
.. code-block:: shell
|
|
13
|
+
|
|
14
|
+
pip install jacobus
|
|
15
|
+
|
|
16
|
+
Typing
|
|
17
|
+
------
|
|
18
|
+
|
|
19
|
+
This project is strictly typed with ``mypy``.
|
|
20
|
+
|
|
21
|
+
Features
|
|
22
|
+
--------
|
|
23
|
+
|
|
24
|
+
``jacobus.core``
|
|
25
|
+
''''''''''''''''
|
|
26
|
+
|
|
27
|
+
The functions in ``jacobus.core`` can also be imported from ``jacobus`` directly.
|
|
28
|
+
|
|
29
|
+
``main(args: Optional[Iterable[str]] = None, /) -> None``
|
|
30
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
31
|
+
|
|
32
|
+
This function is a CLI implementation of ``run``.
|
|
33
|
+
|
|
34
|
+
``run(root: str, /, *, files: Iterable[str] = (), indent: Optional[int] = None) -> None``
|
|
35
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
36
|
+
|
|
37
|
+
This function finds all the files in ``root`` that match one of the patterns of ``files``.
|
|
38
|
+
|
|
39
|
+
Then, it removes unnecessary whitespace.
|
|
40
|
+
|
|
41
|
+
Lastly, if an ``indent`` is given, the previous indentation is corrected.
|
|
42
|
+
|
|
43
|
+
``jacobus.tests``
|
|
44
|
+
'''''''''''''''''
|
|
45
|
+
|
|
46
|
+
``test() -> unittest.TextTestResult``
|
|
47
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
48
|
+
|
|
49
|
+
This project can be tested through its ``test`` function.
|
|
50
|
+
|
|
51
|
+
.. code-block:: python
|
|
52
|
+
|
|
53
|
+
import jacobus.tests
|
|
54
|
+
jacobus.tests.test()
|
|
55
|
+
|
|
56
|
+
License
|
|
57
|
+
-------
|
|
58
|
+
|
|
59
|
+
This project is licensed under the MIT License.
|
|
60
|
+
|
|
61
|
+
Links
|
|
62
|
+
-----
|
|
63
|
+
|
|
64
|
+
- Download: https://pypi.org/project/jacobus/#files
|
|
65
|
+
- Index: https://pypi.org/project/jacobus/
|
|
66
|
+
- Source: https://github.com/johannes-programming/jacobus/
|
|
67
|
+
- Website: https://jacobus.johannes-programming.online/
|
|
68
|
+
|
|
69
|
+
Impressum
|
|
70
|
+
---------
|
|
71
|
+
|
|
72
|
+
**Johannes Programming**
|
|
73
|
+
|
|
74
|
+
- Name: Johannes
|
|
75
|
+
- Email: johannes.programming@gmail.com
|
|
76
|
+
- Homepage: https://www.johannes-programming.online/
|
|
77
|
+
- Gravatar: https://www.johannes-programming.fyi/
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Overview
|
|
2
|
+
--------
|
|
3
|
+
|
|
4
|
+
This project normalizes whitespace.
|
|
5
|
+
|
|
6
|
+
Installation
|
|
7
|
+
------------
|
|
8
|
+
|
|
9
|
+
To install this project, you can use ``pip``.
|
|
10
|
+
Open your terminal and run:
|
|
11
|
+
|
|
12
|
+
.. code-block:: shell
|
|
13
|
+
|
|
14
|
+
pip install jacobus
|
|
15
|
+
|
|
16
|
+
Typing
|
|
17
|
+
------
|
|
18
|
+
|
|
19
|
+
This project is strictly typed with ``mypy``.
|
|
20
|
+
|
|
21
|
+
Features
|
|
22
|
+
--------
|
|
23
|
+
|
|
24
|
+
``jacobus.core``
|
|
25
|
+
''''''''''''''''
|
|
26
|
+
|
|
27
|
+
The functions in ``jacobus.core`` can also be imported from ``jacobus`` directly.
|
|
28
|
+
|
|
29
|
+
``main(args: Optional[Iterable[str]] = None, /) -> None``
|
|
30
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
31
|
+
|
|
32
|
+
This function is a CLI implementation of ``run``.
|
|
33
|
+
|
|
34
|
+
``run(filepatterns: Iterable[str] = (), *, indent: Optional[int] = None) -> None``
|
|
35
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
36
|
+
|
|
37
|
+
This function finds all the files that match one of the ``filepatterns``.
|
|
38
|
+
|
|
39
|
+
Then, it removes unnecessary whitespace.
|
|
40
|
+
|
|
41
|
+
Lastly, if an ``indent`` is given, the previous indentation is corrected.
|
|
42
|
+
|
|
43
|
+
``jacobus.tests``
|
|
44
|
+
'''''''''''''''''
|
|
45
|
+
|
|
46
|
+
``test() -> unittest.TextTestResult``
|
|
47
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
48
|
+
|
|
49
|
+
This project can be tested through its ``test`` function.
|
|
50
|
+
|
|
51
|
+
.. code-block:: python
|
|
52
|
+
|
|
53
|
+
import jacobus.tests
|
|
54
|
+
jacobus.tests.test()
|
|
55
|
+
|
|
56
|
+
License
|
|
57
|
+
-------
|
|
58
|
+
|
|
59
|
+
This project is licensed under the MIT License.
|
|
60
|
+
|
|
61
|
+
Links
|
|
62
|
+
-----
|
|
63
|
+
|
|
64
|
+
- Download: https://pypi.org/project/jacobus/#files
|
|
65
|
+
- Index: https://pypi.org/project/jacobus/
|
|
66
|
+
- Source: https://github.com/johannes-programming/jacobus/
|
|
67
|
+
- Website: https://jacobus.johannes-programming.online/
|
|
68
|
+
|
|
69
|
+
Impressum
|
|
70
|
+
---------
|
|
71
|
+
|
|
72
|
+
**Johannes Programming**
|
|
73
|
+
|
|
74
|
+
- Name: Johannes
|
|
75
|
+
- Email: johannes.programming@gmail.com
|
|
76
|
+
- Homepage: https://www.johannes-programming.online/
|
|
77
|
+
- Gravatar: https://www.johannes-programming.fyi/
|
|
@@ -83,17 +83,16 @@ def run(
|
|
|
83
83
|
stream: io.TextIOWrapper
|
|
84
84
|
absfiles = list()
|
|
85
85
|
for pattern in filepatterns:
|
|
86
|
-
for absfile in map(
|
|
86
|
+
for absfile in map(
|
|
87
|
+
os.path.abspath, glob.iglob(pattern, recursive=True)
|
|
88
|
+
):
|
|
87
89
|
if absfile in absfiles:
|
|
88
90
|
continue
|
|
89
|
-
|
|
91
|
+
if os.path.isfile(absfile):
|
|
92
|
+
absfiles.append(absfile)
|
|
90
93
|
for absfile in absfiles:
|
|
91
94
|
with open(file=absfile, mode="r") as stream:
|
|
92
95
|
lines = stream.readlines()
|
|
93
96
|
lines = go(lines, indent=indent)
|
|
94
97
|
with open(file=absfile, mode="w") as stream:
|
|
95
98
|
stream.writelines(lines)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if __name__ == "__main__":
|
|
99
|
-
main()
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import os
|
|
3
4
|
import tempfile
|
|
4
5
|
import unittest
|
|
5
6
|
from pathlib import Path
|
|
6
|
-
from typing import Self
|
|
7
|
+
from typing import Any, Self
|
|
7
8
|
|
|
8
9
|
from jacobus.core import run
|
|
9
10
|
|
|
11
|
+
__all__ = ["JacobusRunTests"]
|
|
12
|
+
|
|
10
13
|
|
|
11
14
|
class JacobusRunTests(unittest.TestCase):
|
|
12
15
|
def test_strips_trailing_whitespace_and_outer_blank_lines(
|
|
13
16
|
self: Self,
|
|
14
17
|
) -> None:
|
|
18
|
+
root: Path
|
|
19
|
+
target: Path
|
|
20
|
+
tmp: str
|
|
15
21
|
with tempfile.TemporaryDirectory() as tmp:
|
|
16
22
|
root = Path(tmp)
|
|
17
23
|
target = root / "sample.txt"
|
|
@@ -19,7 +25,7 @@ class JacobusRunTests(unittest.TestCase):
|
|
|
19
25
|
"\n\nalpha \n\n beta\t\t\n\n", encoding="utf-8"
|
|
20
26
|
)
|
|
21
27
|
|
|
22
|
-
run(
|
|
28
|
+
run(filepatterns=[os.path.join(tmp, "*.txt")])
|
|
23
29
|
|
|
24
30
|
self.assertEqual(
|
|
25
31
|
target.read_text(encoding="utf-8"), "alpha\n\n beta\n"
|
|
@@ -28,12 +34,15 @@ class JacobusRunTests(unittest.TestCase):
|
|
|
28
34
|
def test_rescales_space_indentation_when_indent_is_given(
|
|
29
35
|
self: Self,
|
|
30
36
|
) -> None:
|
|
37
|
+
root: Path
|
|
38
|
+
target: Path
|
|
39
|
+
tmp: str
|
|
31
40
|
with tempfile.TemporaryDirectory() as tmp:
|
|
32
41
|
root = Path(tmp)
|
|
33
42
|
target = root / "sample.py"
|
|
34
43
|
target.write_text(" alpha\n beta\nplain\n", encoding="utf-8")
|
|
35
44
|
|
|
36
|
-
run(
|
|
45
|
+
run(filepatterns=[os.path.join(tmp, "*.py")], indent=4)
|
|
37
46
|
|
|
38
47
|
self.assertEqual(
|
|
39
48
|
target.read_text(encoding="utf-8"),
|
|
@@ -41,19 +50,27 @@ class JacobusRunTests(unittest.TestCase):
|
|
|
41
50
|
)
|
|
42
51
|
|
|
43
52
|
def test_unmatched_glob_does_not_touch_files(self: Self) -> None:
|
|
53
|
+
root: Path
|
|
54
|
+
tmp: str
|
|
55
|
+
target: Path
|
|
56
|
+
original: str
|
|
44
57
|
with tempfile.TemporaryDirectory() as tmp:
|
|
45
58
|
root = Path(tmp)
|
|
46
59
|
target = root / "sample.txt"
|
|
47
60
|
original = "alpha \n"
|
|
48
61
|
target.write_text(original, encoding="utf-8")
|
|
49
62
|
|
|
50
|
-
run(
|
|
63
|
+
run(filepatterns=[os.path.join(tmp, "*.py")])
|
|
51
64
|
|
|
52
65
|
self.assertEqual(target.read_text(encoding="utf-8"), original)
|
|
53
66
|
|
|
54
67
|
def test_binary_or_invalid_utf8_file_is_left_unchanged_on_decode_error(
|
|
55
68
|
self: Self,
|
|
56
69
|
) -> None:
|
|
70
|
+
original: Any
|
|
71
|
+
root: Path
|
|
72
|
+
target: Path
|
|
73
|
+
tmp: str
|
|
57
74
|
with tempfile.TemporaryDirectory() as tmp:
|
|
58
75
|
root = Path(tmp)
|
|
59
76
|
target = root / "bad.bin"
|
|
@@ -61,7 +78,7 @@ class JacobusRunTests(unittest.TestCase):
|
|
|
61
78
|
target.write_bytes(original)
|
|
62
79
|
|
|
63
80
|
with self.assertRaises(UnicodeDecodeError):
|
|
64
|
-
run(str(
|
|
81
|
+
run(filepatterns=[str(target)])
|
|
65
82
|
|
|
66
83
|
self.assertEqual(target.read_bytes(), original)
|
|
67
84
|
|
jacobus-2.0.0.dev1/MANIFEST.in
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
recursive-include src *.toml
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|