omdev 0.0.0.dev99__py3-none-any.whl → 0.0.0.dev101__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.
omdev/.manifests.json CHANGED
@@ -71,18 +71,6 @@
71
71
  }
72
72
  }
73
73
  },
74
- {
75
- "module": ".findmagic",
76
- "attr": "_CLI_MODULE",
77
- "file": "omdev/findmagic.py",
78
- "line": 65,
79
- "value": {
80
- "$.cli.types.CliModule": {
81
- "cmd_name": "py/findmagic",
82
- "mod_name": "omdev.findmagic"
83
- }
84
- }
85
- },
86
74
  {
87
75
  "module": ".imgur",
88
76
  "attr": "_FOO_CLI_MODULE",
@@ -107,6 +95,18 @@
107
95
  }
108
96
  }
109
97
  },
98
+ {
99
+ "module": ".magic.find",
100
+ "attr": "_CLI_MODULE",
101
+ "file": "omdev/magic/find.py",
102
+ "line": 230,
103
+ "value": {
104
+ "$.cli.types.CliModule": {
105
+ "cmd_name": "py/findmagic",
106
+ "mod_name": "omdev.magic.find"
107
+ }
108
+ }
109
+ },
110
110
  {
111
111
  "module": ".precheck.__main__",
112
112
  "attr": "_CLI_MODULE",
omdev/amalg/amalg.py CHANGED
@@ -41,7 +41,7 @@ from omlish import lang
41
41
  from omlish import logs
42
42
  from omlish.lite.runtime import REQUIRED_PYTHON_VERSION
43
43
 
44
- from .. import findmagic
44
+ from .. import magic
45
45
  from .. import tokens as tks
46
46
 
47
47
 
@@ -94,11 +94,14 @@ def strip_main_lines(cls: ta.Sequence[Tokens]) -> list[Tokens]:
94
94
 
95
95
 
96
96
  STRIPPED_HEADER_MAGICS = [
97
- '# @omlish-lite',
98
- '# @omlish-script',
97
+ '@omlish-lite',
98
+ '@omlish-script',
99
99
  ]
100
100
 
101
- STRIPPED_HEADER_PATS = [findmagic.compile_magic_pat(m) for m in STRIPPED_HEADER_MAGICS]
101
+ STRIPPED_HEADER_PAT = magic.compile_magic_style_pat(
102
+ magic.PY_MAGIC_STYLE,
103
+ keys=STRIPPED_HEADER_MAGICS,
104
+ )
102
105
 
103
106
 
104
107
  def strip_header_lines(hls: ta.Sequence[Tokens]) -> list[Tokens]:
@@ -107,7 +110,7 @@ def strip_header_lines(hls: ta.Sequence[Tokens]) -> list[Tokens]:
107
110
  out = []
108
111
  for l in hls:
109
112
  ls = tks.join_toks(l)
110
- if not any(p.fullmatch(ls) for p in STRIPPED_HEADER_PATS):
113
+ if not STRIPPED_HEADER_PAT.fullmatch(ls):
111
114
  out.append(l)
112
115
  return out
113
116
 
@@ -3,6 +3,7 @@ TODO:
3
3
  - filesystem OPTIONAL
4
4
  - also postgres + (s3?) blobstore
5
5
  - locking
6
+ - alt codecs? json?
6
7
 
7
8
  ==
8
9
 
omdev/cexts/cmake.py CHANGED
@@ -37,7 +37,7 @@ from omlish import lang
37
37
  from omlish import logs
38
38
 
39
39
  from .. import cmake
40
- from .. import findmagic
40
+ from .. import magic
41
41
  from ..cli import CliModule
42
42
  from .magic import CextMagic
43
43
 
@@ -137,10 +137,10 @@ class CmakeProjectGen:
137
137
  out.append(e)
138
138
  elif os.path.isdir(e):
139
139
  out.extend(
140
- findmagic.find_magic(
140
+ magic.find_magic_files(
141
+ CextMagic.STYLE,
141
142
  [e],
142
- [CextMagic.MAGIC_COMMENT],
143
- CextMagic.FILE_EXTENSIONS,
143
+ keys=[CextMagic.KEY],
144
144
  ),
145
145
  )
146
146
  else:
omdev/cexts/magic.py CHANGED
@@ -1,7 +1,7 @@
1
1
  # @omlish-lite
2
+ from ..magic.styles import C_MAGIC_STYLE
2
3
 
3
- class CextMagic:
4
- MAGIC = '@omlish-cext'
5
- MAGIC_COMMENT = f'// {MAGIC}'
6
4
 
7
- FILE_EXTENSIONS = ('c', 'cc', 'cpp')
5
+ class CextMagic:
6
+ KEY = '@omlish-cext'
7
+ STYLE = C_MAGIC_STYLE
omdev/cexts/scan.py CHANGED
@@ -15,7 +15,7 @@ def scan_one(
15
15
  input_path: str,
16
16
  **kwargs: ta.Any,
17
17
  ) -> None:
18
- if not any(input_path.endswith('.' + fx) for fx in CextMagic.FILE_EXTENSIONS):
18
+ if not any(input_path.endswith('.' + fx) for fx in CextMagic.STYLE.exts):
19
19
  return
20
20
 
21
21
  with open(input_path, 'rb') as f:
@@ -26,9 +26,9 @@ def scan_one(
26
26
  except UnicodeDecodeError:
27
27
  return
28
28
 
29
- sls = [l for l in src.splitlines() if l.startswith(CextMagic.MAGIC_COMMENT)]
29
+ sls = [l for l in src.splitlines() if l.startswith('// ' + CextMagic.KEY)] # FIXME
30
30
  for sl in sls:
31
- sas = sl[len(CextMagic.MAGIC_COMMENT):].split() # noqa
31
+ sas = sl[len(CextMagic.KEY) + 3:].split() # noqa
32
32
 
33
33
  log.info('Found ext: %s', input_path)
34
34
 
omdev/clipboard/darwin.py CHANGED
@@ -123,47 +123,47 @@ def cfstring_to_string(cf_string: CFStringRef) -> str:
123
123
  ##
124
124
 
125
125
 
126
- class OsxClipboardError(Exception):
126
+ class DarwinClipboardError(Exception):
127
127
  pass
128
128
 
129
129
 
130
130
  @dc.dataclass(frozen=True)
131
- class StatusOsxClipboardError(OsxClipboardError):
131
+ class StatusDarwinClipboardError(DarwinClipboardError):
132
132
  fn: str
133
133
  status: int
134
134
 
135
135
 
136
136
  @dc.dataclass(frozen=True)
137
- class OsxClipboardItem:
137
+ class DarwinClipboardItem:
138
138
  type: str | None
139
139
  data: bytes | None
140
140
 
141
141
 
142
- def get_osx_clipboard_data(
142
+ def get_darwin_clipboard_data(
143
143
  *,
144
144
  types: ta.Container[str | None] | None = None,
145
145
  strict: bool = False,
146
146
  types_only: bool = False,
147
- ) -> list[OsxClipboardItem]:
148
- lst: list[OsxClipboardItem] = []
147
+ ) -> list[DarwinClipboardItem]:
148
+ lst: list[DarwinClipboardItem] = []
149
149
 
150
150
  pasteboard = PasteboardRef()
151
151
  if status := aps.PasteboardCreate(kPasteboardClipboard, ct.byref(pasteboard)):
152
- raise StatusOsxClipboardError('PasteboardCreate', status)
152
+ raise StatusDarwinClipboardError('PasteboardCreate', status)
153
153
 
154
154
  try:
155
155
  item_count = ct.c_ulong(0)
156
156
  if status := aps.PasteboardGetItemCount(pasteboard, ct.byref(item_count)):
157
- raise StatusOsxClipboardError('PasteboardGetItemCount', status)
157
+ raise StatusDarwinClipboardError('PasteboardGetItemCount', status)
158
158
 
159
159
  for i in range(1, item_count.value + 1):
160
160
  item_id = PasteboardItemID()
161
161
  if status := aps.PasteboardGetItemIdentifier(pasteboard, i, ct.byref(item_id)):
162
- raise StatusOsxClipboardError('PasteboardGetItemIdentifier', status)
162
+ raise StatusDarwinClipboardError('PasteboardGetItemIdentifier', status)
163
163
 
164
164
  data_types = CFArrayRef()
165
165
  if status := aps.PasteboardCopyItemFlavors(pasteboard, item_id, ct.byref(data_types)):
166
- raise StatusOsxClipboardError('PasteboardCopyItemFlavors', status)
166
+ raise StatusDarwinClipboardError('PasteboardCopyItemFlavors', status)
167
167
  if not data_types:
168
168
  continue
169
169
 
@@ -181,7 +181,7 @@ def get_osx_clipboard_data(
181
181
  continue
182
182
 
183
183
  if types_only:
184
- lst.append(OsxClipboardItem(
184
+ lst.append(DarwinClipboardItem(
185
185
  type=data_type_str,
186
186
  data=None,
187
187
  ))
@@ -191,7 +191,7 @@ def get_osx_clipboard_data(
191
191
  if status := aps.PasteboardCopyItemFlavorData(pasteboard, item_id, data_type, ct.byref(data)):
192
192
  if not strict:
193
193
  continue
194
- raise StatusOsxClipboardError('PasteboardCopyItemFlavorData', status)
194
+ raise StatusDarwinClipboardError('PasteboardCopyItemFlavorData', status)
195
195
  if not data:
196
196
  continue
197
197
 
@@ -200,7 +200,7 @@ def get_osx_clipboard_data(
200
200
  data_ptr = cf.CFDataGetBytePtr(data)
201
201
  data_bytes = ct.string_at(data_ptr, data_size)
202
202
 
203
- lst.append(OsxClipboardItem(
203
+ lst.append(DarwinClipboardItem(
204
204
  type=data_type_str,
205
205
  data=data_bytes,
206
206
  ))
@@ -221,7 +221,7 @@ def get_osx_clipboard_data(
221
221
 
222
222
 
223
223
  def _main() -> None:
224
- for i in get_osx_clipboard_data():
224
+ for i in get_darwin_clipboard_data():
225
225
  print(i)
226
226
 
227
227
 
@@ -0,0 +1,28 @@
1
+ # @omlish-lite
2
+
3
+ from .find import ( # noqa
4
+ chop_magic_block,
5
+ chop_magic_lines,
6
+ compile_magic_style_pat,
7
+ find_magic,
8
+ find_magic_files,
9
+ find_magic_py_modules,
10
+ )
11
+
12
+ from .magic import ( # noqa
13
+ Magic,
14
+ )
15
+
16
+ from .prepare import ( # noqa
17
+ MagicPrepareError,
18
+ json_magic_preparer,
19
+ py_compile_magic_preparer,
20
+ py_eval_magic_preparer,
21
+ )
22
+
23
+ from .styles import ( # noqa
24
+ C_MAGIC_STYLE,
25
+ MAGIC_KEY_PREFIX,
26
+ MagicStyle,
27
+ PY_MAGIC_STYLE,
28
+ )
omdev/magic/find.py ADDED
@@ -0,0 +1,268 @@
1
+ # ruff: noqa: UP006 UP007
2
+ import functools
3
+ import os.path
4
+ import re
5
+ import typing as ta
6
+
7
+ from .magic import Magic
8
+ from .prepare import MagicPrepareError
9
+ from .prepare import py_compile_magic_preparer
10
+ from .styles import C_MAGIC_STYLE
11
+ from .styles import PY_MAGIC_STYLE
12
+ from .styles import MagicStyle
13
+
14
+
15
+ ##
16
+
17
+
18
+ def compile_magic_style_pat(
19
+ style: MagicStyle,
20
+ *,
21
+ keys: ta.Optional[ta.Iterable[str]] = None,
22
+ ) -> re.Pattern:
23
+ ps: ta.List[str] = []
24
+ if style.line_prefix is not None:
25
+ ps.append(style.line_prefix)
26
+ if style.block_prefix_suffix is not None:
27
+ ps.append(style.block_prefix_suffix[0])
28
+ if not ps:
29
+ raise Exception('No prefixes')
30
+
31
+ ms: ta.List[str] = []
32
+ if keys is not None:
33
+ if isinstance(keys, str):
34
+ raise TypeError(keys)
35
+ for k in keys:
36
+ if not k.startswith(style.key_prefix):
37
+ raise Exception(f'Key does not start with prefix: {k!r} {style.key_prefix!r}')
38
+ ms.extend([re.escape(p + k) for p in ps])
39
+ else:
40
+ ms = [re.escape(p + style.key_prefix) + r'\S*' for p in ps]
41
+ if not ms:
42
+ raise Exception('No matchers')
43
+
44
+ b = '|'.join(f'({m})' for m in ms)
45
+ s = '^(' + b + r')($|(\s.*))'
46
+ return re.compile(s)
47
+
48
+
49
+ ##
50
+
51
+
52
+ def chop_magic_lines(
53
+ magic_key: str,
54
+ prefix: str,
55
+ lines: ta.Iterable[str],
56
+ ) -> ta.Optional[ta.List[str]]:
57
+ out: ta.List[str] = []
58
+ for i, line in enumerate(lines):
59
+ if not i:
60
+ if not line.startswith(prefix + magic_key):
61
+ return None
62
+ out.append(line[len(prefix) + len(magic_key) + 1:])
63
+ else:
64
+ if not line.startswith(prefix):
65
+ return None
66
+ out.append(line[len(prefix):])
67
+ return out
68
+
69
+
70
+ def chop_magic_block(
71
+ magic_key: str,
72
+ prefix: str,
73
+ suffix: str,
74
+ lines: ta.Iterable[str],
75
+ ) -> ta.Optional[ta.List[str]]:
76
+ out: ta.List[str] = []
77
+ for i, line in enumerate(lines):
78
+ if not i:
79
+ if not line.startswith(prefix + magic_key):
80
+ return None
81
+ s = line[len(prefix) + len(magic_key) + 1:]
82
+ if s.rstrip().endswith(suffix):
83
+ out.append(s.rstrip()[:-len(suffix)])
84
+ break
85
+ out.append(s)
86
+ elif line.rstrip().endswith(suffix):
87
+ out.append(line.rstrip()[:-len(suffix)])
88
+ break
89
+ else:
90
+ out.append(line)
91
+ return out
92
+
93
+
94
+ ##
95
+
96
+
97
+ def find_magic(
98
+ style: MagicStyle,
99
+ lines: ta.Sequence[str],
100
+ *,
101
+ file: ta.Optional[str] = None,
102
+ preparer: ta.Callable[[str], ta.Any] = py_compile_magic_preparer,
103
+ ) -> ta.List[Magic]:
104
+ out: ta.List[Magic] = []
105
+
106
+ start = 0
107
+ while start < len(lines):
108
+ start_line = lines[start]
109
+
110
+ chopper: ta.Callable[[ta.Iterable[str]], ta.Optional[ta.List[str]]]
111
+ if (
112
+ style.line_prefix is not None and
113
+ start_line.startswith(style.line_prefix + style.key_prefix)
114
+ ):
115
+ key = start_line[len(style.line_prefix):].split()[0]
116
+ chopper = functools.partial(
117
+ chop_magic_lines,
118
+ key,
119
+ style.line_prefix,
120
+ )
121
+
122
+ elif (
123
+ style.block_prefix_suffix is not None and
124
+ start_line.startswith(style.block_prefix_suffix[0] + style.key_prefix)
125
+ ):
126
+ key = start_line[len(style.block_prefix_suffix[0]):].split()[0]
127
+ chopper = functools.partial(
128
+ chop_magic_block,
129
+ key,
130
+ *style.block_prefix_suffix,
131
+ )
132
+
133
+ else:
134
+ start += 1
135
+ continue
136
+
137
+ end = start
138
+ magic: ta.Optional[Magic] = None
139
+ while end < len(lines):
140
+ block_lines = chopper(lines[start:end + 1])
141
+ if block_lines is None:
142
+ raise Exception(f'Failed to find magic block terminator : {file=} {start=} {end=}')
143
+
144
+ block_src = ''.join(block_lines)
145
+ if not block_src:
146
+ prepared = None
147
+ else:
148
+ try:
149
+ prepared = preparer(block_src)
150
+ except MagicPrepareError:
151
+ end += 1
152
+ continue
153
+
154
+ magic = Magic(
155
+ key=key,
156
+ file=file,
157
+ start_line=start + 1,
158
+ end_line=end + 1,
159
+ body=block_src,
160
+ prepared=prepared,
161
+ )
162
+ break
163
+
164
+ if magic is None:
165
+ raise Exception(f'Failed to find magic block terminator : {file=} {start=} {end=}')
166
+
167
+ out.append(magic)
168
+ start = end + 1
169
+
170
+ return out
171
+
172
+
173
+ ##
174
+
175
+
176
+ def find_magic_files(
177
+ style: MagicStyle,
178
+ roots: ta.Sequence[str],
179
+ *,
180
+ keys: ta.Optional[ta.Iterable[str]] = None,
181
+ ) -> ta.Iterator[str]:
182
+ if isinstance(roots, str):
183
+ raise TypeError(roots)
184
+
185
+ pat = compile_magic_style_pat(
186
+ style,
187
+ keys=keys,
188
+ )
189
+
190
+ for root in roots:
191
+ for dp, dns, fns in os.walk(root): # noqa
192
+ for fn in fns:
193
+ if not any(fn.endswith(f'.{x}') for x in style.exts):
194
+ continue
195
+
196
+ fp = os.path.join(dp, fn)
197
+ try:
198
+ with open(fp) as f:
199
+ src = f.read()
200
+ except UnicodeDecodeError:
201
+ continue
202
+
203
+ if not any(pat.fullmatch(l) for l in src.splitlines()):
204
+ continue
205
+
206
+ yield fp
207
+
208
+
209
+ def find_magic_py_modules(
210
+ roots: ta.Sequence[str],
211
+ *,
212
+ style: MagicStyle = PY_MAGIC_STYLE,
213
+ **kwargs: ta.Any,
214
+ ) -> ta.Iterator[str]:
215
+ for fp in find_magic_files(style, roots, **kwargs):
216
+ dp = os.path.dirname(fp)
217
+ fn = os.path.basename(fp)
218
+
219
+ if fn == '__init__.py':
220
+ yield dp.replace(os.sep, '.')
221
+ elif fn.endswith('.py'):
222
+ yield fp[:-3].replace(os.sep, '.')
223
+ else:
224
+ yield fp
225
+
226
+
227
+ ##
228
+
229
+
230
+ # @omlish-manifest
231
+ _CLI_MODULE = {'$omdev.cli.types.CliModule': {
232
+ 'cmd_name': 'py/findmagic',
233
+ 'mod_name': __name__,
234
+ }}
235
+
236
+
237
+ if __name__ == '__main__':
238
+ def _main(argv=None) -> None:
239
+ import argparse
240
+
241
+ arg_parser = argparse.ArgumentParser()
242
+ arg_parser.add_argument('--style', '-s', default='py')
243
+ arg_parser.add_argument('--key', '-k', dest='keys', action='append')
244
+ arg_parser.add_argument('--modules', action='store_true')
245
+ arg_parser.add_argument('roots', nargs='*')
246
+ args = arg_parser.parse_args(argv)
247
+
248
+ style = {
249
+ 'py': PY_MAGIC_STYLE,
250
+ 'c': C_MAGIC_STYLE,
251
+ }[args.style]
252
+
253
+ kw: dict = dict(
254
+ roots=args.roots,
255
+ style=style,
256
+ keys=args.keys,
257
+ )
258
+
259
+ fn: ta.Callable
260
+ if args.modules:
261
+ fn = find_magic_py_modules
262
+ else:
263
+ fn = find_magic_files
264
+
265
+ for out in fn(**kw):
266
+ print(out)
267
+
268
+ _main()
omdev/magic/magic.py ADDED
@@ -0,0 +1,17 @@
1
+ # ruff: noqa: UP007
2
+ import dataclasses as dc
3
+ import typing as ta
4
+
5
+
6
+ @dc.dataclass(frozen=True)
7
+ class Magic:
8
+ key: str
9
+
10
+ file: ta.Optional[str]
11
+
12
+ start_line: int
13
+ end_line: int
14
+
15
+ body: str
16
+
17
+ prepared: ta.Any
omdev/magic/prepare.py ADDED
@@ -0,0 +1,27 @@
1
+ import json
2
+ import typing as ta
3
+
4
+
5
+ class MagicPrepareError(Exception):
6
+ pass
7
+
8
+
9
+ def py_compile_magic_preparer(src: str) -> ta.Any:
10
+ try:
11
+ prepared = compile(f'({src})', '<magic>', 'eval')
12
+ except SyntaxError:
13
+ raise MagicPrepareError # noqa
14
+ return prepared
15
+
16
+
17
+ def py_eval_magic_preparer(src: str) -> ta.Any:
18
+ code = py_compile_magic_preparer(src)
19
+ return eval(code) # noqa
20
+
21
+
22
+ def json_magic_preparer(src: str) -> ta.Any:
23
+ try:
24
+ prepared = json.loads(src)
25
+ except json.JSONDecodeError:
26
+ raise MagicPrepareError # noqa
27
+ return prepared
omdev/magic/styles.py ADDED
@@ -0,0 +1,33 @@
1
+ # ruff: noqa: UP006 UP007
2
+ import dataclasses as dc
3
+ import typing as ta
4
+
5
+
6
+ MAGIC_KEY_PREFIX = '@omlish-'
7
+
8
+
9
+ @dc.dataclass(frozen=True)
10
+ class MagicStyle:
11
+ name: str
12
+
13
+ exts: ta.FrozenSet[str] = frozenset()
14
+
15
+ key_prefix: str = MAGIC_KEY_PREFIX
16
+
17
+ line_prefix: ta.Optional[str] = None
18
+ block_prefix_suffix: ta.Optional[ta.Tuple[str, str]] = None
19
+
20
+
21
+ PY_MAGIC_STYLE = MagicStyle(
22
+ name='py',
23
+ exts=frozenset(['py']),
24
+ line_prefix='# ',
25
+ )
26
+
27
+
28
+ C_MAGIC_STYLE = MagicStyle(
29
+ name='c',
30
+ exts=frozenset(['c', 'cc', 'cpp']),
31
+ line_prefix='// ',
32
+ block_prefix_suffix=('/* ', '*/'),
33
+ )
omdev/manifests/build.py CHANGED
@@ -32,7 +32,7 @@ from omlish.lite.json import json_dumps_pretty
32
32
  from omlish.lite.logs import configure_standard_logging
33
33
  from omlish.lite.logs import log
34
34
 
35
- from .. import findmagic
35
+ from .. import magic
36
36
  from .load import ManifestLoader
37
37
  from .types import Manifest
38
38
  from .types import ManifestOrigin
@@ -44,7 +44,7 @@ T = ta.TypeVar('T')
44
44
  ##
45
45
 
46
46
 
47
- MANIFEST_MAGIC = '# @omlish-manifest'
47
+ MANIFEST_MAGIC_KEY = '@omlish-manifest'
48
48
 
49
49
  _MANIFEST_GLOBAL_PAT = re.compile(r'^(?P<name>[A-Za-z_][A-Za-z0-9_]*)\s*=.*')
50
50
 
@@ -148,7 +148,7 @@ class ManifestBuilder:
148
148
  origins: ta.List[ManifestOrigin] = []
149
149
  lines = src.splitlines(keepends=True)
150
150
  for i, l in enumerate(lines):
151
- if l.startswith(MANIFEST_MAGIC):
151
+ if l.startswith('# ' + MANIFEST_MAGIC_KEY):
152
152
  if (m := _MANIFEST_GLOBAL_PAT.match(nl := lines[i + 1])) is None:
153
153
  raise Exception(nl)
154
154
 
@@ -235,10 +235,10 @@ class ManifestBuilder:
235
235
  if not os.path.isdir(pkg_dir) or not os.path.isfile(os.path.join(pkg_dir, '__init__.py')):
236
236
  raise Exception(pkg_dir)
237
237
 
238
- files = sorted(findmagic.find_magic(
238
+ files = sorted(magic.find_magic_files(
239
+ magic.PY_MAGIC_STYLE,
239
240
  [pkg_dir],
240
- [MANIFEST_MAGIC],
241
- ['py'],
241
+ keys=[MANIFEST_MAGIC_KEY],
242
242
  ))
243
243
  manifests: ta.List[Manifest] = list(itertools.chain.from_iterable(await asyncio.gather(*[
244
244
  self._spawn(
omdev/precheck/lite.py CHANGED
@@ -8,10 +8,10 @@ import subprocess
8
8
  import textwrap
9
9
  import typing as ta
10
10
 
11
- from omdev import findmagic
12
11
  from omlish import cached
13
12
  from omlish.lite.subprocesses import subprocess_maybe_shell_wrap_exec
14
13
 
14
+ from .. import magic
15
15
  from .base import Precheck
16
16
  from .base import PrecheckContext
17
17
 
@@ -121,10 +121,10 @@ class LitePython8Precheck(Precheck['LitePython8Precheck.Config']):
121
121
  return vs
122
122
 
123
123
  async def run(self) -> ta.AsyncGenerator[Precheck.Violation, None]:
124
- for fp in findmagic.find_magic(
124
+ for fp in magic.find_magic_files(
125
+ magic.PY_MAGIC_STYLE,
125
126
  self._context.src_roots,
126
- ['# @omlish-lite'],
127
- ['py'],
127
+ keys=['@omlish-lite'],
128
128
  ):
129
129
  with open(fp) as f: # noqa # FIXME
130
130
  src = f.read()