vim-eof-comment 0.3.21__py3-none-any.whl → 0.4.1__py3-none-any.whl

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/eof.py CHANGED
@@ -77,7 +77,7 @@ def eof_comment_search(
77
77
  if last_line != comment_map[ext] or (newline and not had_nwl):
78
78
  verbose_print(f"{_BRIGHT}{_RED}CHANGED", verbose=verbose)
79
79
  result[path] = EOFCommentSearch(
80
- state=IOWrapperBool(file=open(path, "rb"), had_nwl=had_nwl),
80
+ state=IOWrapperBool(file=open(path, "r"), had_nwl=had_nwl),
81
81
  lang=ext,
82
82
  match=matches(last_line, verbose)
83
83
  )
vim_eof_comment/file.py CHANGED
@@ -5,7 +5,13 @@ File management utilities.
5
5
 
6
6
  Copyright (c) 2025 Guennadi Maximov C. All Rights Reserved.
7
7
  """
8
- __all__ = ["bootstrap_paths", "open_batch_paths", "modify_file", "get_last_line"]
8
+ __all__ = [
9
+ "bootstrap_paths",
10
+ "get_last_line",
11
+ "modify_file",
12
+ "open_batch_paths",
13
+ "try_open",
14
+ ]
9
15
 
10
16
  from io import TextIOWrapper
11
17
  from os import walk
@@ -39,41 +45,18 @@ def try_open(fpath: str) -> bool:
39
45
  bool
40
46
  Whether the file triggers a ``UnicodeDecodeError`` or not.
41
47
  """
42
- file = open(fpath, "rb")
43
- success: bool = True
44
- try:
45
- file.read().decode(encoding="utf8")
46
- except UnicodeDecodeError:
47
- success = False
48
- except Exception:
49
- die("Something went wrong in `try_open()`!", code=2)
48
+ with open(fpath, "r") as file:
49
+ success: bool = True
50
+ try:
51
+ file.read()
52
+ except UnicodeDecodeError:
53
+ success = False
54
+ except Exception:
55
+ die("Something went wrong in `try_open()`!", code=2)
50
56
 
51
- file.close()
52
57
  return success
53
58
 
54
59
 
55
- def has_excluded(dir: str) -> bool:
56
- """
57
- Check whether a directory list contains any excluded directories.
58
-
59
- Parameters
60
- ----------
61
- dir : str
62
- The directory to check.
63
-
64
- Returns
65
- -------
66
- bool
67
- Whether an excluded directory was found.
68
- """
69
- dir = dir.rstrip("/")
70
- for excluded in EXCLUDED_DIRS:
71
- if dir.endswith(excluded):
72
- return True
73
-
74
- return False
75
-
76
-
77
60
  def bootstrap_paths(paths: List[str], exts: List[str]) -> List[BatchPairDict]:
78
61
  """
79
62
  Bootstrap all the matching paths in current dir and below.
@@ -92,22 +75,13 @@ def bootstrap_paths(paths: List[str], exts: List[str]) -> List[BatchPairDict]:
92
75
  """
93
76
  result = list()
94
77
  for path in paths:
95
- if not isdir(path) or has_excluded(path):
78
+ if not isdir(path):
96
79
  continue
97
80
 
98
81
  root: str
99
82
  dirs: List[str]
100
83
  files: List[str]
101
84
  for root, dirs, files in walk(path):
102
- excluded = False
103
- for dir in dirs:
104
- if has_excluded(dir):
105
- excluded = True
106
- break
107
-
108
- if excluded:
109
- continue
110
-
111
85
  for file in files:
112
86
  for ext in exts:
113
87
  if not file.endswith(ext):
@@ -139,7 +113,7 @@ def open_batch_paths(paths: List[BatchPairDict]) -> Dict[str, BatchPathDict]:
139
113
  continue
140
114
 
141
115
  try:
142
- result[fpath] = {"file": open(fpath, "rb"), "ft_ext": ext}
116
+ result[fpath] = {"file": open(fpath, "r"), "ft_ext": ext}
143
117
  except KeyboardInterrupt:
144
118
  die("\nProgram interrupted!", code=1) # Kills the program
145
119
  except FileNotFoundError:
@@ -173,7 +147,7 @@ def modify_file(file: TextIOWrapper, comments: Dict[str, str], ext: str, **kwarg
173
147
  matching: bool = kwargs.get("matching", False)
174
148
  newline: bool = kwargs.get("newline", False)
175
149
 
176
- bdata: str = file.read().decode(encoding="utf8")
150
+ bdata: str = file.read()
177
151
  data: List[str] = bdata.split("\n")
178
152
  file.close()
179
153
 
@@ -216,7 +190,7 @@ def get_last_line(file: TextIOWrapper) -> LineBool:
216
190
  LineBool
217
191
  An object containing both the last line in a string and a boolean indicating a newline.
218
192
  """
219
- bdata: str = file.read().decode(encoding="utf8")
193
+ bdata: str = file.read()
220
194
  data: List[str] = bdata.split("\n")
221
195
  file.close()
222
196
 
vim_eof_comment/file.pyi CHANGED
@@ -2,8 +2,22 @@ from io import TextIOWrapper
2
2
 
3
3
  from .types import BatchPairDict, BatchPathDict, LineBool
4
4
 
5
- __all__ = ['bootstrap_paths', 'open_batch_paths', 'modify_file', 'get_last_line']
5
+ __all__ = ['bootstrap_paths', 'get_last_line', 'modify_file', 'open_batch_paths', 'try_open']
6
6
 
7
+ def try_open(fpath: str) -> bool:
8
+ """
9
+ Try to open a file, unless a ``UnicodeDecodeError`` triggers.
10
+
11
+ Parameters
12
+ ----------
13
+ fpath : str
14
+ The file path to try and open.
15
+
16
+ Returns
17
+ -------
18
+ bool
19
+ Whether the file triggers a ``UnicodeDecodeError`` or not.
20
+ """
7
21
  def bootstrap_paths(paths: list[str], exts: list[str]) -> list[BatchPairDict]:
8
22
  """
9
23
  Bootstrap all the matching paths in current dir and below.
@@ -228,6 +228,8 @@ version_info = VersionInfo([
228
228
  (0, 3, 19),
229
229
  (0, 3, 20),
230
230
  (0, 3, 21),
231
+ (0, 4, 0),
232
+ (0, 4, 1),
231
233
  ])
232
234
 
233
235
  __version__: str = str(version_info)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vim-eof-comment
3
- Version: 0.3.21
3
+ Version: 0.4.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>
@@ -7,10 +7,10 @@ docs/source/installation.rst,sha256=PkiS3E_ujNTWeKXicZ7aBPch2l1R0TsRRL6pFj_oMJI,
7
7
  vim_eof_comment/__init__.py,sha256=ESbmhca9mTst3TYMer8zFw73IRsJvn5EESci_RpfLbQ,487
8
8
  vim_eof_comment/__init__.pyi,sha256=Eh8FQwE_F9TrQEiT7CR1mdGHBT6fHUzfV6VP8uSN33g,478
9
9
  vim_eof_comment/__main__.py,sha256=0AFVSkz8RuxSuPbJJWycyxs6u5Yypl8FKUMR3ZVLJbk,343
10
- vim_eof_comment/eof.py,sha256=JpU5v_V_4fIaWt0BJfPvgp-0ZjzhDdyj_otpusIa7a8,5160
10
+ vim_eof_comment/eof.py,sha256=vKVVg_-HRa9ccqTrnyMfzczQk7aQpzxpuaDNb5DfFQk,5159
11
11
  vim_eof_comment/eof.pyi,sha256=BTw9brhrHBTX12fYuwfO8_D-Gyrf0387ErmgrcTdvh0,1786
12
- vim_eof_comment/file.py,sha256=eIsaB8r20awtBDcUFt2oL8SD_gvpxhiCjaldK_Zh4Xs,5742
13
- vim_eof_comment/file.pyi,sha256=BWBtHbFkAdiNSRfe9SQBJvxtH3WHZfIgz03kFsIWX4w,1950
12
+ vim_eof_comment/file.py,sha256=r6vRI7CrZVqNrqkQE4TesbuDTIXT2x7W9i9FRP44BS8,5067
13
+ vim_eof_comment/file.pyi,sha256=S02kb4Ta5kDXpC3fYAVboC89jSUzHv6AHoll5HMICUg,2265
14
14
  vim_eof_comment/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  vim_eof_comment/regex.py,sha256=rGfFIBMbfWlIxAScXqvgBlB-tMJBUxQwTVjEkoxDZ3o,1007
16
16
  vim_eof_comment/regex.pyi,sha256=LJt6HN9s0Vo1B5plpaYURVZ3okmtl5jnV6kKdn1KyqA,433
@@ -18,7 +18,7 @@ vim_eof_comment/types.py,sha256=ofo6X9sbNG1ONsofMFganJPlYYsCZmriMWuZHj7dukg,3832
18
18
  vim_eof_comment/types.pyi,sha256=dJcnOLxqVShYHSyafbNZEQJ4D3MC42A-oDtlJArApRE,3562
19
19
  vim_eof_comment/util.py,sha256=0-SUdHqpgMdwHauZawaY3KL5FkIfe1u2zA1AHb80ez8,4125
20
20
  vim_eof_comment/util.pyi,sha256=5RQukLgpVZTwbALhBOtd1NqFkiqC-V6JEWeT1_B9-2k,2675
21
- vim_eof_comment/version.py,sha256=GYzQ9G8yuBoWKkLgu5qA3-swNe3XjWMtBh4AMVGXHrs,5798
21
+ vim_eof_comment/version.py,sha256=alJ1lTKfAe1VxRi5BEt3bid6qhgJ1pPcXSz5ppYIwQU,5828
22
22
  vim_eof_comment/version.pyi,sha256=suF5VwVtpA0rVOuKpa6cvJ8TNocXgtJiI51DRrpzOTs,3692
23
23
  vim_eof_comment/args/__init__.py,sha256=Hyqun15456NVFLAJ3cpdtuNEz5XaFH93vfVlbC-aeuc,318
24
24
  vim_eof_comment/args/__init__.pyi,sha256=cXK7nEpYBveD4kxtVTe2x8oUxT9mhENS5r3wK3AAX2U,151
@@ -31,9 +31,9 @@ vim_eof_comment/comments/__init__.pyi,sha256=cecbbrShh0If8btwJ8zKYpBt9dIsMwrDXbd
31
31
  vim_eof_comment/comments/filetypes.json,sha256=JpSrnBNO2AivLYi-C5--8yVocyBwye3IkMesNIz1uHA,2973
32
32
  vim_eof_comment/comments/generator.py,sha256=Mi3Yi0j-8aXQnVUsXqI1VE1yW71tWemooWgO9smSilI,7731
33
33
  vim_eof_comment/comments/generator.pyi,sha256=Nj33jwria5FWUuydUD_uZSH__PxSZ3yPxOPYF1_TIpM,3272
34
- vim_eof_comment-0.3.21.dist-info/licenses/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
35
- vim_eof_comment-0.3.21.dist-info/METADATA,sha256=SrFvzlchrAr0eJFaCWzFnrocDgrmDUhDszAMZn8eSH0,2763
36
- vim_eof_comment-0.3.21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
- vim_eof_comment-0.3.21.dist-info/entry_points.txt,sha256=vm47g4hoUbow4elcHr9yylYfj6IvAs10wSFKqwqTu6E,61
38
- vim_eof_comment-0.3.21.dist-info/top_level.txt,sha256=TkaQ5vuhVzXaJnfUdcLJCQ81ILK2V6OtvX5-hIMZAc0,21
39
- vim_eof_comment-0.3.21.dist-info/RECORD,,
34
+ vim_eof_comment-0.4.1.dist-info/licenses/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
35
+ vim_eof_comment-0.4.1.dist-info/METADATA,sha256=sYnxoPd1Ypiar4SglzMRtQJaiFibzMOelZ7Cto6185c,2762
36
+ vim_eof_comment-0.4.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
+ vim_eof_comment-0.4.1.dist-info/entry_points.txt,sha256=vm47g4hoUbow4elcHr9yylYfj6IvAs10wSFKqwqTu6E,61
38
+ vim_eof_comment-0.4.1.dist-info/top_level.txt,sha256=TkaQ5vuhVzXaJnfUdcLJCQ81ILK2V6OtvX5-hIMZAc0,21
39
+ vim_eof_comment-0.4.1.dist-info/RECORD,,