Created
January 24, 2016 11:35
-
-
Save zeffii/61123e60bab373a72e69 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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