Skip to content

Commit c5c6685

Browse files
committed
feat: change outPath to snake-case _out_path and add a setter method for it
1 parent a3f9a8b commit c5c6685

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

src/onc/modules/_OncArchive.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def getFile(self, filename: str = "", overwrite: bool = False):
5151

5252
if response.ok:
5353
# Save file to output path
54-
outPath: Path = self._config("outPath")
55-
saveAsFile(response, outPath, filename, overwrite)
54+
_out_path: Path = self._config("_out_path")
55+
saveAsFile(response, _out_path, filename, overwrite)
5656

5757
else:
5858
msg = _createErrorMessage(response)
@@ -110,8 +110,8 @@ def getDirectFiles(
110110
downInfos = []
111111
for filename in dataRows["files"]:
112112
# only download if file doesn't exist (or overwrite is True)
113-
outPath: Path = self._config("outPath")
114-
filePath = outPath / filename
113+
_out_path: Path = self._config("_out_path")
114+
filePath = _out_path / filename
115115
fileExists = os.path.exists(filePath)
116116

117117
if (not fileExists) or (fileExists and overwrite):

src/onc/modules/_OncDelivery.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def _downloadProductFiles(
174174
status = dpf.download(
175175
timeout,
176176
self.pollPeriod,
177-
self._config("outPath"),
177+
self._config("_out_path"),
178178
maxRetries,
179179
overwrite,
180180
)
@@ -196,7 +196,7 @@ def _downloadProductFiles(
196196
status = dpf.download(
197197
timeout,
198198
self.pollPeriod,
199-
self._config("outPath"),
199+
self._config("_out_path"),
200200
maxRetries,
201201
overwrite,
202202
)

src/onc/onc.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ def __init__(
2323
token,
2424
production: bool = True,
2525
showInfo: bool = False,
26-
outPath: str | Path = "output",
26+
_out_path: str | Path = "output",
2727
timeout: int = 60,
2828
):
2929
self.token = re.sub(r"[^a-zA-Z0-9\-]+", "", token)
3030
self.showInfo = showInfo
3131
self.timeout = timeout
3232
self.baseUrl = "https://data.oceannetworks.ca/"
33-
self.outPath = Path(outPath)
33+
self._out_path = Path(_out_path)
3434

3535
# switch to qa if needed
3636
if not production:
@@ -42,18 +42,21 @@ def __init__(
4242
self.realTime = _OncRealTime(self)
4343
self.archive = _OncArchive(self)
4444

45+
def set_out_path(self, out_path: str | Path):
46+
self._out_path = Path(out_path)
47+
4548
def print(self, obj, filename: str = ""):
4649
"""
4750
Helper for printing a JSON dictionary to the console or to a file
4851
@filename: if present, creates a file with a ".json" extension
49-
in "self.outPath" directory, and writes the output to the file.
52+
in "self._out_path" directory, and writes the output to the file.
5053
if not present, prints the output to the console.
5154
"""
5255
text = json.dumps(obj, indent=4)
5356
if filename == "":
5457
print(text)
5558
else:
56-
filePath = self.outPath / filename
59+
filePath = self._out_path / filename
5760
filePath = filePath.with_suffix(".json")
5861

5962
with open(filePath, "w+") as file:

tests/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ pabot --testlevelsplit tests/robot/suites
6666
_To run a single RF test suite (replace 0X with the prefix of the test file name, e.g., 01):_
6767

6868
```shell
69-
robot tests/suites/01* # robot tests/suites/0X*
69+
robot tests/robot/suites/01* # robot tests/robot/suites/0X*
7070
```
7171

7272
_To run a single RF test in a test suite (replace Y with the prefix of the test name, e.g., 01):_
7373

7474
```shell
75-
robot --test "01*" tests/suites/01* # robot --test "Y*" tests/suites/0X*
75+
robot --test "01*" tests/robot/suites/01* # robot --test "Y*" tests/robot/suites/0X*
7676
```
7777

7878
_To run pytest_
@@ -84,7 +84,7 @@ pytest
8484
_`--variable TOKEN:${YOUR_TOKEN}` can be used if no `.env` file is present_
8585

8686
```shell
87-
robot --variable TOKEN:${YOUR_TOKEN} tests/suites/01*
87+
robot --variable TOKEN:${YOUR_TOKEN} tests/robot/suites/01*
8888
```
8989

9090
Additionally, You can check the three bash files (testall, testcoverage and testsuite) for running the test suites.

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111

1212
@pytest.fixture
1313
def requester(tmp_path) -> ONC:
14-
return ONC(token, is_prod, outPath=tmp_path)
14+
return ONC(token, is_prod, _out_path=tmp_path)

tests/robot/libraries/delivery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def manualRunProduct(dpRequestId: int):
1717

1818
def manualDownloadProduct(dpRunId: int, outPath: str = "", resultsOnly: bool = False):
1919
# Manually downloads runId
20-
onc.outPath = Path(outPath)
20+
onc.set_out_path(outPath)
2121
return onc.downloadDataProduct(dpRunId, downloadResultsOnly=resultsOnly)
2222

2323

0 commit comments

Comments
 (0)