Skip to content

Commit

Permalink
Moved seamm.ini from ~/SEAMM to ~/.seamm.d
Browse files Browse the repository at this point in the history
  • Loading branch information
paulsaxe committed Apr 22, 2024
1 parent 4440e46 commit e3d2802
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ History
=======
2024.4.22 -- Moving user preferences to ~/.seamm.d
* To better support Docker, moving ~/.seammrc to ~/.seamm.d/seamrc
* Moved seamm.ini from ~/SEAMM to ~/seamm.d since it only contains personal preferences.

2023.11.12 -- Internal update
* Versioneer needed to be updated to account for changes in configparser.
Expand Down
27 changes: 25 additions & 2 deletions seamm_util/argument_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import configparser
import logging
import os
from pathlib import Path
import sys

# logging.basicConfig(level="WARNING")
Expand Down Expand Up @@ -40,8 +41,7 @@ def __init__(
self,
*args,
ini_files=[
"etc/SEAMM/seamm.ini",
os.path.expanduser("~/SEAMM/seamm.ini"),
os.path.expanduser("~/.seamm.d/seamm.ini"),
"seamm.ini",
],
interpolation=configparser.ExtendedInterpolation(),
Expand Down Expand Up @@ -169,6 +169,29 @@ def parse_args(self, args=None):

# 2. Read the .ini files, if any.

# Moving from ~/SEAMM/seamm.ini to ~/.seamm.d/seamm.ini
# Make directory and move if it does not exist
path = Path("~/.seamm.d/seamm.ini").expanduser()
tmp = Path("~/SEAMM/seamm.ini").expanduser()
print(f"{path=}")
print(f"{path.exists()=}")
print(f" {tmp=}")
print(f"{tmp.exists()=}")
if not path.parent.exists():
path.parent.mkdir(parents=True)
print("made directory")
else:
print("directory existed")

if tmp.exists() and not path.exists():
print("/ntext:")
print(tmp.read_text())
print()
path.write_text(tmp.read_text())
tmp.unlink()

# Now read...

config = configparser.ConfigParser(interpolation=None)
self._ini_files_used = config.read(self._ini_files)

Expand Down

0 comments on commit e3d2802

Please sign in to comment.