You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mo...@apache.org on 2015/05/09 15:41:35 UTC
incubator-zeppelin git commit: Fixed pyspark indentation issue - take
2
Repository: incubator-zeppelin
Updated Branches:
refs/heads/master 5caace75e -> 956e3f74a
Fixed pyspark indentation issue - take 2
see https://issues.apache.org/jira/browse/ZEPPELIN-34, should allow:
```
%pyspark
if True:
print "one"
else:
print "two"
def test_func(text):
for i in range(1, 10):
print text + '-' + str(i)
test_func('fixed')
```
Author: whisperstream <ax...@whisperstream.com>
Closes #63 from whisperstream/pyspark-indentation-fix-2 and squashes the following commits:
ec4398d [whisperstream] Fixed pyspark indentation issue
Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/956e3f74
Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/956e3f74
Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/956e3f74
Branch: refs/heads/master
Commit: 956e3f74a1b2f28fd8caa25055e77f687ca8d211
Parents: 5caace7
Author: whisperstream <ax...@whisperstream.com>
Authored: Wed May 6 13:47:32 2015 -0700
Committer: Lee moon soo <mo...@apache.org>
Committed: Sat May 9 15:41:29 2015 +0200
----------------------------------------------------------------------
.../main/resources/python/zeppelin_pyspark.py | 42 ++++----------------
1 file changed, 7 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/956e3f74/spark/src/main/resources/python/zeppelin_pyspark.py
----------------------------------------------------------------------
diff --git a/spark/src/main/resources/python/zeppelin_pyspark.py b/spark/src/main/resources/python/zeppelin_pyspark.py
index 5b70d85..2e99c44 100644
--- a/spark/src/main/resources/python/zeppelin_pyspark.py
+++ b/spark/src/main/resources/python/zeppelin_pyspark.py
@@ -85,9 +85,7 @@ while True :
try:
stmts = req.statements().split("\n")
jobGroup = req.jobGroup()
- single = None
- incomplete = None
- compiledCode = None
+ final_code = None
for s in stmts:
if s == None or len(s.strip()) == 0:
@@ -97,38 +95,13 @@ while True :
if s.strip().startswith("#"):
continue
- if s[0] != " " and s[0] != "\t":
- if incomplete != None:
- raise incomplete
-
- if compiledCode != None:
- sc.setJobGroup(jobGroup, "Zeppelin")
- eval(compiledCode)
- compiledCode = None
- single = None
- incomplete = None
-
- if single == None:
- single = s
+ if final_code:
+ final_code += "\n" + s
else:
- single += "\n" + s
-
- try :
- compiledCode = compile(single, "<string>", "single")
- incomplete = None
- except SyntaxError as e:
- if str(e).startswith("unexpected EOF while parsing") :
- # incomplete expression
- incomplete = e
- continue
- else :
- # actual error
- raise e
-
- if incomplete != None:
- raise incomplete
-
- if compiledCode != None:
+ final_code = s
+
+ if final_code:
+ compiledCode = compile(final_code, "<string>", "exec")
sc.setJobGroup(jobGroup, "Zeppelin")
eval(compiledCode)
@@ -137,4 +110,3 @@ while True :
intp.setStatementsFinished(str(sys.exc_info()), True)
output.reset()
-