--- a/common/migration.py Sat Nov 28 10:27:58 2009 +0100
+++ b/common/migration.py Sat Nov 28 11:42:37 2009 +0100
@@ -268,10 +268,17 @@
in interactive mode, display the migration script path, ask for
confirmation and execute it if confirmed
"""
- assert migrscript.endswith('.py'), migrscript
migrscript = os.path.normpath(migrscript)
- if self.execscript_confirm(migrscript):
- scriptlocals = self._create_context().copy()
+ if migrscript.endswith('.py'):
+ script_mode = 'python'
+ elif migrscript.endswith('.txt') or migrscript.endswith('.rst'):
+ script_mode = 'doctest'
+ else:
+ raise Exception('This is not a valid cubicweb shell input')
+ if not self.execscript_confirm(migrscript):
+ return
+ scriptlocals = self._create_context().copy()
+ if script_mode == 'python':
if funcname is None:
pyname = '__main__'
else:
@@ -287,6 +294,10 @@
self.critical('no %s in script %s', funcname, migrscript)
return None
return func(*args, **kwargs)
+ else: # script_mode == 'doctest'
+ import doctest
+ doctest.testfile(migrscript, module_relative=False,
+ optionflags=doctest.ELLIPSIS, globs=scriptlocals)
def cmd_option_renamed(self, oldname, newname):
"""a configuration option has been renamed"""