Skip to content

Commit d680570

Browse files
authored
Merge pull request #96 from molssi-seamm/dev
Enhancement to allow paths with directories.
2 parents 1cf185c + 72e81f7 commit d680570

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed

HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
=======
22
History
33
=======
4+
2025.6.1 -- Enhancement to allow paths with directories.
5+
* As in reading/writing structures, paths beginning with '/' are relative to the
6+
root of the job, and relative paths are relative to the directory where the table
7+
step is invoked.
8+
49
2023.11.10 -- Bugfix: title of edit dialog was wrong
510

611
2023.10.30 -- Cleaned up output

devtools/conda-envs/test_env.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dependencies:
3131
# Integration testing
3232
- custom-step
3333
- loop-step
34+
- seamm-exec
3435
# Documentation
3536
- sphinx-copybutton
3637
- sphinxnotes-strike

table_step/table.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"""Non-graphical part of the Table step in SEAMM"""
44

55
import logging
6-
import os.path
7-
from pathlib import PurePath
6+
from pathlib import Path, PurePath
87

98
import numpy as np
109
import pandas
@@ -208,6 +207,9 @@ def run(self):
208207
)
209208
tablename = P["table name"]
210209

210+
# Pathnames are relative to current working directory
211+
wd = Path(self.directory).parent
212+
211213
# Print out header to the main output
212214
printer.important(self.description_text(P))
213215
printer.important("")
@@ -330,16 +332,21 @@ def run(self):
330332
file_type = P["file type"]
331333
table_handle = self.get_variable(tablename)
332334
table = table_handle["table"]
335+
333336
if P["method"] == "Save as":
334-
filename = P["filename"]
337+
filename = P["filename"].strip()
338+
if filename.startswith("/"):
339+
filename = str(
340+
Path(self.flowchart.root_directory) / filename[1:]
341+
)
342+
else:
343+
filename = str(wd / filename)
335344
table_handle["filename"] = filename
336345
else:
337346
if "filename" not in table_handle:
338347
if file_type == "from extension":
339348
file_type = ".csv"
340-
table_handle["filename"] = os.path.join(
341-
self.flowchart.root_directory, tablename + file_type
342-
)
349+
table_handle["filename"] = str(wd / tablename) + file_type
343350
filename = table_handle["filename"]
344351

345352
index = table_handle["index column"]

table_step/table_parameters.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
"""Control parameters for loops
3-
"""
2+
"""Control parameters for tables"""
43

54
import logging
65
import seamm

tests/test_flowcharts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""Tests for `table_step` running full flowcharts."""
55
from pathlib import Path
66
import pytest
7-
from seamm import run_flowchart
7+
from seamm_exec import run
88

99
test_dir = Path(__file__).resolve().parent
1010

@@ -25,4 +25,4 @@ def test_flowchart(monkeypatch, tmp_path, flowchart):
2525
],
2626
)
2727

28-
run_flowchart(wdir=str(tmp_path))
28+
run(wdir=str(tmp_path))

versioneer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,9 @@ def get_config_from_root(root):
339339
# configparser.NoOptionError (if it lacks "VCS="). See the docstring at
340340
# the top of versioneer.py for instructions on writing your setup.cfg .
341341
setup_cfg = os.path.join(root, "setup.cfg")
342-
parser = configparser.SafeConfigParser()
342+
parser = configparser.ConfigParser()
343343
with open(setup_cfg, "r") as f:
344-
parser.readfp(f)
344+
parser.read_file(f)
345345
VCS = parser.get("versioneer", "VCS") # mandatory
346346

347347
def get(parser, name):

0 commit comments

Comments
 (0)