Simple python wrapper for alfred workflow / snippets
Project description
🎩 AlfredClient
Simplest Alfred Client that I use my own projects.
pip install alfred5
- Via
SnippetsClient
API create custom snippets programmaically - Via
WorkflowClient
API create custom alfred workflow - Use
WorkflowClient.log
to log your message to alfred debugger - Use
client.load_cached_response
andclient.cache_response
method to use caching system- Just do it for static response (not timebased response)
- Db path is
db/results.yml
also you can see it from workflow debug panel
Example Db Format
⭐️ Example Project
from re import sub
from urllib.parse import quote_plus
from alfred5 import WorkflowClient
async def main(client: WorkflowClient):
query = client.query
client.log(f"my query: {query}") # use it to see your log in workflow debug panel
# Use cache system to quick response
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)
client.cache_response() # to cache result for query (if u work with static results (not dynamic; coin price etc.))
if __name__ == "__main__":
WorkflowClient.run(main)
🔰 How to Create Workflow
🪪 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
alfred5-1.0.9.tar.gz
(49.0 kB
view details)
Built Distribution
alfred5-1.0.9-py3-none-any.whl
(47.3 kB
view details)
File details
Details for the file alfred5-1.0.9.tar.gz
.
File metadata
- Download URL: alfred5-1.0.9.tar.gz
- Upload date:
- Size: 49.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b9893a7f103a44523330f8b400ba437fe37541bb6d69a53cd5bec1ef11d6660 |
|
MD5 | 59cb40f3085fab9dfb7df2653cbc41c7 |
|
BLAKE2b-256 | 737c1d7a7a589d3c5b5239329aa073d8d79001e72bdf1c3af513f1da1864d583 |
File details
Details for the file alfred5-1.0.9-py3-none-any.whl
.
File metadata
- Download URL: alfred5-1.0.9-py3-none-any.whl
- Upload date:
- Size: 47.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 003c2f28589f1a09438d3ca8c47e77a3708cffeaae01dd62e5924f0e03006cd0 |
|
MD5 | f0cfda37ff50fe6c0b8b22dd49a58728 |
|
BLAKE2b-256 | 59a8817fefd4cfa605916f031944d48d8d40284be66260b41ebd6c540cda24af |