fontlab-grablab 1.1.16__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.
@@ -0,0 +1,268 @@
1
+ Metadata-Version: 2.5
2
+ Name: fontlab-grablab
3
+ Version: 1.1.16
4
+ Summary: FontLab screenshot and vector export helpers
5
+ Project-URL: Repository, https://github.com/fontlabcom/fontlab-grablab
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.11
9
+ Requires-Dist: fontlab-fontlabapp>=1.2.0
10
+ Provides-Extra: svg
11
+ Requires-Dist: cssselect2>=0.8; extra == 'svg'
12
+ Requires-Dist: pillow>=10; extra == 'svg'
13
+ Requires-Dist: svgelements>=1.9.6; extra == 'svg'
14
+ Requires-Dist: tinycss2>=1.4; extra == 'svg'
15
+ Provides-Extra: test
16
+ Requires-Dist: cssselect2>=0.8; extra == 'test'
17
+ Requires-Dist: pillow>=10; extra == 'test'
18
+ Requires-Dist: pytest>=8; extra == 'test'
19
+ Requires-Dist: svgelements>=1.9.6; extra == 'test'
20
+ Requires-Dist: tinycss2>=1.4; extra == 'test'
21
+ Description-Content-Type: text/markdown
22
+
23
+ ---
24
+ this_file: README.md
25
+ ---
26
+
27
+ ## Development status — 2026-11-05
28
+
29
+ Canonical source inspected for this proposal: `91a03a858f50`. This is a dated source observation, not an installed or native acceptance claim.
30
+
31
+ Keep capture and SVG/icon modes aligned with reviewed App APIs and current supported native bindings.
32
+
33
+ Qualify genuine distributions and owned native capture/rendering separately; preserve archived source and existing input provenance.
34
+
35
+ ## Repository and development
36
+
37
+ `src/` holds capture utilities; `examples/` shows their use; `tests/` covers offline behavior. `MIGRATION.json` records `legacy/source.tar.gz` at immutable Git revision `e74a8abc3888f2b829c2d3702f0b1f7fbeb6c0cb`; that path is historical, absent from the current tree and both distributions.
38
+
39
+ Run `uv venv --python cpython-3.11-macos-aarch64-none`, then `uv pip install -e ../fontlab-fontlabapp -e ".[test,svg]"`, then `./test.sh`. The wrapper uses `--no-sync`, so prepare the environment first. Build with `uv build`.
40
+
41
+ Keep runtime, ordinary installed artifacts, native workflows and published documentation as separate acceptance results. Track open checks in [TODO.md](TODO.md), the implementation route in [PLAN.md](PLAN.md), and dated evidence in [CHANGELOG.md](CHANGELOG.md).
42
+
43
+ ## Documentation source and build
44
+
45
+ The product guide starts at [src_docs/md/index.md](src_docs/md/index.md). Build with the separate hash-locked docs environment and `sh src_docs/build.sh`; run `python -m unittest discover -s tests_docs -v`. Every main commit qualifies source/output identity and byte parity. Private Pages configuration and publication remain owner-held.
46
+
47
+ # GrabLab
48
+
49
+ Install `fontlab-grablab` for the `grablab` namespace, alongside `fontlab-fontlabapp>=1.2.0`. Python 3.11+ and native FontLab
50
+ APIs are required for capture. Importing `grablab` itself is host-free; requesting Grab loads native APIs.
51
+
52
+ The retained menu scripts and native smoke example use `fontlab-fly>=1.3.0` for App and native Qt access.
53
+ Install Fly alongside GrabLab to run those consumers; the source installer declares it. The library-only wheel
54
+ keeps App as its runtime dependency. GrabLab itself remains available through `grablab`.
55
+
56
+ ```python
57
+ from grablab import Grab
58
+ capture = Grab(grab_canvas=False, grab_screens=False)
59
+ capture.newGrab()
60
+ paths = capture.grabPanel("elements")
61
+ ```
62
+
63
+ Screenshots, native widget SVG, canvas SVG/PDF, panels, menus, glyph/font windows and screen capture retain the source
64
+ interfaces. An optional `Grab(application=app, **preferences)` reuses an existing context, useful for controlled capture
65
+ and temporary preference-library paths.
66
+
67
+ Construction no longer alters rendering preferences or opens a confirmation dialog. Actual capture calls temporarily
68
+ adjust OpenGL, outline thickness and pixel rendering, then restore them and the dark-glyph preference even on failure.
69
+ Alternative-view exports pair their view toggles in finally blocks. Explicit `setAppPrefs()` applies settings directly;
70
+ use capture methods for restoration. The preference library still saves GrabLab configuration when explicitly used.
71
+
72
+ A failed QImage.save returns None even when a stale target exists. Filename collisions are handled iteratively,
73
+ including existing directories. Menu capture returns all submenu paths. Failed screen saves are omitted from returned
74
+ artifact lists. PNG and SVG preserve title/description metadata. `optimizeSVG(..., restyle=True)` explicitly opts into
75
+ the old font/stroke substitutions; raw capture preserves them.
76
+
77
+ ```sh
78
+ # Install the sibling dependency locally (arm64 Python 3.11, as in FontLab):
79
+ uv venv --python cpython-3.11-macos-aarch64-none
80
+ uv pip install -e ../fontlab-fontlabapp -e '.[test,svg]'
81
+ ./test.sh
82
+ uv build
83
+ ```
84
+
85
+ `./test.sh` uses `--no-sync`; create the environment first. The suite covers capture, source-installer contracts and the four icon modes.
86
+ Ordinary-wheel capture in FontLab 9.0.9794 verified actual Font/Glyph windows, canvas and four panels, paired metadata,
87
+ DPR2 and preference restoration. Four public grabCanvas variants also passed native PNG/SVG/JSON checks; six actual
88
+ Designer files passed Qt5 uic. An owned CC0 sample was closed afterward with its source unchanged. Whole-desktop capture
89
+ and every panel/window configuration remain separate integration checks.
90
+
91
+ Migration provenance/licences are in MIGRATION.json; verification is in WORK.md. Versions derive from Git tags through
92
+ hatch-vcs.
93
+
94
+ ## Issue 131 capture bundles
95
+
96
+ `grabWidget`, panel/window/menu captures, and standalone `grabWidgetPNG` / `grabWidgetSVG` reserve one basename across
97
+ `.png`, `.svg`, `.json` and `.ui`. Image names no longer append physical pixel dimensions, so DPR 2 PNG and logical SVG
98
+ stay paired. Existing image-only path list returns (and single-path methods) remain compatible; discover additive
99
+ sidecars with `path.with_suffix(".json")` and `path.with_suffix(".ui")`. The enabled image formats remain configurable.
100
+ A failed image or sidecar aborts the bundle; exclusive publication never replaces existing files and rolls back this
101
+ capture's published members on failure.
102
+
103
+ JSON uses the FontSnap version-2 field shapes with `manifest.tool="grablab"` and
104
+ `extensions.schema="grablab.capture/1"`; this describes compatibility, not FontSnap authorship or an identical capture
105
+ policy. Identical records are embedded in PNG text key `grablab` and SVG `<metadata id="grablab-metadata">`. `size`,
106
+ `rects`, and widget coordinates are logical units; `pixels` records actual PNG dimensions and `dpr` its device ratio.
107
+ Use `pixels / size` per axis for fractional-scale mapping. Widget SVG-only captures leave raster measurements null.
108
+
109
+ `extensions.widgets` records the bounded visible QWidget hierarchy (at most 2,000 widgets), root-relative `rect`,
110
+ parent-relative `geometry`, original semantic statusTip/objectName, unique XML-safe `id`, allowlisted control content,
111
+ and local action associations. The `.ui` is Qt Designer XML with runtime geometry/content; JSON retains details
112
+ unsuitable for Designer. Separate child windows, hidden children, models and arbitrary Qt properties are never
113
+ traversed. The root may be hidden for owned test captures; descendants use `isVisibleTo(root)` so explicitly shown
114
+ children painted by `render()` remain represented. Password text is omitted; other editable content is captured and may
115
+ contain document data. No source code is copied from FontSnap.
116
+
117
+ Runtime capture cannot recreate layouts, signal connections, custom painting or icon resources. Original custom widget
118
+ plugins are needed to load their classes. Coordinates describe widget rectangles, including portions clipped by
119
+ ancestors; they do not prove pixel ownership. Directly owned named actions absent from rectangles populate
120
+ `context.outside`; remote `reaches`, opener, build, theme and background stay explicitly unknown where unmeasured.
121
+ Truncation and limitations are disclosed in JSON and the UI comment. Native SVG/PDF primitives retain their existing
122
+ interfaces; high-level non-widget bundles are described below. Issue 131 ordinary-artifact and owned native acceptance
123
+ is recorded in WORK.md.
124
+
125
+ Designer content uses writable properties for known standard controls; read-only progress/spin display text and
126
+ unknown-class content remain in JSON. Numeric ranges/precision precede values, and checkable precedes the deduplicated
127
+ checked property. QMenu/QMenuBar actions have their visible, nonempty rectangles measured only when wholly inside the
128
+ widget and captured image; hidden/null/clipped owned actions stay outside. Designer action/addaction elements preserve
129
+ supported QAction labels/state; submenu structure and signal wiring remain runtime-only.
130
+
131
+ ## Screen and canvas bundles
132
+
133
+ `grabScreens()` respects the screen-selection and PNG/SVG flags, captures each chosen screen once, and publishes
134
+ requested images plus one JSON sidecar under a shared basename. Its SVG embeds that same PNG in logical screen
135
+ coordinates: `extensions.capture_kind="screen-raster"` explicitly discloses a raster-backed representation, not desktop
136
+ vectorization. Actual PNG pixels/DPR and desktop geometry are retained. SVG-only still embeds a temporary PNG; it
137
+ publishes no standalone PNG. `grabScreenPNG` retains its single PNG-path/None interface.
138
+
139
+ `grabCanvas()` keeps its four native workspace vector variants and optional PDF. Each enabled PNG renders the exact
140
+ paired SVG through Qt QSvgRenderer into an owned QImage, with transparent initialization and guaranteed painter cleanup.
141
+ `extensions.capture_kind="canvas-export"`, `source_viewBox` and `frame_mapping` describe the native vector frame,
142
+ logical dimensions and raster scale. PNG uses DPR1 at ceil(viewBox width/height); it does not claim correspondence to
143
+ another editor viewport. PNG-only keeps its source SVG temporary; SVG-only skips rendering.
144
+
145
+ These non-widget captures have empty semantic records and no fabricated `.ui`. They reuse exclusive staged publication,
146
+ collision checks and failure rollback; rendering preferences and alternative/dark toggles restore on failure. Return
147
+ lists still contain only image paths (plus the existing optional PDF). Source tests alone do not qualify native
148
+ behavior. The four canvas variants were also checked in FontLab 9.0.9794; whole-desktop capture remains unqualified.
149
+
150
+ ## Host-free SVG processing
151
+
152
+ Install `fontlab-grablab[svg]` outside FontLab for postprocessing. Pillow decodes PNG pixels; pure-Python svgelements
153
+ measures transformed SVG geometry. Neither dependency loads during native capture or ordinary `import grablab`.
154
+
155
+ ```python
156
+ import json
157
+ from pathlib import Path
158
+ from grablab import svg
159
+
160
+ root = svg.read_svg("panel.svg")
161
+ index = svg.build_raster_index("assets-manifest.json", source_dirs=["source-pngs"])
162
+ mapping = svg.map_images(root, index) # JSON-serializable URI -> candidates/status
163
+ stats = {"icons": svg.process_images(root, mapping)}
164
+ stats["widgets"] = svg.tag_widgets(root, json.loads(Path("panel.json").read_text()))
165
+ svg.write_svg(root, "panel-processed.svg") # refuses any existing output
166
+ svg.restyle(root, wireframe=True, background="white")
167
+ svg.write_svg(root, "panel-wireframe.svg")
168
+ ```
169
+
170
+ Every data URI must match known decoded PNG dimensions and 8-bit premultiplied RGBa pixels exactly. This preserves Qt's
171
+ rendered pixels despite lossy PNG unpremultiplication at translucent edges; it is not fuzzy or alpha-only matching.
172
+ Index schema 2 records `pixel_format="RGBa8"`; rebuild older indexes before use. Candidates disclose
173
+ `match="pixel-exact"` for exported PNG matches and `match="source-name"` for authoritative source PNGs associated by
174
+ unique original asset name (only `@2x` is normalized). The latter preserves provenance but does not claim the new vector
175
+ renders exactly like the old PNG. Multiple distinct SVG candidates are ambiguous and stay rasterized; unknown,
176
+ unsupported and malformed images also remain untouched. Retain mapping and index JSON as receipts; paths may contain
177
+ local/private information.
178
+
179
+ Nested SVGs retain image viewport/aspect ratio, ancestor transforms and clipping; local IDs, fragment/url references and
180
+ CSS classes are namespaced. `tag_widgets` tags original elements in place using transformed bounds and the smallest
181
+ containing `extensions.widgets[].rect`, preserving paint order and existing IDs. Equal-area ties require one proven
182
+ descendant through the recorded parent chain; otherwise elements stay untagged, with sorted candidate IDs in ambiguity
183
+ stats. New IDs derive from widget IDs; `data-widget` records the exact widget identity. Text uses its transformed
184
+ anchor, disclosed by `data-widget-method="text-anchor"`, rather than invented font metrics. Bounds containment is
185
+ approximate ownership: clipping, text extents, use-instance ownership and arbitrary CSS are not inferred.
186
+ Unsupported/unmatched counts and limits remain in returned stats.
187
+
188
+ `compose([(path, x, y), ...], width=..., height=...)` uses explicit logical positions, input paint order, source viewBox
189
+ sizes and collision-free local IDs. `restyle` changes stroke/fill/width/background/font (`system-ui` by default),
190
+ including inline CSS. Documents containing `<mask>` are refused before any mutation, including font-only changes:
191
+ inherited paint and text geometry affect mask opacity. Wireframe keeps readable monochrome text and outlines on opaque
192
+ surfaces. Monochrome applies a root grayscale filter, preserving luminance and existing filter effects. It refuses
193
+ author stylesheets, important root filters and CSS-wide root-filter values before mutation. Wireframe alone wraps
194
+ retained rasters with grayscale groups; combining rasters with author stylesheets is refused because wrapping can change
195
+ selectors. Stylesheet-only vector inputs remain supported for wireframe and ordinary restyling. Image bytes/geometry
196
+ remain intact; filtered_images reports the affected raster count. CSS grayscale needs a supporting SVG renderer.
197
+ Ordinary color changes preserve effective `none` from presentation attributes, class/ID CSS and inline styles using
198
+ specificity, source order, inheritance and `!important`. Conditional stylesheet rules and unresolved contextual paints
199
+ fail before mutation. cssselect2/tinycss2 provide the selector and declaration parsing. External resources, global CSS
200
+ selectors and `!important` rules need separate review; helpers target trusted Qt captures and the known Illustrator
201
+ assets.
202
+
203
+ Optional `deduplicate_paths` removes only consecutive identical opaque fill-only paths without IDs, strokes or inherited
204
+ opacity/effects. Repeated antialiased edges can differ; compare processed renders or leave cleanup disabled when exact
205
+ pixels matter. Raw inputs remain separate. Host-free tests and asset indexing do not establish native screenshot
206
+ fidelity.
207
+
208
+ ## Icon representation modes
209
+
210
+ `process_images(root, mapping=None, icon_mode="inline-svg", output=None)` returns mode, linked/inlined/retained counts,
211
+ retained reasons and resolved targets. The existing `inline_images` API is unchanged. Modes:
212
+
213
+ - `base64`: retain every image without indexing assets; mapping is optional.
214
+ - `png-url`: link a matching exported PNG, preferring exact pixels; ties use
215
+ sorted paths. Source-name matches use the manifest's standard PNG (then the
216
+ first sorted PNG variant). This is provenance, not visual equivalence.
217
+ - `svg-url`: link the unique matched SVG without inserting its paths.
218
+ - `inline-svg` (default): retain the existing namespaced vector substitution.
219
+
220
+ URL modes require `output`, the destination SVG filename, and emit escaped relative URLs to the original named assets.
221
+ They do not copy/rename resources. Keep the referenced asset tree available when moving or serving the result. Both href
222
+ forms are read with SVG2 href precedence; a replaced image has only href. Geometry, transforms, clipping, opacity and
223
+ aspect ratio stay intact. Missing/invalid targets and ambiguous/unknown images are retained with reasons. Base64 mode
224
+ preserves even malformed image URIs without decoding them. Pass `output` to `compose` as well when its directory differs
225
+ from the panels; it rebases relative image URLs, preserving queries/fragments and remote URLs. These helpers target
226
+ trusted Qt captures without XML base overrides.
227
+
228
+ Linked SVG interiors cannot inherit screenshot paint or font changes. Mono filters the rendered image; wireframe keeps a
229
+ grayscale image rather than converting its paths. Open linked screenshots directly or use HTML iframe/object. HTML img
230
+ embedding restricts external resources, so an SVG load event alone does not prove its icons loaded. See the [SVG2
231
+ processing modes](https://www.w3.org/TR/SVG2/conform.html#secure-static-mode) and [image
232
+ element](https://www.w3.org/TR/SVG2/embedded.html#ImageElement).
233
+
234
+
235
+ ## Source installation and retained history — 2026-11-06
236
+
237
+ The source sdist includes the four current `Scripts/GrabLab` scripts and
238
+ `install.vfpy`; the wheel installs only the library. The source installer declares
239
+ App >=1.2.0, Fly >=1.3.0 for the authored consumers, and
240
+ `pyobjc-framework-Quartz>=10; sys_platform == 'darwin'` for the macOS F5/F6 hotkey script. App's optional `hotkeys` extra remains available;
241
+ the linked installer metadata needs the explicit Quartz requirement. See
242
+ [DEPENDENCIES.md](DEPENDENCIES.md) for its metadata boundary.
243
+
244
+ To install into FontLab 9, open `install.vfpy` from a checkout in FontLab
245
+ (double-click it or drop it onto FontLab), then restart FontLab. The file is a
246
+ short stub that hands the work to
247
+ [fontlab-instamix](https://github.com/fontlabcom/fontlab-python-instamix); if
248
+ instamix is not installed yet, the stub installs it from PyPI first. Instamix
249
+ installs the package and its declared dependencies and records the install under
250
+ the extension id `com.fontlab.grablab`. Owned tests do not establish native
251
+ installation.
252
+
253
+ Glyph-window capture uses App's supported adapter for both direct and named-child
254
+ viewports. Missing viewports raise `LookupError`; visibility preferences, viewport
255
+ then window order, image-only returns and failure restoration remain unchanged.
256
+ Current native capture is a separate acceptance surface.
257
+
258
+ Five earlier helpers remain preserved historical source, outside active Scripts
259
+ and distributions, with individual dispositions:
260
+
261
+ - `copy_statusid.py`: clipboard/status-ID watcher; needs owned disconnect/traversal/clipboard acceptance.
262
+ - `copy_statusid2.py`: quick-help/clipboard watcher; needs separate lifecycle qualification.
263
+ - `print_menu.py`: manual Markdown menu-export candidate; screenshot APIs do not replace its output.
264
+ - `print_uimenu.py`: manual Designer-menu export candidate; dialog and loader state need native qualification.
265
+ - `ui_hider.py`: persisted visibility/watcher prototype; needs persistence ownership and visibility/signal restoration.
266
+
267
+ Preservation does not deliver those runtime functions. No new cleanup deletion,
268
+ owner installation, native acceptance or private Pages publication is qualified.
@@ -0,0 +1,8 @@
1
+ grablab/__init__.py,sha256=qV4h2nEzDvbN6ZxxMLiunaYrSINgK43O-Z2Ybsrif0A,2361
2
+ grablab/grab.py,sha256=QV1kUzhE87K6-6-wsmBh_oBhhMCAGHS9w_Al940zhcI,27368
3
+ grablab/snapshot.py,sha256=qfhwzl2dxIl6W_24EpjfcLPrcZC8MOmiRWrZHJVuHi0,12505
4
+ grablab/svg.py,sha256=IzgiOmEWpXkNzg-vlEhm1YubmPjIDPuo6nmS-PLFxas,32061
5
+ fontlab_grablab-1.1.16.dist-info/METADATA,sha256=DdTiXc31pqTVGYfnz4Ln-6clH4x4CaPgDJK-k6NIGng,18667
6
+ fontlab_grablab-1.1.16.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
7
+ fontlab_grablab-1.1.16.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
8
+ fontlab_grablab-1.1.16.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
grablab/__init__.py ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env python3
2
+ # this_file: src/grablab/__init__.py
3
+ # -*- coding: utf-8 -*-
4
+ # Copyright (c) 2022 Adam Twardoch
5
+ # License: BSD 3-Clause License
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are met:
9
+ #
10
+ # 1. Redistributions of source code must retain the above copyright notice, this
11
+ # list of conditions and the following disclaimer.
12
+ #
13
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
14
+ # this list of conditions and the following disclaimer in the documentation
15
+ # and/or other materials provided with the distribution.
16
+ #
17
+ # 3. Neither the name of the copyright holder nor the names of its
18
+ # contributors may be used to endorse or promote products derived from
19
+ # this software without specific prior written permission.
20
+ #
21
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+
32
+ """Lazy screenshot helpers; native access occurs when Grab is requested."""
33
+ from importlib import import_module
34
+ from typing import Any
35
+ from importlib.metadata import PackageNotFoundError, version
36
+
37
+ try:
38
+ __version__ = version("fontlab-grablab")
39
+ except PackageNotFoundError:
40
+ __version__ = "0.1.0"
41
+
42
+ __all__ = ["Grab"]
43
+
44
+
45
+ def __getattr__(name: str) -> Any:
46
+ if name != "Grab":
47
+ raise AttributeError(name)
48
+ try:
49
+ value = import_module("grablab.grab").Grab
50
+ except ModuleNotFoundError as error:
51
+ if error.name.split('.')[0] in {"fontlab", "PythonQt"}:
52
+ raise RuntimeError("Grab requires native FontLab APIs") from error
53
+ raise
54
+ globals()[name] = value
55
+ return value