vim-eof-comment 0.5.1__tar.gz → 0.5.3__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.5.1 → vim_eof_comment-0.5.3}/.github/workflows/vim-eof-comment.yml +4 -7
  2. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/PKG-INFO +1 -1
  3. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/pyproject.toml +1 -1
  4. vim_eof_comment-0.5.3/version.txt +1 -0
  5. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/eof.py +14 -12
  6. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/eof.pyi +4 -2
  7. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/file.py +32 -19
  8. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/file.pyi +1 -1
  9. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/types.py +8 -2
  10. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/types.pyi +8 -2
  11. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/version.py +2 -0
  12. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment.egg-info/PKG-INFO +1 -1
  13. vim_eof_comment-0.5.1/version.txt +0 -1
  14. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/.flake8 +0 -0
  15. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/.gitattributes +0 -0
  16. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/.github/CODEOWNERS +0 -0
  17. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/.github/FUNDING.yml +0 -0
  18. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/.github/workflows/flake8-lint.yml +0 -0
  19. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/.github/workflows/mypy-lint.yml +0 -0
  20. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/.github/workflows/release.yml +0 -0
  21. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/.pre-commit-config.yaml +0 -0
  22. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/CHANGELOG.md +0 -0
  23. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/LICENSE +0 -0
  24. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/Makefile +0 -0
  25. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/README.md +0 -0
  26. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/docs/Makefile +0 -0
  27. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/docs/make.bat +0 -0
  28. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/docs/source/conf.py +0 -0
  29. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/docs/source/functions.rst +0 -0
  30. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/docs/source/index.rst +0 -0
  31. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/docs/source/installation.rst +0 -0
  32. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/requirements.txt +0 -0
  33. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/setup.cfg +0 -0
  34. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/taplo.toml +0 -0
  35. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/__init__.py +0 -0
  36. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/__init__.pyi +0 -0
  37. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/__main__.py +0 -0
  38. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/args/__init__.py +0 -0
  39. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/args/__init__.pyi +0 -0
  40. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/args/completion.py +0 -0
  41. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/args/completion.pyi +0 -0
  42. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/args/parsing.py +0 -0
  43. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/args/parsing.pyi +0 -0
  44. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/comments/__init__.py +0 -0
  45. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/comments/__init__.pyi +0 -0
  46. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/comments/filetypes.json +0 -0
  47. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/comments/generator.py +0 -0
  48. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/comments/generator.pyi +0 -0
  49. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/py.typed +0 -0
  50. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/regex.py +0 -0
  51. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/regex.pyi +0 -0
  52. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/util.py +0 -0
  53. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/util.pyi +0 -0
  54. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment/version.pyi +0 -0
  55. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment.egg-info/SOURCES.txt +0 -0
  56. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment.egg-info/dependency_links.txt +0 -0
  57. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment.egg-info/entry_points.txt +0 -0
  58. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment.egg-info/requires.txt +0 -0
  59. {vim_eof_comment-0.5.1 → vim_eof_comment-0.5.3}/vim_eof_comment.egg-info/top_level.txt +0 -0
@@ -21,17 +21,14 @@ jobs:
21
21
  - name: Set up Python
22
22
  uses: actions/setup-python@v6.1.0
23
23
  with:
24
- python-version: '3.13'
25
- - name: Install pipenv
26
- run: |
27
- python -m pip install -U pip
28
- pip install pipenv
24
+ python-version: '3.14'
29
25
  - name: Install vim-eof-comment
30
26
  run: |
31
- pipenv install --dev vim-eof-comment
27
+ python -m pip install -U pip
28
+ pip install -U vim-eof-comment
32
29
  - name: Run vim-eof-comment
33
30
  run: |
34
- pipenv run vim-eof-comment -e py,pyi,md,Makefile,yaml,toml -i py:4:Y,pyi:4:Y,md:2:Y -nv .
31
+ vim-eof-comment -e py,pyi,md,Makefile,yaml,toml -i py:4:Y,pyi:4:Y,md:2:Y -nv .
35
32
  - name: Auto Commit Changes
36
33
  uses: stefanzweifel/git-auto-commit-action@v7.1.0
37
34
  with:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vim-eof-comment
3
- Version: 0.5.1
3
+ Version: 0.5.3
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>
@@ -40,7 +40,7 @@ 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.5.1"
43
+ version = "0.5.3"
44
44
 
45
45
  [project.scripts]
46
46
  vim-eof-comment = "vim_eof_comment.eof:main"
@@ -0,0 +1 @@
1
+ 0.5.3
@@ -9,7 +9,7 @@ Copyright (c) 2025 Guennadi Maximov C. All Rights Reserved.
9
9
  __all__ = ["append_eof_comment", "eof_comment_search", "main"]
10
10
 
11
11
  from io import TextIOWrapper
12
- from typing import Dict, List, NoReturn
12
+ from typing import Dict, List, NoReturn, Tuple
13
13
 
14
14
  from colorama import Fore, Style
15
15
  from colorama import init as color_init
@@ -32,7 +32,7 @@ def eof_comment_search(
32
32
  files: Dict[str, BatchPathDict],
33
33
  comments: Comments,
34
34
  **kwargs
35
- ) -> Dict[str, EOFCommentSearch]:
35
+ ) -> Tuple[Dict[str, EOFCommentSearch], bool]:
36
36
  """
37
37
  Search through opened files.
38
38
 
@@ -71,7 +71,7 @@ def eof_comment_search(
71
71
  ext: str = file["ft_ext"]
72
72
 
73
73
  wrapper = get_last_line(file_obj)
74
- last_line, had_nwl = wrapper["line"], wrapper["had_nwl"]
74
+ last_line, had_nwl, crlf = wrapper["line"], wrapper["had_nwl"], wrapper["crlf"]
75
75
 
76
76
  verbose_print(f"{_RESET} - {path} ==> ", verbose=verbose, end="", sep="")
77
77
  if last_line != comment_map[ext] or (newline and not had_nwl):
@@ -84,13 +84,14 @@ def eof_comment_search(
84
84
  else:
85
85
  verbose_print(f"{_BRIGHT}{_GREEN}OK", verbose=verbose)
86
86
 
87
- return result
87
+ return result, crlf
88
88
 
89
89
 
90
90
  def append_eof_comment(
91
91
  files: Dict[str, EOFCommentSearch],
92
92
  comments: Comments,
93
- newline: bool
93
+ newline: bool,
94
+ crlf: bool
94
95
  ) -> NoReturn:
95
96
  """
96
97
  Append a Vim EOF comment to files missing it.
@@ -103,6 +104,8 @@ def append_eof_comment(
103
104
  The ``Comments`` object containing the hardcoded comments per file extension.
104
105
  newline : bool
105
106
  Indicates whether a newline should be added before the comment.
107
+ crlf : bool
108
+ Whether the file is CRLF-terminated.
106
109
  """
107
110
  comment_map = comments.generate()
108
111
  for path, file in files.items():
@@ -117,12 +120,11 @@ def append_eof_comment(
117
120
  ext=ext,
118
121
  newline=newline,
119
122
  had_nwl=had_nwl,
120
- matching=matching
123
+ matching=matching,
124
+ crlf=crlf
121
125
  )
122
- file_obj = open(path, "w")
123
-
124
- file_obj.write(txt)
125
- file_obj.close()
126
+ with open(path, "w") as file_obj:
127
+ file_obj.write(txt)
126
128
 
127
129
 
128
130
  def main() -> int:
@@ -166,9 +168,9 @@ def main() -> int:
166
168
  die("No matching files found!", code=code)
167
169
 
168
170
  comments = Comments(gen_indent_maps(indent.copy()))
169
- results = eof_comment_search(files, comments, verbose=verbose, newline=newline)
171
+ results, crlf = eof_comment_search(files, comments, verbose=verbose, newline=newline)
170
172
  if len(results) > 0 and not dry_run:
171
- append_eof_comment(results, comments, newline)
173
+ append_eof_comment(results, comments, newline, crlf)
172
174
 
173
175
  return 0
174
176
 
@@ -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, **kwargs) -> dict[str, EOFCommentSearch]:
8
+ def eof_comment_search(files: dict[str, BatchPathDict], comments: Comments, **kwargs) -> tuple[dict[str, EOFCommentSearch], bool]:
9
9
  """
10
10
  Search through opened files.
11
11
 
@@ -30,7 +30,7 @@ def eof_comment_search(files: dict[str, BatchPathDict], comments: Comments, **kw
30
30
  vim_eof_comment.types.EOFCommentSearch
31
31
  The object type for the returning dictionary values.
32
32
  """
33
- def append_eof_comment(files: dict[str, EOFCommentSearch], comments: Comments, newline: bool) -> NoReturn:
33
+ def append_eof_comment(files: dict[str, EOFCommentSearch], comments: Comments, newline: bool, crlf: bool) -> NoReturn:
34
34
  """
35
35
  Append a Vim EOF comment to files missing it.
36
36
 
@@ -42,6 +42,8 @@ def append_eof_comment(files: dict[str, EOFCommentSearch], comments: Comments, n
42
42
  The ``Comments`` object containing the hardcoded comments per file extension.
43
43
  newline : bool
44
44
  Indicates whether a newline should be added before the comment.
45
+ crlf : bool
46
+ Whether the file is CRLF-terminated.
45
47
  """
46
48
  def main() -> int:
47
49
  """
@@ -137,7 +137,7 @@ def modify_file(file: TextIOWrapper, comments: Dict[str, str], ext: str, **kwarg
137
137
  ext : str
138
138
  The file-type/file-extension given by the user.
139
139
  **kwargs
140
- Contains the ``newline``, and ``matching`` boolean attributes.
140
+ Contains the ``newline``, ``matching`` and ``crlf`` boolean attributes.
141
141
 
142
142
  Returns
143
143
  -------
@@ -146,25 +146,29 @@ def modify_file(file: TextIOWrapper, comments: Dict[str, str], ext: str, **kwarg
146
146
  """
147
147
  matching: bool = kwargs.get("matching", False)
148
148
  newline: bool = kwargs.get("newline", False)
149
+ crlf: bool = kwargs.get("crlf", False)
149
150
 
150
- bdata: str = file.read()
151
- data: List[str] = bdata.split("\n")
151
+ data: List[str] = file.read().split("\n")
152
152
  file.close()
153
153
 
154
- data_len = len(data)
155
- comment = comments[ext]
156
- if data_len == 0:
157
- data = [comment, ""]
158
- elif data_len == 1:
154
+ if len(data) >= 1 and data[-1] != "":
155
+ data.append("")
156
+
157
+ if crlf:
158
+ data[-2] = ""
159
+
160
+ if len(data) == 0:
161
+ data = [comments[ext], ""]
162
+ elif len(data) == 1:
159
163
  if matching:
160
- data = [comment, ""]
164
+ data = [comments[ext], ""]
161
165
  else:
162
- data.insert(0, comment)
163
- elif data_len >= 2:
166
+ data.insert(0, comments[ext])
167
+ elif len(data) >= 2:
164
168
  if matching:
165
- data[-2] = comment
169
+ data[-2] = comments[ext]
166
170
  else:
167
- data.insert(-1, comment)
171
+ data.insert(-1, comments[ext])
168
172
 
169
173
  if len(data) >= 3:
170
174
  if newline and data[-3] != "":
@@ -173,6 +177,9 @@ def modify_file(file: TextIOWrapper, comments: Dict[str, str], ext: str, **kwarg
173
177
  if not newline and data[-3] == "":
174
178
  data.pop(-3)
175
179
 
180
+ if crlf:
181
+ data.insert(-1, "\r")
182
+
176
183
  return "\n".join(data)
177
184
 
178
185
 
@@ -190,19 +197,25 @@ def get_last_line(file: TextIOWrapper) -> LineBool:
190
197
  LineBool
191
198
  An object containing both the last line in a string and a boolean indicating a newline.
192
199
  """
193
- bdata: str = file.read()
194
- data: List[str] = bdata.split("\n")
200
+ data: List[str] = file.read().split("\n")
195
201
  file.close()
196
202
 
197
- had_newline, line = False, ""
198
- if len(data) <= 1:
203
+ if data[-1] != "":
204
+ data.append("")
205
+
206
+ had_nwl, crlf, line = False, False, ""
207
+ if len(data) == 0:
208
+ line = ""
209
+ elif len(data) == 1:
199
210
  line = data[0]
200
211
  elif len(data) >= 2:
201
212
  line: str = data[-2]
213
+ if line == "\r":
214
+ line, crlf = "", True
202
215
 
203
216
  if len(data) >= 3:
204
- had_newline = data[-3] == ""
217
+ had_nwl = data[-3] == ""
205
218
 
206
- return LineBool(line=line, had_nwl=had_newline)
219
+ return LineBool(line=line, had_nwl=had_nwl, crlf=crlf)
207
220
 
208
221
  # vim: set ts=4 sts=4 sw=4 et ai si sta:
@@ -61,7 +61,7 @@ def modify_file(file: TextIOWrapper, comments: dict[str, str], ext: str, **kwarg
61
61
  ext : str
62
62
  The file-type/file-extension given by the user.
63
63
  **kwargs
64
- Contains the ``newline``, and ``matching`` boolean attributes.
64
+ Contains the ``newline``, ``matching`` and ``crlf`` boolean attributes.
65
65
 
66
66
  Returns
67
67
  -------
@@ -266,7 +266,7 @@ class IndentHandler(TypedDict):
266
266
 
267
267
  class IOWrapperBool(TypedDict):
268
268
  """
269
- A dict containing ``file`` and ``had_nwl`` as keys.
269
+ A dict containing ``file``, ``had_nwl`` and ``crlf`` as keys.
270
270
 
271
271
  This is a ``TypedDict``-like object.
272
272
 
@@ -276,15 +276,18 @@ class IOWrapperBool(TypedDict):
276
276
  The opened file as a ``TextIO`` wrapper.
277
277
  had_nwl : bool
278
278
  Whether the file has a newline or not.
279
+ crlf : bool
280
+ Whether the file is CRLF-terminated.
279
281
  """
280
282
 
281
283
  file: TextIO
282
284
  had_nwl: bool
285
+ crlf: bool
283
286
 
284
287
 
285
288
  class LineBool(TypedDict):
286
289
  """
287
- A dict containing ``line`` and ``had_nwl`` as keys.
290
+ A dict containing ``line``, ``had_nwl`` and ``crlf`` as keys.
288
291
 
289
292
  This is a ``TypedDict``-like object.
290
293
 
@@ -294,10 +297,13 @@ class LineBool(TypedDict):
294
297
  The last line of the target file.
295
298
  had_nwl : bool
296
299
  Whether the file has a newline or not.
300
+ crlf : bool
301
+ Whether the file is CRLF-terminated.
297
302
  """
298
303
 
299
304
  line: str
300
305
  had_nwl: bool
306
+ crlf: bool
301
307
 
302
308
 
303
309
  class BatchPathDict(TypedDict):
@@ -208,7 +208,7 @@ class IndentHandler(TypedDict):
208
208
 
209
209
  class IOWrapperBool(TypedDict):
210
210
  """
211
- A dict containing ``file`` and ``had_nwl`` as keys.
211
+ A dict containing ``file``, ``had_nwl`` and ``crlf`` as keys.
212
212
 
213
213
  This is a ``TypedDict``-like object.
214
214
 
@@ -218,13 +218,16 @@ class IOWrapperBool(TypedDict):
218
218
  The opened file as a ``TextIO`` wrapper.
219
219
  had_nwl : bool
220
220
  Whether the file has a newline or not.
221
+ crlf : bool
222
+ Whether the file is CRLF-terminated.
221
223
  """
222
224
  file: TextIO
223
225
  had_nwl: bool
226
+ crlf: bool
224
227
 
225
228
  class LineBool(TypedDict):
226
229
  """
227
- A dict containing ``line`` and ``had_nwl`` as keys.
230
+ A dict containing ``line``, ``had_nwl`` and ``crlf`` as keys.
228
231
 
229
232
  This is a ``TypedDict``-like object.
230
233
 
@@ -234,9 +237,12 @@ class LineBool(TypedDict):
234
237
  The last line of the target file.
235
238
  had_nwl : bool
236
239
  Whether the file has a newline or not.
240
+ crlf : bool
241
+ Whether the file is CRLF-terminated.
237
242
  """
238
243
  line: str
239
244
  had_nwl: bool
245
+ crlf: bool
240
246
 
241
247
  class BatchPathDict(TypedDict):
242
248
  """
@@ -82,6 +82,8 @@ version_info = VersionInfo([
82
82
  (0, 4, 2),
83
83
  (0, 5, 0),
84
84
  (0, 5, 1),
85
+ (0, 5, 2),
86
+ (0, 5, 3),
85
87
  ])
86
88
 
87
89
  __version__: str = str(version_info)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vim-eof-comment
3
- Version: 0.5.1
3
+ Version: 0.5.3
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>
@@ -1 +0,0 @@
1
- 0.5.1
File without changes
File without changes