omdev 0.0.0.dev79__tar.gz → 0.0.0.dev81__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.

Potentially problematic release.


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

Files changed (139) hide show
  1. {omdev-0.0.0.dev79/omdev.egg-info → omdev-0.0.0.dev81}/PKG-INFO +2 -2
  2. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/.manifests.json +36 -0
  3. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/amalg/amalg.py +31 -1
  4. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/bracepy.py +7 -0
  5. omdev-0.0.0.dev81/omdev/clipboard/clipboard.py +23 -0
  6. omdev-0.0.0.dev81/omdev/clipboard/darwin.py +229 -0
  7. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/findimports.py +10 -4
  8. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/findmagic.py +7 -0
  9. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/manifests/build.py +1 -1
  10. omdev-0.0.0.dev81/omdev/precheck/__init__.py +0 -0
  11. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/precheck/__main__.py +1 -1
  12. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/precheck/lite.py +12 -7
  13. omdev-0.0.0.dev79/omdev/precheck/precheck.py → omdev-0.0.0.dev81/omdev/precheck/main.py +7 -3
  14. omdev-0.0.0.dev81/omdev/precheck/manifests.py +26 -0
  15. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/scripts/pyproject.py +7 -0
  16. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81/omdev.egg-info}/PKG-INFO +2 -2
  17. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev.egg-info/SOURCES.txt +5 -1
  18. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev.egg-info/requires.txt +1 -1
  19. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/pyproject.toml +2 -2
  20. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/LICENSE +0 -0
  21. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/MANIFEST.in +0 -0
  22. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/README.rst +0 -0
  23. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/__about__.py +0 -0
  24. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/__init__.py +0 -0
  25. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/amalg/__init__.py +0 -0
  26. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/amalg/__main__.py +0 -0
  27. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/antlr/__init__.py +0 -0
  28. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/antlr/_antlr/__init__.py +0 -0
  29. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/antlr/consts.py +0 -0
  30. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/antlr/gen.py +0 -0
  31. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cache/__init__.py +0 -0
  32. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cache/compute/__init__.py +0 -0
  33. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cache/compute/cache.py +0 -0
  34. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cache/compute/contexts.py +0 -0
  35. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cache/compute/currents.py +0 -0
  36. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cache/compute/fns.py +0 -0
  37. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cache/compute/resolvers.py +0 -0
  38. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cache/compute/storage.py +0 -0
  39. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cache/compute/types.py +0 -0
  40. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cache/data/__init__.py +0 -0
  41. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cache/data/actions.py +0 -0
  42. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cache/data/cache.py +0 -0
  43. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cache/data/consts.py +0 -0
  44. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cache/data/defaults.py +0 -0
  45. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cache/data/manifests.py +0 -0
  46. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cache/data/specs.py +0 -0
  47. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/__init__.py +0 -0
  48. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/_boilerplate.cc +0 -0
  49. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/_distutils/LICENSE +0 -0
  50. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/_distutils/__init__.py +0 -0
  51. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/_distutils/build_ext.py +0 -0
  52. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/_distutils/compilers/__init__.py +0 -0
  53. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/_distutils/compilers/ccompiler.py +0 -0
  54. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/_distutils/compilers/options.py +0 -0
  55. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/_distutils/compilers/unixccompiler.py +0 -0
  56. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/_distutils/dir_util.py +0 -0
  57. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/_distutils/errors.py +0 -0
  58. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/_distutils/extension.py +0 -0
  59. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/_distutils/file_util.py +0 -0
  60. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/_distutils/modified.py +0 -0
  61. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/_distutils/spawn.py +0 -0
  62. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/_distutils/sysconfig.py +0 -0
  63. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/_distutils/util.py +0 -0
  64. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/_distutils/version.py +0 -0
  65. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/build.py +0 -0
  66. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/cmake.py +0 -0
  67. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/importhook.py +0 -0
  68. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/magic.py +0 -0
  69. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cexts/scan.py +0 -0
  70. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/classdot.py +0 -0
  71. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cli/__init__.py +0 -0
  72. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cli/__main__.py +0 -0
  73. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cli/_pathhack.py +0 -0
  74. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cli/clicli.py +0 -0
  75. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cli/install.py +0 -0
  76. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cli/main.py +0 -0
  77. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cli/managers.py +0 -0
  78. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cli/types.py +0 -0
  79. {omdev-0.0.0.dev79/omdev/mypy → omdev-0.0.0.dev81/omdev/clipboard}/__init__.py +0 -0
  80. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/cmake.py +0 -0
  81. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/git.py +0 -0
  82. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/imgur.py +0 -0
  83. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/interp/__init__.py +0 -0
  84. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/interp/__main__.py +0 -0
  85. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/interp/cli.py +0 -0
  86. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/interp/inspect.py +0 -0
  87. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/interp/providers.py +0 -0
  88. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/interp/pyenv.py +0 -0
  89. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/interp/resolvers.py +0 -0
  90. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/interp/standalone.py +0 -0
  91. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/interp/system.py +0 -0
  92. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/interp/types.py +0 -0
  93. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/manifests/__init__.py +0 -0
  94. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/manifests/load.py +0 -0
  95. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/manifests/types.py +0 -0
  96. {omdev-0.0.0.dev79/omdev/precheck → omdev-0.0.0.dev81/omdev/mypy}/__init__.py +0 -0
  97. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/mypy/debug.py +0 -0
  98. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/packaging/__init__.py +0 -0
  99. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/packaging/names.py +0 -0
  100. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/packaging/requires.py +0 -0
  101. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/packaging/specifiers.py +0 -0
  102. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/packaging/versions.py +0 -0
  103. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/precheck/base.py +0 -0
  104. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/precheck/git.py +0 -0
  105. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/precheck/scripts.py +0 -0
  106. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/pyproject/__init__.py +0 -0
  107. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/pyproject/__main__.py +0 -0
  108. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/pyproject/cexts.py +0 -0
  109. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/pyproject/cli.py +0 -0
  110. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/pyproject/configs.py +0 -0
  111. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/pyproject/pkg.py +0 -0
  112. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/pyproject/reqs.py +0 -0
  113. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/revisions.py +0 -0
  114. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/scripts/__init__.py +0 -0
  115. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/scripts/bumpversion.py +0 -0
  116. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/scripts/execrss.py +0 -0
  117. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/scripts/exectime.py +0 -0
  118. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/scripts/importtrace.py +0 -0
  119. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/scripts/interp.py +0 -0
  120. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/secrets.py +0 -0
  121. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/tokens.py +0 -0
  122. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/toml/__init__.py +0 -0
  123. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/toml/parser.py +0 -0
  124. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/toml/writer.py +0 -0
  125. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/tools/__init__.py +0 -0
  126. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/tools/dockertools.py +0 -0
  127. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/tools/gittools.py +0 -0
  128. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/tools/importscan.py +0 -0
  129. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/tools/mkrelimp.py +0 -0
  130. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/tools/nbtools.py +0 -0
  131. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/tools/piptools.py +0 -0
  132. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/tools/proftools.py +0 -0
  133. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/tools/rsttool.py +0 -0
  134. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/tools/sqlrepl.py +0 -0
  135. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev/wheelfile.py +0 -0
  136. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev.egg-info/dependency_links.txt +0 -0
  137. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev.egg-info/entry_points.txt +0 -0
  138. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/omdev.egg-info/top_level.txt +0 -0
  139. {omdev-0.0.0.dev79 → omdev-0.0.0.dev81}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omdev
3
- Version: 0.0.0.dev79
3
+ Version: 0.0.0.dev81
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.dev79
15
+ Requires-Dist: omlish==0.0.0.dev81
16
16
  Provides-Extra: all
17
17
  Requires-Dist: black~=24.10; extra == "all"
18
18
  Requires-Dist: pycparser~=2.22; extra == "all"
@@ -11,6 +11,18 @@
11
11
  }
12
12
  }
13
13
  },
14
+ {
15
+ "module": ".bracepy",
16
+ "attr": "_CLI_MODULE",
17
+ "file": "omdev/bracepy.py",
18
+ "line": 88,
19
+ "value": {
20
+ "$.cli.types.CliModule": {
21
+ "cmd_name": "bracepy",
22
+ "mod_name": "omdev.bracepy"
23
+ }
24
+ }
25
+ },
14
26
  {
15
27
  "module": ".cexts.cmake",
16
28
  "attr": "_CLI_MODULE",
@@ -47,6 +59,30 @@
47
59
  }
48
60
  }
49
61
  },
62
+ {
63
+ "module": ".findimports",
64
+ "attr": "_CLI_MODULE",
65
+ "file": "omdev/findimports.py",
66
+ "line": 81,
67
+ "value": {
68
+ "$.cli.types.CliModule": {
69
+ "cmd_name": "py/findimports",
70
+ "mod_name": "omdev.findimports"
71
+ }
72
+ }
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
+ },
50
86
  {
51
87
  "module": ".imgur",
52
88
  "attr": "_FOO_CLI_MODULE",
@@ -24,6 +24,7 @@ Targets:
24
24
  - supervisor?
25
25
  """
26
26
  import argparse
27
+ import ast
27
28
  import dataclasses as dc
28
29
  import io
29
30
  import logging
@@ -297,7 +298,11 @@ def make_src_file(
297
298
  tys: list[Typing] = []
298
299
  ctls: list[Tokens] = []
299
300
 
300
- for line in cls:
301
+ i = 0
302
+ while i < len(cls):
303
+ line = cls[i]
304
+ i += 1
305
+
301
306
  if (imp := make_import(
302
307
  line,
303
308
  src_path=path,
@@ -311,6 +316,31 @@ def make_src_file(
311
316
  )) is not None:
312
317
  tys.append(ty)
313
318
 
319
+ elif (
320
+ line and
321
+ (ft := line[0]).name == 'COMMENT' and
322
+ ft.src.startswith('# @omlish-manifest')
323
+ ):
324
+ mls = [line]
325
+ while True:
326
+ mls.append(cls[i])
327
+ i += 1
328
+
329
+ msrc = tks.join_lines(mls).strip()
330
+ try:
331
+ node = ast.parse(msrc)
332
+ except SyntaxError:
333
+ continue
334
+
335
+ mmod = check.isinstance(node, ast.Module)
336
+ check.isinstance(check.single(mmod.body), ast.Assign)
337
+ break
338
+
339
+ ctls.extend([
340
+ [trt.Token('COMMENT', '# ' + tks.join_toks(ml))]
341
+ for ml in mls
342
+ ])
343
+
314
344
  else:
315
345
  ctls.append(line)
316
346
 
@@ -85,6 +85,13 @@ def translate_brace_python(
85
85
  return ret.getvalue()
86
86
 
87
87
 
88
+ # @omlish-manifest
89
+ _CLI_MODULE = {'$omdev.cli.types.CliModule': {
90
+ 'cmd_name': 'bracepy',
91
+ 'mod_name': __name__,
92
+ }}
93
+
94
+
88
95
  if __name__ == '__main__':
89
96
  def _main(argv=None) -> None:
90
97
  import argparse
@@ -0,0 +1,23 @@
1
+ """
2
+ https://askubuntu.com/questions/11925/a-command-line-clipboard-copy-and-paste-utility
3
+ """
4
+ import abc
5
+ import subprocess
6
+
7
+
8
+ class Clipboard(abc.ABC):
9
+ @abc.abstractmethod
10
+ def get(self) -> str:
11
+ raise NotImplementedError
12
+
13
+ @abc.abstractmethod
14
+ def put(self, s: str) -> None:
15
+ raise NotImplementedError
16
+
17
+
18
+ class DarwinClipboard(Clipboard):
19
+ def get(self) -> str:
20
+ return subprocess.check_output(['pbpaste']).decode('utf-8')
21
+
22
+ def put(self, s: str) -> None:
23
+ subprocess.run(['pbcopy'], input=s.encode('utf-8'), check=True)
@@ -0,0 +1,229 @@
1
+ # ruff: noqa: N802 N816
2
+ import ctypes as ct
3
+ import ctypes.util
4
+ import dataclasses as dc
5
+ import sys
6
+ import typing as ta
7
+
8
+ from omlish import check
9
+
10
+
11
+ ##
12
+
13
+
14
+ if getattr(sys, 'platform') != 'darwin':
15
+ raise OSError(sys.platform)
16
+
17
+
18
+ ##
19
+ # CoreFoundation
20
+
21
+ cf = ct.cdll.LoadLibrary(check.not_none(ct.util.find_library('CoreFoundation')))
22
+
23
+ #
24
+
25
+ CFArrayRef = ct.c_void_p
26
+ CFDataRef = ct.c_void_p
27
+ CFIndex = ct.c_long
28
+ CFStringEncoding = ct.c_uint32
29
+ CFStringRef = ct.c_void_p
30
+ CFTypeID = ct.c_ulong
31
+
32
+ #
33
+
34
+ cf.CFArrayGetCount.argtypes = [CFArrayRef]
35
+ cf.CFArrayGetCount.restype = CFIndex
36
+
37
+ cf.CFArrayGetValueAtIndex.argtypes = [CFArrayRef, CFIndex]
38
+ cf.CFArrayGetValueAtIndex.restype = CFStringRef
39
+
40
+ cf.CFDataGetBytePtr.argtypes = [CFDataRef]
41
+ cf.CFDataGetBytePtr.restype = ct.POINTER(ct.c_uint8)
42
+
43
+ cf.CFDataGetLength.argtypes = [CFDataRef]
44
+ cf.CFDataGetLength.restype = CFIndex
45
+
46
+ cf.CFGetTypeID.argtypes = [ct.c_void_p]
47
+ cf.CFGetTypeID.restype = CFTypeID
48
+
49
+ cf.CFRelease.argtypes = [ct.c_void_p]
50
+ cf.CFRelease.restype = None
51
+
52
+ cf.CFStringCreateWithCString.argtypes = [ct.c_void_p, ct.c_char_p, ct.c_int32]
53
+ cf.CFStringCreateWithCString.restype = CFStringRef
54
+
55
+ cf.CFStringGetCString.argtypes = [CFStringRef, ct.c_char_p, ct.c_long, ct.c_uint32]
56
+ cf.CFStringGetCString.restype = ct.c_bool
57
+
58
+ cf.CFStringGetLength.argtypes = [CFStringRef]
59
+ cf.CFStringGetLength.restype = CFIndex
60
+
61
+ cf.CFStringGetMaximumSizeForEncoding.argtypes = [CFIndex, CFStringEncoding]
62
+ cf.CFStringGetMaximumSizeForEncoding.restype = CFIndex
63
+
64
+ cf.CFStringGetTypeID.argtypes = []
65
+ cf.CFStringGetTypeID.restype = CFTypeID
66
+
67
+
68
+ ##
69
+ # ApplicationServices
70
+
71
+ aps = ct.cdll.LoadLibrary(check.not_none(ct.util.find_library('ApplicationServices')))
72
+
73
+ #
74
+
75
+ OSStatus = ct.c_int32
76
+
77
+ PasteboardItemID = ct.c_ulong
78
+ PasteboardRef = ct.c_void_p
79
+
80
+ #
81
+
82
+ aps.PasteboardCopyItemFlavorData.argtypes = [PasteboardRef, PasteboardItemID, CFStringRef, ct.POINTER(CFDataRef)]
83
+ aps.PasteboardCopyItemFlavorData.restype = OSStatus
84
+
85
+ aps.PasteboardCopyItemFlavors.argtypes = [PasteboardRef, PasteboardItemID, ct.POINTER(CFArrayRef)]
86
+ aps.PasteboardCopyItemFlavors.restype = OSStatus
87
+
88
+ aps.PasteboardCreate.argtypes = [CFStringRef, ct.POINTER(PasteboardRef)]
89
+ aps.PasteboardCreate.restype = OSStatus
90
+
91
+ aps.PasteboardGetItemCount.argtypes = [PasteboardRef, ct.POINTER(ct.c_ulong)]
92
+ aps.PasteboardGetItemCount.restype = OSStatus
93
+
94
+ aps.PasteboardGetItemIdentifier.argtypes = [PasteboardRef, ct.c_ulong, ct.POINTER(PasteboardItemID)]
95
+ aps.PasteboardGetItemIdentifier.restype = OSStatus
96
+
97
+
98
+ ##
99
+
100
+
101
+ def CFSTR(string):
102
+ return cf.CFStringCreateWithCString(None, string.encode('utf-8'), 0)
103
+
104
+
105
+ kCFStringEncodingUTF8 = 0x08000100
106
+ kPasteboardClipboard = CFSTR('com.apple.pasteboard.clipboard')
107
+
108
+
109
+ def cfstring_to_string(cf_string: CFStringRef) -> str:
110
+ if not cf_string:
111
+ return ''
112
+
113
+ length = cf.CFStringGetLength(cf_string)
114
+ max_size = cf.CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1
115
+ buffer = ct.create_string_buffer(max_size)
116
+
117
+ if success := cf.CFStringGetCString(cf_string, buffer, max_size, kCFStringEncodingUTF8): # noqa
118
+ return ''
119
+
120
+ return buffer.value.decode('utf-8')
121
+
122
+
123
+ ##
124
+
125
+
126
+ class OsxClipboardError(Exception):
127
+ pass
128
+
129
+
130
+ @dc.dataclass(frozen=True)
131
+ class StatusOsxClipboardError(OsxClipboardError):
132
+ fn: str
133
+ status: int
134
+
135
+
136
+ @dc.dataclass(frozen=True)
137
+ class OsxClipboardItem:
138
+ type: str | None
139
+ data: bytes | None
140
+
141
+
142
+ def get_osx_clipboard_data(
143
+ *,
144
+ types: ta.Container[str | None] | None = None,
145
+ strict: bool = False,
146
+ types_only: bool = False,
147
+ ) -> list[OsxClipboardItem]:
148
+ lst: list[OsxClipboardItem] = []
149
+
150
+ pasteboard = PasteboardRef()
151
+ if status := aps.PasteboardCreate(kPasteboardClipboard, ct.byref(pasteboard)):
152
+ raise StatusOsxClipboardError('PasteboardCreate', status)
153
+
154
+ try:
155
+ item_count = ct.c_ulong(0)
156
+ if status := aps.PasteboardGetItemCount(pasteboard, ct.byref(item_count)):
157
+ raise StatusOsxClipboardError('PasteboardGetItemCount', status)
158
+
159
+ for i in range(1, item_count.value + 1):
160
+ item_id = PasteboardItemID()
161
+ if status := aps.PasteboardGetItemIdentifier(pasteboard, i, ct.byref(item_id)):
162
+ raise StatusOsxClipboardError('PasteboardGetItemIdentifier', status)
163
+
164
+ data_types = CFArrayRef()
165
+ if status := aps.PasteboardCopyItemFlavors(pasteboard, item_id, ct.byref(data_types)):
166
+ raise StatusOsxClipboardError('PasteboardCopyItemFlavors', status)
167
+ if not data_types:
168
+ continue
169
+
170
+ try:
171
+ type_count = cf.CFArrayGetCount(data_types)
172
+ for j in range(type_count):
173
+ data_type = cf.CFArrayGetValueAtIndex(data_types, j)
174
+
175
+ if cf.CFGetTypeID(data_type) == cf.CFStringGetTypeID():
176
+ data_type_str = cfstring_to_string(data_type)
177
+ else:
178
+ data_type_str = None
179
+
180
+ if types is not None and data_type_str not in types:
181
+ continue
182
+
183
+ if types_only:
184
+ lst.append(OsxClipboardItem(
185
+ type=data_type_str,
186
+ data=None,
187
+ ))
188
+ continue
189
+
190
+ data = CFDataRef()
191
+ if status := aps.PasteboardCopyItemFlavorData(pasteboard, item_id, data_type, ct.byref(data)):
192
+ if not strict:
193
+ continue
194
+ raise StatusOsxClipboardError('PasteboardCopyItemFlavorData', status)
195
+ if not data:
196
+ continue
197
+
198
+ try:
199
+ data_size = cf.CFDataGetLength(data)
200
+ data_ptr = cf.CFDataGetBytePtr(data)
201
+ data_bytes = ct.string_at(data_ptr, data_size)
202
+
203
+ lst.append(OsxClipboardItem(
204
+ type=data_type_str,
205
+ data=data_bytes,
206
+ ))
207
+
208
+ finally:
209
+ cf.CFRelease(data)
210
+
211
+ finally:
212
+ cf.CFRelease(data_types)
213
+
214
+ finally:
215
+ cf.CFRelease(pasteboard)
216
+
217
+ return lst
218
+
219
+
220
+ ##
221
+
222
+
223
+ def _main() -> None:
224
+ for i in get_osx_clipboard_data():
225
+ print(i)
226
+
227
+
228
+ if __name__ == '__main__':
229
+ _main()
@@ -78,11 +78,17 @@ def get_import_deps(imps: set[str]) -> set[str]:
78
78
  return {i for i in eimps if whichmod(i) != 'builtin'}
79
79
 
80
80
 
81
- def _main() -> None:
82
- imps = find_imports(*sys.argv[1:])
83
- deps = get_import_deps(imps)
84
- print(chr(10).join(sorted(deps)))
81
+ # @omlish-manifest
82
+ _CLI_MODULE = {'$omdev.cli.types.CliModule': {
83
+ 'cmd_name': 'py/findimports',
84
+ 'mod_name': __name__,
85
+ }}
85
86
 
86
87
 
87
88
  if __name__ == '__main__':
89
+ def _main() -> None:
90
+ imps = find_imports(*sys.argv[1:])
91
+ deps = get_import_deps(imps)
92
+ print(chr(10).join(sorted(deps)))
93
+
88
94
  _main()
@@ -62,6 +62,13 @@ def find_magic(
62
62
  yield out
63
63
 
64
64
 
65
+ # @omlish-manifest
66
+ _CLI_MODULE = {'$omdev.cli.types.CliModule': {
67
+ 'cmd_name': 'py/findmagic',
68
+ 'mod_name': __name__,
69
+ }}
70
+
71
+
65
72
  if __name__ == '__main__':
66
73
  def _main(argv=None) -> None:
67
74
  import argparse
@@ -1,7 +1,7 @@
1
1
  """
2
2
  TODO:
3
3
  - separate build from cli
4
- - parallelize & sort
4
+ - verify classes instantiate
5
5
 
6
6
  See (entry_points):
7
7
  - https://github.com/pytest-dev/pluggy/blob/main/src/pluggy/_manager.py#L405
File without changes
@@ -6,6 +6,6 @@ _CLI_MODULE = CliModule('precheck', __name__)
6
6
 
7
7
 
8
8
  if __name__ == '__main__':
9
- from .precheck import _main
9
+ from .main import _main
10
10
 
11
11
  _main()
@@ -10,6 +10,7 @@ import typing as ta
10
10
 
11
11
  from omdev import findmagic
12
12
  from omlish import cached
13
+ from omlish.lite.subprocesses import subprocess_maybe_shell_wrap_exec
13
14
 
14
15
  from .base import Precheck
15
16
  from .base import PrecheckContext
@@ -69,10 +70,12 @@ class LitePython8Precheck(Precheck['LitePython8Precheck.Config']):
69
70
  vs: list[Precheck.Violation] = []
70
71
 
71
72
  proc = await asyncio.create_subprocess_exec(
72
- '.venvs/8/bin/python',
73
- '-c',
74
- self._load_file_module_payload(),
75
- fp,
73
+ *subprocess_maybe_shell_wrap_exec(
74
+ '.venvs/8/bin/python',
75
+ '-c',
76
+ self._load_file_module_payload(),
77
+ fp,
78
+ ),
76
79
  stderr=subprocess.PIPE,
77
80
  )
78
81
 
@@ -90,9 +93,11 @@ class LitePython8Precheck(Precheck['LitePython8Precheck.Config']):
90
93
  log.debug('%s: loading module %s', self.__class__.__name__, mod)
91
94
 
92
95
  proc = await asyncio.create_subprocess_exec(
93
- '.venvs/8/bin/python',
94
- '-c',
95
- f'import {mod}',
96
+ *subprocess_maybe_shell_wrap_exec(
97
+ '.venvs/8/bin/python',
98
+ '-c',
99
+ f'import {mod}',
100
+ ),
96
101
  stderr=subprocess.PIPE,
97
102
  )
98
103
 
@@ -2,7 +2,7 @@
2
2
  Tiny pre-commit
3
3
 
4
4
  TODO:
5
- - ! manifests
5
+ - define new prechecks with manifests
6
6
  - global config
7
7
  - global analyses - FilesWithShebang
8
8
  - shebang files have no relative imports
@@ -31,6 +31,7 @@ from .base import Precheck
31
31
  from .base import PrecheckContext
32
32
  from .git import GitBlacklistPrecheck
33
33
  from .lite import LitePython8Precheck
34
+ from .manifests import ManifestsPrecheck
34
35
  from .scripts import ScriptDepsPrecheck
35
36
 
36
37
 
@@ -52,6 +53,7 @@ def _check_cmd(args) -> None:
52
53
  GitBlacklistPrecheck(ctx),
53
54
  ScriptDepsPrecheck(ctx),
54
55
  LitePython8Precheck(ctx),
56
+ ManifestsPrecheck(ctx),
55
57
  ]
56
58
 
57
59
  async def run() -> list[Precheck.Violation]:
@@ -81,16 +83,18 @@ def _build_parser() -> argparse.ArgumentParser:
81
83
 
82
84
  parser_check = subparsers.add_parser('check')
83
85
  parser_check.add_argument('roots', nargs='+')
86
+ parser_check.add_argument('-v', '--verbose', action='store_true')
84
87
  parser_check.set_defaults(func=_check_cmd)
85
88
 
86
89
  return parser
87
90
 
88
91
 
89
92
  def _main(argv: ta.Sequence[str] | None = None) -> None:
90
- logs.configure_standard_logging('INFO')
91
-
92
93
  parser = _build_parser()
93
94
  args = parser.parse_args(argv)
95
+
96
+ logs.configure_standard_logging('DEBUG' if args.verbose else 'INFO')
97
+
94
98
  if not getattr(args, 'func', None):
95
99
  parser.print_help()
96
100
  else:
@@ -0,0 +1,26 @@
1
+ import dataclasses as dc
2
+ import typing as ta
3
+
4
+ from ..manifests.load import ManifestLoader
5
+ from .base import Precheck
6
+ from .base import PrecheckContext
7
+
8
+
9
+ ##
10
+
11
+
12
+ class ManifestsPrecheck(Precheck['ManifestsPrecheck.Config']):
13
+ @dc.dataclass(frozen=True)
14
+ class Config(Precheck.Config):
15
+ pass
16
+
17
+ def __init__(self, context: PrecheckContext, config: Config = Config()) -> None:
18
+ super().__init__(context, config)
19
+
20
+ async def run(self) -> ta.AsyncGenerator[Precheck.Violation, None]:
21
+ for src_root in self._context.src_roots:
22
+ ml = ManifestLoader()
23
+ try:
24
+ ml.load(src_root)
25
+ except Exception as e: # noqa
26
+ yield Precheck.Violation(self, f'Error loading manifest for {src_root}: {e!r}')
@@ -170,6 +170,13 @@ def find_magic(
170
170
  yield out
171
171
 
172
172
 
173
+ # # @omlish-manifest
174
+ # _CLI_MODULE = {'$omdev.cli.types.CliModule': {
175
+ # 'cmd_name': 'py/findmagic',
176
+ # 'mod_name': __name__,
177
+ # }}
178
+
179
+
173
180
  ########################################
174
181
  # ../../git.py
175
182
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omdev
3
- Version: 0.0.0.dev79
3
+ Version: 0.0.0.dev81
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.dev79
15
+ Requires-Dist: omlish==0.0.0.dev81
16
16
  Provides-Extra: all
17
17
  Requires-Dist: black~=24.10; extra == "all"
18
18
  Requires-Dist: pycparser~=2.22; extra == "all"
@@ -76,6 +76,9 @@ omdev/cli/install.py
76
76
  omdev/cli/main.py
77
77
  omdev/cli/managers.py
78
78
  omdev/cli/types.py
79
+ omdev/clipboard/__init__.py
80
+ omdev/clipboard/clipboard.py
81
+ omdev/clipboard/darwin.py
79
82
  omdev/interp/__init__.py
80
83
  omdev/interp/__main__.py
81
84
  omdev/interp/cli.py
@@ -102,7 +105,8 @@ omdev/precheck/__main__.py
102
105
  omdev/precheck/base.py
103
106
  omdev/precheck/git.py
104
107
  omdev/precheck/lite.py
105
- omdev/precheck/precheck.py
108
+ omdev/precheck/main.py
109
+ omdev/precheck/manifests.py
106
110
  omdev/precheck/scripts.py
107
111
  omdev/pyproject/__init__.py
108
112
  omdev/pyproject/__main__.py
@@ -1,4 +1,4 @@
1
- omlish==0.0.0.dev79
1
+ omlish==0.0.0.dev81
2
2
 
3
3
  [all]
4
4
  black~=24.10
@@ -12,7 +12,7 @@ authors = [
12
12
  urls = {source = 'https://github.com/wrmsr/omlish'}
13
13
  license = {text = 'BSD-3-Clause'}
14
14
  requires-python = '~=3.12'
15
- version = '0.0.0.dev79'
15
+ version = '0.0.0.dev81'
16
16
  classifiers = [
17
17
  'License :: OSI Approved :: BSD License',
18
18
  'Development Status :: 2 - Pre-Alpha',
@@ -22,7 +22,7 @@ classifiers = [
22
22
  ]
23
23
  description = 'omdev'
24
24
  dependencies = [
25
- 'omlish == 0.0.0.dev79',
25
+ 'omlish == 0.0.0.dev81',
26
26
  ]
27
27
 
28
28
  [project.optional-dependencies]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes