# Character Occurrence Counter with Caching

This Python package calculates the number of unique characters in a given string or text file, while using caching to optimize performance for repeated calculations.

## Features

- **Unique Character Counting**: Identify characters that occur only once in a string or file.
- **Caching Mechanism**: Uses `lru_cache` to speed up repeated character counting operations.
- **Command-Line Interface (CLI)**: Allows processing of input directly from the terminal.
- **Optimized Performance**: Leverages the `collections` module for efficient counting.
- **Robust Testing**: Comprehensive tests written with `pytest` to handle various edge cases and performance scenarios.
- **Coverage Reports**: Ability to generate coverage reports to ensure all code is thoroughly tested.

---

## Prerequisites

Before installing, ensure you have the following:

- **Python 3.6 or later** installed.

---

## Installation

You can install the package directly from PyPI:

```bash
pip install unique_character_counter
```

---

## Usage

### 1. As a Module

You can import and use the module in your Python scripts as follows:

```python
from collection.unique_char_count import get_unique_character_count

result = get_unique_character_count("abcdefg")
print(f"Number of unique characters: {result}")
```

### 2. Command-Line Interface

After installing, you can use the provided CLI commands to process strings or files:

#### To Process a String:

```bash
unique-counter --string "abcdefg"
```

#### To Process a File:

```bash
unique-counter --file path/to/your/file.txt
```

---

## Testing

This package includes tests to ensure all features are working as expected. You can use `pytest` to run the tests after installation.

### Important Note About Tests
Ensure that the `tests` folder contains an `__init__.py` file. This file is necessary to make `tests` a proper package that can be discovered by `pytest` during the installation process.

#### Run All Tests

Specify the package name to run all tests:

```bash
pytest --pyargs collection.tests
```

This ensures `pytest` can locate and run all test files included in the installed package.

#### Alternatively, Specify the Path to the Tests Folder:

```bash
pytest collection/tests
```

#### Generate a Coverage Report

To generate a coverage report, use the following commands:

```bash
coverage run -m pytest --pyargs collection.tests
coverage report
```

Ensure `pytest` is installed if it isn't already:

```bash
pip install pytest
```

---

## Optional: Create a Virtual Environment

It is recommended to use a virtual environment to keep dependencies isolated. This step is optional but can help maintain a clean development environment.

To create a virtual environment:

```bash
python -m venv venv
```

Activate the virtual environment:

- **On Windows**:
  ```bash
  venv\Scripts\activate
  ```
- **On macOS/Linux**:
  ```bash
  source venv/bin/activate
  ```

---

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.

---

## Support

If you encounter any issues or have suggestions, please feel free to open an issue on the [GitLab repository](https://git.foxminded.ua/povh_andriy/task-5-python-package).

