vim-eof-comment 0.6.2__tar.gz → 0.7.1__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.
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/.pre-commit-config.yaml +4 -11
- vim_eof_comment-0.7.1/Makefile +66 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/PKG-INFO +1 -1
- vim_eof_comment-0.7.1/Pipfile +42 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/docs/source/conf.py +17 -17
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/pyproject.toml +8 -2
- vim_eof_comment-0.7.1/version.txt +1 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/__init__.py +5 -3
- vim_eof_comment-0.7.1/vim_eof_comment/__init__.pyi +27 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/__main__.py +2 -1
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/args/__init__.py +1 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/args/__init__.pyi +1 -1
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/args/completion.py +2 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/args/completion.pyi +2 -1
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/args/parsing.py +4 -2
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/args/parsing.pyi +7 -4
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/comments/__init__.py +1 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/comments/__init__.pyi +1 -1
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/comments/generator.py +11 -18
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/comments/generator.pyi +5 -21
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/file.py +2 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/file.pyi +12 -1
- vim_eof_comment-0.6.2/vim_eof_comment/eof.py → vim_eof_comment-0.7.1/vim_eof_comment/main.py +6 -9
- vim_eof_comment-0.6.2/vim_eof_comment/eof.pyi → vim_eof_comment-0.7.1/vim_eof_comment/main.pyi +9 -3
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/regex.py +4 -2
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/regex.pyi +1 -1
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/types.py +4 -5
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/types.pyi +25 -2
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/util.py +3 -2
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/util.pyi +6 -3
- vim_eof_comment-0.7.1/vim_eof_comment/version.py +115 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/version.pyi +2 -1
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment.egg-info/PKG-INFO +1 -1
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment.egg-info/SOURCES.txt +3 -2
- vim_eof_comment-0.7.1/vim_eof_comment.egg-info/entry_points.txt +2 -0
- vim_eof_comment-0.6.2/Makefile +0 -68
- vim_eof_comment-0.6.2/version.txt +0 -1
- vim_eof_comment-0.6.2/vim_eof_comment/__init__.pyi +0 -16
- vim_eof_comment-0.6.2/vim_eof_comment/version.py +0 -109
- vim_eof_comment-0.6.2/vim_eof_comment.egg-info/entry_points.txt +0 -2
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/.flake8 +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/.gitattributes +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/.github/CODEOWNERS +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/.github/FUNDING.yml +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/.github/workflows/flake8-lint.yml +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/.github/workflows/mypy-lint.yml +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/.github/workflows/release.yml +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/.github/workflows/vim-eof-comment.yml +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/CHANGELOG.md +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/LICENSE +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/README.md +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/docs/Makefile +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/docs/make.bat +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/docs/source/functions.rst +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/docs/source/index.rst +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/docs/source/installation.rst +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/requirements.txt +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/setup.cfg +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/taplo.toml +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/comments/filetypes.json +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment/py.typed +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment.egg-info/dependency_links.txt +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment.egg-info/requires.txt +0 -0
- {vim_eof_comment-0.6.2 → vim_eof_comment-0.7.1}/vim_eof_comment.egg-info/top_level.txt +0 -0
|
@@ -18,19 +18,12 @@ repos:
|
|
|
18
18
|
verbose: true
|
|
19
19
|
- repo: local
|
|
20
20
|
hooks:
|
|
21
|
-
- id:
|
|
22
|
-
name:
|
|
21
|
+
- id: build
|
|
22
|
+
name: Build and run project
|
|
23
23
|
language: system
|
|
24
|
+
entry: make
|
|
25
|
+
always_run: true
|
|
24
26
|
types: [python]
|
|
25
|
-
files: ^(vim_eof_comment/.*\.pyi?|Makefile)$
|
|
26
|
-
entry: make lint
|
|
27
|
-
verbose: true
|
|
28
|
-
- id: run_script
|
|
29
|
-
name: Install and Run Script Locally
|
|
30
|
-
language: system
|
|
31
|
-
types: [python]
|
|
32
|
-
files: ^(vim_eof_comment/.*\.py|Makefile)$
|
|
33
|
-
entry: make run-script
|
|
34
27
|
verbose: true
|
|
35
28
|
|
|
36
29
|
# vim: set ts=2 sts=2 sw=2 et ai si sta:
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
.PHONY: all help lint build local-install clean run-script docs format
|
|
2
|
+
|
|
3
|
+
all: run-script
|
|
4
|
+
|
|
5
|
+
clean: ## Clean built files
|
|
6
|
+
@echo "Cleaning..."
|
|
7
|
+
@rm -rf build dist *.egg-info
|
|
8
|
+
@echo "Done!"
|
|
9
|
+
|
|
10
|
+
distclean: clean ## Clean everything
|
|
11
|
+
@echo "Cleaning Everything..."
|
|
12
|
+
@rm -rf .mypy_cache .ropeproject .pytest_cache .ruff_cache
|
|
13
|
+
@echo "Done!"
|
|
14
|
+
|
|
15
|
+
docs: ## Generate Sphinx docs
|
|
16
|
+
@echo "Generating docs..."
|
|
17
|
+
@$(MAKE) -C docs html
|
|
18
|
+
@echo "Done!"
|
|
19
|
+
|
|
20
|
+
help: ## Show help
|
|
21
|
+
@echo -e "Usage: make [target]\n\nAvailable targets:"
|
|
22
|
+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
|
23
|
+
@echo
|
|
24
|
+
|
|
25
|
+
lint: ## Lint files
|
|
26
|
+
@echo "Running flake8..."
|
|
27
|
+
@pipenv run flake8 vim_eof_comment
|
|
28
|
+
@echo -e "Done!\n\nRunning pydocstyle..."
|
|
29
|
+
@pipenv run pydocstyle --convention=numpy --match='.*\.py' vim_eof_comment
|
|
30
|
+
$(eval files := $(shell fd --full-path vim_eof_comment -e py))
|
|
31
|
+
@echo -e "Done!\n\nLinting with numpydoc..."
|
|
32
|
+
@pipenv run numpydoc lint $(files)
|
|
33
|
+
@echo "Done!"
|
|
34
|
+
|
|
35
|
+
stubs: lint ## Generate mypy stubs
|
|
36
|
+
@echo "Generating stubs..."
|
|
37
|
+
@pipenv run stubgen --include-docstrings --include-private -v -p vim_eof_comment -o .
|
|
38
|
+
@echo -e "Done!\n\nRunning isort..."
|
|
39
|
+
@pipenv run isort vim_eof_comment
|
|
40
|
+
@echo -e "Done!\n\nChecking typing with mypy..."
|
|
41
|
+
@pipenv run mypy vim_eof_comment
|
|
42
|
+
@echo "Done!"
|
|
43
|
+
|
|
44
|
+
format: stubs ## Format using Ruff
|
|
45
|
+
@echo "Formatting with Ruff..."
|
|
46
|
+
@pipenv run ruff format vim_eof_comment
|
|
47
|
+
@echo -e "Done!\n\nChecking with Ruff..."
|
|
48
|
+
@pipenv run ruff check vim_eof_comment
|
|
49
|
+
@echo "Done!"
|
|
50
|
+
|
|
51
|
+
build: format ## Build project
|
|
52
|
+
@echo "Building..."
|
|
53
|
+
@pipenv run python -m build
|
|
54
|
+
@echo "Done!"
|
|
55
|
+
|
|
56
|
+
local-install: build ## Install project in current pipenv virtual environment
|
|
57
|
+
@echo "Installing locally..."
|
|
58
|
+
@pipenv run python -m pip install .
|
|
59
|
+
@echo "Done!"
|
|
60
|
+
|
|
61
|
+
run-script: local-install ## Run the built project
|
|
62
|
+
@echo "Running vim-eof-comment..."
|
|
63
|
+
@pipenv run vim-eof-comment -e py,pyi,Makefile,md,yaml,yml,toml -nv .
|
|
64
|
+
@echo "Done!"
|
|
65
|
+
|
|
66
|
+
# vim: set ts=4 sts=4 sw=0 noet ai si sta:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: vim-eof-comment
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.1
|
|
4
4
|
Summary: Adds Vim EOF modeline comments for given filetypes in given directories
|
|
5
5
|
Author-email: Guennadi Maximov C <g.maxc.fox@protonmail.com>
|
|
6
6
|
Maintainer-email: Guennadi Maximov C <g.maxc.fox@protonmail.com>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[[source]]
|
|
2
|
+
url = "https://pypi.org/simple"
|
|
3
|
+
verify_ssl = true
|
|
4
|
+
name = "pypi"
|
|
5
|
+
|
|
6
|
+
[packages]
|
|
7
|
+
argparse = "*"
|
|
8
|
+
colorama = "*"
|
|
9
|
+
argcomplete = "*"
|
|
10
|
+
|
|
11
|
+
[dev-packages]
|
|
12
|
+
pyproject = "*"
|
|
13
|
+
setuptools = "*"
|
|
14
|
+
wheel = "*"
|
|
15
|
+
pynvim = "*"
|
|
16
|
+
build = "*"
|
|
17
|
+
pre-commit = "*"
|
|
18
|
+
furo = "*"
|
|
19
|
+
sphinx-rtd-theme = "*"
|
|
20
|
+
renku-sphinx-theme = "*"
|
|
21
|
+
sphinxawesome-theme = "*"
|
|
22
|
+
numpydoc = "*"
|
|
23
|
+
vim-eof-comment = "*"
|
|
24
|
+
pip = "*"
|
|
25
|
+
update-version = "*"
|
|
26
|
+
python-lsp-server = {extras = ["all"], version = "*"}
|
|
27
|
+
pylsp-mypy = "*"
|
|
28
|
+
pylsp-rope = "*"
|
|
29
|
+
python-lsp-isort = "*"
|
|
30
|
+
mypy = "*"
|
|
31
|
+
mypy-extensions = "*"
|
|
32
|
+
ruff = "*"
|
|
33
|
+
|
|
34
|
+
[scripts]
|
|
35
|
+
lint = "flake8 --statistics --show-source --color always --max-line-length 100 --docstring-convention numpy --ignore=D401 ."
|
|
36
|
+
build = "python3 -m build"
|
|
37
|
+
local-install = "python3 -m pip install ."
|
|
38
|
+
install = "python3 -m pip install"
|
|
39
|
+
stubs = "stubgen -p vim_eof_comment -o ."
|
|
40
|
+
|
|
41
|
+
[requires]
|
|
42
|
+
python_version = "3.14"
|
|
@@ -8,35 +8,35 @@ import sys
|
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
from typing import List
|
|
10
10
|
|
|
11
|
-
sys.path.insert(0, str(Path(
|
|
11
|
+
sys.path.insert(0, str(Path("..", "src").resolve()))
|
|
12
12
|
|
|
13
13
|
# -- Project information -----------------------------------------------------
|
|
14
14
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
|
15
15
|
|
|
16
|
-
project: str =
|
|
17
|
-
copyright: str =
|
|
18
|
-
author: str =
|
|
19
|
-
release: str =
|
|
16
|
+
project: str = "vim-eof-comment"
|
|
17
|
+
copyright: str = "2025, Guennadi Maximov C"
|
|
18
|
+
author: str = "Guennadi Maximov C"
|
|
19
|
+
release: str = "0.1.33"
|
|
20
20
|
|
|
21
21
|
# -- General configuration ---------------------------------------------------
|
|
22
22
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
|
23
23
|
|
|
24
24
|
extensions: List[str] = [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
"numpydoc",
|
|
26
|
+
"sphinx.ext.autodoc",
|
|
27
|
+
"sphinx.ext.autosectionlabel",
|
|
28
|
+
"sphinx.ext.autosummary",
|
|
29
|
+
"sphinx.ext.duration",
|
|
30
30
|
]
|
|
31
31
|
|
|
32
|
-
templates_path: List[str] = [
|
|
32
|
+
templates_path: List[str] = ["_templates"]
|
|
33
33
|
exclude_patterns: List[str] = []
|
|
34
34
|
|
|
35
35
|
# -- Options for HTML output -------------------------------------------------
|
|
36
36
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
|
37
37
|
|
|
38
|
-
html_theme: str =
|
|
39
|
-
html_static_path: List[str] = [
|
|
38
|
+
html_theme: str = "sphinx_rtd_theme"
|
|
39
|
+
html_static_path: List[str] = ["_static"]
|
|
40
40
|
|
|
41
41
|
# -- Options for numpydoc ----------------------------------------------------
|
|
42
42
|
numpydoc_xref_param_type = True
|
|
@@ -47,10 +47,10 @@ numpydoc_validation_checks = {
|
|
|
47
47
|
"SA01",
|
|
48
48
|
}
|
|
49
49
|
numpydoc_xref_aliases = {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
"TextIO": "typing.TextIO",
|
|
51
|
+
"List": "list",
|
|
52
|
+
"Dict": "dict",
|
|
53
|
+
"Tuple": "tuple",
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
# vim: set ts=4 sts=4 sw=4 et ai si sta:
|
|
@@ -40,10 +40,10 @@ maintainers = [{ name = "Guennadi Maximov C", email = "g.maxc.fox@protonmail.com
|
|
|
40
40
|
name = "vim-eof-comment"
|
|
41
41
|
readme = "README.md"
|
|
42
42
|
requires-python = ">=3.10"
|
|
43
|
-
version = "0.
|
|
43
|
+
version = "0.7.1"
|
|
44
44
|
|
|
45
45
|
[project.scripts]
|
|
46
|
-
vim-eof-comment = "vim_eof_comment.
|
|
46
|
+
vim-eof-comment = "vim_eof_comment.main:main"
|
|
47
47
|
|
|
48
48
|
[project.urls]
|
|
49
49
|
Download = "https://github.com/DrKJeff16/vim-eof-comment/releases/latest"
|
|
@@ -127,4 +127,10 @@ save_objectdb = true
|
|
|
127
127
|
split_imports = false
|
|
128
128
|
validate_objectdb = true
|
|
129
129
|
|
|
130
|
+
[tool.ruff]
|
|
131
|
+
line-length = 100
|
|
132
|
+
|
|
133
|
+
[tool.ruff.lint.pydocstyle]
|
|
134
|
+
convention = "numpy"
|
|
135
|
+
|
|
130
136
|
# vim: set ts=4 sts=4 sw=4 et ai si sta:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.7.1
|
|
@@ -5,11 +5,13 @@ Ensure EOF Vim comments.
|
|
|
5
5
|
|
|
6
6
|
Copyright (c) 2025 Guennadi Maximov C. All Rights Reserved.
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
__all__ = [
|
|
9
10
|
"__version__",
|
|
11
|
+
"append_eof_comment",
|
|
10
12
|
"args",
|
|
11
13
|
"comments",
|
|
12
|
-
"
|
|
14
|
+
"eof_comment_search",
|
|
13
15
|
"file",
|
|
14
16
|
"main",
|
|
15
17
|
"regex",
|
|
@@ -18,8 +20,8 @@ __all__ = [
|
|
|
18
20
|
"version",
|
|
19
21
|
]
|
|
20
22
|
|
|
21
|
-
from . import args, comments,
|
|
22
|
-
from .
|
|
23
|
+
from . import args, comments, file, regex, types, util, version
|
|
24
|
+
from .main import append_eof_comment, eof_comment_search, main
|
|
23
25
|
from .version import __version__
|
|
24
26
|
|
|
25
27
|
# vim: set ts=4 sts=4 sw=4 et ai si sta:
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from . import args as args
|
|
2
|
+
from . import comments as comments
|
|
3
|
+
from . import file as file
|
|
4
|
+
from . import regex as regex
|
|
5
|
+
from . import types as types
|
|
6
|
+
from . import util as util
|
|
7
|
+
from . import version as version
|
|
8
|
+
from .main import append_eof_comment as append_eof_comment
|
|
9
|
+
from .main import eof_comment_search as eof_comment_search
|
|
10
|
+
from .main import main as main
|
|
11
|
+
from .version import __version__ as __version__
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"__version__",
|
|
15
|
+
"append_eof_comment",
|
|
16
|
+
"args",
|
|
17
|
+
"comments",
|
|
18
|
+
"eof_comment_search",
|
|
19
|
+
"file",
|
|
20
|
+
"main",
|
|
21
|
+
"regex",
|
|
22
|
+
"types",
|
|
23
|
+
"util",
|
|
24
|
+
"version",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
# vim: set ts=4 sts=4 sw=4 et ai si sta:
|
|
@@ -5,6 +5,7 @@ Argument parsing completion utilities for ``vim-eof-comment``.
|
|
|
5
5
|
|
|
6
6
|
Copyright (c) 2025 Guennadi Maximov C. All Rights Reserved.
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
__all__ = ["complete_parser", "complete_validator"]
|
|
9
10
|
|
|
10
11
|
from argparse import ArgumentParser
|
|
@@ -45,4 +46,5 @@ def complete_parser(parser: ArgumentParser, **kwargs) -> None:
|
|
|
45
46
|
"""
|
|
46
47
|
autocomplete(parser, validator=complete_validator, **kwargs)
|
|
47
48
|
|
|
49
|
+
|
|
48
50
|
# vim: set ts=4 sts=4 sw=4 et ai si sta:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from argparse import ArgumentParser
|
|
2
2
|
|
|
3
|
-
__all__ = [
|
|
3
|
+
__all__ = ["complete_parser", "complete_validator"]
|
|
4
4
|
|
|
5
5
|
def complete_validator(completion_candidate: list[str], current_input: str) -> bool:
|
|
6
6
|
"""
|
|
@@ -18,6 +18,7 @@ def complete_validator(completion_candidate: list[str], current_input: str) -> b
|
|
|
18
18
|
bool
|
|
19
19
|
Whether the current input fits the completion candidates pool.
|
|
20
20
|
"""
|
|
21
|
+
|
|
21
22
|
def complete_parser(parser: ArgumentParser, **kwargs) -> None:
|
|
22
23
|
"""
|
|
23
24
|
Complete the script argument parser.
|
|
@@ -5,6 +5,7 @@ Argument parsing utilities for ``vim-eof-comment``.
|
|
|
5
5
|
|
|
6
6
|
Copyright (c) 2025 Guennadi Maximov C. All Rights Reserved.
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
__all__ = ["gen_parser_specs", "bootstrap_args", "arg_parser_init", "indent_handler"]
|
|
9
10
|
|
|
10
11
|
from argparse import ArgumentDefaultsHelpFormatter, ArgumentError, ArgumentParser, Namespace
|
|
@@ -90,7 +91,7 @@ def arg_parser_init(prog: str = "vim-eof-comment") -> Tuple[ArgumentParser, Name
|
|
|
90
91
|
exit_on_error=False,
|
|
91
92
|
formatter_class=ArgumentDefaultsHelpFormatter,
|
|
92
93
|
add_help=True,
|
|
93
|
-
allow_abbrev=True
|
|
94
|
+
allow_abbrev=True,
|
|
94
95
|
)
|
|
95
96
|
spec: List[ParserSpec] = gen_parser_specs(
|
|
96
97
|
{
|
|
@@ -168,7 +169,7 @@ def arg_parser_init(prog: str = "vim-eof-comment") -> Tuple[ArgumentParser, Name
|
|
|
168
169
|
"kwargs": {
|
|
169
170
|
"required": False,
|
|
170
171
|
"metavar": "EXT1[,EXT2[,EXT3[,...]]]",
|
|
171
|
-
"help":
|
|
172
|
+
"help": 'A comma-separated list of file extensions (e.g. "lua,c,cpp,cc,c++")',
|
|
172
173
|
"dest": "exts",
|
|
173
174
|
},
|
|
174
175
|
},
|
|
@@ -224,4 +225,5 @@ def indent_handler(indent: str) -> List[IndentHandler]:
|
|
|
224
225
|
|
|
225
226
|
return maps
|
|
226
227
|
|
|
228
|
+
|
|
227
229
|
# vim: set ts=4 sts=4 sw=4 et ai si sta:
|
|
@@ -2,7 +2,7 @@ from argparse import ArgumentParser, Namespace
|
|
|
2
2
|
|
|
3
3
|
from ..types import IndentHandler, ParserSpec
|
|
4
4
|
|
|
5
|
-
__all__ = [
|
|
5
|
+
__all__ = ["gen_parser_specs", "bootstrap_args", "arg_parser_init", "indent_handler"]
|
|
6
6
|
|
|
7
7
|
def gen_parser_specs(*specs) -> list[ParserSpec]:
|
|
8
8
|
"""
|
|
@@ -18,6 +18,7 @@ def gen_parser_specs(*specs) -> list[ParserSpec]:
|
|
|
18
18
|
List[ParserSpec]
|
|
19
19
|
The converted dictionaries inside a list.
|
|
20
20
|
"""
|
|
21
|
+
|
|
21
22
|
def bootstrap_args(parser: ArgumentParser, specs: list[ParserSpec]) -> Namespace:
|
|
22
23
|
"""
|
|
23
24
|
Bootstrap the program arguments.
|
|
@@ -34,8 +35,9 @@ def bootstrap_args(parser: ArgumentParser, specs: list[ParserSpec]) -> Namespace
|
|
|
34
35
|
argparse.Namespace
|
|
35
36
|
The generated ``argparse.Namespace`` object.
|
|
36
37
|
"""
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
|
|
39
|
+
def arg_parser_init(prog: str = "vim-eof-comment") -> tuple[ArgumentParser, Namespace]:
|
|
40
|
+
"""
|
|
39
41
|
Generate the argparse namespace.
|
|
40
42
|
|
|
41
43
|
Parameters
|
|
@@ -49,7 +51,8 @@ def arg_parser_init(prog: str = 'vim-eof-comment') -> tuple[ArgumentParser, Name
|
|
|
49
51
|
The generated ``argparse.ArgumentParser`` object.
|
|
50
52
|
namespace : argparse.Namespace
|
|
51
53
|
The generated ``argparse.Namespace`` object.
|
|
52
|
-
|
|
54
|
+
"""
|
|
55
|
+
|
|
53
56
|
def indent_handler(indent: str) -> list[IndentHandler]:
|
|
54
57
|
"""
|
|
55
58
|
Parse indent levels defined by the user.
|
|
@@ -5,11 +5,10 @@ Per-filetype modeline comment class.
|
|
|
5
5
|
|
|
6
6
|
Copyright (c) 2025 Guennadi Maximov C. All Rights Reserved.
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
__all__ = [
|
|
9
10
|
"Comments",
|
|
10
|
-
"export_json",
|
|
11
11
|
"generate_list_items",
|
|
12
|
-
"import_json",
|
|
13
12
|
"list_filetypes",
|
|
14
13
|
]
|
|
15
14
|
|
|
@@ -17,7 +16,7 @@ import json
|
|
|
17
16
|
import os
|
|
18
17
|
from io import TextIOWrapper
|
|
19
18
|
from os.path import exists, isdir, realpath
|
|
20
|
-
from typing import Dict,
|
|
19
|
+
from typing import Dict, List, Tuple
|
|
21
20
|
|
|
22
21
|
from colorama import Fore, Style
|
|
23
22
|
from colorama import init as color_init
|
|
@@ -25,8 +24,7 @@ from colorama import init as color_init
|
|
|
25
24
|
from ..types import IndentMap
|
|
26
25
|
from ..util import die
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
_COMMENT_STR: str = "vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:"
|
|
30
28
|
_JSON_FILE: str = realpath("./vim_eof_comment/comments/filetypes.json")
|
|
31
29
|
_BLUE: int = Fore.BLUE
|
|
32
30
|
_YELLOW: int = Fore.YELLOW
|
|
@@ -60,15 +58,12 @@ def import_json() -> Tuple[Dict[str, str], Dict[str, IndentMap]]:
|
|
|
60
58
|
maps = result[1]
|
|
61
59
|
|
|
62
60
|
for k, v in comments.items():
|
|
63
|
-
comments[k] = v.format(comment=
|
|
61
|
+
comments[k] = v.format(comment=_COMMENT_STR)
|
|
64
62
|
|
|
65
63
|
return comments, maps
|
|
66
64
|
|
|
67
65
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
class Comments():
|
|
66
|
+
class Comments:
|
|
72
67
|
"""
|
|
73
68
|
Vim EOF comments class.
|
|
74
69
|
|
|
@@ -96,8 +91,8 @@ class Comments():
|
|
|
96
91
|
get_ft()
|
|
97
92
|
"""
|
|
98
93
|
|
|
99
|
-
__DEFAULT: Dict[str, IndentMap]
|
|
100
|
-
__formats: Dict[str, str]
|
|
94
|
+
__DEFAULT: Dict[str, IndentMap]
|
|
95
|
+
__formats: Dict[str, str]
|
|
101
96
|
comments: Dict[str, str]
|
|
102
97
|
langs: Dict[str, IndentMap]
|
|
103
98
|
|
|
@@ -110,6 +105,8 @@ class Comments():
|
|
|
110
105
|
mappings : Dict[str, IndentMap], optional, default=None
|
|
111
106
|
The ``str`` to ``IndentMap`` dictionary.
|
|
112
107
|
"""
|
|
108
|
+
self.__formats, self.__DEFAULT = import_json()
|
|
109
|
+
|
|
113
110
|
if mappings is None or len(mappings) == 0:
|
|
114
111
|
self.langs = self.__DEFAULT.copy()
|
|
115
112
|
return
|
|
@@ -127,11 +124,6 @@ class Comments():
|
|
|
127
124
|
|
|
128
125
|
self.__fill_langs(langs)
|
|
129
126
|
|
|
130
|
-
def __iter__(self) -> Iterator[str]:
|
|
131
|
-
"""Iterate through comment langs."""
|
|
132
|
-
for k, v in self.langs.items():
|
|
133
|
-
yield (k, v)
|
|
134
|
-
|
|
135
127
|
def __is_available(self, lang: str) -> bool:
|
|
136
128
|
"""
|
|
137
129
|
Check if a given lang is available within the class.
|
|
@@ -268,7 +260,7 @@ def export_json() -> None:
|
|
|
268
260
|
return
|
|
269
261
|
|
|
270
262
|
try:
|
|
271
|
-
data: str = json.dumps((
|
|
263
|
+
data: str = json.dumps(import_json(), ensure_ascii=False)
|
|
272
264
|
except KeyboardInterrupt:
|
|
273
265
|
die(code=1)
|
|
274
266
|
except Exception:
|
|
@@ -285,4 +277,5 @@ def export_json() -> None:
|
|
|
285
277
|
|
|
286
278
|
file.close()
|
|
287
279
|
|
|
280
|
+
|
|
288
281
|
# vim: set ts=4 sts=4 sw=4 et ai si sta:
|
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
from typing import Iterator
|
|
2
|
-
|
|
3
1
|
from ..types import IndentMap
|
|
4
2
|
|
|
5
|
-
__all__ = [
|
|
6
|
-
|
|
7
|
-
def import_json() -> tuple[dict[str, str], dict[str, IndentMap]]:
|
|
8
|
-
"""
|
|
9
|
-
Import default vars from JSON file.
|
|
10
|
-
|
|
11
|
-
Returns
|
|
12
|
-
-------
|
|
13
|
-
comments : Dict[str, str]
|
|
14
|
-
The default ``Dict[str, str]``.
|
|
15
|
-
map_dict : Dict[str, IndentMap]
|
|
16
|
-
The default indent mappings dict.
|
|
17
|
-
"""
|
|
3
|
+
__all__ = ["Comments", "generate_list_items", "list_filetypes"]
|
|
18
4
|
|
|
19
5
|
class Comments:
|
|
20
6
|
"""
|
|
@@ -43,6 +29,7 @@ class Comments:
|
|
|
43
29
|
get_defaults()
|
|
44
30
|
get_ft()
|
|
45
31
|
"""
|
|
32
|
+
|
|
46
33
|
__DEFAULT: dict[str, IndentMap]
|
|
47
34
|
__formats: dict[str, str]
|
|
48
35
|
comments: dict[str, str]
|
|
@@ -56,8 +43,6 @@ class Comments:
|
|
|
56
43
|
mappings : Dict[str, IndentMap], optional, default=None
|
|
57
44
|
The ``str`` to ``IndentMap`` dictionary.
|
|
58
45
|
"""
|
|
59
|
-
def __iter__(self) -> Iterator[str]:
|
|
60
|
-
"""Iterate through comment langs."""
|
|
61
46
|
def __is_available(self, lang: str) -> bool:
|
|
62
47
|
"""
|
|
63
48
|
Check if a given lang is available within the class.
|
|
@@ -115,7 +100,7 @@ class Comments:
|
|
|
115
100
|
"""
|
|
116
101
|
|
|
117
102
|
def generate_list_items(ft: str, level: int, expandtab: str) -> str:
|
|
118
|
-
|
|
103
|
+
"""
|
|
119
104
|
Generate a colored string for filetypes listing.
|
|
120
105
|
|
|
121
106
|
Parameters
|
|
@@ -131,10 +116,9 @@ def generate_list_items(ft: str, level: int, expandtab: str) -> str:
|
|
|
131
116
|
-------
|
|
132
117
|
str
|
|
133
118
|
The generated string.
|
|
134
|
-
|
|
119
|
+
"""
|
|
120
|
+
|
|
135
121
|
def list_filetypes() -> None:
|
|
136
122
|
"""List all available filetypes."""
|
|
137
|
-
def export_json() -> None:
|
|
138
|
-
"""Export default vars to JSON."""
|
|
139
123
|
|
|
140
124
|
# vim: set ts=4 sts=4 sw=4 et ai si sta:
|
|
@@ -5,6 +5,7 @@ File management utilities.
|
|
|
5
5
|
|
|
6
6
|
Copyright (c) 2025 Guennadi Maximov C. All Rights Reserved.
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
__all__ = [
|
|
9
10
|
"EXCLUDED_DIRS",
|
|
10
11
|
"bootstrap_paths",
|
|
@@ -219,4 +220,5 @@ def get_last_line(file: TextIOWrapper) -> LineBool:
|
|
|
219
220
|
|
|
220
221
|
return LineBool(line=line, had_nwl=had_nwl, crlf=crlf)
|
|
221
222
|
|
|
223
|
+
|
|
222
224
|
# vim: set ts=4 sts=4 sw=4 et ai si sta:
|
|
@@ -2,7 +2,14 @@ from io import TextIOWrapper
|
|
|
2
2
|
|
|
3
3
|
from .types import BatchPairDict, BatchPathDict, LineBool
|
|
4
4
|
|
|
5
|
-
__all__ = [
|
|
5
|
+
__all__ = [
|
|
6
|
+
"EXCLUDED_DIRS",
|
|
7
|
+
"bootstrap_paths",
|
|
8
|
+
"get_last_line",
|
|
9
|
+
"modify_file",
|
|
10
|
+
"open_batch_paths",
|
|
11
|
+
"try_open",
|
|
12
|
+
]
|
|
6
13
|
|
|
7
14
|
EXCLUDED_DIRS: list[str]
|
|
8
15
|
|
|
@@ -20,6 +27,7 @@ def try_open(fpath: str) -> bool:
|
|
|
20
27
|
bool
|
|
21
28
|
Whether the file triggers a ``UnicodeDecodeError`` or not.
|
|
22
29
|
"""
|
|
30
|
+
|
|
23
31
|
def bootstrap_paths(paths: list[str], exts: list[str]) -> list[BatchPairDict]:
|
|
24
32
|
"""
|
|
25
33
|
Bootstrap all the matching paths in current dir and below.
|
|
@@ -36,6 +44,7 @@ def bootstrap_paths(paths: list[str], exts: list[str]) -> list[BatchPairDict]:
|
|
|
36
44
|
List[BatchPairDict]
|
|
37
45
|
A list of ``BatchPairDict`` type objects.
|
|
38
46
|
"""
|
|
47
|
+
|
|
39
48
|
def open_batch_paths(paths: list[BatchPairDict]) -> dict[str, BatchPathDict]:
|
|
40
49
|
"""
|
|
41
50
|
Return a list of TextIO objects given file path strings.
|
|
@@ -50,6 +59,7 @@ def open_batch_paths(paths: list[BatchPairDict]) -> dict[str, BatchPathDict]:
|
|
|
50
59
|
Dict[str, BatchPathDict]
|
|
51
60
|
A ``str`` to ``BatchPathDict``` dictionary.
|
|
52
61
|
"""
|
|
62
|
+
|
|
53
63
|
def modify_file(file: TextIOWrapper, comments: dict[str, str], ext: str, **kwargs) -> str:
|
|
54
64
|
"""
|
|
55
65
|
Modify a file containing a bad EOF comment.
|
|
@@ -70,6 +80,7 @@ def modify_file(file: TextIOWrapper, comments: dict[str, str], ext: str, **kwarg
|
|
|
70
80
|
str
|
|
71
81
|
The modified contents of the given file.
|
|
72
82
|
"""
|
|
83
|
+
|
|
73
84
|
def get_last_line(file: TextIOWrapper) -> LineBool:
|
|
74
85
|
"""
|
|
75
86
|
Return the last line of a file and indicates whether it already has a newline.
|