From c17b3b999dac4d019e651711224aec2dd87f0ad8 Mon Sep 17 00:00:00 2001 From: Fabio Caccamo Date: Tue, 19 Dec 2023 17:54:43 +0100 Subject: [PATCH] Update `README`. --- README.md | 18 +++++++++++++++++- fsutil/__init__.py | 6 +++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 67eed65..5e68631 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ import fsutil - [`get_file_size_formatted`](#get_file_size_formatted) - [`get_filename`](#get_filename) - [`get_parent_dir`](#get_parent_dir) +- [`get_permissions`](#get_permissions) - [`get_unique_name`](#get_unique_name) - [`is_dir`](#is_dir) - [`is_empty`](#is_empty) @@ -107,6 +108,7 @@ import fsutil - [`replace_file`](#replace_file) - [`search_dirs`](#search_dirs) - [`search_files`](#search_files) +- [`set_permissions`](#set_permissions) - [`split_filename`](#split_filename) - [`split_filepath`](#split_filepath) - [`split_path`](#split_path) @@ -436,10 +438,17 @@ filename = fsutil.get_filename(path) parent_dir = fsutil.get_parent_dir(path, levels=1) ``` +#### `get_permissions` + +```python +# Get the file/directory permissions. +permissions = fsutil.get_permissions(path) +``` + #### `get_unique_name` ```python -# Gets a unique name for a directory/file ath the given directory path. +# Get a unique name for a directory/file ath the given directory path. unique_name = fsutil.get_unique_name(path, prefix="", suffix="", extension="", separator="-") ``` @@ -689,6 +698,13 @@ dirs = fsutil.search_dirs(path, pattern="**/*") files = fsutil.search_files(path, pattern="**/*.*") ``` +#### `set_permissions` + +```python +# Set the file/directory permissions. +fsutil.set_permissions(path, 700) +``` + #### `split_filename` ```python diff --git a/fsutil/__init__.py b/fsutil/__init__.py index 6bb9fe3..50e0d63 100644 --- a/fsutil/__init__.py +++ b/fsutil/__init__.py @@ -792,7 +792,7 @@ def get_parent_dir(path: PathIn, *, levels: int = 1) -> str: def get_permissions(path: PathIn) -> int: """ - Gets the file/directory permissions. + Get the file/directory permissions. """ path = _get_path(path) assert_exists(path) @@ -810,7 +810,7 @@ def get_unique_name( separator: str = "-", ) -> str: """ - Gets a unique name for a directory/file ath the given directory path. + Get a unique name for a directory/file ath the given directory path. """ path = _get_path(path) assert_dir(path) @@ -1297,7 +1297,7 @@ def search_files(path: PathIn, pattern: str = "**/*.*") -> list[str]: def set_permissions(path: PathIn, value: int) -> None: """ - Sets the file/directory permissions. + Set the file/directory permissions. """ path = _get_path(path) assert_exists(path)