Paste P656

operator_id_py_to_c.py
ActivePublic

Authored by Campbell Barton (campbellbarton) on Apr 16 2018, 1:34 PM.
Tags
None
Subscribers
None
1#!/usr/bin/env python3
2
3# Script to convert py ID's to C operator ID's
4# Ctrl-C over button or menu item, paste here, then run.
5a = '''
6bpy.ops.foo()
7'''
8
9pre = "bpy.ops."
10ls = []
11for w in a.strip().split('\n'):
12if w.startswith(pre):
13w = w[len(pre):].split('(')[0]
14head, tail = w.partition('.')[0::2]
15ls.append(head.upper() + "_OT_" + tail)
16# print w/ dotpoints
17for w in ls:
18print("- " + w + '')