Skip to content

Commit f9daa14

Browse files
committed
Show amount in notification
1 parent dd3f73e commit f9daa14

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

forex_python/__main__.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ def symbol(currency_code):
3737
return currency_code
3838

3939

40-
def conversion_result(amount, base, converted_amount, dest, use_symbols=False):
40+
def conversion_result(args, use_symbols=False):
41+
amount = args.amount
42+
base = args.base
43+
dest = args.dest
44+
converted_amount = converter.convert(args.base, args.dest, args.amount)
4145
if use_symbols:
4246
return "{} {} = {} {}".format(
4347
symbol(base), amount, symbol(dest), converted_amount
@@ -54,10 +58,7 @@ def notify_posix(args):
5458
print("Requires Linux or macOS with notify2 and dbus package.")
5559
raise
5660
notify2.init("forex-python")
57-
notification = conversion_result(
58-
1.0, args.base, converter.get_rate(args.base, args.dest), args.dest,
59-
True
60-
)
61+
notification = conversion_result(args, True)
6162
n = notify2.Notification(
6263
"forex-python", notification, "notification-message-im" # Icon name
6364
)
@@ -73,12 +74,4 @@ def run(args=None, output=sys.stdout):
7374
raise ValueError(
7475
"The option [-n] is available only for POSIX operating systems")
7576
else:
76-
print(
77-
conversion_result(
78-
args.amount,
79-
args.base,
80-
converter.convert(args.base, args.dest, args.amount),
81-
args.dest,
82-
),
83-
file=output
84-
)
77+
print(conversion_result(args), file=output)

0 commit comments

Comments
 (0)