Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created January 24, 2016 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/61123e60bab373a72e69 to your computer and use it in GitHub Desktop.
Save zeffii/61123e60bab373a72e69 to your computer and use it in GitHub Desktop.
import bpy
import re
def ls_show_features(ctx, match, m):
print(match, m*3)
def man_show_features(ctx, match, m):
print(match, m*4)
def make_alias_to_object(ctx, match, m):
print(match, m*5)
def make_alias_to_nodes(ctx, match, m):
print(match, m*6)
def unpack_with_stride(items, stride=2):
for i in range(0, len(items), stride):
yield items[i:i+stride]
def process_input(context, m):
""" this function iterates through regexes and executes when matched """
regex_lib = [
"ls", ls_show_features,
"man", man_show_features,
"o=", make_alias_to_object,
"n=", make_alias_to_nodes
]
for pattern, func in unpack_with_stride(regex_lib):
match = re.match(pattern, m)
if match:
func(context, match, m)
break
context = 'bpy'
m = 'o='
process_input(context, m)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment