This might be a weird requirement but it's what I've run into. I Googled but yield nothing.
I'm coding an application who's using a lot of constant attributes / values recorded in an XML file (they'll not change so a static file), things work fine until I generated an egg file for it.
When the logic reaches the XML accessing part, I got one complaint like this: /home/Workspace/my_proj/dist/mps-1.2.0_M2-py2.6.egg/mps/par/client/syntax/syntax.xml
Actually I've bundled the XML file in the path above but seems Python doesn't know how to access it.
The code to access the XML is as...
file_handler = open(path_to_the_file) lines = file_handler.read().splitlines()
Any idea?
EGG files can be opened with Python using the "SetupTools" package. The files can also be decompressed with a Zip-decompression program, such as Microsoft File Explorer, Corel WinZip, or Apple Archive Utility.
Open File Explorer to locate the zipped folder. To unzip the entire folder click on the right-click menu and select Extract All. Follow the instructions. Double-click the zip folder to unzip it.
Python eggs are an older distribution format for Python. The new format is called a Python wheel, which we will look at in the next chapter. An egg file is basically a zip file with a different extension. Python can import directly from an egg. You will need the SetupTools package to work with eggs.
egg-info format: a file or directory placed adjacent to the project's code and resources, that directly contains the project's metadata.
egg
files are zipfiles, so you must access "stuff" inside them with the zipfile module of the Python standard libraries, not with the built-in open
function!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With