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.
Files changed (49) hide show
  1. {papyru-2.11.1.dev139/papyru.egg-info → papyru-2.11.1.dev147}/PKG-INFO +1 -1
  2. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/edit_template/xml.py +38 -70
  3. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147/papyru.egg-info}/PKG-INFO +1 -1
  4. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/setup.py +1 -1
  5. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/LICENSE.txt +0 -0
  6. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/README.md +0 -0
  7. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/bin/generate_jsonschema.py +0 -0
  8. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/__init__.py +0 -0
  9. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/auth.py +0 -0
  10. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/context.py +0 -0
  11. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/__init__.py +0 -0
  12. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/component.py +0 -0
  13. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/constants.py +0 -0
  14. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/edit_template/__init__.py +0 -0
  15. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/edit_template/ean.py +0 -0
  16. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/edit_template/manufacturer_address.py +0 -0
  17. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/edit_template/motive.py +0 -0
  18. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/edit_template/render_text.py +0 -0
  19. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/edit_template/title.py +0 -0
  20. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/create_variant/resi.py +0 -0
  21. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/logger.py +0 -0
  22. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/logger_stdout.py +0 -0
  23. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/logger_types.py +0 -0
  24. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/middleware.py +0 -0
  25. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/problem.py +0 -0
  26. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/profiler.py +0 -0
  27. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/resource.py +0 -0
  28. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/serializer.py +0 -0
  29. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/stack_context.py +0 -0
  30. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/static/__init__.py +0 -0
  31. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/static/apps.py +0 -0
  32. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/static/urls.py +0 -0
  33. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/static/views.py +0 -0
  34. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/utils.py +0 -0
  35. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/validation.py +0 -0
  36. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/varspool/__init__.py +0 -0
  37. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/varspool/assets/Job.json +0 -0
  38. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/varspool/assets/JobStatusHistory.json +0 -0
  39. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/varspool/command/__init__.py +0 -0
  40. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/varspool/command/config.py +0 -0
  41. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/varspool/command/types.py +0 -0
  42. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/varspool/serializers.py +0 -0
  43. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/varspool/types.py +0 -0
  44. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru/xml_helper.py +0 -0
  45. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru.egg-info/SOURCES.txt +0 -0
  46. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru.egg-info/dependency_links.txt +0 -0
  47. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru.egg-info/requires.txt +0 -0
  48. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/papyru.egg-info/top_level.txt +0 -0
  49. {papyru-2.11.1.dev139 → papyru-2.11.1.dev147}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: papyru
3
- Version: 2.11.1.dev139
3
+ Version: 2.11.1.dev147
4
4
  Summary: minimal REST library with OpenAPI-based validation for django
5
5
  Home-page: http://www.puzzleyou.net/
6
6
  Author: puzzleYOU GmbH
@@ -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 CustomPlacement:
15
- container_width: float
16
- container_height: float
17
- scaled_img_width: float
18
- scaled_img_height: float
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
- placement: CustomPlacement = None
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
- if image_info.placement is not None:
92
- return _place_custom_image(doc, ph, image_info)
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
- image_dims = (float(image_info.width),
98
- float(image_info.height))
93
+ image_dims = (float(image_info.width),
94
+ float(image_info.height))
99
95
 
100
- viewbox = _fit_dimensions(wrapper_dims, image_dims)
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
- doc.set_attribute(ph.wrapper,
103
- 'viewBox',
104
- '%s %s %s %s' % viewbox)
101
+ doc.set_attribute(ph.wrapper,
102
+ 'viewBox',
103
+ '%s %s %s %s' % viewbox)
105
104
 
106
- has_xlink = doc.namespace('xlink') is not None
107
- doc.set_attribute(ph.placeholder,
108
- 'href', image_info.location,
109
- 'xlink' if has_xlink else None)
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
- doc.set_attribute(ph.placeholder, 'x', '0.0')
112
- doc.set_attribute(ph.placeholder, 'y', '0.0')
113
- doc.set_attribute(ph.placeholder, 'width', '%s' % image_dims[0])
114
- doc.set_attribute(ph.placeholder, 'height', '%s' % image_dims[1])
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
- _set_changed(doc, ph.placeholder)
125
+ _set_changed(doc, ph.placeholder)
117
126
 
118
- return doc
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: papyru
3
- Version: 2.11.1.dev139
3
+ Version: 2.11.1.dev147
4
4
  Summary: minimal REST library with OpenAPI-based validation for django
5
5
  Home-page: http://www.puzzleyou.net/
6
6
  Author: puzzleYOU GmbH
@@ -2,7 +2,7 @@ from setuptools import setup
2
2
 
3
3
  setup(
4
4
  name='papyru',
5
- version='2.11.1.dev139',
5
+ version='2.11.1.dev147',
6
6
  description=(
7
7
  'minimal REST library with OpenAPI-based validation for django'),
8
8
  author='puzzleYOU GmbH',
File without changes
File without changes