segnomms 0.2.1__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.
Files changed (75) hide show
  1. segnomms/__init__.py +249 -0
  2. segnomms/a11y/__init__.py +72 -0
  3. segnomms/a11y/accessibility.py +541 -0
  4. segnomms/algorithms/__init__.py +49 -0
  5. segnomms/algorithms/clustering.py +534 -0
  6. segnomms/algorithms/models.py +166 -0
  7. segnomms/capabilities/__init__.py +58 -0
  8. segnomms/capabilities/manifest.py +341 -0
  9. segnomms/color/__init__.py +77 -0
  10. segnomms/color/color_analysis.py +270 -0
  11. segnomms/color/palette.py +472 -0
  12. segnomms/config/__init__.py +69 -0
  13. segnomms/config/enums.py +400 -0
  14. segnomms/config/models/__init__.py +48 -0
  15. segnomms/config/models/advanced.py +151 -0
  16. segnomms/config/models/core.py +848 -0
  17. segnomms/config/models/geometry.py +203 -0
  18. segnomms/config/models/phases.py +112 -0
  19. segnomms/config/models/visual.py +319 -0
  20. segnomms/config/presets.py +437 -0
  21. segnomms/constants.py +221 -0
  22. segnomms/core/__init__.py +31 -0
  23. segnomms/core/advanced_qr.py +518 -0
  24. segnomms/core/detector.py +364 -0
  25. segnomms/core/geometry/__init__.py +9 -0
  26. segnomms/core/geometry/centerpiece_geometry.py +256 -0
  27. segnomms/core/interfaces.py +256 -0
  28. segnomms/core/matrix/__init__.py +19 -0
  29. segnomms/core/matrix/imprint_processor.py +336 -0
  30. segnomms/core/matrix/knockout_processor.py +214 -0
  31. segnomms/core/matrix/manipulator.py +677 -0
  32. segnomms/core/matrix/matrix_validator.py +567 -0
  33. segnomms/core/matrix/performance_monitor.py +539 -0
  34. segnomms/core/models.py +146 -0
  35. segnomms/core/performance.py +523 -0
  36. segnomms/degradation/__init__.py +36 -0
  37. segnomms/degradation/manager.py +143 -0
  38. segnomms/degradation/models.py +88 -0
  39. segnomms/degradation/rules.py +401 -0
  40. segnomms/exceptions.py +699 -0
  41. segnomms/intents/__init__.py +99 -0
  42. segnomms/intents/models.py +409 -0
  43. segnomms/intents/processor.py +2007 -0
  44. segnomms/plugin/__init__.py +31 -0
  45. segnomms/plugin/config.py +16 -0
  46. segnomms/plugin/export.py +140 -0
  47. segnomms/plugin/interface.py +444 -0
  48. segnomms/plugin/patterns.py +96 -0
  49. segnomms/plugin/rendering.py +867 -0
  50. segnomms/py.typed +3 -0
  51. segnomms/shapes/__init__.py +109 -0
  52. segnomms/shapes/basic.py +772 -0
  53. segnomms/shapes/connected.py +618 -0
  54. segnomms/shapes/factory.py +341 -0
  55. segnomms/shapes/frames.py +391 -0
  56. segnomms/svg/__init__.py +74 -0
  57. segnomms/svg/accessibility.py +271 -0
  58. segnomms/svg/composite.py +298 -0
  59. segnomms/svg/core.py +329 -0
  60. segnomms/svg/definitions.py +286 -0
  61. segnomms/svg/frame_visual.py +402 -0
  62. segnomms/svg/interactivity.py +233 -0
  63. segnomms/svg/models.py +307 -0
  64. segnomms/svg/path_clipper.py +296 -0
  65. segnomms/types.py +180 -0
  66. segnomms/utils/__init__.py +55 -0
  67. segnomms/validation/__init__.py +50 -0
  68. segnomms/validation/composition.py +529 -0
  69. segnomms/validation/models.py +119 -0
  70. segnomms/validation/phase4.py +38 -0
  71. segnomms-0.2.1.dist-info/METADATA +465 -0
  72. segnomms-0.2.1.dist-info/RECORD +75 -0
  73. segnomms-0.2.1.dist-info/WHEEL +4 -0
  74. segnomms-0.2.1.dist-info/entry_points.txt +2 -0
  75. segnomms-0.2.1.dist-info/licenses/LICENSE +21 -0
segnomms/__init__.py ADDED
@@ -0,0 +1,249 @@
1
+ """SegnoMMS - Advanced QR Code Generation with Intent-Based API.
2
+
3
+ A modular plugin for generating interactive SVG QR codes with custom shapes,
4
+ advanced clustering, and dynamic styling capabilities.
5
+
6
+ This plugin provides two APIs:
7
+
8
+ **Intent-Based API (Recommended)**: High-level declarative QR generation with
9
+ structured configuration, comprehensive error handling, and graceful degradation.
10
+
11
+ **Legacy Write API**: Direct function-based generation for simple use cases and
12
+ backward compatibility.
13
+
14
+ Features:
15
+
16
+ * **Intent-Based Configuration**: Structured, type-safe configuration with
17
+ automatic validation
18
+ * **Multiple Shape Renderers**: 14+ shapes including squares, circles, stars,
19
+ and connected shapes
20
+ * **Context-Aware Shapes**: Adaptive shapes based on neighboring modules
21
+ * **Safe Mode**: Preserves QR code scannability using simple shapes for
22
+ critical patterns
23
+ * **CSS Classes & Interactivity**: Full styling and animation support
24
+ * **Graceful Degradation**: Automatic fallbacks with detailed warning system
25
+ * **Performance Optimization**: Multi-phase processing pipeline with
26
+ clustering algorithms
27
+ * **Phase 4 Features**: Custom frames, centerpiece areas, and gradient
28
+ backgrounds
29
+ * **Comprehensive Error Handling**: Structured exceptions with suggestions
30
+ and alternatives
31
+
32
+ Example:
33
+ Modern Intent-Based API (Recommended)::
34
+
35
+ from segnomms.intents import render_with_intents, PayloadConfig, IntentsConfig
36
+ from segnomms.intents.models import StyleIntents
37
+
38
+ # Define payload and styling intentions
39
+ payload = PayloadConfig(text="Hello, World!")
40
+ intents = IntentsConfig(
41
+ style=StyleIntents(
42
+ module_shape="squircle",
43
+ palette={"fg": "#1a1a2e", "bg": "#ffffff"}
44
+ )
45
+ )
46
+
47
+ # Generate with comprehensive error handling
48
+ result = render_with_intents(payload, intents)
49
+
50
+ # Check for warnings and degradations
51
+ if result.has_warnings:
52
+ for warning in result.warnings:
53
+ print(f"Notice: {warning.detail}")
54
+
55
+ with open('modern-qr.svg', 'w') as f:
56
+ f.write(result.svg_content)
57
+
58
+ Legacy Write API (Simple Cases)::
59
+
60
+ import segno
61
+ from segnomms import write
62
+
63
+ qr = segno.make("Hello, World!")
64
+ with open('basic.svg', 'w') as f:
65
+ write(qr, f, shape='connected', scale=10)
66
+
67
+ Configuration Presets::
68
+
69
+ from segnomms.config import ConfigPresets
70
+
71
+ qr = segno.make("Hello, World!")
72
+ config = ConfigPresets.artistic()
73
+ with open('preset.svg', 'w') as f:
74
+ write(qr, f, **config.to_kwargs())
75
+
76
+ Note:
77
+ This plugin requires Segno >= 1.5.2 and Pydantic >= 2.7.
78
+ The Intent-Based API provides superior error handling and is recommended
79
+ for production applications.
80
+
81
+ """
82
+
83
+ # Import constants module for convenient access (but don't pollute main namespace)
84
+ from . import constants
85
+ from .algorithms.clustering import ConnectedComponentAnalyzer
86
+ from .config import (
87
+ AdvancedQRConfig,
88
+ Phase1Config,
89
+ Phase2Config,
90
+ Phase3Config,
91
+ RenderingConfig,
92
+ )
93
+ from .config.presets import ConfigPresets
94
+ from .core.detector import ModuleDetector
95
+ from .core.interfaces import AlgorithmProcessor, RendererFactory, ShapeRenderer
96
+
97
+ # Import exceptions
98
+ from .exceptions import (
99
+ CapabilityError,
100
+ CapabilityManifestError,
101
+ ColorError,
102
+ ConfigurationError,
103
+ ContrastRatioError,
104
+ DependencyError,
105
+ FeatureNotSupportedError,
106
+ IncompatibleConfigError,
107
+ IntentDegradationError,
108
+ IntentProcessingError,
109
+ IntentTransformationError,
110
+ IntentValidationError,
111
+ InvalidColorFormatError,
112
+ MatrixBoundsError,
113
+ MatrixError,
114
+ MatrixSizeError,
115
+ MissingDependencyError,
116
+ OptionalFeatureUnavailableError,
117
+ PaletteValidationError,
118
+ PerformanceError,
119
+ PresetNotFoundError,
120
+ RenderingError,
121
+ SegnoMMSError,
122
+ ShapeRenderingError,
123
+ SVGGenerationError,
124
+ UnsupportedIntentError,
125
+ ValidationError,
126
+ )
127
+
128
+ # Import the main write functions
129
+ from .plugin import generate_interactive_svg, write, write_advanced
130
+ from .shapes.factory import (
131
+ create_shape_renderer,
132
+ get_shape_factory,
133
+ register_custom_renderer,
134
+ )
135
+ from .svg import InteractiveSVGBuilder
136
+
137
+ # Import capability discovery (with graceful degradation)
138
+ try:
139
+ from .capabilities import ( # noqa: F401
140
+ CapabilityManifest,
141
+ get_capability_manifest,
142
+ get_supported_features,
143
+ )
144
+
145
+ _capabilities_available = True
146
+ except ImportError:
147
+ _capabilities_available = False
148
+
149
+ # Import intent-based API (with graceful degradation)
150
+ try:
151
+ from .intents import ( # noqa: F401
152
+ IntentsConfig,
153
+ PayloadConfig,
154
+ RenderingResult,
155
+ process_intents,
156
+ render_with_intents,
157
+ )
158
+
159
+ _intents_available = True
160
+ except ImportError:
161
+ _intents_available = False
162
+
163
+ # Version information
164
+ __version__ = "0.2.1" # x-release-please-version
165
+ __author__ = "SYSTMMS"
166
+
167
+ # Export main functionality
168
+ __all__ = [
169
+ # Main functions
170
+ "write",
171
+ "write_advanced",
172
+ "generate_interactive_svg",
173
+ # Constants module
174
+ "constants",
175
+ # Core classes
176
+ "ModuleDetector",
177
+ "RenderingConfig",
178
+ "InteractiveSVGBuilder",
179
+ # Configuration classes
180
+ "Phase1Config",
181
+ "Phase2Config",
182
+ "Phase3Config",
183
+ "AdvancedQRConfig",
184
+ "ConfigPresets",
185
+ # Factory functions
186
+ "get_shape_factory",
187
+ "create_shape_renderer",
188
+ "register_custom_renderer",
189
+ # Algorithm classes
190
+ "ConnectedComponentAnalyzer",
191
+ # Interfaces for extension
192
+ "ShapeRenderer",
193
+ "AlgorithmProcessor",
194
+ "RendererFactory",
195
+ # Exceptions
196
+ "SegnoMMSError",
197
+ "ConfigurationError",
198
+ "ValidationError",
199
+ "IntentValidationError",
200
+ "PresetNotFoundError",
201
+ "IncompatibleConfigError",
202
+ "RenderingError",
203
+ "MatrixError",
204
+ "MatrixSizeError",
205
+ "MatrixBoundsError",
206
+ "ShapeRenderingError",
207
+ "SVGGenerationError",
208
+ "PerformanceError",
209
+ "IntentProcessingError",
210
+ "UnsupportedIntentError",
211
+ "IntentDegradationError",
212
+ "IntentTransformationError",
213
+ "ColorError",
214
+ "InvalidColorFormatError",
215
+ "ContrastRatioError",
216
+ "PaletteValidationError",
217
+ "CapabilityError",
218
+ "FeatureNotSupportedError",
219
+ "CapabilityManifestError",
220
+ "DependencyError",
221
+ "MissingDependencyError",
222
+ "OptionalFeatureUnavailableError",
223
+ ]
224
+
225
+ # Add capability discovery exports if available
226
+ if _capabilities_available:
227
+ __all__.extend(
228
+ [
229
+ "CapabilityManifest",
230
+ "get_capability_manifest",
231
+ "get_supported_features",
232
+ ]
233
+ )
234
+
235
+ # Add intent-based API exports if available
236
+ if _intents_available:
237
+ __all__.extend(
238
+ [
239
+ "PayloadConfig",
240
+ "IntentsConfig",
241
+ "RenderingResult",
242
+ "render_with_intents",
243
+ "process_intents",
244
+ ]
245
+ )
246
+
247
+ # Plugin metadata for segno registration
248
+ PLUGIN_NAME = "interactive_svg"
249
+ PLUGIN_VERSION = __version__
@@ -0,0 +1,72 @@
1
+ """Accessibility enhancement subsystem.
2
+
3
+ This package provides comprehensive accessibility features for QR code
4
+ generation, ensuring compliance with accessibility standards and best
5
+ practices for assistive technologies.
6
+
7
+ Key Components:
8
+
9
+ ARIA Support:
10
+ - Role definitions and management
11
+ - Label and description generation
12
+ - Live region support
13
+
14
+ ID Management:
15
+ - Stable, predictable ID generation
16
+ - Configurable prefixes and schemes
17
+ - Conflict resolution
18
+
19
+ Screen Reader Optimization:
20
+ - Semantic SVG structure
21
+ - Alternative text generation
22
+ - Content description
23
+
24
+ Keyboard Navigation:
25
+ - Focus management
26
+ - Tab order optimization
27
+ - Keyboard shortcuts
28
+
29
+ The accessibility subsystem handles:
30
+
31
+ * ARIA attribute management
32
+ * Screen reader compatibility
33
+ * Keyboard navigation support
34
+ * ID generation and management
35
+ * Accessibility validation
36
+ * WCAG compliance checking
37
+ * Alternative content generation
38
+
39
+ Example:
40
+ Basic accessibility enhancement::
41
+
42
+ from segnomms.a11y import AccessibilityEnhancer, ARIARole
43
+
44
+ enhancer = AccessibilityEnhancer(
45
+ id_prefix="qr",
46
+ default_role=ARIARole.IMG
47
+ )
48
+
49
+ # Generate stable IDs
50
+ module_id = enhancer.generate_id("module", 5, 3)
51
+
52
+ # Add ARIA attributes
53
+ aria_attrs = enhancer.get_aria_attributes(
54
+ role=ARIARole.GRAPHICS_OBJECT,
55
+ label="QR code module at position 5,3"
56
+ )
57
+
58
+ See Also:
59
+ :mod:`segnomms.a11y.accessibility`: Core accessibility features
60
+ """
61
+
62
+ from .accessibility import (
63
+ AccessibilityConfig,
64
+ AccessibilityEnhancer,
65
+ ARIARole,
66
+ )
67
+
68
+ __all__ = [
69
+ "AccessibilityEnhancer",
70
+ "ARIARole",
71
+ "AccessibilityConfig",
72
+ ]