Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ import potato_util.sanitizer as sanitizer_utils
import potato_util.validator as validator_utils
import potato_util.http as http_utils
import potato_util.crypto.jwt as jwt_utils
import potato_util.io as io_utils

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -328,6 +329,14 @@ def main() -> None:
except jwt.InvalidTokenError:
logger.error("JWT token is invalid!")

logger.info("-" * 80)

# IO utils:
logger.info("[IO UTILITIES]")
io_utils.create_dir("test_dir", warn_mode="ALWAYS")
io_utils.remove_dir("test_dir", warn_mode="ALWAYS")
Comment on lines +334 to +337
logger.info("-" * 80)

return


Expand Down
9 changes: 9 additions & 0 deletions examples/simple/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import potato_util.validator as validator_utils
import potato_util.http as http_utils
import potato_util.crypto.jwt as jwt_utils
import potato_util.io as io_utils

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -188,6 +189,14 @@ def main() -> None:
except jwt.InvalidTokenError:
logger.error("JWT token is invalid!")

logger.info("-" * 80)

# IO utils:
logger.info("[IO UTILITIES]")
io_utils.create_dir("test_dir", warn_mode="ALWAYS")
io_utils.remove_dir("test_dir", warn_mode="ALWAYS")
Comment on lines +194 to +197
logger.info("-" * 80)

return


Expand Down
7 changes: 3 additions & 4 deletions src/potato_util/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

from ._sync import *

_async_package_name = "aiofiles"
_async_spec = importlib.util.find_spec(_async_package_name)

if _async_spec is not None:
if (importlib.util.find_spec("aiofiles") is not None) and (
importlib.util.find_spec("aioshutil") is not None
):
from ._async import *
Comment on lines +7 to 10