aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2021-09-09 10:04:33 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2021-09-09 10:04:33 +0200
commit42ec3e2afc1be06022ea4c1641ce4010f2531fc8 (patch)
tree93d505f47552abfa42f3475d651ea65d286ee661
parent0abab7461ce76248a176ae5996e436224a4fcc02 (diff)
downloadgeldschieberbot-42ec3e2afc1be06022ea4c1641ce4010f2531fc8.tar.gz
geldschieberbot-42ec3e2afc1be06022ea4c1641ce4010f2531fc8.zip
make format
-rw-r--r--geldschieberbot.py7
-rw-r--r--tanken.py13
-rwxr-xr-xtest.py5
3 files changed, 17 insertions, 8 deletions
diff --git a/geldschieberbot.py b/geldschieberbot.py
index 3ad9960..93766fe 100644
--- a/geldschieberbot.py
+++ b/geldschieberbot.py
@@ -269,6 +269,7 @@ def summary(sender, args, msg): # pylint: disable=unused-argument
cmds["sum"] = summary
cmds["summary"] = summary
+
def full_summary(sender, args, msg): # pylint: disable=unused-argument
if len(args) == 1:
return create_total_summary(), None
@@ -516,7 +517,7 @@ def cars(sender, args, msg):
del available_cars[car]
remove_from_balance(car)
return f'removed "{car}" from the available cars', None
-
+
# pay bill
if args[1] in ["pay"]:
if len(args) < 4:
@@ -584,7 +585,7 @@ def cars(sender, args, msg):
changes[sender_name].append(change)
return output, None
-
+
return None, f'unknown car subcommand "{args[1]}".'
@@ -847,6 +848,7 @@ def cancel(sender, args, msg):
cmds["cancel"] = cancel
+
def thanks(sender, args, msg):
sender_name = num2name.get(sender, sender)
msg = f'You are welcome. It is a pleasure to work with you, {sender_name}.'
@@ -856,6 +858,7 @@ def thanks(sender, args, msg):
return msg, None
+
cmds["thanks"] = thanks
diff --git a/tanken.py b/tanken.py
index b7064cd..19d65c7 100644
--- a/tanken.py
+++ b/tanken.py
@@ -1,5 +1,6 @@
#!/bin/env python3
+
# cost should be given in cents
def tanken(drives, cost, service_charge=0):
passengers = {}
@@ -19,17 +20,19 @@ def tanken(drives, cost, service_charge=0):
# collect distances per passenger
for p in d[1:]:
if p not in passengers:
- passengers[p] = {"distance": d[0],
- "cost": 0,
- "service_charge": 0}
+ passengers[p] = {
+ "distance": d[0],
+ "cost": 0,
+ "service_charge": 0
+ }
else:
passengers[p]["distance"] += d[0]
-
+
# calculate cost per kilometer
if distance <= 0:
return None, "Driven distance must be greater than 0!"
- c = cost/distance
+ c = cost / distance
for d in drives:
# calculate cost per drive split among passengers
diff --git a/test.py b/test.py
index 79098f2..d4e94cf 100755
--- a/test.py
+++ b/test.py
@@ -1120,6 +1120,7 @@ fiat:
\tBalance: -3.00"""
self.assertEqual(res.stdout, msg)
+
class TestThanks(unittest.TestCase):
def test_thanks(self):
res = run_bot(self, num[alice], "!thanks")
@@ -1131,7 +1132,9 @@ class TestThanks(unittest.TestCase):
res = run_bot(self, num[alice], "!thanks pussy")
self.assertEqual(
res.stdout,
- f"You are welcome. It is a pleasure to work with you, {alice}.\nBut don't call me pussy.")
+ f"You are welcome. It is a pleasure to work with you, {alice}.\nBut don't call me pussy."
+ )
+
if __name__ == '__main__':
unittest.main()