[IronPython] Importing embedded .py files

JoeSox joesox at gmail.com
Mon Jul 3 22:43:15 PDT 2006


Thanks Szymon for the reply and I have looked at your proposed solution.
I already can achieve reading the resource files using StreamReader.
If it's easy to surface it into PythonEngine so it appears to already
been imported, then I am asking for more clarity because I do not see
what method I need to be calling.
If I call:
myIronPythonEngine.Evaluate(Misc.getEmbeddedResourceContent("CNUDB.py"));
//getEmbeddedResourceContent returns a string

I get 'unexpected token import' probably formatting issues which are
too numerous for me to manually to fix because of the .py file size
and the other files I need to do the same for.

If I call:
cn_pe.Import(Misc.getEmbeddedResourceContent("CNUDB.py"));
I get 'Illegal characters in path.'

So I really don't know what else to try.  These are only a few things
out of a number of methods I have tried.  I am still open to specific
suggestions but I am almost completed with the workaround suggested by
Michael.

Joe

On 7/3/06, Szymon Kobalczyk <s.kobalczyk at softwaremind.pl> wrote:
> Hi,
>  From the source code I can see that the FromFile method on Parser class
> reads the file contents to byte array and later uses MemoryStream to
> create StreamReader for actual parsing. You can easily generalize this
> code to extract a FromStream method and then surface it to the
> PythonEngine API.
> If you have this you can easily read the file from a resource stream.

-- 
Later, Joe


More information about the users mailing list