papyru 2.11.1.dev139__tar.gz → 2.11.1.dev147__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.
- {papyru-2.11.1.dev139/papyru.egg-info → papyru-2.11.1.dev147}/PKG-INFO +1 -1
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/edit_template/xml.py +38 -70
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147/papyru.egg-info}/PKG-INFO +1 -1
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/setup.py +1 -1
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/LICENSE.txt +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/README.md +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/bin/generate_jsonschema.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/__init__.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/auth.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/context.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/__init__.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/component.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/constants.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/edit_template/__init__.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/edit_template/ean.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/edit_template/manufacturer_address.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/edit_template/motive.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/edit_template/render_text.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/edit_template/title.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/resi.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/logger.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/logger_stdout.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/logger_types.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/middleware.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/problem.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/profiler.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/resource.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/serializer.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/stack_context.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/static/__init__.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/static/apps.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/static/urls.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/static/views.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/utils.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/validation.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/varspool/__init__.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/varspool/assets/Job.json +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/varspool/assets/JobStatusHistory.json +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/varspool/command/__init__.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/varspool/command/config.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/varspool/command/types.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/varspool/serializers.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/varspool/types.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/xml_helper.py +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru.egg-info/SOURCES.txt +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru.egg-info/dependency_links.txt +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru.egg-info/requires.txt +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru.egg-info/top_level.txt +0 -0
- {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/setup.cfg +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
|
+
from typing import Optional
|
|
2
3
|
from xml.etree.ElementTree import Element, SubElement
|
|
3
4
|
|
|
4
5
|
from papyru import XMLHelper
|
|
@@ -11,13 +12,11 @@ class PlaceholderInfo:
|
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
@dataclass(frozen=True)
|
|
14
|
-
class
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
x_offset: float
|
|
20
|
-
y_offset: float
|
|
15
|
+
class ImageCrop:
|
|
16
|
+
x: float
|
|
17
|
+
y: float
|
|
18
|
+
width: float
|
|
19
|
+
height: float
|
|
21
20
|
|
|
22
21
|
|
|
23
22
|
@dataclass(frozen=True)
|
|
@@ -25,7 +24,7 @@ class ImageInfo:
|
|
|
25
24
|
location: str
|
|
26
25
|
width: int
|
|
27
26
|
height: int
|
|
28
|
-
|
|
27
|
+
crop: Optional[ImageCrop] = None
|
|
29
28
|
|
|
30
29
|
|
|
31
30
|
def find_placeholder(doc: XMLHelper,
|
|
@@ -88,34 +87,44 @@ def fit_image(doc: XMLHelper,
|
|
|
88
87
|
if ph is None:
|
|
89
88
|
return doc
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
else:
|
|
94
|
-
wrapper_dims = (float(doc.get_attribute(ph.wrapper, 'width')),
|
|
95
|
-
float(doc.get_attribute(ph.wrapper, 'height')))
|
|
90
|
+
wrapper_dims = (float(doc.get_attribute(ph.wrapper, 'width')),
|
|
91
|
+
float(doc.get_attribute(ph.wrapper, 'height')))
|
|
96
92
|
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
image_dims = (float(image_info.width),
|
|
94
|
+
float(image_info.height))
|
|
99
95
|
|
|
100
|
-
|
|
96
|
+
viewbox = (_fit_dimensions(wrapper_dims, image_dims)
|
|
97
|
+
if image_info.crop is None else
|
|
98
|
+
(image_info.crop.x, image_info.crop.y,
|
|
99
|
+
image_info.crop.width, image_info.crop.height))
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
doc.set_attribute(ph.wrapper,
|
|
102
|
+
'viewBox',
|
|
103
|
+
'%s %s %s %s' % viewbox)
|
|
105
104
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
has_xlink = doc.namespace('xlink') is not None
|
|
106
|
+
doc.set_attribute(ph.placeholder,
|
|
107
|
+
'href', image_info.location,
|
|
108
|
+
'xlink' if has_xlink else None)
|
|
110
109
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
doc.set_attribute(ph.placeholder, 'x', '0.0')
|
|
111
|
+
doc.set_attribute(ph.placeholder, 'y', '0.0')
|
|
112
|
+
doc.set_attribute(ph.placeholder, 'width', '%s' % image_dims[0])
|
|
113
|
+
doc.set_attribute(ph.placeholder, 'height', '%s' % image_dims[1])
|
|
114
|
+
|
|
115
|
+
if image_info.crop is not None:
|
|
116
|
+
doc.set_attribute(ph.placeholder, 'bbox',
|
|
117
|
+
'{"x": %s, "y": %s, "width": %s, "height": %s}'
|
|
118
|
+
% (image_info.crop.x, image_info.crop.y,
|
|
119
|
+
image_info.crop.width,
|
|
120
|
+
image_info.crop.height), 'pap')
|
|
121
|
+
doc.set_attribute(ph.placeholder, 'img-dimensions',
|
|
122
|
+
'{"width": %s, "height": %s}'
|
|
123
|
+
% (image_dims[0], image_dims[1]), 'pap')
|
|
115
124
|
|
|
116
|
-
|
|
125
|
+
_set_changed(doc, ph.placeholder)
|
|
117
126
|
|
|
118
|
-
|
|
127
|
+
return doc
|
|
119
128
|
|
|
120
129
|
|
|
121
130
|
def _set_changed(document: XMLHelper, element: Element):
|
|
@@ -138,44 +147,3 @@ def _fit_dimensions(container_dims: (float, float),
|
|
|
138
147
|
else:
|
|
139
148
|
w = element_dims[1] * aspect_container
|
|
140
149
|
return ((e_w - w) / 2, 0.0, w, e_h)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
def _place_custom_image(doc: XMLHelper, ph: PlaceholderInfo,
|
|
144
|
-
image_info: ImageInfo):
|
|
145
|
-
placement = image_info.placement
|
|
146
|
-
|
|
147
|
-
scale_x = placement.scaled_img_width / image_info.width
|
|
148
|
-
scale_y = placement.scaled_img_height / image_info.height
|
|
149
|
-
|
|
150
|
-
crop = {
|
|
151
|
-
'x': -placement.x_offset / scale_x,
|
|
152
|
-
'y': -placement.y_offset / scale_y,
|
|
153
|
-
'width': placement.container_width / scale_x,
|
|
154
|
-
'height': placement.container_height / scale_y,
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
doc.set_attribute(ph.wrapper, 'viewBox',
|
|
158
|
-
'%s %s %s %s' % (crop['x'], crop['y'],
|
|
159
|
-
crop['width'], crop['height']))
|
|
160
|
-
|
|
161
|
-
has_xlink = doc.namespace('xlink') is not None
|
|
162
|
-
doc.set_attribute(ph.placeholder,
|
|
163
|
-
'href', image_info.location,
|
|
164
|
-
'xlink' if has_xlink else None)
|
|
165
|
-
|
|
166
|
-
doc.set_attribute(ph.placeholder, 'x', '0.0')
|
|
167
|
-
doc.set_attribute(ph.placeholder, 'y', '0.0')
|
|
168
|
-
doc.set_attribute(ph.placeholder, 'width', '%s' % image_info.width)
|
|
169
|
-
doc.set_attribute(ph.placeholder, 'height', '%s' % image_info.height)
|
|
170
|
-
|
|
171
|
-
doc.set_attribute(ph.placeholder, 'bbox',
|
|
172
|
-
'{"x": %s, "y": %s, "width": %s, "height": %s}'
|
|
173
|
-
% (crop['x'], crop['y'],
|
|
174
|
-
crop['width'], crop['height']), 'pap')
|
|
175
|
-
doc.set_attribute(ph.placeholder, 'img-dimensions',
|
|
176
|
-
'{"width": %s, "height": %s}'
|
|
177
|
-
% (image_info.width, image_info.height), 'pap')
|
|
178
|
-
|
|
179
|
-
_set_changed(doc, ph.placeholder)
|
|
180
|
-
|
|
181
|
-
return doc
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/edit_template/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/edit_template/render_text.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|