Skip to content

Commit

Permalink
Merge pull request #19 from deefrawley/verboseconvert
Browse files Browse the repository at this point in the history
Add verbose output (long form unit and abbreviation)
  • Loading branch information
deefrawley authored Apr 13, 2023
2 parents 4bb6443 + 604a14c commit 85950c7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Name": "General Converter",
"Description": "General weights and measures converter",
"Author": "deefrawley",
"Version": "2.0.0",
"Version": "2.0.1",
"Language": "python",
"Website": "https://github.com/deefrawley/Flow.Launcher.Plugin.GenConvert",
"IcoPath": "assets/favicon.ico",
Expand Down
17 changes: 12 additions & 5 deletions plugin/general_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,19 @@ def query(self, query):
subtitle=_("Check documentation for accepted units"),
)
else:
c = do_convert["converted"]
p = smart_precision(locale.localeconv()["decimal_point"], c, 3)
converted = do_convert["converted"]
category = do_convert["category"]
to_long = do_convert["toplural"]
to_abb = do_convert["toabbrev"]
from_long = do_convert["fromplural"]
from_abb = do_convert["fromabbrev"]
converted_precision = smart_precision(
locale.localeconv()["decimal_point"], converted, 3
)
self.add_item(
title=(do_convert["category"]),
title=(category),
subtitle=(
f"{locale.format_string('%.10g', float(args[0]), grouping=True)} {args[1]} = {locale.format_string(f'%.{p}f', c, grouping=True)} {args[2]}"
f"{locale.format_string('%.10g', float(args[0]), grouping=True)} {from_long} ({from_abb}) = {locale.format_string(f'%.{converted_precision}f', converted, grouping=True)} {to_long} ({to_abb})"
),
icon=f"assets/{do_convert['category']}.ico",
)
Expand All @@ -94,7 +101,7 @@ def query(self, query):
)


def get_all_units(short=False):
def get_all_units(short: bool = False):
"""Returns all available units as a list of lists by category
:param short: if True only unit abbreviations are returned, default is False
Expand Down

0 comments on commit 85950c7

Please sign in to comment.