INNER CODE UNIT · Python
dot_hook
probcomp/bayeslite · shell/src/core.py:297
def dot_hook(self, path):
'''add custom commands from a python source file
<path_to_source.py>
'''
import imp
if path in self._hooked_filenames:
self.stdout.write("The file %s has already been hooked. Do you "
"want to rehook?\n" % (path,))
yesno = raw_input('y/n? ')
affirmative = ['yes', 'y']
negative = ['no', 'n']
while yesno.lower() not in affirmative+negative:
self.stdout.write("Invalid response to yes/no question.\n")
yesno = raw_input('y/n? ')
if yesno in negative:
self.stdout.write("Abandoning hook of %s\n" % (path,))