SideFX Houdini customization package
git clone https://git.lucas.co/hou-control.git
python3.13libs/hc/hcmaps.py (1K)
1 """HC Panel command map, generated from the @command decorators.
2
3 This used to be four hand-written dicts of ``label -> bound method``, a second
4 place to keep in sync with the methods themselves. Renaming a method left a
5 stale entry that raised AttributeError, which SelectionDialog then swallowed --
6 so the command silently did nothing.
7
8 The map is now derived. The four tab_map_* methods that callers composed by
9 hand are one call: every command the session, the pane and the current tab
10 expose. Which tab kinds see a command is which class it is declared on; a
11 command that only some instances of a class can run declares an `available`
12 predicate and bind() leaves it out where that is false.
13 """
14
15 from . import hccommands
16
17
18 class HCMaps:
19 def commands(self, session, pane, tab):
20 """{label: bound method} for the current session, pane and tab."""
21 merged = {}
22 for instance in (session, pane, tab):
23 merged.update(hccommands.bind(instance))
24 return dict(sorted(merged.items()))