@lark-apaas/coding-steering 0.1.28 → 0.1.30-alpha.20260809164221

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 (24) hide show
  1. package/package.json +1 -1
  2. package/steering/design-html/skills/animated-video/SKILL.md +1 -1
  3. package/steering/design-html/skills/charts/SKILL.md +1 -1
  4. package/steering/design-html/skills/data-viz/SKILL.md +1 -1
  5. package/steering/design-html/skills/frontend-design/SKILL.md +2 -2
  6. package/steering/design-html/skills/pptx-style-extract/SKILL.md +87 -0
  7. package/steering/design-html/skills/pptx-style-extract/font-fallback.yaml +129 -0
  8. package/steering/design-html/skills/pptx-style-extract/scripts/census.py +962 -0
  9. package/steering/design-html/skills/pptx-style-extract/scripts/check_v2.py +907 -0
  10. package/steering/design-html/skills/pptx-style-extract/scripts/draft.py +873 -0
  11. package/steering/design-html/skills/pptx-style-extract/scripts/extract.py +787 -0
  12. package/steering/design-html/skills/pptx-style-extract/scripts/ooxml.py +701 -0
  13. package/steering/design-html/skills/pptx-style-extract/scripts/package.py +935 -0
  14. package/steering/design-html/skills/pptx-style-extract/scripts/parts.py +490 -0
  15. package/steering/design-html/skills/pptx-style-extract/scripts/query.py +567 -0
  16. package/steering/design-html/skills/pptx-style-extract/scripts/render_pages.py +669 -0
  17. package/steering/design-html/skills/pptx-style-extract/scripts/verify_font.py +68 -0
  18. package/steering/design-html/skills/pptx-style-extract/v2-format-spec.md +191 -0
  19. package/steering/design-html/skills/preflight/SKILL.md +131 -26
  20. package/steering/design-html/skills/slide-deck/SKILL.md +19 -0
  21. package/steering/design-html/skills/{visual-report → visual-exposure}/SKILL.md +1 -1
  22. package/steering/design-html/skills/mini-game/SKILL.md +0 -71
  23. package/steering/design-html/skills/mini-game/references/three-js.md +0 -54
  24. package/steering/design-html/skills/preflight/scripts/probe.sh +0 -108
@@ -0,0 +1,490 @@
1
+ #!/usr/bin/env python3
2
+ """S1 unpack / S2 reference graph + master triage / S3 theme+clrMap / S4 shape facts."""
3
+ import os
4
+ import re
5
+ import zipfile
6
+ from collections import Counter
7
+ from xml.etree import ElementTree as ET
8
+
9
+ from ooxml import (NS, R_EMBED, R_ID, R_LINK, OFFICE_DEFAULT_ACCENTS, OFFICE_DEFAULT_FONTS,
10
+ classify_box, describe_effects, describe_fill,
11
+ describe_geom, describe_line, group_transform, local,
12
+ read_color, read_lvl, read_txbody, read_xfrm, resolve_color,
13
+ resolve_part, rotated_bbox)
14
+
15
+ SLIDE_RE = re.compile(r'ppt/slides/slide\d+\.xml$')
16
+ LAYOUT_RE = re.compile(r'ppt/slideLayouts/slideLayout\d+\.xml$')
17
+ MASTER_RE = re.compile(r'ppt/slideMasters/slideMaster\d+\.xml$')
18
+ THEME_RE = re.compile(r'ppt/theme/theme\d+\.xml$')
19
+ MAX_ZIP_ENTRY_BYTES = 50 * 1024 * 1024
20
+ MAX_MEDIA_READ_BYTES = 120 * 1024 * 1024
21
+
22
+
23
+ def _num(part):
24
+ m = re.search(r'(\d+)\.xml$', part)
25
+ return int(m.group(1)) if m else 0
26
+
27
+
28
+ class Package:
29
+ """S1: the opened container + part inventory + content-type discrimination."""
30
+
31
+ def __init__(self, path):
32
+ self.path = path
33
+ self.zip = zipfile.ZipFile(path)
34
+ self.names = set(self.zip.namelist())
35
+ self._cache = {}
36
+ self._media_bytes_read = 0
37
+ self._media_parts_read = set()
38
+ ct = self.zip.read('[Content_Types].xml').decode('utf-8', 'replace')
39
+ m = re.search(r'presentationml\.(presentation|template|slideshow)\.main', ct)
40
+ self.kind = m.group(1) if m else 'unknown'
41
+ self.slides = sorted((n for n in self.names if SLIDE_RE.match(n)), key=_num)
42
+ self.layouts = sorted((n for n in self.names if LAYOUT_RE.match(n)), key=_num)
43
+ self.masters = sorted((n for n in self.names if MASTER_RE.match(n)), key=_num)
44
+ self.themes, self.theme_discovery = self._find_themes(ct)
45
+ # zip directory entries ('ppt/media/') must not be counted as assets —
46
+ # 票 03 recon counted one, which is why its media totals run one high.
47
+ self.media = sorted(n for n in self.names
48
+ if n.startswith('ppt/media/') and not n.endswith('/'))
49
+
50
+ def _find_themes(self, ct):
51
+ """Theme parts come from [Content_Types].xml, not from a path pattern.
52
+
53
+ Compressors relocate them — 飞书压缩版 puts them at
54
+ ppt/slideMasters/theme/themeN.xml — and a `ppt/theme/` regex then finds
55
+ nothing to bind the masters to, so every schemeClr resolves to
56
+ UNRESOLVED:no-scheme. The path regex stays as the fallback for packages
57
+ whose content types are unreadable.
58
+ """
59
+ try:
60
+ root = ET.fromstring(ct.encode('utf-8'))
61
+ found = [o.get('PartName', '').lstrip('/') for o in root.findall('ct:Override', NS)
62
+ if (o.get('ContentType') or '').endswith('theme+xml')]
63
+ found = sorted((n for n in found if n in self.names), key=_num)
64
+ except ET.ParseError:
65
+ found = []
66
+ if found:
67
+ return found, 'content-types'
68
+ return sorted((n for n in self.names if THEME_RE.match(n)), key=_num), 'path-regex'
69
+
70
+ def xml(self, part):
71
+ if part not in self._cache:
72
+ self._cache[part] = ET.fromstring(self.zip.read(part))
73
+ return self._cache[part]
74
+
75
+ def rels(self, part):
76
+ d, f = os.path.split(part)
77
+ rp = '%s/_rels/%s.rels' % (d, f)
78
+ out = {}
79
+ if rp in self.names:
80
+ for r in self.xml(rp).findall('rel:Relationship', NS):
81
+ out[r.get('Id')] = {'type': r.get('Type').rsplit('/', 1)[-1],
82
+ 'target': r.get('Target'),
83
+ 'external': r.get('TargetMode') == 'External'}
84
+ return out
85
+
86
+ def size_of(self, part):
87
+ return self.zip.getinfo(part).file_size if part in self.names else 0
88
+
89
+ def read_media_part(self, part):
90
+ """Read a media part only after zip-bomb and cumulative budget checks."""
91
+ if part not in self.names:
92
+ return None, 'missing'
93
+ zinfo = self.zip.getinfo(part)
94
+ if zinfo.file_size > MAX_ZIP_ENTRY_BYTES:
95
+ return None, 'zip-entry-too-large'
96
+ new_total = self._media_bytes_read
97
+ if part not in self._media_parts_read:
98
+ new_total += zinfo.file_size
99
+ if new_total > MAX_MEDIA_READ_BYTES:
100
+ return None, 'zip-media-budget-exceeded'
101
+ raw = self.zip.read(part)
102
+ if part not in self._media_parts_read:
103
+ self._media_parts_read.add(part)
104
+ self._media_bytes_read += len(raw)
105
+ return raw, None
106
+
107
+
108
+ class PartCtx:
109
+ """Per-part resolution context: units + the master's clrMap + its theme's clrScheme."""
110
+
111
+ def __init__(self, pkg, part, layer, units, clrmap, clrscheme, master=None, theme=None):
112
+ self.pkg, self.part, self.layer = pkg, part, layer
113
+ self.units, self.clrmap, self.clrscheme = units, clrmap, clrscheme
114
+ self.master, self.theme = master, theme
115
+ self._rels = pkg.rels(part)
116
+
117
+ def media_of(self, rid):
118
+ if not rid:
119
+ return None
120
+ rel = self._rels.get(rid)
121
+ if not rel or rel['external']:
122
+ return None
123
+ return resolve_part(self.part, rel['target'])
124
+
125
+ def rel_target(self, rid):
126
+ rel = self._rels.get(rid)
127
+ return resolve_part(self.part, rel['target']) if rel and not rel['external'] else None
128
+
129
+
130
+ # ------------------------------------------------------------------ S3 theme
131
+ def read_theme(pkg, part):
132
+ root = pkg.xml(part)
133
+ cs = root.find('.//a:clrScheme', NS)
134
+ scheme, scheme_raw = {}, {}
135
+ if cs is not None:
136
+ for slot in cs:
137
+ tag = local(slot.tag)
138
+ for ch in slot:
139
+ raw = read_color(ch)
140
+ if raw:
141
+ scheme_raw[tag] = raw
142
+ r = resolve_color(raw)
143
+ scheme[tag] = (r or {}).get('hex')
144
+ break
145
+ fonts = {}
146
+ fs = root.find('.//a:fontScheme', NS)
147
+ if fs is not None:
148
+ for kind in ('majorFont', 'minorFont'):
149
+ k = fs.find('a:%s' % kind, NS)
150
+ if k is None:
151
+ continue
152
+ d = {}
153
+ for sc in k:
154
+ tag = local(sc.tag)
155
+ if tag in ('latin', 'ea', 'cs') and sc.get('typeface') is not None:
156
+ d[tag] = sc.get('typeface')
157
+ fonts[kind] = d
158
+ accents = [scheme.get('accent%d' % i, '') or '' for i in range(1, 7)]
159
+ factory_colors = bool(accents) and all(
160
+ a.lstrip('#').upper() in OFFICE_DEFAULT_ACCENTS for a in accents if a)
161
+ latins = {fonts.get(k, {}).get('latin') for k in ('majorFont', 'minorFont')}
162
+ factory_fonts = bool(latins - {None}) and all(
163
+ f in OFFICE_DEFAULT_FONTS for f in latins if f)
164
+ bg_styles = len(root.findall('.//a:bgFillStyleLst/*', NS))
165
+ return {
166
+ 'part': part,
167
+ 'name': root.get('name'),
168
+ 'scheme_name': cs.get('name') if cs is not None else None,
169
+ 'clrScheme': scheme,
170
+ 'clrScheme_raw': {k: v.get('type') + ':' + str(v.get('val')) for k, v in scheme_raw.items()},
171
+ 'fontScheme': fonts,
172
+ 'factory_colors': factory_colors,
173
+ 'factory_fonts': factory_fonts,
174
+ 'bg_fill_styles': bg_styles,
175
+ }
176
+
177
+
178
+ def read_clrmap(pkg, master_part):
179
+ cm = pkg.xml(master_part).find('p:clrMap', NS)
180
+ return dict(cm.attrib) if cm is not None else {}
181
+
182
+
183
+ # ------------------------------------------------------------------- S2 graph
184
+ def build_graph(pkg):
185
+ """slide -> layout -> master -> theme, plus master -> layouts ownership."""
186
+ pres = pkg.xml('ppt/presentation.xml')
187
+ prels = pkg.rels('ppt/presentation.xml')
188
+ master_order = []
189
+ for m in pres.findall('p:sldMasterIdLst/p:sldMasterId', NS):
190
+ t = prels.get(m.get(R_ID))
191
+ if t:
192
+ master_order.append(resolve_part('ppt/presentation.xml', t['target']))
193
+ for m in pkg.masters:
194
+ if m not in master_order:
195
+ master_order.append(m)
196
+
197
+ theme_of_master, layouts_of_master = {}, {}
198
+ for mp in master_order:
199
+ mrels = pkg.rels(mp)
200
+ for rel in mrels.values():
201
+ if rel['type'] == 'theme':
202
+ theme_of_master[mp] = resolve_part(mp, rel['target'])
203
+ lids = []
204
+ for l in pkg.xml(mp).findall('p:sldLayoutIdLst/p:sldLayoutId', NS):
205
+ rel = mrels.get(l.get(R_ID))
206
+ if rel:
207
+ lids.append(resolve_part(mp, rel['target']))
208
+ layouts_of_master[mp] = lids
209
+
210
+ master_of_layout = {}
211
+ for mp, lids in layouts_of_master.items():
212
+ for lp in lids:
213
+ master_of_layout.setdefault(lp, mp)
214
+ for lp in pkg.layouts:
215
+ if lp in master_of_layout:
216
+ continue
217
+ for rel in pkg.rels(lp).values():
218
+ if rel['type'] == 'slideMaster':
219
+ master_of_layout[lp] = resolve_part(lp, rel['target'])
220
+
221
+ layout_of_slide = {}
222
+ for sp in pkg.slides:
223
+ for rel in pkg.rels(sp).values():
224
+ if rel['type'] == 'slideLayout':
225
+ layout_of_slide[sp] = resolve_part(sp, rel['target'])
226
+
227
+ slides_per_layout = Counter(layout_of_slide.values())
228
+ slides_per_master = Counter(
229
+ master_of_layout.get(layout_of_slide[sp]) for sp in pkg.slides if sp in layout_of_slide)
230
+ used_themes = {theme_of_master[m] for m in master_order if m in theme_of_master}
231
+ return {
232
+ 'master_order': master_order,
233
+ 'theme_of_master': theme_of_master,
234
+ 'layouts_of_master': layouts_of_master,
235
+ 'master_of_layout': master_of_layout,
236
+ 'layout_of_slide': layout_of_slide,
237
+ 'slides_per_layout': dict(slides_per_layout),
238
+ 'slides_per_master': dict(slides_per_master),
239
+ 'used_themes': sorted(used_themes),
240
+ 'orphan_themes': sorted(set(pkg.themes) - used_themes),
241
+ }
242
+
243
+
244
+ def triage_masters(pkg, graph, twin_pairs):
245
+ """S2 母版三分规则: ① 主母版仅用于冲突裁决 ② 模板态保全链 ③ 引用 0 且不孪生 -> dropped."""
246
+ order = graph['master_order']
247
+ used = graph['slides_per_master']
248
+ layout_used = graph['slides_per_layout']
249
+ n_layouts = len(pkg.layouts)
250
+ unused_layouts = sum(1 for lp in pkg.layouts if layout_used.get(lp, 0) == 0)
251
+ unused_ratio = (unused_layouts / n_layouts) if n_layouts else 0.0
252
+ template_mode = pkg.kind == 'template' or unused_ratio >= 0.8
253
+
254
+ twinned = set()
255
+ for a, b in twin_pairs:
256
+ twinned.add(graph['master_of_layout'].get(a))
257
+ twinned.add(graph['master_of_layout'].get(b))
258
+
259
+ primary = max(order, key=lambda m: (used.get(m, 0), -order.index(m))) if order else None
260
+ entries = []
261
+ for mp in order:
262
+ refs = used.get(mp, 0)
263
+ reasons = []
264
+ if refs:
265
+ reasons.append('referenced-by-%d-slides' % refs)
266
+ if template_mode:
267
+ reasons.append('template-mode')
268
+ if mp in twinned:
269
+ reasons.append('twinned-with-main-chain')
270
+ picked = bool(reasons)
271
+ entries.append({
272
+ 'part': mp, 'theme': graph['theme_of_master'].get(mp),
273
+ 'layouts': len(graph['layouts_of_master'].get(mp, [])),
274
+ 'slide_refs': refs, 'picked': picked,
275
+ 'reasons': reasons or ['zero-refs-and-not-twinned'],
276
+ 'is_primary': mp == primary,
277
+ })
278
+ return {
279
+ 'primary': primary,
280
+ 'primary_role': 'conflict-arbitration-only',
281
+ 'template_mode': template_mode,
282
+ 'template_mode_evidence': {'content_type': pkg.kind,
283
+ 'layouts_unused': unused_layouts,
284
+ 'layouts_total': n_layouts,
285
+ 'unused_ratio': round(unused_ratio, 3)},
286
+ 'masters': entries,
287
+ 'dropped': [e['part'] for e in entries if not e['picked']],
288
+ }
289
+
290
+
291
+ # ------------------------------------------------------------- S4 shape facts
292
+ def _bg_descriptor(root, ctx):
293
+ bg = root.find('p:cSld/p:bg', NS)
294
+ if bg is None:
295
+ return None
296
+ pr = bg.find('p:bgPr', NS)
297
+ if pr is not None:
298
+ d = describe_fill(pr, ctx) or {}
299
+ return {'source': 'bgPr', **d}
300
+ ref = bg.find('p:bgRef', NS)
301
+ if ref is not None:
302
+ col = None
303
+ for ch in ref:
304
+ col = resolve_color(read_color(ch), ctx.clrmap, ctx.clrscheme)
305
+ if col:
306
+ break
307
+ # bgFillStyleLst[idx-1000] is not expanded; the phClr carries the actual hue.
308
+ return {'source': 'bgRef', 'idx': ref.get('idx'), 'color': col,
309
+ 'note': 'theme bgFillStyleLst pattern not expanded'}
310
+ return None
311
+
312
+
313
+ def _ph(nv):
314
+ ph = nv.find('p:nvPr/p:ph', NS) if nv is not None else None
315
+ if ph is None:
316
+ return None
317
+ return {'type': ph.get('type', 'body'), 'idx': ph.get('idx')}
318
+
319
+
320
+ NV_TAGS = {'sp': 'p:nvSpPr', 'pic': 'p:nvPicPr', 'grpSp': 'p:nvGrpSpPr',
321
+ 'cxnSp': 'p:nvCxnSpPr', 'graphicFrame': 'p:nvGraphicFramePr'}
322
+
323
+
324
+ def walk_tree(el, ctx, out, path=(), xf=(1.0, 1.0, 0.0, 0.0), depth=0):
325
+ sx, sy, dx, dy = xf
326
+ units = ctx.units
327
+ canvas_w, canvas_h = ctx.units.w, ctx.units.h
328
+ for sp in el:
329
+ tag = local(sp.tag)
330
+ if tag not in NV_TAGS:
331
+ continue
332
+ nv = sp.find(NV_TAGS[tag], NS)
333
+ cnv = nv.find('p:cNvPr', NS) if nv is not None else None
334
+ name = cnv.get('name') if cnv is not None else None
335
+ rec = {'part': ctx.part, 'layer': ctx.layer, 'kind': tag,
336
+ 'id': cnv.get('id') if cnv is not None else None, 'name': name,
337
+ 'depth': depth}
338
+ if path:
339
+ rec['group_path'] = list(path)
340
+ ph = _ph(nv)
341
+ if ph:
342
+ rec['ph'] = ph
343
+ if cnv is not None and cnv.get('hidden') == '1':
344
+ rec['hidden'] = True
345
+
346
+ raw = read_xfrm(sp, tag)
347
+ if raw:
348
+ ax = raw['x'] * sx + dx
349
+ ay = raw['y'] * sy + dy
350
+ aw, ah = raw['cx'] * sx, raw['cy'] * sy
351
+ rec['box_emu'] = {'x': round(ax), 'y': round(ay), 'cx': round(aw), 'cy': round(ah)}
352
+ bx, by, bw, bh = units.px(ax), units.px(ay), units.px(aw), units.px(ah)
353
+ rec['box_unrotated'] = {'x': bx, 'y': by, 'w': bw, 'h': bh}
354
+ if raw['rot']:
355
+ rec['rot'] = round(raw['rot'], 2)
356
+ rx, ry, rw, rh = rotated_bbox(bx, by, bw, bh, raw['rot'])
357
+ box = {'x': round(rx, 1), 'y': round(ry, 1), 'w': round(rw, 1), 'h': round(rh, 1)}
358
+ else:
359
+ box = dict(rec['box_unrotated'])
360
+ if raw['flipH']:
361
+ rec['flipH'] = True
362
+ if raw['flipV']:
363
+ rec['flipV'] = True
364
+ verdict, over, clamp = classify_box(
365
+ box['x'], box['y'], box['w'], box['h'], canvas_w, canvas_h)
366
+ rec['placement'] = verdict
367
+ if over:
368
+ rec['overflow_pct'] = over
369
+ if verdict == 'bleed':
370
+ rec['bleed'] = True
371
+ elif verdict == 'clamped':
372
+ rec['box_before_clamp'] = dict(box)
373
+ box = {'x': clamp[0], 'y': clamp[1], 'w': clamp[2], 'h': clamp[3]}
374
+ rec['clamped'] = True
375
+ rec['box'] = box
376
+ rec['w_pct'] = round(box['w'] / canvas_w * 100, 2)
377
+ rec['h_pct'] = round(box['h'] / canvas_h * 100, 2)
378
+ if box['w'] == 0 or box['h'] == 0:
379
+ rec['degenerate_axis'] = 'w' if box['w'] == 0 else 'h'
380
+ else:
381
+ rec['placement'] = 'inherited'
382
+
383
+ sp_pr = sp.find('p:spPr', NS)
384
+ bw = rec.get('box', {}).get('w')
385
+ bh = rec.get('box', {}).get('h')
386
+ geom, radius = describe_geom(sp_pr, ctx, bw, bh)
387
+ if geom:
388
+ rec['geom'] = geom
389
+ if radius is not None:
390
+ rec['radius_px'] = radius
391
+ f = describe_fill(sp_pr, ctx)
392
+ if f:
393
+ rec['fill'] = f
394
+ ln = describe_line(sp_pr, ctx)
395
+ if ln:
396
+ rec['line'] = ln
397
+ ef = describe_effects(sp_pr, ctx)
398
+ if ef:
399
+ rec['effects'] = ef
400
+ style = sp.find('p:style', NS)
401
+ if style is not None:
402
+ st = {}
403
+ for refname in ('fillRef', 'lnRef', 'effectRef', 'fontRef'):
404
+ e = style.find('a:%s' % refname, NS)
405
+ if e is None:
406
+ continue
407
+ col = None
408
+ for ch in e:
409
+ col = resolve_color(read_color(ch), ctx.clrmap, ctx.clrscheme)
410
+ if col:
411
+ break
412
+ st[refname] = {'idx': e.get('idx'), 'color': col}
413
+ if st:
414
+ rec['styleRef'] = st
415
+
416
+ if tag == 'pic':
417
+ blip = sp.find('p:blipFill/a:blip', NS)
418
+ if blip is not None:
419
+ rec['media'] = ctx.media_of(blip.get(R_EMBED)) or ctx.media_of(blip.get(R_LINK))
420
+ svg = blip.find('a:extLst//asvg:svgBlip', NS)
421
+ if svg is not None:
422
+ rec['media_svg'] = ctx.media_of(svg.get(R_EMBED))
423
+ sr = sp.find('p:blipFill/a:srcRect', NS)
424
+ if sr is not None and sr.attrib:
425
+ rec['crop'] = {k: round(int(v) / 1000.0, 2) for k, v in sr.attrib.items()}
426
+ stretch = sp.find('p:blipFill/a:stretch', NS)
427
+ if stretch is None and sp.find('p:blipFill/a:tile', NS) is not None:
428
+ rec['tile'] = True
429
+ elif tag == 'graphicFrame':
430
+ _fill_graphic_frame_record(sp, rec)
431
+
432
+ tx = sp.find('p:txBody', NS)
433
+ if tx is None:
434
+ tx = sp.find('a:txBody', NS)
435
+ if tx is not None:
436
+ body = read_txbody(tx, ctx)
437
+ if body:
438
+ rec['text'] = body
439
+ out.append(rec)
440
+
441
+
442
+ def _fill_graphic_frame_record(sp, rec):
443
+ gd = sp.find('a:graphic/a:graphicData', NS)
444
+ uri = gd.get('uri') if gd is not None else None
445
+ rec['graphic_uri'] = uri
446
+ if gd is None:
447
+ return
448
+ tbl = gd.find('.//a:tbl', NS)
449
+ if tbl is not None:
450
+ rec['kind'] = 'table'
451
+ rec['table'] = {'rows': len(tbl.findall('a:tr', NS)),
452
+ 'cols': len(tbl.findall('a:tblGrid/a:gridCol', NS))}
453
+ elif uri and 'chart' in uri:
454
+ rec['kind'] = 'chart'
455
+ elif uri and 'diagram' in uri:
456
+ rec['kind'] = 'diagram'
457
+
458
+ if tag == 'grpSp':
459
+ gsx, gsy, gdx, gdy = group_transform(sp)
460
+ walk_tree(sp, ctx, out, path + (name,),
461
+ (sx * gsx, sy * gsy, dx + gdx * sx, dy + gdy * sy), depth + 1)
462
+
463
+
464
+ def read_part_shapes(pkg, part, layer, units, clrmap, clrscheme, master=None, theme=None):
465
+ ctx = PartCtx(pkg, part, layer, units, clrmap, clrscheme, master, theme)
466
+ root = pkg.xml(part)
467
+ shapes = []
468
+ tree = root.find('p:cSld/p:spTree', NS)
469
+ if tree is not None:
470
+ walk_tree(tree, ctx, shapes)
471
+ return ctx, shapes, _bg_descriptor(root, ctx)
472
+
473
+
474
+ def read_txstyles(pkg, master_part, ctx):
475
+ ts = pkg.xml(master_part).find('p:txStyles', NS)
476
+ if ts is None:
477
+ return None
478
+ out = {}
479
+ for which in ('titleStyle', 'bodyStyle', 'otherStyle'):
480
+ el = ts.find('p:%s' % which, NS)
481
+ if el is None:
482
+ continue
483
+ lvls = {}
484
+ for lvl in el:
485
+ d = read_lvl(lvl, ctx)
486
+ if d:
487
+ lvls[local(lvl.tag)] = d
488
+ if lvls:
489
+ out[which] = lvls
490
+ return out or None