semvec/pypi-packages huggingface dataset:
pynsted 1.0.8
Add a method to dictionaries to get nested values
Requires Python: <3.13,>=3.11
Keywords: dictionary, nested

# pynsted

This is a Python library which in a hackish way adds to Python dictionaries
a method for getting nested values. It can be installed with
`pip install pynsted`.

## Usage

Start by importing the module: `import pynsted`.

Now access nested values in dictionaries by specifing path to them and using
`getn` method:

```python
>>> import pynsted
>>> a = {1: {2: {"foo": "bar"}}}
>>> a.getn([1, 2, "foo"])
'bar'
>>>
```

If at some moment there is no value, corresponding to the next key in path,
`None` is returned:

```python
>>> print(a.getn([1, 3, "foo"]))
None
>>>
```

It is possible to specify the default value, which will be returned instead of
`None` if there is no value at the given path:

```python
>>> a.getn([1, 3, "foo"], "new default")
'new default'
>>>
```

## Linters

There are two problems with this module and linters:

- unused import
- nonexisting `.getn()` method for dictionaries

### Unused import

If the import is really unused (see below why it may not be), do the following:

- for `pylint` put `# pylint: disable=unused-import` in the line right before
  the import and `# pylint: disable=unused-import` in the line right after, or
  `pylint: disable=unused-import` as an end comment into the import line
- for `ruff` put `noqa: F401` as an end comment into the import line
- for `pyright`: put `# pyright: reportUnusedImport=false` in the line right
  before the import line and `# pyright: reportUnusedImport=false` in the line
  right after, or `pyright: ignore` as an end comment into the import line

Notice that in the case of multiple linters combination of end of line comments
in the import line will not work, and you will need to do something like

```python
# pylint: disable=unused-import
# pyright: reportUnusedImport=false
import pynsted  # noqa: F401
# pyright: reportUnusedImport=true
# pylint: enable=unused-import
```

### Nonexisting method

#### Quick and dirty pylint solution

Add inte yoir pylint configuration file something like
`extension-pkg-whitelist=pynsted`. Notice that method is insecure and allows
the authors of `pynsted` to do whatever they want with your computer, and maybe
also kill your cat.

### Using protocol

The benefit of this approach that it will pacify not only `pylint` but
`pyright`, `ruff`, and `mypy`, and will make import used. The idea is that
`pytested` module defines `SupportsGetn` protocol, which claims the presence of
`getn` method. You have to assert that your dictionary is BOTH `dict` and
`SupportsGetn`:

```python
assert isinstance(input_dict, dict)
assert isinstance(input_dict, pynsted.SupportsGetn)
```

## Development

The project uses `poetry` tool (highly recommended!), you should know your way
around. The supplied `Makefile` defines the following targets:

- `test` -- runs `pytest` and demands 100% test coverage
- `qa` -- runs `test` target and then runs a bunch of linters
- `format` -- formats the code with `black` and `isort`
resize-images 1.0.0
A simple tool to resize images in a directory.
Requires Python: >=3.6

# Resize Images

## Python Installation :

``` sh
sudo apt-get install python3
sudo apt-get install python3-pip
pip install --upgrade pip
```
## Resize Images installation :

``` sh
pip install resize-image
```

## Usage :

``` sh
python resize_images.py -d "path/to/directory" -w 150 -h 150
```
student-helper 1.0.1
This is my first module
Requires Python: >=3.7
Keywords: example python

Р­С‚Рѕ Р±РёР±Р»РёРѕС‚РµРєР° СЃРѕР·РґР°РЅР° РґР»СЏ РїРѕРјРѕС‰Рё СЃС‚СѓРґРµРЅС‚Р°Рј
image-text-reader 1.0.1
A library to read text from images
Requires Python: >=3.6

# Image Text Reader

The `image-text-reader` library allows you to extract text from images using Optical Character Recognition (OCR) with the help of the `pytesseract` library and `Pillow` for image processing.

## Table of Contents

- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Usage](#usage)
- [Code Explanation](#code-explanation)
- [Contributing](#contributing)
- [License](#license)

## Prerequisites

- Python 3.x
- Tesseract-OCR

## Installation

1. **Install the required Python libraries:**

   ```bash
   pip install image-text-reader
   ```

2. **Install Tesseract-OCR:**

   - **Windows:** Download and install from [here](https://github.com/UB-Mannheim/tesseract/wiki).
   - **macOS:** Use Homebrew to install:

     ```bash
     brew install tesseract
     ```

   - **Linux:** Use your package manager, for example:

     ```bash
     sudo apt-get install tesseract-ocr
     ```

## Usage

1. **Create a Python script** (e.g., `test_script.py`) and import the `ocr_image` function from the `image_text_reader` library:

   ```python
   from image_text_reader import ocr_image
   ```

2. **Set the path to your image and Tesseract-OCR executable:**

   ```python
   # Update these paths for your system
   image_path = 'C:/path_to_your_image.jpg'  # Replace with the path to your test image
   tesseract_cmd = 'C:/Program Files/Tesseract-OCR/tesseract.exe'  # Path to Tesseract executable

   extracted_text = ocr_image(image_path, tesseract_cmd=tesseract_cmd)
   print("Extracted Text:")
   print(extracted_text)
   ```

3. **Run your script:**

   ```bash
   python test_script.py
   ```

## Code Explanation

- **Preprocessing Function:**

  The `preprocess_image` function prepares the image for OCR by converting it to grayscale, sharpening it, and enhancing its contrast:

  ```python
  def preprocess_image(image_path):
      image = Image.open(image_path).convert('L')
      image = image.filter(ImageFilter.SHARPEN)
      enhancer = ImageEnhance.Contrast(image)
      image = enhancer.enhance(2)
      return image
  ```

- **OCR Function:**

  The `ocr_image` function processes the image and then extracts the text using `pytesseract`:

  ```python
  def ocr_image(image_path, tesseract_cmd=None):
      if tesseract_cmd:
          pytesseract.pytesseract.tesseract_cmd = tesseract_cmd
      image = preprocess_image(image_path)
      text = pytesseract.image_to_string(image, lang='eng')
      return text
  ```

## Contributing

Contributions are welcome! Please open an issue or submit a pull request for any changes.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.

For more information, visit the [image-text-reader library page on PyPI](https://pypi.org/project/image-text-reader/).