Skip to content

Commit

Permalink
Merge pull request #13 from deefrawley/gramupdate
Browse files Browse the repository at this point in the history
Update gram unit to g and fix logic to add multi category hints. Fix #13
  • Loading branch information
deefrawley authored Nov 2, 2022
2 parents 2c8a3da + 1c7a075 commit 93ce8b4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 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": "1.1.2",
"Version": "1.1.3",
"Language": "python",
"Website": "https://github.com/deefrawley/Flow.Launcher.Plugin.GenConvert",
"IcoPath": "assets/favicon.ico",
Expand Down
4 changes: 2 additions & 2 deletions plugin/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# Base
["ml", _("millilitre"), _("millilitres"), "x * 1", "x * 1"],
# All below convert to/from base
["gm", _("gram"), _("grams"), "x * 1", "x * 1"],
["g", _("gram"), _("grams"), "x * 1", "x * 1"],
["l", _("litre"), _("litres"), "x / 0.001", "x * 0.001"],
["pt", _("pint US"), _("pints US"), "x / 0.002113383", "x * 0.002113383"],
[
Expand Down Expand Up @@ -157,7 +157,7 @@
],
"Weight": [
# Base
["gm", _("gram"), _("grams"), "x * 1", "x * 1"],
["g", _("gram"), _("grams"), "x * 1", "x * 1"],
# All below convert to/from base
["kg", _("kilogram"), _("kilograms"), "x / 0.001", "x * 0.001"],
["lb", _("pound"), _("pounds"), "x / 0.002205", "x * 0.002205"],
Expand Down
9 changes: 3 additions & 6 deletions plugin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@ def get_hints_for_category(from_unit: str):
for u2 in gc_units.units[u]:
if u2[0] == from_unit:
category = str(u)
for uu in gc_units.units[category]:
if uu[0] != from_unit:
c.append(uu[0])
if category:
# Go back and iterate over the category again and get all the units that are not the from unit
for uu in gc_units.units[category]:
if uu[0] != from_unit:
c.append(uu[0])
if not c:
return ["no valid units"]
return c
else:
return ["no valid units"]
Expand Down

0 comments on commit 93ce8b4

Please sign in to comment.