Skip to content

Commit

Permalink
configfile stores the path to ground-grid
Browse files Browse the repository at this point in the history
  • Loading branch information
relleums committed Feb 15, 2024
1 parent 68c7f62 commit 8fc2037
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions plenoirf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from . import configuration
from . import event_table
from . import ground_grid
from . import configfile

import os
from os import path as op
Expand Down
28 changes: 28 additions & 0 deletions plenoirf/configfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
import json_utils


def get_configfile_path(programname="plenoirf.json"):
return os.path.join(os.path.expanduser("~"), "." + programname)


def read():
configfile_path = get_configfile_path()
if not os.path.exists(configfile_path):
write(config=default(build_dir="build"))

with open(configfile_path, "rt") as f:
config = json_utils.loads(f.read())
return config


def write(config):
with open(get_configfile_path(), "wt") as f:
f.write(json_utils.dumps(config, indent=4))


def default(merlict_c89_ground_grid_path):
out = {
"ground-grid": os.path.abspath(merlict_c89_ground_grid_path),
}
return out
2 changes: 1 addition & 1 deletion plenoirf/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.2"
__version__ = "1.0.4"

0 comments on commit 8fc2037

Please sign in to comment.