Skip to content

Commit

Permalink
add append_path (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtimms authored Nov 11, 2024
1 parent 07ca17c commit 5ac4678
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
13 changes: 12 additions & 1 deletion iwutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pandas as pd
from pathlib import Path
import shutil

import sys

def subplots_autolayout(
n, *args, n_rows=None, figsize=None, layout="constrained", **kwargs
Expand Down Expand Up @@ -164,3 +164,14 @@ def this_dir(file):
Get the directory of the file
"""
return Path(file).parent

def append_path(path):
"""
Append a path to the current path
Parameters
----------
path : str or Path
Path to append
"""
sys.path.append(str(path))
6 changes: 6 additions & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import iwutil
import tempfile
from pathlib import Path
import sys


def test_check_and_combine_options():
Expand Down Expand Up @@ -117,3 +118,8 @@ def test_this_dir():
file_path = ""
expected_dir = Path(".")
assert iwutil.this_dir(file_path) == expected_dir


def test_append_path():
iwutil.append_path(".")
assert "." in sys.path

0 comments on commit 5ac4678

Please sign in to comment.