vim-eof-comment 0.4.0__py3-none-any.whl → 0.4.2__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.
@@ -17,7 +17,7 @@ from ..util import die
17
17
  from .completion import complete_parser
18
18
 
19
19
 
20
- def gen_parser_specs(*specs) -> Tuple[ParserSpec]:
20
+ def gen_parser_specs(*specs) -> List[ParserSpec]:
21
21
  """
22
22
  Generate a ``ParserSpec`` object.
23
23
 
@@ -28,13 +28,13 @@ def gen_parser_specs(*specs) -> Tuple[ParserSpec]:
28
28
 
29
29
  Returns
30
30
  -------
31
- Tuple[ParserSpec]
32
- The converted dictionaries inside a tuple.
31
+ List[ParserSpec]
32
+ The converted dictionaries inside a list.
33
33
  """
34
- return tuple([ParserSpec(**d) for d in [*specs]])
34
+ return [ParserSpec(**d) for d in [*specs]]
35
35
 
36
36
 
37
- def bootstrap_args(parser: ArgumentParser, specs: Tuple[ParserSpec]) -> Namespace:
37
+ def bootstrap_args(parser: ArgumentParser, specs: List[ParserSpec]) -> Namespace:
38
38
  """
39
39
  Bootstrap the program arguments.
40
40
 
@@ -92,7 +92,7 @@ def arg_parser_init(prog: str = "vim-eof-comment") -> Tuple[ArgumentParser, Name
92
92
  add_help=True,
93
93
  allow_abbrev=True
94
94
  )
95
- spec: Tuple[ParserSpec] = gen_parser_specs(
95
+ spec: List[ParserSpec] = gen_parser_specs(
96
96
  {
97
97
  "opts": ["directories"],
98
98
  "kwargs": {
@@ -4,7 +4,7 @@ from ..types import IndentHandler, ParserSpec
4
4
 
5
5
  __all__ = ['gen_parser_specs', 'bootstrap_args', 'arg_parser_init', 'indent_handler']
6
6
 
7
- def gen_parser_specs(*specs) -> tuple[ParserSpec]:
7
+ def gen_parser_specs(*specs) -> list[ParserSpec]:
8
8
  """
9
9
  Generate a ``ParserSpec`` object.
10
10
 
@@ -15,10 +15,10 @@ def gen_parser_specs(*specs) -> tuple[ParserSpec]:
15
15
 
16
16
  Returns
17
17
  -------
18
- Tuple[ParserSpec]
19
- The converted dictionaries inside a tuple.
18
+ List[ParserSpec]
19
+ The converted dictionaries inside a list.
20
20
  """
21
- def bootstrap_args(parser: ArgumentParser, specs: tuple[ParserSpec]) -> Namespace:
21
+ def bootstrap_args(parser: ArgumentParser, specs: list[ParserSpec]) -> Namespace:
22
22
  """
23
23
  Bootstrap the program arguments.
24
24
 
@@ -108,7 +108,7 @@ class Comments():
108
108
  self.langs = self.__DEFAULT.copy()
109
109
  return
110
110
 
111
- langs = dict()
111
+ langs: Dict[str, IndentMap] = dict()
112
112
  for lang, mapping in mappings.items():
113
113
  if not (self.__is_available(lang)) or len(mapping) == 0:
114
114
  continue
@@ -117,7 +117,7 @@ class Comments():
117
117
  if len(mapping) > 1:
118
118
  expandtab = mapping["expandtab"]
119
119
 
120
- langs[lang] = {"level": indent, "expandtab": expandtab}
120
+ langs[lang] = IndentMap(level=indent, expandtab=expandtab)
121
121
 
122
122
  self.__fill_langs(langs)
123
123
 
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
  )
@@ -153,10 +153,9 @@ def main() -> int:
153
153
  dirs: List[str] = ns.directories
154
154
  exts: List[str] = ns.exts.split(",")
155
155
  newline: bool = ns.newline
156
- indent: List[IndentHandler] = indent_handler(ns.indent)
157
156
  verbose: bool = ns.verbose
158
-
159
157
  dry_run: bool = ns.dry_run
158
+ indent: List[IndentHandler] = indent_handler(ns.indent)
160
159
 
161
160
  if dry_run:
162
161
  verbose = True
vim_eof_comment/file.py CHANGED
@@ -6,10 +6,8 @@ File management utilities.
6
6
  Copyright (c) 2025 Guennadi Maximov C. All Rights Reserved.
7
7
  """
8
8
  __all__ = [
9
- "EXCLUDED_DIRS",
10
9
  "bootstrap_paths",
11
10
  "get_last_line",
12
- "has_excluded",
13
11
  "modify_file",
14
12
  "open_batch_paths",
15
13
  "try_open",
@@ -47,41 +45,18 @@ def try_open(fpath: str) -> bool:
47
45
  bool
48
46
  Whether the file triggers a ``UnicodeDecodeError`` or not.
49
47
  """
50
- file = open(fpath, "rb")
51
- success: bool = True
52
- try:
53
- file.read().decode(encoding="utf8")
54
- except UnicodeDecodeError:
55
- success = False
56
- except Exception:
57
- 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)
58
56
 
59
- file.close()
60
57
  return success
61
58
 
62
59
 
63
- def has_excluded(dir: str) -> bool:
64
- """
65
- Check whether a directory list contains any excluded directories.
66
-
67
- Parameters
68
- ----------
69
- dir : str
70
- The directory to check.
71
-
72
- Returns
73
- -------
74
- bool
75
- Whether an excluded directory was found.
76
- """
77
- dir = dir.rstrip("/")
78
- for excluded in EXCLUDED_DIRS:
79
- if dir.endswith(excluded):
80
- return True
81
-
82
- return False
83
-
84
-
85
60
  def bootstrap_paths(paths: List[str], exts: List[str]) -> List[BatchPairDict]:
86
61
  """
87
62
  Bootstrap all the matching paths in current dir and below.
@@ -100,22 +75,13 @@ def bootstrap_paths(paths: List[str], exts: List[str]) -> List[BatchPairDict]:
100
75
  """
101
76
  result = list()
102
77
  for path in paths:
103
- if not isdir(path) or has_excluded(path):
78
+ if not isdir(path):
104
79
  continue
105
80
 
106
81
  root: str
107
82
  dirs: List[str]
108
83
  files: List[str]
109
84
  for root, dirs, files in walk(path):
110
- excluded = False
111
- for dir in dirs:
112
- if has_excluded(dir):
113
- excluded = True
114
- break
115
-
116
- if excluded:
117
- continue
118
-
119
85
  for file in files:
120
86
  for ext in exts:
121
87
  if not file.endswith(ext):
@@ -140,14 +106,14 @@ def open_batch_paths(paths: List[BatchPairDict]) -> Dict[str, BatchPathDict]:
140
106
  Dict[str, BatchPathDict]
141
107
  A ``str`` to ``BatchPathDict``` dictionary.
142
108
  """
143
- result = dict()
109
+ result: Dict[str, BatchPathDict] = dict()
144
110
  for path in paths:
145
111
  fpath, ext = path["fpath"], path["ft_ext"]
146
112
  if not try_open(fpath):
147
113
  continue
148
114
 
149
115
  try:
150
- result[fpath] = {"file": open(fpath, "rb"), "ft_ext": ext}
116
+ result[fpath] = BatchPathDict(file=open(fpath, "r"), ft_ext=ext)
151
117
  except KeyboardInterrupt:
152
118
  die("\nProgram interrupted!", code=1) # Kills the program
153
119
  except FileNotFoundError:
@@ -181,7 +147,7 @@ def modify_file(file: TextIOWrapper, comments: Dict[str, str], ext: str, **kwarg
181
147
  matching: bool = kwargs.get("matching", False)
182
148
  newline: bool = kwargs.get("newline", False)
183
149
 
184
- bdata: str = file.read().decode(encoding="utf8")
150
+ bdata: str = file.read()
185
151
  data: List[str] = bdata.split("\n")
186
152
  file.close()
187
153
 
@@ -224,7 +190,7 @@ def get_last_line(file: TextIOWrapper) -> LineBool:
224
190
  LineBool
225
191
  An object containing both the last line in a string and a boolean indicating a newline.
226
192
  """
227
- bdata: str = file.read().decode(encoding="utf8")
193
+ bdata: str = file.read()
228
194
  data: List[str] = bdata.split("\n")
229
195
  file.close()
230
196
 
vim_eof_comment/file.pyi CHANGED
@@ -2,9 +2,7 @@ from io import TextIOWrapper
2
2
 
3
3
  from .types import BatchPairDict, BatchPathDict, LineBool
4
4
 
5
- __all__ = ['EXCLUDED_DIRS', 'bootstrap_paths', 'get_last_line', 'has_excluded', 'modify_file', 'open_batch_paths', 'try_open']
6
-
7
- EXCLUDED_DIRS: list[str]
5
+ __all__ = ['bootstrap_paths', 'get_last_line', 'modify_file', 'open_batch_paths', 'try_open']
8
6
 
9
7
  def try_open(fpath: str) -> bool:
10
8
  """
@@ -20,20 +18,6 @@ def try_open(fpath: str) -> bool:
20
18
  bool
21
19
  Whether the file triggers a ``UnicodeDecodeError`` or not.
22
20
  """
23
- def has_excluded(dir: str) -> bool:
24
- """
25
- Check whether a directory list contains any excluded directories.
26
-
27
- Parameters
28
- ----------
29
- dir : str
30
- The directory to check.
31
-
32
- Returns
33
- -------
34
- bool
35
- Whether an excluded directory was found.
36
- """
37
21
  def bootstrap_paths(paths: list[str], exts: list[str]) -> list[BatchPairDict]:
38
22
  """
39
23
  Bootstrap all the matching paths in current dir and below.
vim_eof_comment/types.py CHANGED
@@ -19,7 +19,7 @@ __all__ = [
19
19
 
20
20
  from typing import Any, Dict, List, TextIO, TypedDict
21
21
 
22
- from argcomplete.completers import DirectoriesCompleter
22
+ import argcomplete
23
23
 
24
24
 
25
25
  class ParserSpec(TypedDict):
@@ -40,7 +40,7 @@ class ParserSpec(TypedDict):
40
40
 
41
41
  opts: List[str]
42
42
  kwargs: Dict[str, Any]
43
- completer: DirectoriesCompleter
43
+ completer: argcomplete.DirectoriesCompleter
44
44
 
45
45
 
46
46
  class CommentMap(TypedDict):
vim_eof_comment/types.pyi CHANGED
@@ -1,6 +1,6 @@
1
1
  from typing import Any, TextIO, TypedDict
2
2
 
3
- from argcomplete.completers import DirectoriesCompleter
3
+ import argcomplete
4
4
 
5
5
  __all__ = ['BatchPairDict', 'BatchPathDict', 'CommentMap', 'EOFCommentSearch', 'IOWrapperBool', 'IndentHandler', 'IndentMap', 'LineBool', 'ParserSpec']
6
6
 
@@ -21,7 +21,7 @@ class ParserSpec(TypedDict):
21
21
  """
22
22
  opts: list[str]
23
23
  kwargs: dict[str, Any]
24
- completer: DirectoriesCompleter
24
+ completer: argcomplete.DirectoriesCompleter
25
25
 
26
26
  class CommentMap(TypedDict):
27
27
  """
vim_eof_comment/util.py CHANGED
@@ -5,7 +5,12 @@ EOF comments checker utilities.
5
5
 
6
6
  Copyright (c) 2025 Guennadi Maximov C. All Rights Reserved.
7
7
  """
8
- __all__ = ["die", "error", "gen_indent_maps", "verbose_print"]
8
+ __all__ = [
9
+ "die",
10
+ "error",
11
+ "gen_indent_maps",
12
+ "verbose_print",
13
+ ]
9
14
 
10
15
  from sys import exit as Exit
11
16
  from sys import stderr, stdout
@@ -15,7 +20,7 @@ from .types import IndentHandler, IndentMap
15
20
 
16
21
 
17
22
  def error(*msg, **kwargs) -> NoReturn:
18
- r"""
23
+ """
19
24
  Print to stderr.
20
25
 
21
26
  Parameters
@@ -29,11 +34,14 @@ def error(*msg, **kwargs) -> NoReturn:
29
34
  --------
30
35
  print : This function is essentially being wrapped around here.
31
36
  """
32
- print(*msg, file=stderr, **kwargs)
37
+ end: str = kwargs.get("end", "\n")
38
+ sep: str = kwargs.get("sep", " ")
39
+ flush: bool = kwargs.get("flush", False)
40
+ print(*msg, file=stderr, end=end, sep=sep, flush=flush)
33
41
 
34
42
 
35
43
  def die(*msg, code: int = 0, func: Callable[[TextIO], None] | None = None, **kwargs) -> NoReturn:
36
- r"""
44
+ """
37
45
  Kill the program execution.
38
46
 
39
47
  Summons ``sys.exit()`` with a provided code and optionally prints code to stderr or stdout
@@ -107,13 +115,13 @@ def verbose_print(*msg, verbose: bool | None = None, **kwargs) -> NoReturn:
107
115
  --------
108
116
  print : This function is essentially being wrapped around here.
109
117
  """
118
+ if verbose is None or not verbose:
119
+ return
120
+
110
121
  end: str = kwargs.get("end", "\n")
111
122
  sep: str = kwargs.get("sep", " ")
112
123
  flush: bool = kwargs.get("flush", False)
113
124
 
114
- if verbose is None or not verbose:
115
- return
116
-
117
125
  print(*msg, end=end, sep=sep, flush=flush)
118
126
 
119
127
 
@@ -150,10 +158,10 @@ def gen_indent_maps(maps: List[IndentHandler]) -> Dict[str, IndentMap] | None:
150
158
  continue
151
159
 
152
160
  mapping_len = mapping_len if mapping_len <= 3 else 3
153
- map_d[ext] = {
154
- "level": level,
155
- "expandtab": True if mapping_len == 2 else mapping["expandtab"],
156
- }
161
+ map_d[ext] = IndentMap(
162
+ level=level,
163
+ expandtab=True if mapping_len == 2 else mapping["expandtab"]
164
+ )
157
165
 
158
166
  return map_d
159
167
 
@@ -229,6 +229,8 @@ version_info = VersionInfo([
229
229
  (0, 3, 20),
230
230
  (0, 3, 21),
231
231
  (0, 4, 0),
232
+ (0, 4, 1),
233
+ (0, 4, 2),
232
234
  ])
233
235
 
234
236
  __version__: str = str(version_info)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vim-eof-comment
3
- Version: 0.4.0
3
+ Version: 0.4.2
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>
@@ -30,8 +30,6 @@ License-File: LICENSE
30
30
  Requires-Dist: argcomplete
31
31
  Requires-Dist: argparse
32
32
  Requires-Dist: colorama
33
- Requires-Dist: setuptools
34
- Requires-Dist: wheel
35
33
  Dynamic: license-file
36
34
 
37
35
  # vim-eof-comment
@@ -7,33 +7,33 @@ 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=3iCP_fL3aUrPndKve3DoSpikZSvyIR0kwaE46EAlJqA,5158
11
11
  vim_eof_comment/eof.pyi,sha256=BTw9brhrHBTX12fYuwfO8_D-Gyrf0387ErmgrcTdvh0,1786
12
- vim_eof_comment/file.py,sha256=jNssQBOgT8Smrqb7fiQf2VGWRN0wHppRA4MMd6EYAJo,5818
13
- vim_eof_comment/file.pyi,sha256=Jelb8dvvqN6IfdX-WvRIgeVhcjdQhT6Qamq9lwlxRy0,2606
12
+ vim_eof_comment/file.py,sha256=HNtwUMteUeKldBcVJEjdxlHLWNDXPbgjswJ-9PKRlQA,5100
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
17
- vim_eof_comment/types.py,sha256=ofo6X9sbNG1ONsofMFganJPlYYsCZmriMWuZHj7dukg,3832
18
- vim_eof_comment/types.pyi,sha256=dJcnOLxqVShYHSyafbNZEQJ4D3MC42A-oDtlJArApRE,3562
19
- vim_eof_comment/util.py,sha256=0-SUdHqpgMdwHauZawaY3KL5FkIfe1u2zA1AHb80ez8,4125
17
+ vim_eof_comment/types.py,sha256=YTFbh0YWYKc8IVDmn45RrD0fP2jmUKA5v9GK1TSk6Jk,3807
18
+ vim_eof_comment/types.pyi,sha256=hBRWM3D6t-v8z5u2XQyDXUZImDQT_3oPcA1fsLwmLho,3537
19
+ vim_eof_comment/util.py,sha256=MHLt-FJz4uhsa56J2sug74uqk6W3S0mVLugvz7KNRUU,4287
20
20
  vim_eof_comment/util.pyi,sha256=5RQukLgpVZTwbALhBOtd1NqFkiqC-V6JEWeT1_B9-2k,2675
21
- vim_eof_comment/version.py,sha256=zjS4fTklwWgIGEEbmhNg-H-iFITfpbr5clLMpAppd5s,5813
21
+ vim_eof_comment/version.py,sha256=aFNpBVEBQbzfxw3Jq_zUJYJKT54gA9D-JVvjRJ8qYDY,5843
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
25
25
  vim_eof_comment/args/completion.py,sha256=ddK6xcpR6SpcGXH7m6m6h9DhB5QMoai324WVvtwwplw,1248
26
26
  vim_eof_comment/args/completion.pyi,sha256=svMFBL6vfiqctncHkOMwxzuufzV3y5VfGic3o71UU4o,455
27
- vim_eof_comment/args/parsing.py,sha256=AOHLN-K0vzbXBwsOjUv4ZcXMDbF_BDEONonZJFwwazo,6617
28
- vim_eof_comment/args/parsing.pyi,sha256=czQNpDTfgUCv1P_bxHykUD9WDn5A8tnz396TT7oEdkY,1745
27
+ vim_eof_comment/args/parsing.py,sha256=Zp1u4--4t4lfQF8RZLhCFfE6Khlc5rcG7gHcPXaPthw,6605
28
+ vim_eof_comment/args/parsing.pyi,sha256=wJMDnW_dtIlv8NfTvf_JyTB7qwk_ZwLvCizp3GkFWhw,1741
29
29
  vim_eof_comment/comments/__init__.py,sha256=KIFAbugEKa8arCASaf7pKNHdzUC99N_T18D1CfaCOQs,292
30
30
  vim_eof_comment/comments/__init__.pyi,sha256=cecbbrShh0If8btwJ8zKYpBt9dIsMwrDXbdaBQqwUus,104
31
31
  vim_eof_comment/comments/filetypes.json,sha256=JpSrnBNO2AivLYi-C5--8yVocyBwye3IkMesNIz1uHA,2973
32
- vim_eof_comment/comments/generator.py,sha256=Mi3Yi0j-8aXQnVUsXqI1VE1yW71tWemooWgO9smSilI,7731
32
+ vim_eof_comment/comments/generator.py,sha256=tnFDM4X8KdH1zHSeceYiyskAGqfsR8yFJzOakesMa-E,7756
33
33
  vim_eof_comment/comments/generator.pyi,sha256=Nj33jwria5FWUuydUD_uZSH__PxSZ3yPxOPYF1_TIpM,3272
34
- vim_eof_comment-0.4.0.dist-info/licenses/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
35
- vim_eof_comment-0.4.0.dist-info/METADATA,sha256=UdfTEL_GC35_ulmY7fBAt0rdsBKijKG_YpLDeQtNoPA,2762
36
- vim_eof_comment-0.4.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
- vim_eof_comment-0.4.0.dist-info/entry_points.txt,sha256=vm47g4hoUbow4elcHr9yylYfj6IvAs10wSFKqwqTu6E,61
38
- vim_eof_comment-0.4.0.dist-info/top_level.txt,sha256=TkaQ5vuhVzXaJnfUdcLJCQ81ILK2V6OtvX5-hIMZAc0,21
39
- vim_eof_comment-0.4.0.dist-info/RECORD,,
34
+ vim_eof_comment-0.4.2.dist-info/licenses/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
35
+ vim_eof_comment-0.4.2.dist-info/METADATA,sha256=YJfEqi88QwH8ulUWHnVI8s0jXDwKZb0qWljE0B9E-xQ,2715
36
+ vim_eof_comment-0.4.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
+ vim_eof_comment-0.4.2.dist-info/entry_points.txt,sha256=vm47g4hoUbow4elcHr9yylYfj6IvAs10wSFKqwqTu6E,61
38
+ vim_eof_comment-0.4.2.dist-info/top_level.txt,sha256=TkaQ5vuhVzXaJnfUdcLJCQ81ILK2V6OtvX5-hIMZAc0,21
39
+ vim_eof_comment-0.4.2.dist-info/RECORD,,