omdev 0.0.0.dev164__py3-none-any.whl → 0.0.0.dev165__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.

Potentially problematic release.


This version of omdev might be problematic. Click here for more details.

omdev/.manifests.json CHANGED
@@ -231,7 +231,7 @@
231
231
  "module": ".tools.cloc",
232
232
  "attr": "_CLI_MODULE",
233
233
  "file": "omdev/tools/cloc.py",
234
- "line": 144,
234
+ "line": 194,
235
235
  "value": {
236
236
  "$.cli.types.CliModule": {
237
237
  "cmd_name": "cloc",
omdev/tools/cloc.py CHANGED
@@ -71,15 +71,29 @@ def count_lines(file_path: str, language: str) -> FileLineCount:
71
71
  )
72
72
 
73
73
 
74
- def count_lines_in_directory(directory: str) -> ta.Mapping[str, FileLineCount]:
74
+ def count_lines_in_directory(
75
+ directory: str,
76
+ *,
77
+ include: list[re.Pattern[str]] | None = None,
78
+ exclude: list[re.Pattern[str]] | None = None,
79
+ ) -> ta.Mapping[str, FileLineCount]:
75
80
  results: dict[str, FileLineCount] = {}
76
81
  for root, _, files in os.walk(directory):
77
82
  for file in files:
78
83
  ext = os.path.splitext(file)[1]
79
- if ext in SUPPORTED_EXTENSIONS:
80
- language = SUPPORTED_EXTENSIONS[ext]
81
- file_path = os.path.join(root, file)
82
- results[file_path] = count_lines(file_path, language)
84
+ if ext not in SUPPORTED_EXTENSIONS:
85
+ continue
86
+
87
+ file_path = os.path.join(root, file)
88
+
89
+ if include and not any(p.fullmatch(file_path) for p in include):
90
+ continue
91
+ if exclude and any(p.fullmatch(file_path) for p in exclude):
92
+ continue
93
+
94
+ language = SUPPORTED_EXTENSIONS[ext]
95
+ results[file_path] = count_lines(file_path, language)
96
+
83
97
  return results
84
98
 
85
99
 
@@ -132,14 +146,50 @@ def _main() -> None:
132
146
  import argparse
133
147
 
134
148
  parser = argparse.ArgumentParser(description='Count lines of code in source files.')
149
+
135
150
  parser.add_argument('directory', help='The directory to analyze.', nargs='+')
151
+
152
+ parser.add_argument('-i,', '--include', action='append')
153
+ parser.add_argument('-e,', '--exclude', action='append')
154
+
136
155
  args = parser.parse_args()
137
156
 
157
+ #
158
+
159
+ include: list[re.Pattern[str]] | None = None
160
+ if args.include:
161
+ include = [re.compile(p) for p in args.include]
162
+
163
+ exclude: list[re.Pattern[str]] | None = None
164
+ if args.exclude:
165
+ exclude = [re.compile(p) for p in args.exclude]
166
+
167
+ #
168
+
169
+ results_by_directory: dict[str, FileLineCount] = {}
138
170
  for directory in args.directory:
139
- results = count_lines_in_directory(directory)
171
+ results = count_lines_in_directory(
172
+ directory,
173
+ include=include,
174
+ exclude=exclude,
175
+ )
176
+
177
+ if not results:
178
+ continue
179
+
140
180
  display_results(results)
141
181
  print()
142
182
 
183
+ results_by_directory[directory] = FileLineCount(
184
+ loc=sum(flc.loc for flc in results.values()),
185
+ blanks=sum(flc.blanks for flc in results.values()),
186
+ comments=sum(flc.comments for flc in results.values()),
187
+ )
188
+
189
+ if len(results_by_directory) > 1:
190
+ display_results(results_by_directory)
191
+ print()
192
+
143
193
 
144
194
  # @omlish-manifest
145
195
  _CLI_MODULE = CliModule('cloc', __name__)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omdev
3
- Version: 0.0.0.dev164
3
+ Version: 0.0.0.dev165
4
4
  Summary: omdev
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -12,7 +12,7 @@ Classifier: Operating System :: OS Independent
12
12
  Classifier: Operating System :: POSIX
13
13
  Requires-Python: >=3.12
14
14
  License-File: LICENSE
15
- Requires-Dist: omlish==0.0.0.dev164
15
+ Requires-Dist: omlish==0.0.0.dev165
16
16
  Provides-Extra: all
17
17
  Requires-Dist: black~=24.10; extra == "all"
18
18
  Requires-Dist: pycparser~=2.22; extra == "all"
@@ -1,4 +1,4 @@
1
- omdev/.manifests.json,sha256=Dm-Nd3V7Ry9d3-tO5OnUM7IYT2_ldruPEjxcSr4BA1U,8306
1
+ omdev/.manifests.json,sha256=tF8O0ywJseQMbbhT2b67QAvjuAaHXLY1MyjeMrDObos,8306
2
2
  omdev/__about__.py,sha256=n5x-SO70OgbDQFzQ1d7sZDVMsnkQc4PxQZPFaIQFa0E,1281
3
3
  omdev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  omdev/bracepy.py,sha256=I8EdqtDvxzAi3I8TuMEW-RBfwXfqKbwp06CfOdj3L1o,2743
@@ -142,7 +142,7 @@ omdev/toml/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
142
142
  omdev/toml/parser.py,sha256=ojhCYIk23ELRx2f9xUCwLTRq13UM6wrYGWoyxZBurlo,29327
143
143
  omdev/toml/writer.py,sha256=lk3on3YXVbWuLJa-xsOzOhs1bBAT1vXqw4mBbluZl_w,3040
144
144
  omdev/tools/__init__.py,sha256=iVJAOQ0viGTQOm0DLX4uZLro-9jOioYJGLg9s0kDx1A,78
145
- omdev/tools/cloc.py,sha256=13lUsYLyn1LoelhsCeKrRkIwwPE0x54JmdhXJ_lvWh0,3811
145
+ omdev/tools/cloc.py,sha256=r5HkvaLoGw8djgvGdt_W_CjfSklW585dar9bDhDFeF8,5098
146
146
  omdev/tools/doc.py,sha256=iblgUq9_7JZN2i8qmvewrz4OX0paObscBaCj8u77WqI,2555
147
147
  omdev/tools/docker.py,sha256=mu0sWnH_L1JjScfWCXXYaux03mcotCS03SD65I93qHI,7384
148
148
  omdev/tools/git.py,sha256=zfdPnN-9WSeOQlLoTw5aqAX-UWvz-2p330dx_zaU0WQ,7014
@@ -164,9 +164,9 @@ omdev/tools/json/rendering.py,sha256=jNShMfCpFR9-Kcn6cUFuOChXHjg71diuTC4x7Ofmz-o
164
164
  omdev/tools/pawk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
165
165
  omdev/tools/pawk/__main__.py,sha256=VCqeRVnqT1RPEoIrqHFSu4PXVMg4YEgF4qCQm90-eRI,66
166
166
  omdev/tools/pawk/pawk.py,sha256=Eckymn22GfychCQcQi96BFqRo_LmiJ-EPhC8TTUJdB4,11446
167
- omdev-0.0.0.dev164.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
168
- omdev-0.0.0.dev164.dist-info/METADATA,sha256=83Zwo5XiW3PNQLrwzB3Kdi4NKBsU1LXpTyZ2sd1HaR4,1760
169
- omdev-0.0.0.dev164.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
170
- omdev-0.0.0.dev164.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
171
- omdev-0.0.0.dev164.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
172
- omdev-0.0.0.dev164.dist-info/RECORD,,
167
+ omdev-0.0.0.dev165.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
168
+ omdev-0.0.0.dev165.dist-info/METADATA,sha256=djJeiQrUAVjts2OjpttnE69PQiKuV_wm3QIHBEWaS8A,1760
169
+ omdev-0.0.0.dev165.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
170
+ omdev-0.0.0.dev165.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
171
+ omdev-0.0.0.dev165.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
172
+ omdev-0.0.0.dev165.dist-info/RECORD,,