philngo / ee-meter

Open Energy Efficiency Meter
MIT License
1 stars 1 forks source link

fix resources directory resolution #18

Closed potash closed 9 years ago

potash commented 9 years ago

The following code

os.path.join(os.path.dirname(os.path.dirname(eemeter.__file__)),
                'resources',
                'GSOD-ISD_station_index.json')

seems to work in some environments but

os.path.dirname(os.path.dirname(eemeter.__file__))

ought to put us in the parent of ee-meter so really we should use

os.path.dirname(eemeter.__file__)

Why does the former work at all?

philngo commented 9 years ago

It seems like the problem originates from the different __file__ attributes for different eggs. The following may work more cleanly:

import pkg_resources
gsod_station_index_filename = pkg_resources.resource_string('eemeter', os.path.join('resources','GSOD-ISD_station_index.json'))