Author Topic: Importing Python - global functions  (Read 627 times)

10Pints

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Importing Python - global functions
« on: February 07, 2013, 02:03:48 am »
Anybody know how to import python global functions into EA?
I can import methods (defined in a class) fine, but alas a lot of the code I want to RE is in global functions ...
Help!

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Importing Python - global functions
« Reply #1 on: February 07, 2013, 02:25:20 am »
Since UML class models lack the concept of 'global functions' I doubt that this will be possible at all.

Best regards,
GŁnther

10Pints

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Importing Python - global functions
« Reply #2 on: February 07, 2013, 03:25:21 am »
I tried a work around:
cut n paste the global functions into a new file
add a class def to the top of the file
like
def class Globals:

then tabbed the functions out one so that they are part of the class,
then placed the file in its own sub directory and tried importing that ...

EA created the class but did not import the functions...

However I did get it to work with another group of global methods which I placed in class called Utilities ...
The only difference I can see is that the Global methods do have functions nested in functions - may be I need to flatten them out to the class level?



10Pints

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Importing Python - global functions
« Reply #3 on: February 08, 2013, 09:07:58 pm »
Ah: found problem:
EA (8.0) does import classes from Python, but not global methods
So I thought - easy ...
I will cut and paste the contents of the file into a new one - remove all the class defs - tab everything out 1 and add a class def to the top like def class Globals:

This worked on one .py file, but not this one as it had an if __name__ == 'main' .... code block.

This apparently stopped EA importing anything.
I found it by importing only 1 method to begin with (that worked) and then 3 then 10 ... and so on.
Once I added the bit  with the  if __name__ == 'main' block -
NOTHING imported, which makes sense since i have moved it inside my Globals  class def 'holder'
But it appears that even with the original  file the import would not import anything - perhaps this has been fixed in later versions of EA?

Anybody know if I can reverse engineer Python sequence diagram in EA? Maybe not 8 - maybe later version? >:(