import vs include [message #1835707] |
Thu, 10 December 2020 13:49  |
Eclipse User |
|
|
|
Hello,
I do some tests with EASE and PyDev and its really powerful! Kudos to the team!
Let's say I have two Python scripts in the same folder.
AddReadMe.py
loadModule('/System/Resources')
def fct_readme():
for iproject in getWorkspace().getProjects():
if not iproject.isOpen():
continue
ifile = iproject.getFile("README.md")
if not ifile.exists():
contents = "# " + iproject.getName() + "\n\n"
if iproject.hasNature("org.eclipse.jdt.core.javanature"):
contents += "A Java Project\n"
elif iproject.hasNature("org.python.pydev.pythonNature"):
contents += "A Python Project\n"
writeFile(ifile, contents)
and Test.py. In Test.py I want to call fct_readme().
The first approach:
import scripts.AddReadMe
scripts.AddReadMe.fct_readme()
leads to an error when executed with Run As > EASE Script (ImportError: No module named scripts.AddReadMe)
The second approach:
include('script://AddReadMe.py')
fct_readme()
is well executed with Run As > EASE Script.
The problem with the second approach is that PyDev shows errors for the include(...) statement and the fct_readme() call.
Is it possible to have no editor error with PyDev editor with the second approach, or better have no execution error with the first approach?
Any pointers to solve one or both problems will be appreciated.
Thank you,
[Updated on: Thu, 10 December 2020 13:50] by Moderator
|
|
|
Re: import vs include [message #1835848 is a reply to message #1835707] |
Tue, 15 December 2020 01:24  |
Eclipse User |
|
|
|
In python each module comes with its own scope. For the java <-> python bridge to work EASE injects some stuff to the global scope of your main script. This allows your python script to connect to java, load modules, etc. In a custom module this is all missing, therefore you are not able to use EASE features there. So I guess making EASE work within a python module will not be an easy task.
The PyDev environment now analyses python code, but cannot see the dynamic injections that will be done by EASE at runtime. Thats the reason why you get error markers on your code. Also fixing these things would be some major effort to be done in PyDev and currently there is no one stepping forward to do this.
Christian
|
|
|
Powered by
FUDForum. Page generated in 0.03862 seconds