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: try:
# grab the method named in cmd and pass it the given arguments # grab the method named in cmd and pass it the given arguments
f = getattr(self, cmd, None) 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 raise ValueError, "unknown command %s" % cmd
f(*args) f(*args)
except Exception: except Exception:
@ -220,7 +220,7 @@ class LoraxTemplateRunner(object):
''' '''
append FILE STRING append FILE STRING
Append STRING (followed by a newline character) to FILE. 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. converted to the appropriate characters.
Examples: Examples:
append /etc/depmod.d/dd.conf "search updates built-in" append /etc/depmod.d/dd.conf "search updates built-in"