mailr11867 - /1.3/prompt/interpreter.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on December 17, 2010 - 15:13:
Author: bugman
Date: Fri Dec 17 15:13:51 2010
New Revision: 11867

URL: http://svn.gna.org/viewcvs/relax?rev=11867&view=rev
Log:
Nested scripting is now better supported.

The full path of the nested script is not needed if is in the same directory 
as the parent script.


Modified:
    1.3/prompt/interpreter.py

Modified: 1.3/prompt/interpreter.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/prompt/interpreter.py?rev=11867&r1=11866&r2=11867&view=diff
==============================================================================
--- 1.3/prompt/interpreter.py (original)
+++ 1.3/prompt/interpreter.py Fri Dec 17 15:13:51 2010
@@ -29,7 +29,7 @@
 # Python module imports.
 import __main__
 from code import InteractiveConsole, softspace
-from os import F_OK, access, getcwd, path
+from os import F_OK, access, chdir, getcwd, path
 import platform
 from re import search
 if dep_check.readline_module:
@@ -353,6 +353,11 @@
     script_path = path.join(getcwd(), head)
     sys.path.append(script_path)
 
+    # Switch directories for nested scripting.
+    if head:
+        orig_dir = getcwd()
+        chdir(head)
+
     # The module name.
     module, ext = path.splitext(tail)
 
@@ -362,6 +367,10 @@
 
     # Execute the module.
     runpy.run_module(module, globals)
+
+    # Switch back to the original working directory.
+    if head:
+        chdir(orig_dir)
 
     # Remove the script path.
     sys.path.pop(sys.path.index(script_path))




Related Messages


Powered by MHonArc, Updated Fri Dec 17 15:40:01 2010