{"id":21428929,"url":"https://github.com/notcoffee418/pythonscriptoperations","last_synced_at":"2025-03-16T21:42:16.922Z","repository":{"id":187070944,"uuid":"676251655","full_name":"NotCoffee418/PythonScriptOperations","owner":"NotCoffee418","description":"Python version of CSharpScriptOperations","archived":false,"fork":false,"pushed_at":"2023-08-09T19:54:44.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T10:49:37.120Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NotCoffee418.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-08T19:20:17.000Z","updated_at":"2023-08-08T20:09:56.000Z","dependencies_parsed_at":"2023-08-08T21:56:59.473Z","dependency_job_id":"3e8fa20d-e3f8-4488-bedd-0d385cfcdd6d","html_url":"https://github.com/NotCoffee418/PythonScriptOperations","commit_stats":null,"previous_names":["notcoffee418/pythonscriptoperations"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotCoffee418%2FPythonScriptOperations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotCoffee418%2FPythonScriptOperations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotCoffee418%2FPythonScriptOperations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotCoffee418%2FPythonScriptOperations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NotCoffee418","download_url":"https://codeload.github.com/NotCoffee418/PythonScriptOperations/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243940062,"owners_count":20372044,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T22:15:15.579Z","updated_at":"2025-03-16T21:42:16.880Z","avatar_url":"https://github.com/NotCoffee418.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 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    from pythonscriptoperations import register_operation, start_listening, start_listening_async\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. Register 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\nasync def example_async_function():\n    print(\"This will be awaited\")\n    await asyncio.sleep(1000)\n\nregister_operations(example_function, \"An example operation\")\nregister_operations(example_async_function, \"An example async operation\")\n```\n\n### 3. Start listening\n\nStart the listener to display available operations and accept user input:\n\n```python\nstart_listening()\n```\n\nIf you need the console to be non-blocking, you can use the async version:\n```python\nstart_listening_async()\n```\n\n### 4. 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.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotcoffee418%2Fpythonscriptoperations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotcoffee418%2Fpythonscriptoperations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotcoffee418%2Fpythonscriptoperations/lists"}