Developing a Package with Sub Packages

J

Josh English

I have created a group of scripts to manage an XML-based database. I'd
like to make it into a proper package that will let me keep track of
the code. I have a lot of files that are similar in name and they just
get crowded in one folder.

Here's a sample of the file structure:

IMS/
IMS/__init__.py
IMS/Config.py
IMS/imsdefaults.cfg
IMS/local.txt
IMS/Data/
IMS/Data/stories.xml
IMS/Story/
IMS/Story/__init__.py
IMS/Story/StoryCreator.py

When the IMS/__init__.py file is loaded, it creates the IMS/Data/
folder and if there are no xml files, it creates them and fills them
in with some default values.
The IMS/Config.py has a subclass of the ConfigParser, and reads the
imsdefaults.cfg and local.txt files.
When I run StoryCreator, buried in it's own package (that imports IMS)
the data folder is created inside the Story folder, and I get an error
message stating the ConfigParser object could not find the
imsdefaults.cfg file.
Here's what I think is happening: IMS/__init__.py uses os.getcwd() to
establish the path to the data folder and the files inside of it. When
I run StoryCreator, os.getcwd() returns the story folder.
If I'm right, how can I get the IMS/__init__.py module to use relative
paths to its own module, and not the current working directory the os
module provides?
This could also solve the problem with Config.py, I think.

Thanks

Josh English
http://joshenglish.livejournal.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top