inky-email 2.0.0b2__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.
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.4
2
+ Name: inky-email
3
+ Version: 2.0.0b2
4
+ Summary: Transform email templates into email-safe HTML — powered by Rust
5
+ License: MIT
6
+ Project-URL: Homepage, https://github.com/foundation/inky
7
+ Project-URL: Repository, https://github.com/foundation/inky
8
+ Keywords: email,html,inky,foundation,responsive
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Communications :: Email
14
+ Classifier: Topic :: Text Processing :: Markup :: HTML
15
+ Requires-Python: >=3.8
@@ -0,0 +1,26 @@
1
+ [project]
2
+ name = "inky-email"
3
+ version = "2.0.0-beta.2"
4
+ description = "Transform email templates into email-safe HTML — powered by Rust"
5
+ license = {text = "MIT"}
6
+ requires-python = ">=3.8"
7
+ keywords = ["email", "html", "inky", "foundation", "responsive"]
8
+ classifiers = [
9
+ "Development Status :: 4 - Beta",
10
+ "Intended Audience :: Developers",
11
+ "License :: OSI Approved :: MIT License",
12
+ "Programming Language :: Python :: 3",
13
+ "Topic :: Communications :: Email",
14
+ "Topic :: Text Processing :: Markup :: HTML",
15
+ ]
16
+
17
+ [project.urls]
18
+ Homepage = "https://github.com/foundation/inky"
19
+ Repository = "https://github.com/foundation/inky"
20
+
21
+ [build-system]
22
+ requires = ["setuptools>=64"]
23
+ build-backend = "setuptools.build_meta"
24
+
25
+ [tool.setuptools.packages.find]
26
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,175 @@
1
+ """
2
+ Inky — Transform email templates into email-safe HTML.
3
+
4
+ Powered by Rust via ctypes FFI.
5
+ """
6
+
7
+ import ctypes
8
+ import json
9
+ import os
10
+ import platform
11
+ import sys
12
+
13
+ __version__ = "2.0.0"
14
+
15
+ _lib = None
16
+
17
+
18
+ def _find_library():
19
+ """Find the libinky shared library."""
20
+ system = platform.system()
21
+ if system == "Darwin":
22
+ name = "libinky.dylib"
23
+ elif system == "Windows":
24
+ name = "inky.dll"
25
+ else:
26
+ name = "libinky.so"
27
+
28
+ # Check paths relative to this package (development layout)
29
+ pkg_dir = os.path.dirname(os.path.abspath(__file__))
30
+ candidates = [
31
+ # Development: cargo build output
32
+ os.path.join(pkg_dir, "..", "..", "..", "..", "target", "release", name),
33
+ os.path.join(pkg_dir, "..", "..", "..", "..", "target", "debug", name),
34
+ # Bundled with package
35
+ os.path.join(pkg_dir, name),
36
+ # System paths
37
+ os.path.join("/usr/local/lib", name),
38
+ os.path.join("/usr/lib", name),
39
+ ]
40
+
41
+ for path in candidates:
42
+ resolved = os.path.normpath(path)
43
+ if os.path.exists(resolved):
44
+ return resolved
45
+
46
+ return None
47
+
48
+
49
+ def _get_lib():
50
+ """Get or initialize the shared library handle."""
51
+ global _lib
52
+ if _lib is not None:
53
+ return _lib
54
+
55
+ lib_path = _find_library()
56
+ if lib_path is None:
57
+ raise RuntimeError(
58
+ "Could not find libinky shared library. "
59
+ "Build it with: cargo build -p inky-ffi --release"
60
+ )
61
+
62
+ _lib = ctypes.CDLL(lib_path)
63
+
64
+ # Configure function signatures
65
+ _lib.inky_transform.argtypes = [ctypes.c_char_p]
66
+ _lib.inky_transform.restype = ctypes.c_char_p
67
+
68
+ _lib.inky_transform_with_columns.argtypes = [ctypes.c_char_p, ctypes.c_uint32]
69
+ _lib.inky_transform_with_columns.restype = ctypes.c_char_p
70
+
71
+ _lib.inky_transform_inline.argtypes = [ctypes.c_char_p]
72
+ _lib.inky_transform_inline.restype = ctypes.c_char_p
73
+
74
+ _lib.inky_migrate.argtypes = [ctypes.c_char_p]
75
+ _lib.inky_migrate.restype = ctypes.c_char_p
76
+
77
+ _lib.inky_migrate_with_details.argtypes = [ctypes.c_char_p]
78
+ _lib.inky_migrate_with_details.restype = ctypes.c_char_p
79
+
80
+ _lib.inky_validate.argtypes = [ctypes.c_char_p]
81
+ _lib.inky_validate.restype = ctypes.c_char_p
82
+
83
+ _lib.inky_version.argtypes = []
84
+ _lib.inky_version.restype = ctypes.c_char_p
85
+
86
+ _lib.inky_free.argtypes = [ctypes.c_char_p]
87
+ _lib.inky_free.restype = None
88
+
89
+ return _lib
90
+
91
+
92
+ def transform(html: str, columns: int = 12) -> str:
93
+ """Transform Inky HTML into email-safe table markup.
94
+
95
+ Args:
96
+ html: Inky template HTML.
97
+ columns: Number of grid columns (default: 12).
98
+
99
+ Returns:
100
+ Transformed HTML string.
101
+ """
102
+ lib = _get_lib()
103
+ encoded = html.encode("utf-8")
104
+ if columns != 12:
105
+ result = lib.inky_transform_with_columns(encoded, columns)
106
+ else:
107
+ result = lib.inky_transform(encoded)
108
+ return result.decode("utf-8")
109
+
110
+
111
+ def transform_inline(html: str) -> str:
112
+ """Transform Inky HTML and inline CSS from <style> blocks.
113
+
114
+ Args:
115
+ html: Inky template HTML with <style> blocks.
116
+
117
+ Returns:
118
+ Transformed HTML with CSS inlined.
119
+ """
120
+ lib = _get_lib()
121
+ result = lib.inky_transform_inline(html.encode("utf-8"))
122
+ return result.decode("utf-8")
123
+
124
+
125
+ def migrate(html: str) -> str:
126
+ """Migrate v1 Inky syntax to v2.
127
+
128
+ Args:
129
+ html: v1 Inky template HTML.
130
+
131
+ Returns:
132
+ Migrated v2 HTML string.
133
+ """
134
+ lib = _get_lib()
135
+ result = lib.inky_migrate(html.encode("utf-8"))
136
+ return result.decode("utf-8")
137
+
138
+
139
+ def migrate_with_details(html: str) -> dict:
140
+ """Migrate v1 syntax and return detailed results.
141
+
142
+ Args:
143
+ html: v1 Inky template HTML.
144
+
145
+ Returns:
146
+ Dict with 'html' (migrated HTML) and 'changes' (list of descriptions).
147
+ """
148
+ lib = _get_lib()
149
+ result = lib.inky_migrate_with_details(html.encode("utf-8"))
150
+ return json.loads(result.decode("utf-8"))
151
+
152
+
153
+ def validate(html: str) -> list:
154
+ """Validate an Inky template and return diagnostics.
155
+
156
+ Args:
157
+ html: Inky template HTML.
158
+
159
+ Returns:
160
+ List of dicts with 'severity', 'rule', and 'message' fields.
161
+ """
162
+ lib = _get_lib()
163
+ result = lib.inky_validate(html.encode("utf-8"))
164
+ return json.loads(result.decode("utf-8"))
165
+
166
+
167
+ def version() -> str:
168
+ """Get the Inky engine version.
169
+
170
+ Returns:
171
+ Version string (e.g. "2.0.0").
172
+ """
173
+ lib = _get_lib()
174
+ result = lib.inky_version()
175
+ return result.decode("utf-8")
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.4
2
+ Name: inky-email
3
+ Version: 2.0.0b2
4
+ Summary: Transform email templates into email-safe HTML — powered by Rust
5
+ License: MIT
6
+ Project-URL: Homepage, https://github.com/foundation/inky
7
+ Project-URL: Repository, https://github.com/foundation/inky
8
+ Keywords: email,html,inky,foundation,responsive
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Communications :: Email
14
+ Classifier: Topic :: Text Processing :: Markup :: HTML
15
+ Requires-Python: >=3.8
@@ -0,0 +1,6 @@
1
+ pyproject.toml
2
+ src/inky/__init__.py
3
+ src/inky_email.egg-info/PKG-INFO
4
+ src/inky_email.egg-info/SOURCES.txt
5
+ src/inky_email.egg-info/dependency_links.txt
6
+ src/inky_email.egg-info/top_level.txt