@@ -68,11 +68,13 @@ def _parse_xform(text: str) -> Matrix:
6868 except ValueError :
6969 logger .warning ("Invalid XForm values: %s, using identity" , text )
7070 return Matrix ()
71- return Matrix ([
72- [a , c , tx ],
73- [b , d , ty ],
74- [0 , 0 , 1 ],
75- ])
71+ return Matrix (
72+ [
73+ [a , c , tx ],
74+ [b , d , ty ],
75+ [0 , 0 , 1 ],
76+ ]
77+ )
7678
7779
7880def _parse_verts (text : str ) -> List [Dict [str , float ]]:
@@ -114,9 +116,7 @@ def _apply_xform_to_geo(geo: Geometry, xform: Matrix) -> Geometry:
114116 return geo
115117
116118
117- def _build_rect (
118- w : float , h : float , cr : float
119- ) -> Geometry :
119+ def _build_rect (w : float , h : float , cr : float ) -> Geometry :
120120 geo = Geometry ()
121121 if w <= 0 or h <= 0 :
122122 return geo
@@ -223,8 +223,12 @@ def _build_path_from_verts_and_prims(
223223 c0y = sv .get ("c0y" )
224224 c1x = ev .get ("c1x" )
225225 c1y = ev .get ("c1y" )
226- if (c0x is not None and c0y is not None
227- and c1x is not None and c1y is not None ):
226+ if (
227+ c0x is not None
228+ and c0y is not None
229+ and c1x is not None
230+ and c1y is not None
231+ ):
228232 geo .bezier_to (ex , ey , c0x , c0y , c1x , c1y )
229233 else :
230234 geo .line_to (ex , ey )
@@ -303,9 +307,7 @@ def _shape_to_geometry(
303307 else ""
304308 )
305309 prims = _parse_prims (prim_list_raw )
306- geo = _build_path_from_verts_and_prims (
307- verts , prims , prim_list_raw
308- )
310+ geo = _build_path_from_verts_and_prims (verts , prims , prim_list_raw )
309311
310312 elif shape_type == "Text" :
311313 has_backup = shape_elem .get ("HasBackupPath" , "0" ) == "1"
@@ -317,9 +319,7 @@ def _shape_to_geometry(
317319 if children_elem is not None :
318320 combined = Geometry ()
319321 for child in children_elem .findall ("Shape" ):
320- child_result = _shape_to_geometry (
321- child , cut_settings , bitmaps
322- )
322+ child_result = _shape_to_geometry (child , cut_settings , bitmaps )
323323 if child_result is not None :
324324 child_cut_idx , child_geo = child_result
325325 child_geo = _apply_xform_to_geo (child_geo , xform )
@@ -339,13 +339,15 @@ def _shape_to_geometry(
339339 logger .warning ("Failed to decode Bitmap data" )
340340 return None
341341 if bitmaps is not None :
342- bitmaps .append (BitmapInfo (
343- cut_index = cut_index ,
344- xform = xform ,
345- width = w ,
346- height = h ,
347- png_data = png_bytes ,
348- ))
342+ bitmaps .append (
343+ BitmapInfo (
344+ cut_index = cut_index ,
345+ xform = xform ,
346+ width = w ,
347+ height = h ,
348+ png_data = png_bytes ,
349+ )
350+ )
349351 geo = _build_rect (w , h , cr = 0 )
350352 else :
351353 return None
@@ -414,9 +416,8 @@ def _parse_cut_settings(
414416 self , project : ET .Element
415417 ) -> Dict [int , Dict [str , Any ]]:
416418 cut_settings : Dict [int , Dict [str , Any ]] = {}
417- for cs_elem in (
418- list (project .findall ("CutSetting" ))
419- + list (project .findall ("CutSetting_Img" ))
419+ for cs_elem in list (project .findall ("CutSetting" )) + list (
420+ project .findall ("CutSetting_Img" )
420421 ):
421422 index_el = cs_elem .find ("index" )
422423 if index_el is None :
@@ -452,9 +453,12 @@ def _render_bitmaps_to_svg(self) -> Optional[bytes]:
452453 for bm in self ._bitmaps :
453454 hw , hh = bm .width / 2.0 , bm .height / 2.0
454455 a , b , c , d , tx , ty = (
455- bm .xform .m [0 , 0 ], bm .xform .m [1 , 0 ],
456- bm .xform .m [0 , 1 ], bm .xform .m [1 , 1 ],
457- bm .xform .m [0 , 2 ], bm .xform .m [1 , 2 ],
456+ bm .xform .m [0 , 0 ],
457+ bm .xform .m [1 , 0 ],
458+ bm .xform .m [0 , 1 ],
459+ bm .xform .m [1 , 1 ],
460+ bm .xform .m [0 , 2 ],
461+ bm .xform .m [1 , 2 ],
458462 )
459463 data_url = "data:image/png;base64," + base64 .b64encode (
460464 bm .png_data
@@ -608,9 +612,9 @@ def vectorize(
608612 merged_geo .extend (geo )
609613
610614 if split_layers :
611- final_geometries : Dict [Optional [str ], Geometry ] = (
612- geometries or { None : merged_geo }
613- )
615+ final_geometries : Dict [Optional [str ], Geometry ] = geometries or {
616+ None : merged_geo
617+ }
614618 else :
615619 final_geometries = {None : merged_geo }
616620
0 commit comments