Skip to content

Commit

Permalink
Merge pull request #25 from deefrawley/handlezero
Browse files Browse the repository at this point in the history
Warning for zero amount. Fixes #24
  • Loading branch information
deefrawley authored Mar 13, 2023
2 parents 01da83f + 070f8e4 commit dd0eee5
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 38 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": "Currency Converter",
"Description": "Currency converter using the euro and rates at https://www.ecb.europa.eu/",
"Author": "deefrawley",
"Version": "2.0.5",
"Version": "2.0.6",
"Language": "python",
"Website": "https://github.com/deefrawley/Flow.Launcher.Plugin.Currency",
"IcoPath": "assets/favicon.ico",
Expand Down
6 changes: 5 additions & 1 deletion plugin/currency_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ def populate_rates(self, xml):
return rates

def getrates_xml(self, max_age):

xmlfile = "eurofxref-daily.xml"
exists = os.path.isfile(xmlfile)
getnewfile = True
Expand Down Expand Up @@ -214,6 +213,7 @@ def getrates_xml(self, max_age):
return 200

def currconv(self, rates, sourcecurr, destcurr, amount):
# converted list - if error return error message, if not error return date and converted amount
converted = []
# Check source currency is in the rates dict -catch odd errors like the bank suspending some rates
if (not sourcecurr.upper() in rates and sourcecurr.upper() != "EUR") or (
Expand All @@ -226,6 +226,10 @@ def currconv(self, rates, sourcecurr, destcurr, amount):
_("Error - expected source or destination currency not in rates file")
)
return converted
# Check for zero amount, warn and don't convert
if decimal.Decimal(amount) == 0:
converted.append(_("Warning - amount entered must be greater than zero"))
return converted

# sourcerate = 1
destrate = 1
Expand Down
Binary file modified plugin/translations/en/LC_MESSAGES/messages.mo
Binary file not shown.
40 changes: 22 additions & 18 deletions plugin/translations/en/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#
msgid ""
msgstr ""
"Project-Id-Version: 2.0.0\n"
"Project-Id-Version: 2.0.6\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2022-04-22 18:59+1000\n"
"POT-Creation-Date: 2023-03-13 11:31+1100\n"
"PO-Revision-Date: 2020-12-13 20:26+1100\n"
"Last-Translator: CitizenDee <[email protected]>\n"
"Language: en\n"
Expand All @@ -18,73 +18,77 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.9.1\n"

#: plugin/currency_converter.py:68
#: plugin/currency_converter.py:64
msgid "<Amount> <Source currency code> <Destination currency code>"
msgstr "<Amount> <Source currency code> <Destination currency code>"

#: plugin/currency_converter.py:69
#: plugin/currency_converter.py:65
msgid ""
"There will be a short delay if the currency rates file needs to be "
"downloaded"
msgstr ""
"There will be a short delay if the currency rates file needs to be "
"downloaded"

#: plugin/currency_converter.py:78
#: plugin/currency_converter.py:74
msgid "Source currency"
msgstr "Source currency"

#: plugin/currency_converter.py:85
#: plugin/currency_converter.py:81
msgid "Destination currency"
msgstr "Destination currency"

#: plugin/currency_converter.py:91
#: plugin/currency_converter.py:87
msgid "Please enter three character currency codes"
msgstr "Please enter three character currency codes"

#: plugin/currency_converter.py:96
#: plugin/currency_converter.py:92
#, fuzzy
msgid "Error - source is not a valid currency"
msgstr "Error - source is not a valid currency"

#: plugin/currency_converter.py:101
#: plugin/currency_converter.py:97
#, fuzzy
msgid "Error - destination is not a valid currency"
msgstr "Error - destination not a valid currency"

#: plugin/currency_converter.py:108
#: plugin/currency_converter.py:104
msgid "Error - amount must be numeric"
msgstr "Error - amount must be numeric"

#: plugin/currency_converter.py:152
#: plugin/currency_converter.py:148
msgid "Rates date : {}"
msgstr "Rates date : {}"

#: plugin/currency_converter.py:156
#: plugin/currency_converter.py:152
msgid "Couldn't download the rates file"
msgstr "Couldn't download the rates file"

#: plugin/currency_converter.py:157
#: plugin/currency_converter.py:153
msgid "{} - check log for more details"
msgstr "{} - check log for more details"

#: plugin/currency_converter.py:210
#: plugin/currency_converter.py:205
msgid "HTTP Error"
msgstr "HTTP Error"

#: plugin/currency_converter.py:213
#: plugin/currency_converter.py:208
msgid "Connection Error"
msgstr "Connection Error"

#: plugin/currency_converter.py:216
#: plugin/currency_converter.py:211
msgid "Unspecifed Download Error"
msgstr "Unspecifed Download Error"

#: plugin/currency_converter.py:228
#: plugin/currency_converter.py:226
msgid "Error - expected source or destination currency not in rates file"
msgstr "Error - expected source or destination currency not in rates file"

#: plugin/currency_converter.py:266
#: plugin/currency_converter.py:231
msgid "Warning - amount entered must be greater than zero"
msgstr "Warning - amount entered must be greater than zero"

#: plugin/currency_converter.py:268
msgid "No matches found"
msgstr "No matches found"

Binary file modified plugin/translations/zh/LC_MESSAGES/messages.mo
Binary file not shown.
40 changes: 22 additions & 18 deletions plugin/translations/zh/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#
msgid ""
msgstr ""
"Project-Id-Version: 2.0.0\n"
"Project-Id-Version: 2.0.6\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2022-04-22 18:59+1000\n"
"POT-Creation-Date: 2023-03-13 11:31+1100\n"
"PO-Revision-Date: 2020-12-13 20:56+1100\n"
"Last-Translator: CitizenDee <[email protected]>\n"
"Language: zh\n"
Expand All @@ -18,72 +18,76 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.9.1\n"

#: plugin/currency_converter.py:68
#: plugin/currency_converter.py:64
#, fuzzy
msgid "<Amount> <Source currency code> <Destination currency code>"
msgstr "<热键> <量> <来源货币> <目标货币>"

#: plugin/currency_converter.py:69
#: plugin/currency_converter.py:65
msgid ""
"There will be a short delay if the currency rates file needs to be "
"downloaded"
msgstr "如果需要下载汇率文件,会有短暂的延迟"

#: plugin/currency_converter.py:78
#: plugin/currency_converter.py:74
msgid "Source currency"
msgstr "来源货币"

#: plugin/currency_converter.py:85
#: plugin/currency_converter.py:81
msgid "Destination currency"
msgstr "目的地货币"

#: plugin/currency_converter.py:91
#: plugin/currency_converter.py:87
msgid "Please enter three character currency codes"
msgstr "输入三个字符的货币代码"

#: plugin/currency_converter.py:96
#: plugin/currency_converter.py:92
#, fuzzy
msgid "Error - source is not a valid currency"
msgstr "错误 - 来源货币不是有效货币"

#: plugin/currency_converter.py:101
#: plugin/currency_converter.py:97
#, fuzzy
msgid "Error - destination is not a valid currency"
msgstr "错误 - 目的地货币不是有效货币"

#: plugin/currency_converter.py:108
#: plugin/currency_converter.py:104
msgid "Error - amount must be numeric"
msgstr "错误 - 金额必须是数字"

#: plugin/currency_converter.py:152
#: plugin/currency_converter.py:148
msgid "Rates date : {}"
msgstr "汇率日期 : {}"

#: plugin/currency_converter.py:156
#: plugin/currency_converter.py:152
msgid "Couldn't download the rates file"
msgstr "无法下载汇率文件"

#: plugin/currency_converter.py:157
#: plugin/currency_converter.py:153
msgid "{} - check log for more details"
msgstr "{} - 查看日志以获取更多详细信息"

#: plugin/currency_converter.py:210
#: plugin/currency_converter.py:205
msgid "HTTP Error"
msgstr "HTTP 错误"

#: plugin/currency_converter.py:213
#: plugin/currency_converter.py:208
msgid "Connection Error"
msgstr "连接错误"

#: plugin/currency_converter.py:216
#: plugin/currency_converter.py:211
msgid "Unspecifed Download Error"
msgstr "未指定的下载错误"

#: plugin/currency_converter.py:228
#: plugin/currency_converter.py:226
msgid "Error - expected source or destination currency not in rates file"
msgstr "错误 - 汇率文件中没有预期的来源或目标货币"

#: plugin/currency_converter.py:266
#: plugin/currency_converter.py:231
msgid "Warning - amount entered must be greater than zero"
msgstr "警告 - 输入的金额必须大于零"

#: plugin/currency_converter.py:268
msgid "No matches found"
msgstr "未找到匹配项"

0 comments on commit dd0eee5

Please sign in to comment.