Skip to content

Commit 85950c7

Browse files
authored
Merge pull request #19 from deefrawley/verboseconvert
Add verbose output (long form unit and abbreviation)
2 parents 4bb6443 + 604a14c commit 85950c7

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Name": "General Converter",
55
"Description": "General weights and measures converter",
66
"Author": "deefrawley",
7-
"Version": "2.0.0",
7+
"Version": "2.0.1",
88
"Language": "python",
99
"Website": "https://github.com/deefrawley/Flow.Launcher.Plugin.GenConvert",
1010
"IcoPath": "assets/favicon.ico",

plugin/general_converter.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,19 @@ def query(self, query):
7474
subtitle=_("Check documentation for accepted units"),
7575
)
7676
else:
77-
c = do_convert["converted"]
78-
p = smart_precision(locale.localeconv()["decimal_point"], c, 3)
77+
converted = do_convert["converted"]
78+
category = do_convert["category"]
79+
to_long = do_convert["toplural"]
80+
to_abb = do_convert["toabbrev"]
81+
from_long = do_convert["fromplural"]
82+
from_abb = do_convert["fromabbrev"]
83+
converted_precision = smart_precision(
84+
locale.localeconv()["decimal_point"], converted, 3
85+
)
7986
self.add_item(
80-
title=(do_convert["category"]),
87+
title=(category),
8188
subtitle=(
82-
f"{locale.format_string('%.10g', float(args[0]), grouping=True)} {args[1]} = {locale.format_string(f'%.{p}f', c, grouping=True)} {args[2]}"
89+
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})"
8390
),
8491
icon=f"assets/{do_convert['category']}.ico",
8592
)
@@ -94,7 +101,7 @@ def query(self, query):
94101
)
95102

96103

97-
def get_all_units(short=False):
104+
def get_all_units(short: bool = False):
98105
"""Returns all available units as a list of lists by category
99106
100107
:param short: if True only unit abbreviations are returned, default is False

0 commit comments

Comments
 (0)