Metadata-Version: 2.1
Name: hidir
Version: 0.0.2
Author-email: CAO Mingpei <caomingpei@outlook.com>
License: MIT License
        
        Copyright (c) 2024 CAO Mingpei
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/caomingpei/hidir
Project-URL: Repository, https://github.com/caomingpei/hidir
Project-URL: Changelog, https://github.com/caomingpei/hidir/blob/main/CHANGELOG.md
Classifier: Intended Audience :: Information Technology
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Desktop Environment :: File Managers
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: ruff ; extra == 'dev'
Requires-Dist: mypy <1.5,>=1.0 ; extra == 'dev'
Requires-Dist: black <24.0,>=23.0 ; extra == 'dev'
Requires-Dist: isort <5.13,>=5.12 ; extra == 'dev'
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: pytest-sphinx ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Requires-Dist: twine >=1.11.0 ; extra == 'dev'
Requires-Dist: build ; extra == 'dev'
Requires-Dist: setuptools ; extra == 'dev'
Requires-Dist: wheel ; extra == 'dev'
Requires-Dist: Sphinx <7.1.0,>=4.3.0 ; extra == 'dev'
Requires-Dist: furo ==2023.7.26 ; extra == 'dev'
Requires-Dist: myst-parser <2.1,>=1.0 ; extra == 'dev'
Requires-Dist: sphinx-copybutton ==0.5.2 ; extra == 'dev'
Requires-Dist: sphinx-autobuild ==2021.3.14 ; extra == 'dev'
Requires-Dist: sphinx-autodoc-typehints ==1.23.3 ; extra == 'dev'
Requires-Dist: packaging ; extra == 'dev'

# HiDir: Hierarchical Directory

**HiDir** is a Python package designed to efficiently manage and organize files within a **Hierarchical Directory** structure. It provides operations to map, check, move, and copy files based on customizable strategies for file identification and path generation.


## Installation

You can install DirectoryManager via pip:

```shell
pip install hidir
```

## Usage

### Initialization

Create an instance of DirectoryManager by specifying the root directory and optional parameters:
```python
from hidir import DirectoryManager

manager = DirectoryManager(root='/path/to/folder', strategy='SHA-256')
```

`files_predict` and `clear_index` is optional parameters. `files_predict` is the estimated number of files. `clear_index` is a boolean value indicating whether to forbid the system file index.

### Method

* `get_base_path(file_name)`: Get the base path for a file based on its name.
* `check_file(file_name)`: Check if a file exists by its name and return its path if it exists.
* `move_file(file_path)`: Move a file to its designated path.
* `copy_file(file_path)`: Copy a file to its designated path.

### Example

```python
# Move a file to its designated folder
manager.move_file('/path/to/file.txt')

# Copy a file to its designated folder
manager.copy_file('/path/to/file.txt')

# Check if a file exists and get its path
file_path = manager.check_file('file.txt')
if file_path:
    print(f'File exists at: {file_path}')
else:
    print('File does not exist.')
```


## Contributing

If you find a bug :bug:, please open a [bug report](https://github.com/allenai/python-package-template/issues/new?assignees=&labels=bug&template=bug_report.md&title=).
If you have an idea for an improvement or new feature :rocket:, please open a [feature request](https://github.com/allenai/python-package-template/issues/new?assignees=&labels=Feature+request&template=feature_request.md&title=).


## License

This package was started off with the [python-package-template](https://github.com/allenai/python-package-template).
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
