decksmith 0.1.6__py3-none-any.whl → 0.1.7__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.
- decksmith/card_builder.py +2 -1
- decksmith/validate.py +66 -50
- {decksmith-0.1.6.dist-info → decksmith-0.1.7.dist-info}/METADATA +1 -1
- {decksmith-0.1.6.dist-info → decksmith-0.1.7.dist-info}/RECORD +6 -6
- {decksmith-0.1.6.dist-info → decksmith-0.1.7.dist-info}/WHEEL +0 -0
- {decksmith-0.1.6.dist-info → decksmith-0.1.7.dist-info}/entry_points.txt +0 -0
decksmith/card_builder.py
CHANGED
|
@@ -7,7 +7,7 @@ import operator
|
|
|
7
7
|
import pandas as pd
|
|
8
8
|
from PIL import Image, ImageDraw, ImageFont
|
|
9
9
|
from .utils import get_wrapped_text, apply_anchor
|
|
10
|
-
from .validate import validate_card
|
|
10
|
+
from .validate import validate_card, transform_card
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class CardBuilder:
|
|
@@ -585,6 +585,7 @@ class CardBuilder:
|
|
|
585
585
|
Args:
|
|
586
586
|
output_path (str): The path where the card image will be saved.
|
|
587
587
|
"""
|
|
588
|
+
self.spec = transform_card(self.spec)
|
|
588
589
|
validate_card(self.spec)
|
|
589
590
|
|
|
590
591
|
for el in self.spec.get("elements", []):
|
decksmith/validate.py
CHANGED
|
@@ -5,79 +5,79 @@ Python module for validating a dictionar
|
|
|
5
5
|
from jval import validate
|
|
6
6
|
|
|
7
7
|
ELEMENT_SPEC = {
|
|
8
|
-
"?*id": "
|
|
9
|
-
"*type": "
|
|
10
|
-
"?*position": ["
|
|
11
|
-
"?*relative_to": ["
|
|
12
|
-
"?*anchor": "
|
|
8
|
+
"?*id": "<?str>",
|
|
9
|
+
"*type": "<?str>",
|
|
10
|
+
"?*position": ["<?float>"],
|
|
11
|
+
"?*relative_to": ["<?str>"],
|
|
12
|
+
"?*anchor": "<?str>",
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
SPECS_FOR_TYPE = {
|
|
16
16
|
"text": {
|
|
17
|
-
"*text": "
|
|
18
|
-
"?*color": ["
|
|
19
|
-
"?*font_path": "
|
|
20
|
-
"?*font_size": "
|
|
21
|
-
"?*font_variant": "
|
|
22
|
-
"?*line_spacing": "
|
|
23
|
-
"?*width": "
|
|
24
|
-
"?*align": "
|
|
25
|
-
"?*stroke_width": "
|
|
26
|
-
"?*stroke_color": ["
|
|
17
|
+
"*text": "<?str>",
|
|
18
|
+
"?*color": ["<?int>"],
|
|
19
|
+
"?*font_path": "<?str>",
|
|
20
|
+
"?*font_size": "<?int>",
|
|
21
|
+
"?*font_variant": "<?str>",
|
|
22
|
+
"?*line_spacing": "<?int>",
|
|
23
|
+
"?*width": "<?int>",
|
|
24
|
+
"?*align": "<?str>",
|
|
25
|
+
"?*stroke_width": "<?int>",
|
|
26
|
+
"?*stroke_color": ["<?int>"],
|
|
27
27
|
},
|
|
28
28
|
"image": {
|
|
29
|
-
"*path": "
|
|
29
|
+
"*path": "<?str>",
|
|
30
30
|
"?*filters": {
|
|
31
|
-
"?*crop_top": "
|
|
32
|
-
"?*crop_bottom": "
|
|
33
|
-
"?*crop_left": "
|
|
34
|
-
"?*crop_right": "
|
|
35
|
-
"?*crop_box": ["
|
|
36
|
-
"?*rotate": "
|
|
37
|
-
"?*flip": "
|
|
31
|
+
"?*crop_top": "<?int>",
|
|
32
|
+
"?*crop_bottom": "<?int>",
|
|
33
|
+
"?*crop_left": "<?int>",
|
|
34
|
+
"?*crop_right": "<?int>",
|
|
35
|
+
"?*crop_box": ["<?int>"],
|
|
36
|
+
"?*rotate": "<?int>",
|
|
37
|
+
"?*flip": "<?str>",
|
|
38
38
|
"?*resize": ["<?int>"],
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
41
|
"circle": {
|
|
42
|
-
"*radius": "
|
|
43
|
-
"?*color": ["
|
|
44
|
-
"?*outline_color": ["
|
|
45
|
-
"?*outline_width": "
|
|
42
|
+
"*radius": "<?int>",
|
|
43
|
+
"?*color": ["<?int>"],
|
|
44
|
+
"?*outline_color": ["<?int>"],
|
|
45
|
+
"?*outline_width": "<?int>",
|
|
46
46
|
},
|
|
47
47
|
"ellipse": {
|
|
48
|
-
"*size": ["
|
|
49
|
-
"?*color": ["
|
|
50
|
-
"?*outline_color": ["
|
|
51
|
-
"?*outline_width": "
|
|
48
|
+
"*size": ["<?int>"],
|
|
49
|
+
"?*color": ["<?int>"],
|
|
50
|
+
"?*outline_color": ["<?int>"],
|
|
51
|
+
"?*outline_width": "<?int>",
|
|
52
52
|
},
|
|
53
53
|
"polygon": {
|
|
54
|
-
"*points": [["
|
|
55
|
-
"?*color": ["
|
|
56
|
-
"?*outline_color": ["
|
|
57
|
-
"?*outline_width": "
|
|
54
|
+
"*points": [["<?int>"]],
|
|
55
|
+
"?*color": ["<?int>"],
|
|
56
|
+
"?*outline_color": ["<?int>"],
|
|
57
|
+
"?*outline_width": "<?int>",
|
|
58
58
|
},
|
|
59
59
|
"regular-polygon": {
|
|
60
|
-
"*radius": "
|
|
61
|
-
"*sides": "
|
|
62
|
-
"?*rotation": "
|
|
63
|
-
"?*color": ["
|
|
64
|
-
"?*outline_color": ["
|
|
65
|
-
"?*outline_width": "
|
|
60
|
+
"*radius": "<?int>",
|
|
61
|
+
"*sides": "<?int>",
|
|
62
|
+
"?*rotation": "<?int>",
|
|
63
|
+
"?*color": ["<?int>"],
|
|
64
|
+
"?*outline_color": ["<?int>"],
|
|
65
|
+
"?*outline_width": "<?int>",
|
|
66
66
|
},
|
|
67
67
|
"rectangle": {
|
|
68
|
-
"*size": ["
|
|
69
|
-
"?*corners": ["
|
|
70
|
-
"?*corner_radius": "
|
|
71
|
-
"?*color": ["
|
|
72
|
-
"?*outline_color": ["
|
|
73
|
-
"?*outline_width": "
|
|
68
|
+
"*size": ["<?int>"],
|
|
69
|
+
"?*corners": ["<?bool>"],
|
|
70
|
+
"?*corner_radius": "<?int>",
|
|
71
|
+
"?*color": ["<?int>"],
|
|
72
|
+
"?*outline_color": ["<?int>"],
|
|
73
|
+
"?*outline_width": "<?int>",
|
|
74
74
|
},
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
CARD_SPEC = {
|
|
78
|
-
"*width": "
|
|
79
|
-
"*height": "
|
|
80
|
-
"?*background_color": ["
|
|
78
|
+
"*width": "<?int>",
|
|
79
|
+
"*height": "<?int>",
|
|
80
|
+
"?*background_color": ["<?int>"],
|
|
81
81
|
"*elements": [],
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -106,3 +106,19 @@ def validate_card(card):
|
|
|
106
106
|
for element in card["elements"]:
|
|
107
107
|
# print(f"DEBUG: {element['type']}")
|
|
108
108
|
validate_element(element, element["type"])
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def transform_card(card):
|
|
112
|
+
"""
|
|
113
|
+
Perform certain automatic type casts on the card and its
|
|
114
|
+
elements. For example, cast the "text" property of elements
|
|
115
|
+
of type "text" to str, to support painting numbers as text.
|
|
116
|
+
Args:
|
|
117
|
+
card (dict): The card.
|
|
118
|
+
Return:
|
|
119
|
+
dict: The transformed card with all automatic casts applied.
|
|
120
|
+
"""
|
|
121
|
+
for element in card.get("elements", []):
|
|
122
|
+
if element.get("type") == "text" and "text" in element:
|
|
123
|
+
element["text"] = str(element["text"])
|
|
124
|
+
return card
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
decksmith/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
decksmith/card_builder.py,sha256=
|
|
2
|
+
decksmith/card_builder.py,sha256=dwM7MOoTQfvJYDLgskzJkWzfeZAPJhSDz9gBLr6qOe0,25374
|
|
3
3
|
decksmith/deck_builder.py,sha256=8YK4ds51-z9f-BUyQ8jyh15BY9f16UQBYFI6Z87yFfU,3415
|
|
4
4
|
decksmith/export.py,sha256=aMMoGdBDQ-Gr4QJ_ziiV3F673kEyXzM0phVq14uDDJg,6225
|
|
5
5
|
decksmith/main.py,sha256=AzDq1aXziQmYz2IWdWSoBFskUeAXfOmcfYnIQUNIYp0,3357
|
|
6
6
|
decksmith/templates/deck.csv,sha256=pNJebNxoDIfM8m0-aj05YrANHih1BTKOMry1kspIpPI,462
|
|
7
7
|
decksmith/templates/deck.json,sha256=BTTnmaFP5AkbbC_B7uMF6R4bOM7JizW6EATcsjjJrT4,695
|
|
8
8
|
decksmith/utils.py,sha256=XKSapVB1_zZvYcl3LgZcHAob4Pk5HUT9AnlAQBAdeTs,2833
|
|
9
|
-
decksmith/validate.py,sha256=
|
|
10
|
-
decksmith-0.1.
|
|
11
|
-
decksmith-0.1.
|
|
12
|
-
decksmith-0.1.
|
|
13
|
-
decksmith-0.1.
|
|
9
|
+
decksmith/validate.py,sha256=86mxEFC9Bvdh7zvgtsatw9Ry6f01WZcQTrVVOK1eMNg,3427
|
|
10
|
+
decksmith-0.1.7.dist-info/entry_points.txt,sha256=-usRztjj2gnfmPubb8nFYHD22drzThAmSfM6geWI98Y,48
|
|
11
|
+
decksmith-0.1.7.dist-info/METADATA,sha256=sh1QC3Jh8dE8Af_fIkoSO-UFsc8QiNI2MGLfk5wB4ZE,2419
|
|
12
|
+
decksmith-0.1.7.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
13
|
+
decksmith-0.1.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|