Skip to content

Commit

Permalink
use pathlib to get config directories (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
wtbarnes authored Feb 6, 2024
1 parent 3286071 commit 39765a5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions hissw/read_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
"""

import os
import pathlib
import configparser

HISSW_DIR = pathlib.Path.home() / '.hissw'
HISSW_RC = HISSW_DIR / 'hisswrc'


defaults = {}
defaults['hissw_home'] = os.path.join(os.environ['HOME'], '.hissw')
if os.path.isfile(os.path.join(os.environ['HOME'], '.hissw', 'hisswrc')):
defaults['hissw_home'] = HISSW_DIR
if HISSW_RC.is_file():
config = configparser.ConfigParser()
config.read(os.path.join(os.environ['HOME'], '.hissw', 'hisswrc'))
config.read(HISSW_RC)
for key in config['hissw']:
defaults[key] = config['hissw'][key]
else:
Expand Down

0 comments on commit 39765a5

Please sign in to comment.