ltmpl: be more careful about checking command names

This commit is contained in:
Will Woods 2011-11-04 13:41:10 -04:00
parent ca4ea16823
commit c8f06bd8ff

View File

@ -149,7 +149,7 @@ class LoraxTemplateRunner(object):
try:
# grab the method named in cmd and pass it the given arguments
f = getattr(self, cmd, None)
if f is None or cmd is 'run':
if cmd[0] == '_' or cmd == 'run' or not callable(f):
raise ValueError, "unknown command %s" % cmd
f(*args)
except Exception:
@ -220,7 +220,7 @@ class LoraxTemplateRunner(object):
'''
append FILE STRING
Append STRING (followed by a newline character) to FILE.
Python character escape sequences ('\n', '\t', etc.) will be
Python character escape sequences ('\\n', '\\t', etc.) will be
converted to the appropriate characters.
Examples:
append /etc/depmod.d/dd.conf "search updates built-in"