Skip to content

Commit 93ce8b4

Browse files
authored
Merge pull request #13 from deefrawley/gramupdate
Update gram unit to g and fix logic to add multi category hints. Fix #13
2 parents 2c8a3da + 1c7a075 commit 93ce8b4

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
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": "1.1.2",
7+
"Version": "1.1.3",
88
"Language": "python",
99
"Website": "https://github.com/deefrawley/Flow.Launcher.Plugin.GenConvert",
1010
"IcoPath": "assets/favicon.ico",

plugin/units.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
# Base
3737
["ml", _("millilitre"), _("millilitres"), "x * 1", "x * 1"],
3838
# All below convert to/from base
39-
["gm", _("gram"), _("grams"), "x * 1", "x * 1"],
39+
["g", _("gram"), _("grams"), "x * 1", "x * 1"],
4040
["l", _("litre"), _("litres"), "x / 0.001", "x * 0.001"],
4141
["pt", _("pint US"), _("pints US"), "x / 0.002113383", "x * 0.002113383"],
4242
[
@@ -157,7 +157,7 @@
157157
],
158158
"Weight": [
159159
# Base
160-
["gm", _("gram"), _("grams"), "x * 1", "x * 1"],
160+
["g", _("gram"), _("grams"), "x * 1", "x * 1"],
161161
# All below convert to/from base
162162
["kg", _("kilogram"), _("kilograms"), "x / 0.001", "x * 0.001"],
163163
["lb", _("pound"), _("pounds"), "x / 0.002205", "x * 0.002205"],

plugin/utils.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@ def get_hints_for_category(from_unit: str):
2020
for u2 in gc_units.units[u]:
2121
if u2[0] == from_unit:
2222
category = str(u)
23+
for uu in gc_units.units[category]:
24+
if uu[0] != from_unit:
25+
c.append(uu[0])
2326
if category:
24-
# Go back and iterate over the category again and get all the units that are not the from unit
25-
for uu in gc_units.units[category]:
26-
if uu[0] != from_unit:
27-
c.append(uu[0])
28-
if not c:
29-
return ["no valid units"]
3027
return c
3128
else:
3229
return ["no valid units"]

0 commit comments

Comments
 (0)