Skip to content

Commit

Permalink
STY: hide _archive_path
Browse files Browse the repository at this point in the history
  • Loading branch information
jklenzing committed Jun 5, 2021
1 parent 352beeb commit 597fa37
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions sami2py/__init__.py
Expand Up @@ -38,15 +38,15 @@
os.makedirs(sami2py_dir)
print('Created {} directory to store settings.'.format(sami2py_dir))

archive_path = os.path.join(sami2py_dir, 'archive_path.txt')
if os.path.isfile(archive_path):
_archive_path = os.path.join(sami2py_dir, 'archive_path.txt')
if os.path.isfile(_archive_path):
# load up stored data path
with open(archive_path, 'r') as fin:
with open(_archive_path, 'r') as fin:
archive_dir = fin.readline()
del fin
else:
# create file
with open(archive_path, 'w+') as fout:
with open(_archive_path, 'w+') as fout:
fout.write('')
del fout
archive_dir = ''
Expand All @@ -66,7 +66,7 @@
test_data_dir = fin.readline()
del fin

del archive_path, home_dir, env_name, on_rtd
del home_dir, env_name, on_rtd

# import main functions
try:
Expand Down
2 changes: 1 addition & 1 deletion sami2py/tests/test_core.py
Expand Up @@ -116,7 +116,7 @@ def test_fortran_executable(self):
if os.path.isdir(tmp_archive_dir):
sami2py.utils.set_archive_dir(path=tmp_archive_dir)
else:
with open(sami2py.archive_path, 'w') as archive_file:
with open(sami2py._archive_path, 'w') as archive_file:
archive_file.write('')
sami2py.archive_dir = ''

Expand Down
4 changes: 2 additions & 2 deletions sami2py/tests/test_utils.py
Expand Up @@ -62,14 +62,14 @@ def test_set_archive_dir(self):
from sami2py import test_data_dir
sami2py.utils.set_archive_dir(path=test_data_dir)

with open(sami2py.archive_path, 'r') as archive_file:
with open(sami2py._archive_path, 'r') as archive_file:
archive_dir = archive_file.readline()
assert archive_dir == test_data_dir

if os.path.isdir(tmp_archive_dir):
sami2py.utils.set_archive_dir(path=tmp_archive_dir)
else:
with open(sami2py.archive_path, 'w') as archive_file:
with open(sami2py._archive_path, 'w') as archive_file:
archive_file.write('')
sami2py.archive_dir = ''

Expand Down

0 comments on commit 597fa37

Please sign in to comment.