Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Advanced Scripting Environment (EASE) » import vs include
import vs include [message #1835707] Thu, 10 December 2020 18:49 Go to next message
Axel RICHARD is currently offline Axel RICHARDFriend
Messages: 43
Registered: September 2010
Location: France

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.

def fct_readme():
    for iproject in getWorkspace().getProjects():
        if not iproject.isOpen():
        ifile = iproject.getFile("")
        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 In I want to call fct_readme().

The first approach:
import scripts.AddReadMe

leads to an error when executed with Run As > EASE Script (ImportError: No module named scripts.AddReadMe)

The second approach:

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,

Axel Richard

[Updated on: Thu, 10 December 2020 18:50]

Report message to a moderator

Re: import vs include [message #1835848 is a reply to message #1835707] Tue, 15 December 2020 06:24 Go to previous message
Christian Pontesegger is currently offline Christian PonteseggerFriend
Messages: 239
Registered: July 2009
Location: Graz, Austria
Senior Member
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.

Previous Topic:Build UIs with unease!
Next Topic:EASE UI module takes over context menus?
Goto Forum:

Current Time: Fri Jan 27 09:27:57 GMT 2023

Powered by FUDForum. Page generated in 0.14217 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top