pygeneral


Namepygeneral JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryTools for Python
upload_time2025-02-12 06:38:14
maintainerNone
docs_urlNone
authorBartSte
requires_python>=3.10
licenseMIT License
keywords tools python helpers utilities general
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # README - pygeneral

A collection of general-purpose Python utilities.

---

## Table of Contents

1. [Overview](#overview)
2. [Installation](#installation)
3. [Command-Line Usage](#command-line-usage)
4. [Python Usage](#python-usage)
   - [Sorting with `lensort`](#sorting-with-lensort)
   - [Using `StdoutCounter`](#using-stdoutcounter)
   - [Checking Root Privileges with `is_root`](#checking-root-privileges-with-is_root)
5. [Project Structure](#project-structure)
6. [License](#license)

---

## Overview

`pygeneral` is a set of small Python utilities that can simplify common tasks.

- **`ProgressBar`** is a simple progress bar that can be used in the console.
- **`StdoutCounter`** provides a straightforward way to show progress in the console, incrementally updating a single line.
- **`is_root`** helps you check if the current user has root (on Linux/Unix) or administrator (on Windows) privileges.
- **`lensort`** sorts lines based on their distance to a match of a specified regular expression.

---

## Installation

```bash
pip install pygeneral
```

Or, for development:

```bash
# (1) Clone the repository
git clone https://github.com/BartSte/pygeneral.git
cd pygeneral
pip install -e ".[dev]"
```

---

## Usage

You can import the classes and functions from `pygeneral` as you normally would
with in a Python script. Additionally, some of the utilities are also available
as command-line tools. As is explained below.

### Lensort

After installation, you will have the `lensort` command available:

```bash
lensort [OPTIONS] <REGEX>
```

#### Example

Suppose you have a file named `input.txt`:

```
abc = 1
x = 2
yy = 3
```

If you run:

```bash
lensort '=' -f input.txt
```

The output will be:

```
x = 2
yy = 3
abc = 1
```

Explanation:

- It sorts lines by the number of characters before the `=` match.
- `x = 2` has 1 character before `=`.
- `yy = 3` has 2 characters before `=`.
- `abc = 1` has 3 characters before `=`.

You can also pipe content directly to `lensort`, for example:

```bash
cat input.txt | lensort '='
```

---

## License

This project is licensed under the [MIT License](https://opensource.org/licenses/MIT).  
See the [LICENSE](LICENSE) file for details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pygeneral",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "tools, python, helpers, utilities, general",
    "author": "BartSte",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/06/5c/050f7f86a6c27ca85a16a6fff86531b502664b67ba00046a4367f2acc913/pygeneral-0.1.0.tar.gz",
    "platform": null,
    "description": "# README - pygeneral\n\nA collection of general-purpose Python utilities.\n\n---\n\n## Table of Contents\n\n1. [Overview](#overview)\n2. [Installation](#installation)\n3. [Command-Line Usage](#command-line-usage)\n4. [Python Usage](#python-usage)\n   - [Sorting with `lensort`](#sorting-with-lensort)\n   - [Using `StdoutCounter`](#using-stdoutcounter)\n   - [Checking Root Privileges with `is_root`](#checking-root-privileges-with-is_root)\n5. [Project Structure](#project-structure)\n6. [License](#license)\n\n---\n\n## Overview\n\n`pygeneral` is a set of small Python utilities that can simplify common tasks.\n\n- **`ProgressBar`** is a simple progress bar that can be used in the console.\n- **`StdoutCounter`** provides a straightforward way to show progress in the console, incrementally updating a single line.\n- **`is_root`** helps you check if the current user has root (on Linux/Unix) or administrator (on Windows) privileges.\n- **`lensort`** sorts lines based on their distance to a match of a specified regular expression.\n\n---\n\n## Installation\n\n```bash\npip install pygeneral\n```\n\nOr, for development:\n\n```bash\n# (1) Clone the repository\ngit clone https://github.com/BartSte/pygeneral.git\ncd pygeneral\npip install -e \".[dev]\"\n```\n\n---\n\n## Usage\n\nYou can import the classes and functions from `pygeneral` as you normally would\nwith in a Python script. Additionally, some of the utilities are also available\nas command-line tools. As is explained below.\n\n### Lensort\n\nAfter installation, you will have the `lensort` command available:\n\n```bash\nlensort [OPTIONS] <REGEX>\n```\n\n#### Example\n\nSuppose you have a file named `input.txt`:\n\n```\nabc = 1\nx = 2\nyy = 3\n```\n\nIf you run:\n\n```bash\nlensort '=' -f input.txt\n```\n\nThe output will be:\n\n```\nx = 2\nyy = 3\nabc = 1\n```\n\nExplanation:\n\n- It sorts lines by the number of characters before the `=` match.\n- `x = 2` has 1 character before `=`.\n- `yy = 3` has 2 characters before `=`.\n- `abc = 1` has 3 characters before `=`.\n\nYou can also pipe content directly to `lensort`, for example:\n\n```bash\ncat input.txt | lensort '='\n```\n\n---\n\n## License\n\nThis project is licensed under the [MIT License](https://opensource.org/licenses/MIT).  \nSee the [LICENSE](LICENSE) file for details.\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Tools for Python",
    "version": "0.1.0",
    "project_urls": null,
    "split_keywords": [
        "tools",
        " python",
        " helpers",
        " utilities",
        " general"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0235d7d090f0db438e418a470a58811eb70572cff023cd2146b8a4e2f6b4b3a0",
                "md5": "e951a5f96d0ba36918a0f8634ec48e4b",
                "sha256": "5ed12d7ff76adf7dd770a50e407fb1d7c945cb0239a088e14c6028dcbc6dfbd6"
            },
            "downloads": -1,
            "filename": "pygeneral-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e951a5f96d0ba36918a0f8634ec48e4b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 8783,
            "upload_time": "2025-02-12T06:38:12",
            "upload_time_iso_8601": "2025-02-12T06:38:12.859468Z",
            "url": "https://files.pythonhosted.org/packages/02/35/d7d090f0db438e418a470a58811eb70572cff023cd2146b8a4e2f6b4b3a0/pygeneral-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "065c050f7f86a6c27ca85a16a6fff86531b502664b67ba00046a4367f2acc913",
                "md5": "bb95a2370167a7942bc27f9e32838aed",
                "sha256": "a0f7158aaf8bdc0736ce88ae25cbf2b6c1d5fda64d7b8872dbbe346079785a02"
            },
            "downloads": -1,
            "filename": "pygeneral-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bb95a2370167a7942bc27f9e32838aed",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 12145,
            "upload_time": "2025-02-12T06:38:14",
            "upload_time_iso_8601": "2025-02-12T06:38:14.819353Z",
            "url": "https://files.pythonhosted.org/packages/06/5c/050f7f86a6c27ca85a16a6fff86531b502664b67ba00046a4367f2acc913/pygeneral-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-12 06:38:14",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pygeneral"
}
        
Elapsed time: 1.27060s