Changes between Version 1 and Version 2 of Ticket #1380, comment 2
- Timestamp:
- Nov 1, 2018, 12:51:45 PM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #1380, comment 2
v1 v2 1 1 I'm not so sure how doable this would be. Finding the function for a command is: 2 3 func = chimerax.core.commands.command_function("save")4 print('%s.%s' % (func.!__module__, func.!__qualname__))5 2 {{{ 3 func = chimerax.core.commands.command_function("save") 4 print('%s.%s' % (func.!__module__, func.!__qualname__)) 5 }}} 6 6 But that function location might not match the supported location given in the documentation. That is, the function location above is just a clue as to where the supported function is. And, there is no public API to get the registered argument types for the function (the CmdDesc instance). help(func) gives some information, but it may be incomplete (especially with the open and save commands where bundles can register additional keyword arguments for their file types). 7 7 8 8 Thinking about how to implement the parse_atom_spec function: 9 10 def parse_atom_spec(session, spec):11 from chimerax.core.commands import AtomSpecArg12 value, _, rest = AtomSpecArg.parse(spec, session)13 if rest:14 raise RuntimeError("extra characters at end of atom specification")15 return value16 9 {{{ 10 def parse_atom_spec(session, spec): 11 from chimerax.core.commands import AtomSpecArg 12 value, _, rest = AtomSpecArg.parse(spec, session) 13 if rest: 14 raise RuntimeError("extra characters at end of atom specification") 15 return value 16 }}} 17 17 That could be generalized to function that wrapped annotations into simple parse function: 18 19 parse_atom_spec = as_parser(AtomSpecArg)20 18 {{{ 19 parse_atom_spec = as_parser(AtomSpecArg) 20 }}}