Add support for dotenv file
Example of .env file:
#
# SPICE kernels location
#
KERNELS_JUICE=/data/ESA/JUICE/kernels
KERNELS_EUROPA_CLIPPER=../kernels/Clipper
Added
-
TourConfignow supports.envfile to locate the mission kernels directories. This will simplify the way people can defined the location of there kernels without having to hardcode their paths. It also allow the user to locally bypass their global configuration if needed. -
New dotenv file finder function to locate
.envfiles in the current working directory or any of its parents:
from moon_coverage.misc import find_dotenv
find_dotenv()
Path('/path/to/.env')
Note: only the first .env is returned.
- If a
.envfile is found, its environment variables will be loaded instead of the global env variables. You can check which env variable is loaded with thegetenvfunction:
from moon_coverage.misc import getenv
getenv('KERNELS_JUICE')
'/data/ESA/JUICE/kernels'
Note: Dotenv variables don't modify the global variables (os.environ).
- To have a list of all the kernels directories available, you can now use the
print_kernels_dir()function:
from moon_coverage import print_kernels_dir
print_kernels_dir()
Dotenv file found:
- .env
Kernels ENV variables:
- KERNELS_JUICE : /data/ESA/JUICE/kernels (.env)
- KERNELS_EUROPA_CLIPPER: ../kernels/Clipper (.env)
- You can also use
%load_ext moon_coveragemagic function for IPython/Jupyter environment to directly the tool configuration:
%load_ext moon_coverage
Installed packages:
- moon-coverage: 0.12.0
- esa-ptr : 1.0
- numpy : 1.23.5
- matplotlib : 3.6.2
- spiceypy : 5.1.2
Dotenv file found:
- .env
Kernels ENV variables:
- KERNELS_JUICE : ../kernels/JUICE (.env)
- KERNELS_EUROPA_CLIPPER: /data/kernels/Clipper
- We also simplify the documentation on
TourConfigto reflect these changes and encourage the user to use global env variable or.envfiles.
Closes #65 (closed).