vim-eof-comment 0.3.5__tar.gz → 0.3.6__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 (59) hide show
  1. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/PKG-INFO +1 -1
  2. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/pyproject.toml +1 -1
  3. vim_eof_comment-0.3.6/version.txt +1 -0
  4. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/__init__.pyi +1 -0
  5. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/args/__init__.pyi +1 -0
  6. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/comments/__init__.pyi +1 -0
  7. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/eof.py +8 -5
  8. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/eof.pyi +3 -3
  9. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/file.py +12 -24
  10. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/file.pyi +3 -8
  11. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/version.py +1 -0
  12. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment.egg-info/PKG-INFO +1 -1
  13. vim_eof_comment-0.3.5/version.txt +0 -1
  14. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/.flake8 +0 -0
  15. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/.github/CODEOWNERS +0 -0
  16. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/.github/workflows/flake8-lint.yml +0 -0
  17. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/.github/workflows/mypy-lint.yml +0 -0
  18. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/.github/workflows/release.yml +0 -0
  19. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/.gitignore +0 -0
  20. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/.pre-commit-config.yaml +0 -0
  21. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/.taplo.toml +0 -0
  22. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/LICENSE +0 -0
  23. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/Makefile +0 -0
  24. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/Pipfile +0 -0
  25. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/README.md +0 -0
  26. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/docs/Makefile +0 -0
  27. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/docs/make.bat +0 -0
  28. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/docs/source/conf.py +0 -0
  29. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/docs/source/functions.rst +0 -0
  30. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/docs/source/index.rst +0 -0
  31. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/docs/source/usage.rst +0 -0
  32. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/requirements.txt +0 -0
  33. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/setup.cfg +0 -0
  34. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/__init__.py +0 -0
  35. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/__main__.py +0 -0
  36. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/args/__init__.py +0 -0
  37. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/args/completion.py +0 -0
  38. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/args/completion.pyi +0 -0
  39. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/args/parsing.py +0 -0
  40. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/args/parsing.pyi +0 -0
  41. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/comments/__init__.py +0 -0
  42. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/comments/filetypes.json +0 -0
  43. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/comments/generator.py +0 -0
  44. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/comments/generator.pyi +0 -0
  45. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/comments/types.py +0 -0
  46. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/comments/types.pyi +0 -0
  47. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/py.typed +0 -0
  48. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/regex.py +0 -0
  49. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/regex.pyi +0 -0
  50. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/types.py +0 -0
  51. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/types.pyi +0 -0
  52. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/util.py +0 -0
  53. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/util.pyi +0 -0
  54. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment/version.pyi +0 -0
  55. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment.egg-info/SOURCES.txt +0 -0
  56. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment.egg-info/dependency_links.txt +0 -0
  57. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment.egg-info/entry_points.txt +0 -0
  58. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment.egg-info/requires.txt +0 -0
  59. {vim_eof_comment-0.3.5 → vim_eof_comment-0.3.6}/vim_eof_comment.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vim-eof-comment
3
- Version: 0.3.5
3
+ Version: 0.3.6
4
4
  Summary: Adds Vim EOF 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>
@@ -34,7 +34,7 @@ maintainers = [{ name = "Guennadi Maximov C", email = "g.maxc.fox@protonmail.com
34
34
  name = "vim-eof-comment"
35
35
  readme = "README.md"
36
36
  requires-python = ">=3.10"
37
- version = "0.3.5"
37
+ version = "0.3.6"
38
38
 
39
39
  [project.scripts]
40
40
  vim-eof-comment = "vim_eof_comment.eof:main"
@@ -0,0 +1 @@
1
+ 0.3.6
@@ -11,4 +11,5 @@ from .version import version_info as version_info
11
11
  __all__ = ['args', 'comments', 'eof', 'file', 'main', 'regex', 'types', 'util', 'version', 'version_info']
12
12
 
13
13
  version: str
14
+
14
15
  # vim: set ts=4 sts=4 sw=4 et ai si sta:
@@ -2,4 +2,5 @@ from . import completion as completion
2
2
  from . import parsing as parsing
3
3
 
4
4
  __all__ = ['completion', 'parsing']
5
+
5
6
  # vim: set ts=4 sts=4 sw=4 et ai si sta:
@@ -2,4 +2,5 @@ from . import generator as generator
2
2
  from . import types as types
3
3
 
4
4
  __all__ = ['generator', 'types']
5
+
5
6
  # vim: set ts=4 sts=4 sw=4 et ai si sta:
@@ -32,7 +32,7 @@ _RESET: int = Style.RESET_ALL
32
32
  def eof_comment_search(
33
33
  files: Dict[str, BatchPathDict],
34
34
  comments: Comments,
35
- verbose: bool
35
+ **kwargs
36
36
  ) -> Dict[str, EOFCommentSearch]:
37
37
  """
38
38
  Search through opened files.
@@ -43,8 +43,8 @@ def eof_comment_search(
43
43
  A dictionary of ``str`` to ``BatchPathDict`` objects.
44
44
  comments : Comments
45
45
  The ``Comments`` object containing the hardcoded comments per file extension.
46
- verbose : bool
47
- Sets verbose mode.
46
+ **kwargs
47
+ COntains the ``verbose`` and ``newline`` boolean options.
48
48
 
49
49
  Returns
50
50
  -------
@@ -58,6 +58,9 @@ def eof_comment_search(
58
58
  vim_eof_comment.types.EOFCommentSearch
59
59
  The object type for the returning dictionary values.
60
60
  """
61
+ verbose: bool = kwargs.get("verbose", False)
62
+ newline: bool = kwargs.get("newline", False)
63
+
61
64
  result: Dict[str, EOFCommentSearch] = dict()
62
65
  comment_map = comments.generate()
63
66
 
@@ -72,7 +75,7 @@ def eof_comment_search(
72
75
  last_line, has_nwl = wrapper["line"], wrapper["has_nwl"]
73
76
 
74
77
  verbose_print(f"{_RESET} - {path} ==> ", verbose=verbose, end="", sep="")
75
- if last_line != comment_map[ext]:
78
+ if last_line != comment_map[ext] or (newline and not has_nwl):
76
79
  verbose_print(f"{_BRIGHT}{_RED}CHANGED", verbose=verbose)
77
80
  result[path] = EOFCommentSearch(
78
81
  state=IOWrapperBool(file=open(path, "r"), has_nwl=has_nwl),
@@ -162,7 +165,7 @@ def main() -> int:
162
165
  if len(files) == 0:
163
166
  die("No matching files found!", code=1)
164
167
 
165
- results = eof_comment_search(files, comments, verbose)
168
+ results = eof_comment_search(files, comments, verbose=verbose, newline=newline)
166
169
  if len(results) > 0:
167
170
  append_eof_comment(results, comments, newline)
168
171
 
@@ -5,7 +5,7 @@ from .types import BatchPathDict, EOFCommentSearch
5
5
 
6
6
  __all__ = ['append_eof_comment', 'eof_comment_search', 'main']
7
7
 
8
- def eof_comment_search(files: dict[str, BatchPathDict], comments: Comments, verbose: bool) -> dict[str, EOFCommentSearch]:
8
+ def eof_comment_search(files: dict[str, BatchPathDict], comments: Comments, **kwargs) -> dict[str, EOFCommentSearch]:
9
9
  """
10
10
  Search through opened files.
11
11
 
@@ -15,8 +15,8 @@ def eof_comment_search(files: dict[str, BatchPathDict], comments: Comments, verb
15
15
  A dictionary of ``str`` to ``BatchPathDict`` objects.
16
16
  comments : Comments
17
17
  The ``Comments`` object containing the hardcoded comments per file extension.
18
- verbose : bool
19
- Sets verbose mode.
18
+ **kwargs
19
+ COntains the ``verbose`` and ``newline`` boolean options.
20
20
 
21
21
  Returns
22
22
  -------
@@ -78,14 +78,7 @@ def open_batch_paths(paths: List[BatchPairDict]) -> Dict[str, BatchPathDict]:
78
78
  return result
79
79
 
80
80
 
81
- def modify_file(
82
- file: TextIOWrapper,
83
- comments: Dict[str, str],
84
- ext: str,
85
- newline: bool,
86
- has_nwl: bool,
87
- matching: bool
88
- ) -> str:
81
+ def modify_file(file: TextIOWrapper, comments: Dict[str, str], ext: str, **kwargs) -> str:
89
82
  """
90
83
  Modify a file containing a bad EOF comment.
91
84
 
@@ -97,24 +90,23 @@ def modify_file(
97
90
  A filetype-to-comment dictionary.
98
91
  ext : str
99
92
  The filetype extension given by the user.
100
- newline : bool
101
- Flag to whether add a newline before the comment.
102
- has_nwl : bool
103
- Indicates whether the file already has a newline at the end
104
- (not counting LF/CRLF line endings).
105
- matching : bool
106
- Indicates whether the file already has a matching EOF comment.
93
+ **kwargs
94
+ Contains the ``newline``, ``has_nwl`` and ``matching`` boolean attributes.
107
95
 
108
96
  Returns
109
97
  -------
110
98
  str
111
99
  The modified contents of the given file.
112
100
  """
101
+ has_nwl: bool = kwargs.get("has_nwl", False)
102
+ matching: bool = kwargs.get("matching", False)
103
+ newline: bool = kwargs.get("newline", False)
104
+
113
105
  data: List[str] = file.read().split("\n")
114
106
  file.close()
115
107
 
116
108
  data_len = len(data)
117
- comment = comments[ext]
109
+ comment = comments[ext] if not (newline and not has_nwl) else f"\n{comments[ext]}"
118
110
  if data_len == 0:
119
111
  data = [comment, ""]
120
112
  elif data_len == 1:
@@ -128,9 +120,6 @@ def modify_file(
128
120
  else:
129
121
  data.insert(-1, comment)
130
122
 
131
- if newline and not has_nwl:
132
- data.insert(-2, "") # Newline
133
-
134
123
  return "\n".join(data)
135
124
 
136
125
 
@@ -149,18 +138,17 @@ def get_last_line(file: TextIOWrapper) -> LineBool:
149
138
  An object containing both the last line in a string and a boolean indicating a newline.
150
139
  """
151
140
  data: List[str] = file.read().split("\n")
152
- has_newline = False
153
- line = ""
141
+ file.close()
142
+
143
+ has_newline, line = False, ""
154
144
  if len(data) == 1:
155
145
  line = data[0]
156
- elif len(data) >= 2:
146
+ else:
157
147
  if len(data) >= 3:
158
148
  has_newline = data[-3] == ""
159
149
 
160
150
  line: str = data[-2]
161
151
 
162
- file.close()
163
-
164
152
  return LineBool(line=line, has_nwl=has_newline)
165
153
 
166
154
  # vim: set ts=4 sts=4 sw=4 et ai si sta:
@@ -34,7 +34,7 @@ def open_batch_paths(paths: list[BatchPairDict]) -> dict[str, BatchPathDict]:
34
34
  Dict[str, BatchPathDict]
35
35
  A ``str`` to ``BatchPathDict``` dictionary.
36
36
  """
37
- def modify_file(file: TextIOWrapper, comments: dict[str, str], ext: str, newline: bool, has_nwl: bool, matching: bool) -> str:
37
+ def modify_file(file: TextIOWrapper, comments: dict[str, str], ext: str, **kwargs) -> str:
38
38
  """
39
39
  Modify a file containing a bad EOF comment.
40
40
 
@@ -46,13 +46,8 @@ def modify_file(file: TextIOWrapper, comments: dict[str, str], ext: str, newline
46
46
  A filetype-to-comment dictionary.
47
47
  ext : str
48
48
  The filetype extension given by the user.
49
- newline : bool
50
- Flag to whether add a newline before the comment.
51
- has_nwl : bool
52
- Indicates whether the file already has a newline at the end
53
- (not counting LF/CRLF line endings).
54
- matching : bool
55
- Indicates whether the file already has a matching EOF comment.
49
+ **kwargs
50
+ Contains the ``newline``, ``has_nwl`` and ``matching`` boolean attributes.
56
51
 
57
52
  Returns
58
53
  -------
@@ -212,6 +212,7 @@ version_info: VersionInfo = VersionInfo([
212
212
  (0, 3, 3),
213
213
  (0, 3, 4),
214
214
  (0, 3, 5),
215
+ (0, 3, 6),
215
216
  ])
216
217
 
217
218
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vim-eof-comment
3
- Version: 0.3.5
3
+ Version: 0.3.6
4
4
  Summary: Adds Vim EOF 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>
@@ -1 +0,0 @@
1
- 0.3.5
File without changes
File without changes
File without changes