[pyzo] 47/68: running file changes current dir

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Sep 28 09:47:13 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/master
in repository pyzo.

commit 47a292ee76b6e1211fad4ba95620075c241e9bb3
Author: Almar Klein <almar.klein at gmail.com>
Date:   Thu Sep 22 13:20:12 2016 +0200

    running file changes current dir
---
 pyzo/core/shell.py             | 6 +++++-
 pyzo/pyzokernel/interpreter.py | 9 ++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/pyzo/core/shell.py b/pyzo/core/shell.py
index 3eb9750..035ddb7 100644
--- a/pyzo/core/shell.py
+++ b/pyzo/core/shell.py
@@ -1313,7 +1313,7 @@ class PythonShell(BaseShell):
         self._ctrl_command.send(text)
     
     
-    def executeCode(self, text, fname, lineno=0, cellName=None):
+    def executeCode(self, text, fname, lineno=None, cellName=None):
         """ executeCode(text, fname, lineno, cellName=None)
         Execute (run) a large piece of code in the remote shell.
         text: the source code to execute
@@ -1336,6 +1336,10 @@ class PythonShell(BaseShell):
         if not text:
             text = ' '
         
+        if lineno is None:
+            lineno = 0
+            cellName = fname  # run all
+        
         # Examine the text line by line...
         # - check for empty/commented lined at the end
         # - calculate minimal indentation
diff --git a/pyzo/pyzokernel/interpreter.py b/pyzo/pyzokernel/interpreter.py
index a0dceb4..b81e781 100644
--- a/pyzo/pyzokernel/interpreter.py
+++ b/pyzo/pyzokernel/interpreter.py
@@ -775,7 +775,14 @@ class PyzoInterpreter:
         fname_show = fname
         if not fname.startswith('<'):
             fname_show = os.path.split(fname)[1]
-        if cellName:
+        if cellName == fname:
+            runtext = '(executing file "%s")\n' % fname_show
+            if os.path.isfile(fname):
+                d = os.path.normpath(os.path.normcase(os.path.dirname(fname)))
+                if d != os.getcwd():
+                    # print('Changing directory to', d)
+                    os.chdir(d)
+        elif cellName:
             runtext = '(executing cell "%s" (line %i of "%s"))\n' % (cellName, lineno1, fname_show)
         elif lineno1 == lineno2:
             runtext = '(executing line %i of "%s")\n' % (lineno1, fname_show)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pyzo.git



More information about the debian-science-commits mailing list