pythonscriptoperations


Namepythonscriptoperations JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/NotCoffee418/PythonScriptOperations
SummaryA package to manage and execute Python operations.
upload_time2023-08-09 16:21:37
maintainer
docs_urlNone
authorStijn Raeymaekers
requires_python
licenseMIT
keywords python script operations manager console selection
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PythonScriptOperations

[![PyPI](https://img.shields.io/pypi/v/pythonscriptoperations?style=for-the-badge)](https://pypi.org/project/pythonscriptoperations/)

## What is it?
`PythonScriptOperations` is a library for Python console applications to quickly set up a console application interface. Developers can utilize it to swiftly access specific portions of their codebase by registering operations.

It is the brother to [CSharpScriptOperations](https://github.com/NotCoffee418/CSharpScriptOperations), a similar library for C# console applications.

## Quick Start

1. **Import the pip package**:
    ```python
    import pythonscriptoperations
    ```
2. **Create a function or async function and register it**:
    ```python
    def add_numbers():
        result = 2 + 2
        print(f"2 + 2 = {result}")

    register_operations(add_numbers, "Print the result of 2+2")
    ```

3. **Start listening for operations**:
    ```python
    start_listening()
    ```

## What does it look like?

This is an example taken from the `demo.py`.
```
Available operations:
0. Exit
1. Addition: 5 + 7
2. Subtraction: 12 - 4
3. Multiplication (async): 6 * 3
4. Division: 36 / 6

Select an operation ('help' for list of operations)
1

Running operation: Addition: 5 + 7
12

Done
```

## Detailed Instructions

### 1. Install the pip package.

Install the pip package using:
```bash
pip install pythonscriptoperations
```
Then, simply `import pythonscriptoperations` wherever you need it.

### 2. Define your operations

Operations are simple Python functions (or async functions) dedicated to specific tasks.  
To provide a description, simply pass it when registering the function:

```python
def example_function():
    print("This is an example.")

register_operations(example_function, "An example operation")
```

### 3. Register your operations

You can register multiple operations at once:

```python
def operation1():
    pass

def operation2():
    pass

register_operations(operation1, "Description for operation1")
register_operations(operation2, "Description for operation2")
```

### 4. Start listening

Start the listener to display available operations and accept user input:

```python
start_listening_async()
```
For synchronous setups, you can use:
```python
start_listening()
```

### 5. Try it out

When you run your script, you should see a list of operations with numbers next to them. To execute an operation, simply input its number.

### Example

For a complete working example, refer to the `demo.py` in the repository.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/NotCoffee418/PythonScriptOperations",
    "name": "pythonscriptoperations",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python script operations manager console selection",
    "author": "Stijn Raeymaekers",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/24/56/945fad72528c2f61c048309dec77cfd47a26d36e7a66ebab2b42515b89c6/pythonscriptoperations-0.1.1.tar.gz",
    "platform": null,
    "description": "# PythonScriptOperations\n\n[![PyPI](https://img.shields.io/pypi/v/pythonscriptoperations?style=for-the-badge)](https://pypi.org/project/pythonscriptoperations/)\n\n## What is it?\n`PythonScriptOperations` is a library for Python console applications to quickly set up a console application interface. Developers can utilize it to swiftly access specific portions of their codebase by registering operations.\n\nIt is the brother to [CSharpScriptOperations](https://github.com/NotCoffee418/CSharpScriptOperations), a similar library for C# console applications.\n\n## Quick Start\n\n1. **Import the pip package**:\n    ```python\n    import pythonscriptoperations\n    ```\n2. **Create a function or async function and register it**:\n    ```python\n    def add_numbers():\n        result = 2 + 2\n        print(f\"2 + 2 = {result}\")\n\n    register_operations(add_numbers, \"Print the result of 2+2\")\n    ```\n\n3. **Start listening for operations**:\n    ```python\n    start_listening()\n    ```\n\n## What does it look like?\n\nThis is an example taken from the `demo.py`.\n```\nAvailable operations:\n0. Exit\n1. Addition: 5 + 7\n2. Subtraction: 12 - 4\n3. Multiplication (async): 6 * 3\n4. Division: 36 / 6\n\nSelect an operation ('help' for list of operations)\n1\n\nRunning operation: Addition: 5 + 7\n12\n\nDone\n```\n\n## Detailed Instructions\n\n### 1. Install the pip package.\n\nInstall the pip package using:\n```bash\npip install pythonscriptoperations\n```\nThen, simply `import pythonscriptoperations` wherever you need it.\n\n### 2. Define your operations\n\nOperations are simple Python functions (or async functions) dedicated to specific tasks.  \nTo provide a description, simply pass it when registering the function:\n\n```python\ndef example_function():\n    print(\"This is an example.\")\n\nregister_operations(example_function, \"An example operation\")\n```\n\n### 3. Register your operations\n\nYou can register multiple operations at once:\n\n```python\ndef operation1():\n    pass\n\ndef operation2():\n    pass\n\nregister_operations(operation1, \"Description for operation1\")\nregister_operations(operation2, \"Description for operation2\")\n```\n\n### 4. Start listening\n\nStart the listener to display available operations and accept user input:\n\n```python\nstart_listening_async()\n```\nFor synchronous setups, you can use:\n```python\nstart_listening()\n```\n\n### 5. Try it out\n\nWhen you run your script, you should see a list of operations with numbers next to them. To execute an operation, simply input its number.\n\n### Example\n\nFor a complete working example, refer to the `demo.py` in the repository.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A package to manage and execute Python operations.",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/NotCoffee418/PythonScriptOperations"
    },
    "split_keywords": [
        "python",
        "script",
        "operations",
        "manager",
        "console",
        "selection"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9b7461cfa77c50cee8d9c3d67dadf338df1ff87710609368414ff78d385c26a8",
                "md5": "e675f153cd9be33829ab3d77f1732e88",
                "sha256": "0e792c84238ef56c61f2069c2ab74447843305f26235e3b2e858062b4e1eedd3"
            },
            "downloads": -1,
            "filename": "pythonscriptoperations-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e675f153cd9be33829ab3d77f1732e88",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5614,
            "upload_time": "2023-08-09T16:21:37",
            "upload_time_iso_8601": "2023-08-09T16:21:37.059885Z",
            "url": "https://files.pythonhosted.org/packages/9b/74/61cfa77c50cee8d9c3d67dadf338df1ff87710609368414ff78d385c26a8/pythonscriptoperations-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2456945fad72528c2f61c048309dec77cfd47a26d36e7a66ebab2b42515b89c6",
                "md5": "39a2421668cf176cad7c3abaf0fdd4cb",
                "sha256": "8f57becf93e2a4015ada8c0e68e174ba79eea002c9fa0716ba9e4600dfdeed62"
            },
            "downloads": -1,
            "filename": "pythonscriptoperations-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "39a2421668cf176cad7c3abaf0fdd4cb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4677,
            "upload_time": "2023-08-09T16:21:37",
            "upload_time_iso_8601": "2023-08-09T16:21:37.912030Z",
            "url": "https://files.pythonhosted.org/packages/24/56/945fad72528c2f61c048309dec77cfd47a26d36e7a66ebab2b42515b89c6/pythonscriptoperations-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-09 16:21:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NotCoffee418",
    "github_project": "PythonScriptOperations",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pythonscriptoperations"
}
        
Elapsed time: 0.38774s