alfred5


Namealfred5 JSON
Version 1.1.6 PyPI version JSON
download
home_pagehttps://github.com/yedhrab/alfred5
SummarySimple python wrapper for alfred5 workflow / snippets
upload_time2023-07-10 23:52:55
maintainer
docs_urlNone
authorYunus Emre Ak
requires_python>=3.9.6
licenseApache Software License 2.0
keywords alfred alfred5 workflow snippets alfred-workflows alfred-snippets
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            #  🎩 AlfredClient

Simplest Alfred Client that I use my own projects.

## Usage

```bash
pip install alfred5
```
- Projects dir structure
    - Put your codes and `requirements.txt` to `src` folders
    - Install `alfred5` via 
        ```bash
        pip install alfred5 --target=src/libs
        ```
    - Add the top of the `main.py`
        ```python
            import sys

            sys.path.insert(0, "src/libs")
        ```
        - ![main](https://i.imgur.com/O6rYLQA.png)
    - If u want to use different `--target` for ex `.` use `WorkflowClient.run(packagedir=".")`
    - Sample of default structure: 
        - ![structure](https://i.imgur.com/doLWDR4.png)
    - **If u install all of requirements, dont need to create `requirements.txt` file in `src`**
    - _If you use `vscode`, add the code that below to `.vscode/settings.json` to debug your file_
        - ![vscode](https://i.imgur.com/QeseMTr.png)
        ```json
        {
            "python.analysis.extraPaths": [
                "./src/libs"
            ],
            "python.analysis.exclude": [
                "./src/libs"
            ]
        }

        ```
- Via `SnippetsClient` API create custom snippets programmaically
- Via `WorkflowClient` API create custom alfred workflow
    - Craete `requirements.txt` file for your python project to let `alfred5` installs them if needed 🙃
    - To install `from requirements.txt` do all import packages inside `main`
            - Use `global` keyword to access imported packages globally
        - `client.query` is the query string
        - `client.page_count` is the page count for pagination results
    - Dont need to add `alfred5` to `requirements.txt`
- Use `WorkflowClient.log` to log your message to alfred debugger 
    - [debugging alfred workflow](https://www.alfredapp.com/help/workflows/utilities/debug/)
    - [why this project use stderr for all logging operation](https://www.alfredforum.com/topic/14721-get-the-python-output-back-to-alfred/?do=findComment&comment=75303)
- Use `WorkflowClient(main, cache=True)` method to use caching system
    - Just do it for static (not timebased nor any dynamic stuff) response 
    - Db path is `db/results.yml` also you can see it from workflow debug panel

## ⭐️ Example Project

![alt](https://i.imgur.com/tUJjVUJ.png)

```python
from re import sub
from urllib.parse import quote_plus
import sys

sys.path.insert(0, "src/libs")

from alfred5 import WorkflowClient


async def main(client: WorkflowClient):
    # To auto install requirements all import operation must be in here
    global get
    from requests import get

    query = client.query
    client.log(f"my query: {query}")  # use it to see your log in workflow debug panel

    # (use cache=True) Use cache system to quick response instead of old style that below
    # if client.load_cached_response():
    #     return

    char_count = str(len( query))
    word_count = str(len(query.split(" ")))
    line_count = str(len(query.split("\n")))

    encoded_string = quote_plus(query)
    remove_dublication = " ".join(dict.fromkeys(query.split(" ")))

    upper_case = query.upper()
    lower_case = query.lower()
    capitalized = query.capitalize()
    template = sub(r"[a-zA-Z0-9]", "X", query)

    client.add_result(encoded_string, "Encoded", arg=encoded_string)
    client.add_result(remove_dublication, "Remove dublication", arg=remove_dublication)
    client.add_result(upper_case, "Upper Case", arg=upper_case)
    client.add_result(lower_case, "Lower Case", arg=lower_case)
    client.add_result(capitalized, "Capitalized", arg=capitalized)
    client.add_result(template, "Template", arg=template)
    client.add_result(char_count, "Characters", arg=char_count)
    client.add_result(word_count, "Words", arg=word_count)
    client.add_result(line_count, "Lines", arg=line_count)
    
    # (use cache=True) to cache result for query instead of old style that below
    #     if u work with static results (not dynamic; coin price etc.)
    # client.cache_response()  

if __name__ == "__main__":
    WorkflowClient.run(main)  # WorkflowClient.run(main, cache=True)

```


## 🔰 How to Create Workflow

![insturaction1](https://i.imgur.com/2oDMChr.png)
![insturaction2](https://i.imgur.com/IMVWNDm.png)
![insturaction3](https://i.imgur.com/WicJKBN.png)
![insturaction4](https://i.imgur.com/AwPNT8Y.png)


## 🪪 License

```
Copyright 2023 Yunus Emre Ak ~ YEmreAk.com

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/yedhrab/alfred5",
    "name": "alfred5",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9.6",
    "maintainer_email": "",
    "keywords": "alfred,alfred5,workflow,snippets,alfred-workflows,alfred-snippets",
    "author": "Yunus Emre Ak",
    "author_email": "yemreak.com@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a1/24/749a20e80d13183d2de68dbbdb3edded900addc81abebcb3c7d7edcf8b13/alfred5-1.1.6.tar.gz",
    "platform": null,
    "description": "#  \ud83c\udfa9 AlfredClient\n\nSimplest Alfred Client that I use my own projects.\n\n## Usage\n\n```bash\npip install alfred5\n```\n- Projects dir structure\n    - Put your codes and `requirements.txt` to `src` folders\n    - Install `alfred5` via \n        ```bash\n        pip install alfred5 --target=src/libs\n        ```\n    - Add the top of the `main.py`\n        ```python\n            import sys\n\n            sys.path.insert(0, \"src/libs\")\n        ```\n        - ![main](https://i.imgur.com/O6rYLQA.png)\n    - If u want to use different `--target` for ex `.` use `WorkflowClient.run(packagedir=\".\")`\n    - Sample of default structure: \n        - ![structure](https://i.imgur.com/doLWDR4.png)\n    - **If u install all of requirements, dont need to create `requirements.txt` file in `src`**\n    - _If you use `vscode`, add the code that below to `.vscode/settings.json` to debug your file_\n        - ![vscode](https://i.imgur.com/QeseMTr.png)\n        ```json\n        {\n            \"python.analysis.extraPaths\": [\n                \"./src/libs\"\n            ],\n            \"python.analysis.exclude\": [\n                \"./src/libs\"\n            ]\n        }\n\n        ```\n- Via `SnippetsClient` API create custom snippets programmaically\n- Via `WorkflowClient` API create custom alfred workflow\n    - Craete `requirements.txt` file for your python project to let `alfred5` installs them if needed \ud83d\ude43\n    - To install `from requirements.txt` do all import packages inside `main`\n            - Use `global` keyword to access imported packages globally\n        - `client.query` is the query string\n        - `client.page_count` is the page count for pagination results\n    - Dont need to add `alfred5` to `requirements.txt`\n- Use `WorkflowClient.log` to log your message to alfred debugger \n    - [debugging alfred workflow](https://www.alfredapp.com/help/workflows/utilities/debug/)\n    - [why this project use stderr for all logging operation](https://www.alfredforum.com/topic/14721-get-the-python-output-back-to-alfred/?do=findComment&comment=75303)\n- Use `WorkflowClient(main, cache=True)` method to use caching system\n    - Just do it for static (not timebased nor any dynamic stuff) response \n    - Db path is `db/results.yml` also you can see it from workflow debug panel\n\n## \u2b50\ufe0f Example Project\n\n![alt](https://i.imgur.com/tUJjVUJ.png)\n\n```python\nfrom re import sub\nfrom urllib.parse import quote_plus\nimport sys\n\nsys.path.insert(0, \"src/libs\")\n\nfrom alfred5 import WorkflowClient\n\n\nasync def main(client: WorkflowClient):\n    # To auto install requirements all import operation must be in here\n    global get\n    from requests import get\n\n    query = client.query\n    client.log(f\"my query: {query}\")  # use it to see your log in workflow debug panel\n\n    # (use cache=True) Use cache system to quick response instead of old style that below\n    # if client.load_cached_response():\n    #     return\n\n    char_count = str(len( query))\n    word_count = str(len(query.split(\" \")))\n    line_count = str(len(query.split(\"\\n\")))\n\n    encoded_string = quote_plus(query)\n    remove_dublication = \" \".join(dict.fromkeys(query.split(\" \")))\n\n    upper_case = query.upper()\n    lower_case = query.lower()\n    capitalized = query.capitalize()\n    template = sub(r\"[a-zA-Z0-9]\", \"X\", query)\n\n    client.add_result(encoded_string, \"Encoded\", arg=encoded_string)\n    client.add_result(remove_dublication, \"Remove dublication\", arg=remove_dublication)\n    client.add_result(upper_case, \"Upper Case\", arg=upper_case)\n    client.add_result(lower_case, \"Lower Case\", arg=lower_case)\n    client.add_result(capitalized, \"Capitalized\", arg=capitalized)\n    client.add_result(template, \"Template\", arg=template)\n    client.add_result(char_count, \"Characters\", arg=char_count)\n    client.add_result(word_count, \"Words\", arg=word_count)\n    client.add_result(line_count, \"Lines\", arg=line_count)\n    \n    #\u00a0(use cache=True) to cache result for query instead of old style that below\n    #     if u work with static results (not dynamic; coin price etc.)\n    # client.cache_response()  \n\nif __name__ == \"__main__\":\n    WorkflowClient.run(main)  # WorkflowClient.run(main, cache=True)\n\n```\n\n\n## \ud83d\udd30 How to Create Workflow\n\n![insturaction1](https://i.imgur.com/2oDMChr.png)\n![insturaction2](https://i.imgur.com/IMVWNDm.png)\n![insturaction3](https://i.imgur.com/WicJKBN.png)\n![insturaction4](https://i.imgur.com/AwPNT8Y.png)\n\n\n## \ud83e\udeaa License\n\n```\nCopyright 2023 Yunus Emre Ak ~\u00a0YEmreAk.com\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": "Simple python wrapper for alfred5 workflow / snippets",
    "version": "1.1.6",
    "project_urls": {
        "Changelog": "https://github.com/yedhrab/alfred5/releases",
        "Homepage": "https://github.com/yedhrab/alfred5",
        "Issue Tracker": "https://github.com/yedhrab/alfred5/issues",
        "Source": "https://github.com/yedhrab/alfred5/"
    },
    "split_keywords": [
        "alfred",
        "alfred5",
        "workflow",
        "snippets",
        "alfred-workflows",
        "alfred-snippets"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4645e799e1a75dcee70dbfd98f3a1e50db6bc48c5def5d74dd7a1a61fe54579d",
                "md5": "2c25a3d8a9ba61da6f60be790543b566",
                "sha256": "e95dd9ada5fcf68f96356ba49cc845b2500f9686b36ebbfcd12cbdaae02e829f"
            },
            "downloads": -1,
            "filename": "alfred5-1.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2c25a3d8a9ba61da6f60be790543b566",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9.6",
            "size": 62221,
            "upload_time": "2023-07-10T23:52:53",
            "upload_time_iso_8601": "2023-07-10T23:52:53.712997Z",
            "url": "https://files.pythonhosted.org/packages/46/45/e799e1a75dcee70dbfd98f3a1e50db6bc48c5def5d74dd7a1a61fe54579d/alfred5-1.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a124749a20e80d13183d2de68dbbdb3edded900addc81abebcb3c7d7edcf8b13",
                "md5": "50c629a397a4ca3b7dfa556281fe0138",
                "sha256": "33849f1306a84cdd2aec486f250a03be5914fa11bfd0ec3bb5cb0cf94c750b62"
            },
            "downloads": -1,
            "filename": "alfred5-1.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "50c629a397a4ca3b7dfa556281fe0138",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9.6",
            "size": 64056,
            "upload_time": "2023-07-10T23:52:55",
            "upload_time_iso_8601": "2023-07-10T23:52:55.143563Z",
            "url": "https://files.pythonhosted.org/packages/a1/24/749a20e80d13183d2de68dbbdb3edded900addc81abebcb3c7d7edcf8b13/alfred5-1.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-10 23:52:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yedhrab",
    "github_project": "alfred5",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "alfred5"
}
        
Elapsed time: 0.09494s