Created
July 19, 2012 15:23
-
-
Save pielgrzym/3144644 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
global !p | |
def fb(string, c=0): | |
'''Count brackets''' | |
left_bracket = string.find("(") | |
if left_bracket > -1: | |
string = string[left_bracket + 1:] | |
right_bracket = string.find(")") | |
if right_bracket > -1: | |
if string[:right_bracket].find("(") == -1: | |
c += 1 | |
string = string[right_bracket + 1:] | |
return fb(string, c) | |
else: | |
return c | |
def check_regexp_for_params(snip, t): | |
if len(t[1]): | |
arg_count = fb(t[1]) | |
if arg_count: | |
args = ", ".join( ["arg%d" % (x+1) for x in range(arg_count)] ) | |
snip.rv = ', ' + args | |
endglobal | |
snippet st "Lettuce step decorated function" b | |
@step(r"${1}") | |
def ${2:step_name}(step${3:`!p check_regexp_for_params(snip, t)`}): | |
${4:pass} | |
endsnippet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment