Skip to content

Commit

Permalink
0.59: +default path for parent & unzipdir
Browse files Browse the repository at this point in the history
  • Loading branch information
ezio416 committed Feb 22, 2023
1 parent 2fe2946 commit d485237
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "py416"
version = "0.58"
version = "0.59"
authors = [
{ name="Ezio416", email="[email protected]" },
]
Expand Down
6 changes: 3 additions & 3 deletions src/py416/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
Name: py416
Author: Ezio416
Created: 2022-08-15
Updated: 2022-12-17
Version: 0.58
Updated: 2023-02-22
Version: 0.59
A collection of various functions
'''
from .general import *
__version__ = 0, 58
__version__ = 0, 59
v = __version__
8 changes: 5 additions & 3 deletions src/py416/files.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'''
| Author: Ezio416
| Created: 2022-08-16
| Updated: 2022-11-10
| Updated: 2023-02-22
- Functions for filesystem and path string manipulation
Expand Down Expand Up @@ -826,14 +826,15 @@ def move(path: str, dest: str, overwrite: bool = False) -> str:
return shmv(path, dest) # dest folder doesn't exist, good


def parent(path: str) -> str:
def parent(path: str = '.') -> str:
'''
- gets the folder containing something
Parameters
----------
path: str
- path to find the parent of
- default: current working directory
Returns
-------
Expand Down Expand Up @@ -1014,7 +1015,7 @@ def unzip(path: str, remove: bool = False) -> None:
raise NotImplementedError(f'unsupported archive format: {path.split(".")[-1]}')


def unzipdir(path: str, ignore_errors: bool = True) -> int:
def unzipdir(path: str = '.', ignore_errors: bool = True) -> int:
'''
- unzips all archives in a folder (only 1st level) until it is unable to continue
- deletes all archives as it unzips
Expand All @@ -1024,6 +1025,7 @@ def unzipdir(path: str, ignore_errors: bool = True) -> int:
----------
path: str
- folder containing archive files
- default: current working directory
ignore_errors: bool
- whether to catch all Exceptions in unzipping
Expand Down
4 changes: 4 additions & 0 deletions tests/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ def test_move(tmp_path):
def test_parent(i, o):
assert p4f.parent(i) == o

def test_parent_default(tmp_path):
os.chdir(str_path := str(tmp_path).replace('\\', '/'))
assert p4f.parent() == os.path.dirname(os.getcwd()).replace('\\', '/')

def test_readfile(tmp_path):
os.chdir(str_path := str(tmp_path).replace('\\', '/'))
file = 'file.txt'
Expand Down

0 comments on commit d485237

Please sign in to comment.