13
13
14
14
class EnumValue (Enum ):
15
15
"""Helper class to represent enumeration like values"""
16
+
16
17
def get_name (self ) -> str :
17
18
raise NotImplementedError ('Override get_name in subclass' )
18
19
19
20
def __str__ (self ) -> str :
20
21
return '({} {})' .format (self .get_name (), self .value )
21
22
22
23
23
- class DateValue () :
24
+ class DateValue :
24
25
"""Helper class to represent a single named date value"""
26
+
25
27
def __init__ (self , name : str , date : str ):
26
28
self .name = name
27
29
self .date = date
@@ -30,8 +32,9 @@ def __str__(self) -> str:
30
32
return '({} {})' .format (self .name , self .date )
31
33
32
34
33
- class UUIDValue () :
35
+ class UUIDValue :
34
36
"""Helper class to represent a single named UUID value"""
37
+
35
38
def __init__ (self , name : str , uuid : str ):
36
39
self .name = name
37
40
self .uuid = uuid
@@ -40,8 +43,9 @@ def __str__(self) -> str:
40
43
return '({} {})' .format (self .name , self .uuid )
41
44
42
45
43
- class BoolValue () :
46
+ class BoolValue :
44
47
"""Helper class to represent a single named boolean value"""
48
+
45
49
def __init__ (self , name : str , value : bool ):
46
50
self .name = name
47
51
self .value = str (value ).lower ()
@@ -50,8 +54,9 @@ def __str__(self) -> str:
50
54
return '({} {})' .format (self .name , self .value )
51
55
52
56
53
- class StringValue () :
57
+ class StringValue :
54
58
"""Helper class to represent a single named string value"""
59
+
55
60
def __init__ (self , name : str , value : str ):
56
61
self .name = name
57
62
self .value = value
@@ -60,8 +65,9 @@ def __str__(self) -> str:
60
65
return '({} "{}")' .format (self .name , escape_string (self .value ))
61
66
62
67
63
- class FloatValue () :
68
+ class FloatValue :
64
69
"""Helper class to represent a single named float value"""
70
+
65
71
def __init__ (self , name : str , value : float ):
66
72
self .name = name
67
73
self .value = value
@@ -115,7 +121,7 @@ def __init__(self, category: str):
115
121
super ().__init__ ('category' , category )
116
122
117
123
118
- class Position () :
124
+ class Position :
119
125
def __init__ (self , x : float , y : float ):
120
126
self .x = x
121
127
self .y = y
@@ -124,7 +130,7 @@ def __str__(self) -> str:
124
130
return '(position {} {})' .format (format_float (self .x ), format_float (self .y ))
125
131
126
132
127
- class Position3D () :
133
+ class Position3D :
128
134
def __init__ (self , x : float , y : float , z : float ):
129
135
self .x = x
130
136
self .y = y
@@ -135,15 +141,17 @@ def zero() -> 'Position3D':
135
141
return Position3D (0.0 , 0.0 , 0.0 )
136
142
137
143
def __str__ (self ) -> str :
138
- return '(3d_position {} {} {})' .format (format_float (self .x ), format_float (self .y ), format_float (self .z ))
144
+ return '(3d_position {} {} {})' .format (
145
+ format_float (self .x ), format_float (self .y ), format_float (self .z )
146
+ )
139
147
140
148
141
149
class Rotation (FloatValue ):
142
150
def __init__ (self , rotation : float ):
143
151
super ().__init__ ('rotation' , rotation )
144
152
145
153
146
- class Rotation3D () :
154
+ class Rotation3D :
147
155
def __init__ (self , x : float , y : float , z : float ):
148
156
self .x = x
149
157
self .y = y
@@ -154,7 +162,9 @@ def zero() -> 'Rotation3D':
154
162
return Rotation3D (0.0 , 0.0 , 0.0 )
155
163
156
164
def __str__ (self ) -> str :
157
- return '(3d_rotation {} {} {})' .format (format_float (self .x ), format_float (self .y ), format_float (self .z ))
165
+ return '(3d_rotation {} {} {})' .format (
166
+ format_float (self .x ), format_float (self .y ), format_float (self .z )
167
+ )
158
168
159
169
160
170
class Length (FloatValue ):
@@ -187,7 +197,7 @@ def __init__(self, grab_area: bool):
187
197
super ().__init__ ('grab_area' , grab_area )
188
198
189
199
190
- class Vertex () :
200
+ class Vertex :
191
201
def __init__ (self , position : Position , angle : Angle ):
192
202
self .position = position
193
203
self .angle = angle
@@ -196,17 +206,24 @@ def __str__(self) -> str:
196
206
return '(vertex {} {})' .format (self .position , self .angle )
197
207
198
208
199
- class Layer () :
209
+ class Layer :
200
210
def __init__ (self , layer : str ):
201
211
self .layer = layer
202
212
203
213
def __str__ (self ) -> str :
204
214
return '(layer {})' .format (self .layer )
205
215
206
216
207
- class Polygon ():
208
- def __init__ (self , uuid : str , layer : Layer , width : Width , fill : Fill ,
209
- grab_area : GrabArea , vertices : Optional [List [Vertex ]] = None ):
217
+ class Polygon :
218
+ def __init__ (
219
+ self ,
220
+ uuid : str ,
221
+ layer : Layer ,
222
+ width : Width ,
223
+ fill : Fill ,
224
+ grab_area : GrabArea ,
225
+ vertices : Optional [List [Vertex ]] = None ,
226
+ ):
210
227
self .uuid = uuid
211
228
self .layer = layer
212
229
self .width = width
@@ -218,8 +235,9 @@ def add_vertex(self, vertex: Vertex) -> None:
218
235
self .vertices .append (vertex )
219
236
220
237
def __str__ (self ) -> str :
221
- ret = '(polygon {} {}\n ' .format (self .uuid , self .layer ) + \
222
- ' {} {} {}\n ' .format (self .width , self .fill , self .grab_area )
238
+ ret = '(polygon {} {}\n ' .format (self .uuid , self .layer ) + ' {} {} {}\n ' .format (
239
+ self .width , self .fill , self .grab_area
240
+ )
223
241
ret += indent_entities (self .vertices )
224
242
ret += ')'
225
243
return ret
@@ -270,9 +288,17 @@ def __init__(self, diameter: float):
270
288
super ().__init__ ('diameter' , diameter )
271
289
272
290
273
- class Circle ():
274
- def __init__ (self , uuid : str , layer : Layer , width : Width , fill : Fill ,
275
- grab_area : GrabArea , diameter : Diameter , position : Position ):
291
+ class Circle :
292
+ def __init__ (
293
+ self ,
294
+ uuid : str ,
295
+ layer : Layer ,
296
+ width : Width ,
297
+ fill : Fill ,
298
+ grab_area : GrabArea ,
299
+ diameter : Diameter ,
300
+ position : Position ,
301
+ ):
276
302
self .uuid = uuid
277
303
self .layer = layer
278
304
self .width = width
@@ -283,8 +309,9 @@ def __init__(self, uuid: str, layer: Layer, width: Width, fill: Fill,
283
309
284
310
def __str__ (self ) -> str :
285
311
ret = '(circle {} {}\n ' .format (self .uuid , self .layer )
286
- ret += ' {} {} {} {} {}\n ' .format (self .width , self .fill , self .grab_area ,
287
- self .diameter , self .position )
312
+ ret += ' {} {} {} {} {}\n ' .format (
313
+ self .width , self .fill , self .grab_area , self .diameter , self .position
314
+ )
288
315
ret += ')'
289
316
return ret
290
317
@@ -294,16 +321,25 @@ def __init__(self, value: str):
294
321
super ().__init__ ('value' , value )
295
322
296
323
297
- class Align () :
324
+ class Align :
298
325
def __init__ (self , align : str ):
299
326
self .align = align
300
327
301
328
def __str__ (self ) -> str :
302
329
return '(align {})' .format (self .align )
303
330
304
331
305
- class Text ():
306
- def __init__ (self , uuid : str , layer : Layer , value : Value , align : Align , height : Height , position : Position , rotation : Rotation ):
332
+ class Text :
333
+ def __init__ (
334
+ self ,
335
+ uuid : str ,
336
+ layer : Layer ,
337
+ value : Value ,
338
+ align : Align ,
339
+ height : Height ,
340
+ position : Position ,
341
+ rotation : Rotation ,
342
+ ):
307
343
self .uuid = uuid
308
344
self .layer = layer
309
345
self .value = value
@@ -313,18 +349,24 @@ def __init__(self, uuid: str, layer: Layer, value: Value, align: Align, height:
313
349
self .rotation = rotation
314
350
315
351
def __str__ (self ) -> str :
316
- return '(text {} {} {}\n ' .format (self .uuid , self .layer , self .value ) + \
317
- ' {} {} {} {}\n ' .format (self .align , self .height , self .position , self .rotation ) + \
318
- ')'
352
+ return (
353
+ '(text {} {} {}\n ' .format (self .uuid , self .layer , self .value )
354
+ + ' {} {} {} {}\n ' .format (self .align , self .height , self .position , self .rotation )
355
+ + ')'
356
+ )
319
357
320
358
321
- class Resource () :
359
+ class Resource :
322
360
def __init__ (self , name : str , mediatype : str , url : str ):
323
361
self .name = name
324
362
self .mediatype = mediatype
325
363
self .url = url
326
364
327
365
def __str__ (self ) -> str :
328
- return '(resource "{}" (mediatype "{}")\n ' .format (escape_string (self .name ), escape_string (self .mediatype )) + \
329
- ' (url "{}")\n ' .format (escape_string (self .url )) + \
330
- ')'
366
+ return (
367
+ '(resource "{}" (mediatype "{}")\n ' .format (
368
+ escape_string (self .name ), escape_string (self .mediatype )
369
+ )
370
+ + ' (url "{}")\n ' .format (escape_string (self .url ))
371
+ + ')'
372
+ )
0 commit comments