Commit e276dcd5 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Merge branch 'config-ids'

parents 9d15ef05 b769f4cd
...@@ -48,7 +48,7 @@ class ListCommandTest(CommandTest): ...@@ -48,7 +48,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|4| (C) Drink beer @ home\n|5| (C) 13 + 29 = 42\n|2| (D) Bar @Context1 +Project2\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list03(self): def test_list03(self):
...@@ -57,7 +57,7 @@ class ListCommandTest(CommandTest): ...@@ -57,7 +57,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.output, "|2| (D) Bar @Context1 +Project2\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list04(self): def test_list04(self):
...@@ -66,7 +66,7 @@ class ListCommandTest(CommandTest): ...@@ -66,7 +66,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 3| (C) Baz @Context1 +Project1 key:value\n| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.output, "|3| (C) Baz @Context1 +Project1 key:value\n|2| (D) Bar @Context1 +Project2\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list05(self): def test_list05(self):
...@@ -74,7 +74,7 @@ class ListCommandTest(CommandTest): ...@@ -74,7 +74,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 3| (C) Baz @Context1 +Project1 key:value\n| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2\n| 7| hidden item h:1\n| 6| x 2014-12-12 Completed but with date:2014-12-12\n") self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|3| (C) Baz @Context1 +Project1 key:value\n|4| (C) Drink beer @ home\n|5| (C) 13 + 29 = 42\n|2| (D) Bar @Context1 +Project2\n|7| hidden item h:1\n|6| x 2014-12-12 Completed but with date:2014-12-12\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list06(self): def test_list06(self):
...@@ -92,7 +92,7 @@ class ListCommandTest(CommandTest): ...@@ -92,7 +92,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 3| (C) Baz @Context1 +Project1 key:value\n| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n") self.assertEqual(self.output, "|3| (C) Baz @Context1 +Project1 key:value\n|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list08(self): def test_list08(self):
...@@ -101,7 +101,7 @@ class ListCommandTest(CommandTest): ...@@ -101,7 +101,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.output, "|4| (C) Drink beer @ home\n|5| (C) 13 + 29 = 42\n|2| (D) Bar @Context1 +Project2\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list09(self): def test_list09(self):
...@@ -110,7 +110,7 @@ class ListCommandTest(CommandTest): ...@@ -110,7 +110,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.output, "|5| (C) 13 + 29 = 42\n|2| (D) Bar @Context1 +Project2\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list10(self): def test_list10(self):
...@@ -119,7 +119,7 @@ class ListCommandTest(CommandTest): ...@@ -119,7 +119,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.output, "|2| (D) Bar @Context1 +Project2\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list11(self): def test_list11(self):
...@@ -129,7 +129,7 @@ class ListCommandTest(CommandTest): ...@@ -129,7 +129,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n") self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list12(self): def test_list12(self):
...@@ -140,7 +140,7 @@ class ListCommandTest(CommandTest): ...@@ -140,7 +140,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 3| (C) Baz @Context1 +Project1 key:value\n| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|3| (C) Baz @Context1 +Project1 key:value\n|2| (D) Bar @Context1 +Project2\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list13(self): def test_list13(self):
...@@ -149,7 +149,7 @@ class ListCommandTest(CommandTest): ...@@ -149,7 +149,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 3| (C) Baz @Context1 +Project1 key:value\n| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 7| hidden item h:1\n| 6| x 2014-12-12 Completed but with date:2014-12-12\n") self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|3| (C) Baz @Context1 +Project1 key:value\n|4| (C) Drink beer @ home\n|5| (C) 13 + 29 = 42\n|7| hidden item h:1\n|6| x 2014-12-12 Completed but with date:2014-12-12\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list14(self): def test_list14(self):
...@@ -159,7 +159,7 @@ class ListCommandTest(CommandTest): ...@@ -159,7 +159,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, " | 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n | 4| (C) Drink beer @ home\n | 5| (C) 13 + 29 = 42\n | 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.output, " |1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n |4| (C) Drink beer @ home\n |5| (C) 13 + 29 = 42\n |2| (D) Bar @Context1 +Project2\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list15(self): def test_list15(self):
...@@ -167,7 +167,7 @@ class ListCommandTest(CommandTest): ...@@ -167,7 +167,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.output, "|2| (D) Bar @Context1 +Project2\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list16(self): def test_list16(self):
...@@ -187,7 +187,7 @@ class ListCommandTest(CommandTest): ...@@ -187,7 +187,7 @@ class ListCommandTest(CommandTest):
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, self.assertEqual(self.output,
"| 3| (C) Baz @Context1 +Project1 key:value\n") "|3| (C) Baz @Context1 +Project1 key:value\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list18(self): def test_list18(self):
...@@ -196,7 +196,7 @@ class ListCommandTest(CommandTest): ...@@ -196,7 +196,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 6| x 2014-12-12 Completed but with date:2014-12-12\n") self.assertEqual(self.output, "|6| x 2014-12-12 Completed but with date:2014-12-12\n")
def test_list19(self): def test_list19(self):
""" Force showing all tags. """ """ Force showing all tags. """
...@@ -207,7 +207,7 @@ class ListCommandTest(CommandTest): ...@@ -207,7 +207,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 3| (C) Baz @Context1 +Project1 id:1 key:value\n| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n") self.assertEqual(self.output, "|3| (C) Baz @Context1 +Project1 id:1 key:value\n|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list20(self): def test_list20(self):
...@@ -215,7 +215,7 @@ class ListCommandTest(CommandTest): ...@@ -215,7 +215,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|4| (C) Drink beer @ home\n|5| (C) 13 + 29 = 42\n|2| (D) Bar @Context1 +Project2\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list21(self): def test_list21(self):
...@@ -224,7 +224,7 @@ class ListCommandTest(CommandTest): ...@@ -224,7 +224,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|4| (C) Drink beer @ home\n|5| (C) 13 + 29 = 42\n|2| (D) Bar @Context1 +Project2\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list22(self): def test_list22(self):
...@@ -236,7 +236,7 @@ class ListCommandTest(CommandTest): ...@@ -236,7 +236,7 @@ class ListCommandTest(CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, '| 1| Foo.\n') self.assertEqual(self.output, '|1| Foo.\n')
def test_list31(self): def test_list31(self):
""" Don't show any todos with -n 0 """ """ Don't show any todos with -n 0 """
...@@ -251,7 +251,7 @@ class ListCommandTest(CommandTest): ...@@ -251,7 +251,7 @@ class ListCommandTest(CommandTest):
command = ListCommand(["-n", "1"], self.todolist, self.out, self.error) command = ListCommand(["-n", "1"], self.todolist, self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n") self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list33(self): def test_list33(self):
...@@ -259,7 +259,7 @@ class ListCommandTest(CommandTest): ...@@ -259,7 +259,7 @@ class ListCommandTest(CommandTest):
command = ListCommand(["-n", "-1"], self.todolist, self.out, self.error) command = ListCommand(["-n", "-1"], self.todolist, self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|4| (C) Drink beer @ home\n|5| (C) 13 + 29 = 42\n|2| (D) Bar @Context1 +Project2\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list34(self): def test_list34(self):
...@@ -269,7 +269,7 @@ class ListCommandTest(CommandTest): ...@@ -269,7 +269,7 @@ class ListCommandTest(CommandTest):
command = ListCommand(["-n", "foo"], self.todolist, self.out, self.error) command = ListCommand(["-n", "foo"], self.todolist, self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 4| (C) Drink beer @ home\n") self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|4| (C) Drink beer @ home\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list35(self): def test_list35(self):
...@@ -277,21 +277,21 @@ class ListCommandTest(CommandTest): ...@@ -277,21 +277,21 @@ class ListCommandTest(CommandTest):
command = ListCommand(["-x", "-n", "foo"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-n", "foo"], self.todolist, self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 3| (C) Baz @Context1 +Project1 key:value\n| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2\n| 7| hidden item h:1\n| 6| x 2014-12-12 Completed but with date:2014-12-12\n") self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|3| (C) Baz @Context1 +Project1 key:value\n|4| (C) Drink beer @ home\n|5| (C) 13 + 29 = 42\n|2| (D) Bar @Context1 +Project2\n|7| hidden item h:1\n|6| x 2014-12-12 Completed but with date:2014-12-12\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list36(self): def test_list36(self):
command = ListCommand(["-i", "1"], self.todolist, self.out, self.error) command = ListCommand(["-i", "1"], self.todolist, self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n") self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list37(self): def test_list37(self):
command = ListCommand(["-i", "1,foo,3"], self.todolist, self.out, self.error) command = ListCommand(["-i", "1,foo,3"], self.todolist, self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 3| (C) Baz @Context1 +Project1 key:value\n") self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|3| (C) Baz @Context1 +Project1 key:value\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list38(self): def test_list38(self):
...@@ -316,7 +316,7 @@ class ListCommandTest(CommandTest): ...@@ -316,7 +316,7 @@ class ListCommandTest(CommandTest):
command = ListCommand(["(<C)"], self.todolist, self.out, self.error) command = ListCommand(["(<C)"], self.todolist, self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output, "| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.output, "|2| (D) Bar @Context1 +Project2\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list41(self): def test_list41(self):
...@@ -331,7 +331,7 @@ class ListCommandTest(CommandTest): ...@@ -331,7 +331,7 @@ class ListCommandTest(CommandTest):
self.out, self.error) self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n") self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
@mock.patch('topydo.commands.ListCommand.get_terminal_size') @mock.patch('topydo.commands.ListCommand.get_terminal_size')
...@@ -342,7 +342,7 @@ class ListCommandTest(CommandTest): ...@@ -342,7 +342,7 @@ class ListCommandTest(CommandTest):
command = ListCommand(["-N"], self.todolist, self.out, self.error) command = ListCommand(["-N"], self.todolist, self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|4| (C) Drink beer @ home\n|5| (C) 13 + 29 = 42\n|2| (D) Bar @Context1 +Project2\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
@mock.patch('topydo.commands.ListCommand.get_terminal_size') @mock.patch('topydo.commands.ListCommand.get_terminal_size')
...@@ -360,7 +360,7 @@ class ListCommandTest(CommandTest): ...@@ -360,7 +360,7 @@ class ListCommandTest(CommandTest):
command = ListCommand(["-N"], self.todolist, self.out, self.error) command = ListCommand(["-N"], self.todolist, self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output, "| 1| (A) item 1\n| 27| (A) item 27\n| 2| (B) item 2\n| 28| (B) item 28\n| 3| (C) item 3\n| 29| (C) item 29\n| 4| (D) item 4\n| 30| (D) item 30\n| 5| (E) item 5\n| 31| (E) item 31\n| 6| (F) item 6\n| 32| (F) item 32\n| 7| (G) item 7\n| 33| (G) item 33\n| 8| (H) item 8\n| 34| (H) item 34\n| 9| (I) item 9\n| 35| (I) item 35\n| 10| (J) item 10\n| 36| (J) item 36\n| 11| (K) item 11\n") self.assertEqual(self.output, "| 1| (A) item 1\n|27| (A) item 27\n| 2| (B) item 2\n|28| (B) item 28\n| 3| (C) item 3\n|29| (C) item 29\n| 4| (D) item 4\n|30| (D) item 30\n| 5| (E) item 5\n|31| (E) item 31\n| 6| (F) item 6\n|32| (F) item 32\n| 7| (G) item 7\n|33| (G) item 33\n| 8| (H) item 8\n|34| (H) item 34\n| 9| (I) item 9\n|35| (I) item 35\n|10| (J) item 10\n|36| (J) item 36\n|11| (K) item 11\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
@mock.patch('topydo.commands.ListCommand.get_terminal_size') @mock.patch('topydo.commands.ListCommand.get_terminal_size')
...@@ -378,7 +378,7 @@ class ListCommandTest(CommandTest): ...@@ -378,7 +378,7 @@ class ListCommandTest(CommandTest):
command = ListCommand(["-N"], self.todolist, self.out, self.error) command = ListCommand(["-N"], self.todolist, self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output, "| 1| (A) item 1\n| 27| (A) item 27\n| 2| (B) item 2\n| 28| (B) item 28\n| 3| (C) item 3\n| 29| (C) item 29\n| 4| (D) item 4\n") self.assertEqual(self.output, "| 1| (A) item 1\n|27| (A) item 27\n| 2| (B) item 2\n|28| (B) item 28\n| 3| (C) item 3\n|29| (C) item 29\n| 4| (D) item 4\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
@mock.patch('topydo.commands.ListCommand.get_terminal_size') @mock.patch('topydo.commands.ListCommand.get_terminal_size')
...@@ -392,7 +392,7 @@ class ListCommandTest(CommandTest): ...@@ -392,7 +392,7 @@ class ListCommandTest(CommandTest):
command = ListCommand(["-N"], self.todolist, self.out, self.error) command = ListCommand(["-N"], self.todolist, self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output, "| 1| (A) item 1\n") self.assertEqual(self.output, "| 1| (A) item 1\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
@mock.patch('topydo.commands.ListCommand.get_terminal_size') @mock.patch('topydo.commands.ListCommand.get_terminal_size')
...@@ -411,14 +411,14 @@ class ListCommandTest(CommandTest): ...@@ -411,14 +411,14 @@ class ListCommandTest(CommandTest):
command = ListCommand(["-N"], self.todolist, self.out, self.error) command = ListCommand(["-N"], self.todolist, self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output, "| 1| (A) item 1\n| 27| (A) item 27\n| 2| (B) item 2\n| 28| (B) item 28\n| 3| (C) item 3\n| 29| (C) item 29\n| 4| (D) item 4\n| 30| (D) item 30\n| 5| (E) item 5\n| 31| (E) item 31\n| 6| (F) item 6\n| 32| (F) item 32\n| 7| (G) item 7\n| 33| (G) item 33\n| 8| (H) item 8\n| 34| (H) item 34\n| 9| (I) item 9\n| 35| (I) item 35\n| 10| (J) item 10\n| 36| (J) item 36\n") self.assertEqual(self.output, "| 1| (A) item 1\n|27| (A) item 27\n| 2| (B) item 2\n|28| (B) item 28\n| 3| (C) item 3\n|29| (C) item 29\n| 4| (D) item 4\n|30| (D) item 30\n| 5| (E) item 5\n|31| (E) item 31\n| 6| (F) item 6\n|32| (F) item 32\n| 7| (G) item 7\n|33| (G) item 33\n| 8| (H) item 8\n|34| (H) item 34\n| 9| (I) item 9\n|35| (I) item 35\n|10| (J) item 10\n|36| (J) item 36\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list48(self): def test_list48(self):
command = ListCommand(["created:2015-11-05"], self.todolist, self.out, self.error) command = ListCommand(["created:2015-11-05"], self.todolist, self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n") self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n")
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list49(self): def test_list49(self):
...@@ -431,9 +431,51 @@ class ListCommandTest(CommandTest): ...@@ -431,9 +431,51 @@ class ListCommandTest(CommandTest):
command = ListCommand(["-n", "1"], todolist, self.out, self.error) command = ListCommand(["-n", "1"], todolist, self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output, '| 2| This item is visible\n') self.assertEqual(self.output, '|2| This item is visible\n')
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list50(self):
"""
Fallback to normal alphabet for too short alphabets, fallback on
default alphabet.
"""
config(p_overrides={('topydo', 'identifier_alphabet'): 'a', ('topydo', 'identifiers'): 'text'})
# self.todolist was loaded with old identifier settings
todolist = load_file_to_todolist("test/data/ListCommandTest.txt")
command = ListCommand(["-F", "%I", "Foo"], todolist, self.out, self.error)
command.execute()
self.assertEqual(self.output, "t5c\n")
self.assertEqual(self.errors, '')
def test_list51(self):
""" Test hexadecimal IDs """
config(p_overrides={('topydo', 'identifier_alphabet'): '0123456789abcdef', ('topydo', 'identifiers'): 'text'})
# self.todolist was loaded with old identifier settings
todolist = load_file_to_todolist("test/data/ListCommandTest.txt")
command = ListCommand(["-F", "%i", "Foo"], todolist, self.out, self.error)
command.execute()
self.assertEqual(self.output, '2c8\n')
self.assertEqual(self.errors, '')
def test_list52(self):
""" Alphabet is too short due to duplicate characters """
config(p_overrides={('topydo', 'identifier_alphabet'): '0123456788', ('topydo', 'identifiers'): 'text'})
# self.todolist was loaded with old identifier settings
todolist = load_file_to_todolist("test/data/ListCommandTest.txt")
command = ListCommand(["-F", "%i", "Foo"], todolist, self.out, self.error)
command.execute()
self.assertEqual(self.output, 't5c\n')
self.assertEqual(self.errors, '')
def test_list_name(self): def test_list_name(self):
name = ListCommand.name() name = ListCommand.name()
...@@ -461,7 +503,7 @@ class ListCommandUnicodeTest(CommandTest): ...@@ -461,7 +503,7 @@ class ListCommandUnicodeTest(CommandTest):
self.assertFalse(self.todolist.dirty) self.assertFalse(self.todolist.dirty)
expected = u"| 1| (C) And some sp\u00e9cial tag:\u25c4\n" expected = u"|1| (C) And some sp\u00e9cial tag:\u25c4\n"
self.assertEqual(self.output, expected) self.assertEqual(self.output, expected)
...@@ -584,17 +626,17 @@ class ListCommandGroupTest(CommandTest): ...@@ -584,17 +626,17 @@ class ListCommandGroupTest(CommandTest):
self.assertEqual(self.output, """\ self.assertEqual(self.output, """\
Project: A Project: A
========== ==========
| 1| +A only test:test_group1 | 1| +A only test:test_group1
| 3| +A and +B test:test_group1 | 3| +A and +B test:test_group1
Project: B Project: B
========== ==========
| 3| +A and +B test:test_group1 | 3| +A and +B test:test_group1
| 2| +B only test:test_group1 | 2| +B only test:test_group1
Project: None Project: None
============= =============
| 4| No project test:test_group1 | 4| No project test:test_group1
""") """)
def test_group2(self): def test_group2(self):
...@@ -608,11 +650,11 @@ Project: None ...@@ -608,11 +650,11 @@ Project: None
self.assertEqual(self.output, """\ self.assertEqual(self.output, """\
l: 0 l: 0
==== ====
| 6| Another item l:0 test:test_group2 | 6| Another item l:0 test:test_group2
l: 1 l: 1
==== ====
| 5| Different item l:1 test:test_group2 | 5| Different item l:1 test:test_group2
""") """)
def test_group3(self): def test_group3(self):
...@@ -626,11 +668,11 @@ l: 1 ...@@ -626,11 +668,11 @@ l: 1
self.assertEqual(self.output, """\ self.assertEqual(self.output, """\
due: today due: today
========== ==========
| 7| Test 1 test:test_group3 due:2016-12-06 | 7| Test 1 test:test_group3 due:2016-12-06
due: in a day due: in a day
============= =============
| 8| Test 2 test:test_group3 due:2016-12-07 | 8| Test 2 test:test_group3 due:2016-12-07
""") """)
def test_group4(self): def test_group4(self):
...@@ -644,7 +686,7 @@ due: in a day ...@@ -644,7 +686,7 @@ due: in a day
self.assertEqual(self.output, """\ self.assertEqual(self.output, """\
t: today t: today
======== ========
| 9| Test 1 test:test_group4 test:test_group5 t:2016-12-06 | 9| Test 1 test:test_group4 test:test_group5 t:2016-12-06
""") """)
def test_group5(self): def test_group5(self):
...@@ -658,11 +700,11 @@ t: today ...@@ -658,11 +700,11 @@ t: today
self.assertEqual(self.output, """\ self.assertEqual(self.output, """\
t: today t: today
======== ========
| 9| Test 1 test:test_group4 test:test_group5 t:2016-12-06 | 9| Test 1 test:test_group4 test:test_group5 t:2016-12-06
t: in a day t: in a day
=========== ===========
| 10| Test 2 test:test_group4 test:test_group5 t:2016-12-07 |10| Test 2 test:test_group4 test:test_group5 t:2016-12-07
""") """)
def test_group6(self): def test_group6(self):
...@@ -676,7 +718,7 @@ t: in a day ...@@ -676,7 +718,7 @@ t: in a day
self.assertEqual(self.output, """\ self.assertEqual(self.output, """\
fake: No value fake: No value
============== ==============
| 11| Group by non-existing tag test:test_group6 |11| Group by non-existing tag test:test_group6
""") """)
def test_group7(self): def test_group7(self):
...@@ -690,11 +732,11 @@ fake: No value ...@@ -690,11 +732,11 @@ fake: No value
self.assertEqual(self.output, """\ self.assertEqual(self.output, """\
Project: B Project: B
========== ==========
| 13| Sort descending +B test:test_group7 |13| Sort descending +B test:test_group7
Project: A Project: A
========== ==========
| 12| Sort descending +A test:test_group7 |12| Sort descending +A test:test_group7
""") """)
def test_group8(self): def test_group8(self):
...@@ -708,19 +750,19 @@ Project: A ...@@ -708,19 +750,19 @@ Project: A
self.assertEqual(self.output, """\ self.assertEqual(self.output, """\
Project: A, Context: B Project: A, Context: B
====================== ======================
| 15| Inner sort 2 +A @B test:test_group8 |15| Inner sort 2 +A @B test:test_group8
Project: A, Context: A Project: A, Context: A
====================== ======================
| 14| Inner sort 1 +A @A test:test_group8 |14| Inner sort 1 +A @A test:test_group8
Project: B, Context: B Project: B, Context: B
====================== ======================
| 17| Inner sort 4 +B @B test:test_group8 |17| Inner sort 4 +B @B test:test_group8
Project: B, Context: A Project: B, Context: A
====================== ======================
| 16| Inner sort 3 +B @A test:test_group8 |16| Inner sort 3 +B @A test:test_group8
""") """)
def test_group9(self): def test_group9(self):
...@@ -734,8 +776,8 @@ Project: B, Context: A ...@@ -734,8 +776,8 @@ Project: B, Context: A
self.assertEqual(self.output, """\ self.assertEqual(self.output, """\
Project: A Project: A
========== ==========
| 19| Inner sort 2 +A test:test_group9 |19| Inner sort 2 +A test:test_group9
| 18| Inner sort 1 +A test:test_group9 |18| Inner sort 1 +A test:test_group9
""") """)
def test_group10(self): def test_group10(self):
...@@ -761,17 +803,17 @@ Project: A ...@@ -761,17 +803,17 @@ Project: A
self.assertEqual(self.output, """\ self.assertEqual(self.output, """\
Project: A Project: A
========== ==========
| 1| +A only test:test_group1 | 1| +A only test:test_group1
| 3| +A and +B test:test_group1 | 3| +A and +B test:test_group1
Project: B Project: B
========== ==========
| 3| +A and +B test:test_group1 | 3| +A and +B test:test_group1
| 2| +B only test:test_group1 | 2| +B only test:test_group1
Project: None Project: None
============= =============
| 4| No project test:test_group1 | 4| No project test:test_group1
""") """)
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
...@@ -784,10 +826,10 @@ Project: None ...@@ -784,10 +826,10 @@ Project: None
self.assertFalse(todolist.dirty) self.assertFalse(todolist.dirty)
self.assertEqual(self.output, """\ self.assertEqual(self.output, """\
| 1| +A only test:test_group1 | 1| +A only test:test_group1
| 2| +B only test:test_group1 | 2| +B only test:test_group1
| 3| +A and +B test:test_group1 | 3| +A and +B test:test_group1
| 4| No project test:test_group1 | 4| No project test:test_group1
""") """)
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
......
...@@ -23,6 +23,7 @@ from test.command_testcase import CommandTest ...@@ -23,6 +23,7 @@ from test.command_testcase import CommandTest
from test.facilities import load_file_to_todolist from test.facilities import load_file_to_todolist
from topydo.commands.ListCommand import ListCommand from topydo.commands.ListCommand import ListCommand
from topydo.lib.Config import config from topydo.lib.Config import config
from topydo.lib.TodoListBase import TodoListBase
# We're searching for 'mock' # We're searching for 'mock'
# 'mock' was added as 'unittest.mock' in Python 3.3, but PyPy 3 is based on Python 3.2 # 'mock' was added as 'unittest.mock' in Python 3.3, but PyPy 3 is based on Python 3.2
...@@ -37,6 +38,7 @@ except ImportError: ...@@ -37,6 +38,7 @@ except ImportError:
class ListFormatTest(CommandTest): class ListFormatTest(CommandTest):
def setUp(self): def setUp(self):
super().setUp() super().setUp()
self.maxDiff = None
self.todolist = load_file_to_todolist("test/data/ListFormat.txt") self.todolist = load_file_to_todolist("test/data/ListFormat.txt")
self.terminal_size = namedtuple('terminal_size', ['columns', 'lines']) self.terminal_size = namedtuple('terminal_size', ['columns', 'lines'])
...@@ -45,12 +47,12 @@ class ListFormatTest(CommandTest): ...@@ -45,12 +47,12 @@ class ListFormatTest(CommandTest):
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """|1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox +jumped over the and jar due:2015-11-08 lazy:bar t:2015-11-07 |2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox +jumped over the and jar due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project |3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value |4| (C) Baz @Context1 +Project1 key:value
| 5| Drink beer @ home ical:foobar id:1 p:2 |5| Drink beer @ home ical:foobar id:1 p:2
| 6| x 2014-12-12 Completed but with date:2014-12-12 |6| x 2014-12-12 Completed but with date:2014-12-12
""" """
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
...@@ -62,12 +64,12 @@ class ListFormatTest(CommandTest): ...@@ -62,12 +64,12 @@ class ListFormatTest(CommandTest):
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """|1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolore... due:2015-11-08 lazy:bar t:2015-11-07 |2| (Z) 2015-11-06 Lorem ipsum dolorem ... due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project |3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value |4| (C) Baz @Context1 +Project1 key:value
| 5| Drink beer @ home ical:foobar id:1 p:2 |5| Drink beer @ home ical:foobar id:1 p:2
| 6| x 2014-12-12 Completed but with date:2014-12-12 |6| x 2014-12-12 Completed but with date:2014-12-12
""" """
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
...@@ -79,12 +81,12 @@ class ListFormatTest(CommandTest): ...@@ -79,12 +81,12 @@ class ListFormatTest(CommandTest):
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """|1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox... due:2015-11-08 lazy:bar t:2015-11-07 |2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox +... due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project |3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value |4| (C) Baz @Context1 +Project1 key:value
| 5| Drink beer @ home ical:foobar id:1 p:2 |5| Drink beer @ home ical:foobar id:1 p:2
| 6| x 2014-12-12 Completed but with date:2014-12-12 |6| x 2014-12-12 Completed but with date:2014-12-12
""" """
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
...@@ -96,12 +98,12 @@ class ListFormatTest(CommandTest): ...@@ -96,12 +98,12 @@ class ListFormatTest(CommandTest):
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """|1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox... due:2015-11-08 lazy:bar t:2015-11-07 |2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox +... due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project |3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value |4| (C) Baz @Context1 +Project1 key:value
| 5| Drink beer @ home ical:foobar id:1 p:2 |5| Drink beer @ home ical:foobar id:1 p:2
| 6| x 2014-12-12 Completed but with date:2014-12-12 |6| x 2014-12-12 Completed but with date:2014-12-12
""" """
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
...@@ -113,12 +115,12 @@ class ListFormatTest(CommandTest): ...@@ -113,12 +115,12 @@ class ListFormatTest(CommandTest):
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """|1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolore... due:2015-11-08 lazy:bar t:2015-11-07 |2| (Z) 2015-11-06 Lorem ipsum dolorem ... due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project |3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value |4| (C) Baz @Context1 +Project1 key:value
| 5| Drink beer @ home ical:foobar id:1 p:2 |5| Drink beer @ home ical:foobar id:1 p:2
| 6| x 2014-12-12 Completed but with date:2014-12-12 |6| x 2014-12-12 Completed but with date:2014-12-12
""" """
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
...@@ -131,12 +133,12 @@ class ListFormatTest(CommandTest): ...@@ -131,12 +133,12 @@ class ListFormatTest(CommandTest):
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = """| 1| D Bar @Context1 +Project2 (3 months ago, due a month ago, started a month ago) result = """|1| D Bar @Context1 +Project2 (3 months ago, due a month ago, started a month ago)
| 2| Z Lorem ipsum dolorem sit amet. Red @fox ... lazy:bar (today, due in 2 days, starts in a day) |2| Z Lorem ipsum dolorem sit amet. Red @fox +j... lazy:bar (today, due in 2 days, starts in a day)
| 3| C Foo @Context2 Not@Context +Project1 Not+Project (4 months ago) |3| C Foo @Context2 Not@Context +Project1 Not+Project (4 months ago)
| 4| C Baz @Context1 +Project1 key:value |4| C Baz @Context1 +Project1 key:value
| 5| Drink beer @ home |5| Drink beer @ home
| 6| x 2014-12-12 Completed but with date:2014-12-12 |6| x 2014-12-12 Completed but with date:2014-12-12
""" """
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
...@@ -148,12 +150,12 @@ class ListFormatTest(CommandTest): ...@@ -148,12 +150,12 @@ class ListFormatTest(CommandTest):
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = """| 1| D Bar @Context1 +Project2 (due a month ago, started a month ago) result = """|1| D Bar @Context1 +Project2 (due a month ago, started a month ago)
| 2| Z Lorem ipsum dolorem sit amet. Red @fox +jumped... lazy:bar (due in 2 days, starts in a day) |2| Z Lorem ipsum dolorem sit amet. Red @fox +jumped o... lazy:bar (due in 2 days, starts in a day)
| 3| C Foo @Context2 Not@Context +Project1 Not+Project |3| C Foo @Context2 Not@Context +Project1 Not+Project
| 4| C Baz @Context1 +Project1 key:value |4| C Baz @Context1 +Project1 key:value
| 5| Drink beer @ home |5| Drink beer @ home
| 6| x 2014-12-12 Completed but with date:2014-12-12 |6| x 2014-12-12 Completed but with date:2014-12-12
""" """
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
...@@ -210,12 +212,12 @@ today | in 2 days | in a day | ...@@ -210,12 +212,12 @@ today | in 2 days | in a day |
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = """| 1| due:2015-09-30 t:2015-09-29 result = """|1| due:2015-09-30 t:2015-09-29
| 2| due:2015-11-08 lazy:bar t:2015-11-07 |2| due:2015-11-08 lazy:bar t:2015-11-07
| 3| |3|
| 4| key:value |4| key:value
| 5| ical:foobar id:1 p:2 |5| ical:foobar id:1 p:2
| 6| date:2014-12-12 |6| date:2014-12-12
""" """
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
...@@ -224,12 +226,12 @@ today | in 2 days | in a day | ...@@ -224,12 +226,12 @@ today | in 2 days | in a day |
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = """| 1| % result = """|1| %
| 2| % |2| %
| 3| % |3| %
| 4| % |4| %
| 5| % |5| %
| 6| % |6| %
""" """
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
...@@ -238,12 +240,12 @@ today | in 2 days | in a day | ...@@ -238,12 +240,12 @@ today | in 2 days | in a day |
self.todolist, self.out, self.error) self.todolist, self.out, self.error)
command.execute() command.execute()
result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """|1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox +jumped over the and jar due:2015-11-08 lazy:bar t:2015-11-07 |2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox +jumped over the and jar due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project |3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value |4| (C) Baz @Context1 +Project1 key:value
| 5| Drink beer @ home ical:foobar id:1 p:2 |5| Drink beer @ home ical:foobar id:1 p:2
| 6| x 2014-12-12 Completed but with date:2014-12-12 |6| x 2014-12-12 Completed but with date:2014-12-12
""" """
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
...@@ -254,8 +256,8 @@ today | in 2 days | in a day | ...@@ -254,8 +256,8 @@ today | in 2 days | in a day |
self.todolist, self.out, self.error) self.todolist, self.out, self.error)
command.execute() command.execute()
result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """|1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 4| (C) Baz @Context1 +Project1 key:value |4| (C) Baz @Context1 +Project1 key:value
""" """
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
...@@ -355,12 +357,12 @@ today, due in 2 days, starts in a day ...@@ -355,12 +357,12 @@ today, due in 2 days, starts in a day
command = ListCommand(["-x", "-F", "%I"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "%I"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = """ 1 result = """1
2 2
3 3
4 4
5 5
6 6
""" """
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
...@@ -610,12 +612,12 @@ Z Z ...@@ -610,12 +612,12 @@ Z Z
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """|1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox... due:2015-11-08 lazy:bar t:2015-11-07 |2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox +... due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project |3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value |4| (C) Baz @Context1 +Project1 key:value
| 5| Drink beer @ home ical:foobar id:1 p:2 |5| Drink beer @ home ical:foobar id:1 p:2
| 6| x 2014-12-12 Completed but with date:2014-12-12 |6| x 2014-12-12 Completed but with date:2014-12-12
""" """
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
...@@ -626,12 +628,12 @@ Z Z ...@@ -626,12 +628,12 @@ Z Z
command = ListCommand(["-x", "-F", "|%I| %x %{(}p{)} %c %S\\t%K"], self.todolist, self.out, self.error) command = ListCommand(["-x", "-F", "|%I| %x %{(}p{)} %c %S\\t%K"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = """| 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """|1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox... due:2015-11-08 lazy:bar t:2015-11-07 |2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox +... due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project |3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value |4| (C) Baz @Context1 +Project1 key:value
| 5| Drink beer @ home ical:foobar id:1 p:2 |5| Drink beer @ home ical:foobar id:1 p:2
| 6| x 2014-12-12 Completed but with date:2014-12-12 |6| x 2014-12-12 Completed but with date:2014-12-12
""" """
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
...@@ -643,12 +645,12 @@ Z Z ...@@ -643,12 +645,12 @@ Z Z
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = """ | 1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29 result = """ |1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
| 2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @... due:2015-11-08 lazy:bar t:2015-11-07 |2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fo... due:2015-11-08 lazy:bar t:2015-11-07
| 3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project |3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
| 4| (C) Baz @Context1 +Project1 key:value |4| (C) Baz @Context1 +Project1 key:value
| 5| Drink beer @ home ical:foobar id:1 p:2 |5| Drink beer @ home ical:foobar id:1 p:2
| 6| x 2014-12-12 Completed but with date:2014-12-12 |6| x 2014-12-12 Completed but with date:2014-12-12
""" """
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
...@@ -681,19 +683,18 @@ C - ...@@ -681,19 +683,18 @@ C -
@mock.patch('topydo.lib.ListFormat.get_terminal_size') @mock.patch('topydo.lib.ListFormat.get_terminal_size')
def test_list_format45(self, mock_terminal_size): def test_list_format45(self, mock_terminal_size):
""" Colorblocks should not affect truncating or right_alignment. """ """ Colorblocks should not affect truncating or right_alignment. """
self.maxDiff = None
mock_terminal_size.return_value = self.terminal_size(100, 25) mock_terminal_size.return_value = self.terminal_size(100, 25)
config(p_overrides={('ls', 'list_format'): '%z|%I| %x %p %S %k\\t%{(}h{)}'}) config(p_overrides={('ls', 'list_format'): '%z|%I| %x %p %S %k\\t%{(}h{)}'})
command = ListCommand(["-x"], self.todolist, self.out, self.error) command = ListCommand(["-x"], self.todolist, self.out, self.error)
command.execute() command.execute()
result = u""" | 1| D Bar @Context1 +Project2 (due a month ago, started a month ago) result = u""" |1| D Bar @Context1 +Project2 (due a month ago, started a month ago)
| 2| Z Lorem ipsum dolorem sit amet. Red @fox +jumpe... lazy:bar (due in 2 days, starts in a day) |2| Z Lorem ipsum dolorem sit amet. Red @fox +jumped ... lazy:bar (due in 2 days, starts in a day)
| 3| C Foo @Context2 Not@Context +Project1 Not+Project |3| C Foo @Context2 Not@Context +Project1 Not+Project
| 4| C Baz @Context1 +Project1 key:value |4| C Baz @Context1 +Project1 key:value
| 5| Drink beer @ home |5| Drink beer @ home
| 6| x 2014-12-12 Completed but with date:2014-12-12 |6| x 2014-12-12 Completed but with date:2014-12-12
""" """
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
...@@ -733,21 +734,6 @@ x 2014-12-12 Completed but with date:2014-12-12 ...@@ -733,21 +734,6 @@ x 2014-12-12 Completed but with date:2014-12-12
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list_format49(self):
"""
Test padded line numbers
"""
command = ListCommand(["-F %N"], self.todolist, self.out, self.error)
command.execute()
result = """ 1
3
4
5
"""
self.assertEqual(self.output, result)
self.assertEqual(self.errors, "")
def test_list_format50(self): def test_list_format50(self):
""" """
Test line numbers Test line numbers
...@@ -778,5 +764,12 @@ x 2014-12-12 Completed but with date:2014-12-12 ...@@ -778,5 +764,12 @@ x 2014-12-12 Completed but with date:2014-12-12
self.assertEqual(self.output, result) self.assertEqual(self.output, result)
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_list_format52(self):
config(p_overrides={('topydo', 'identifier_alphabet'): '0123456789abcdef', ('topydo', 'identifiers'): 'text'})
# make sure that it fallbacks to the default alphabet
todolist = TodoListBase([str(i) for i in range(0, 100 * 16 * 10)])
self.assertEqual(4, todolist.max_id_length())
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
...@@ -7,6 +7,7 @@ default_command = ls ...@@ -7,6 +7,7 @@ default_command = ls
colors = auto colors = auto
; identifiers can be 'linenumber' or 'text' ; identifiers can be 'linenumber' or 'text'
identifiers = linenumber identifiers = linenumber
identifier_alphabet = 0123456789abcdefghijklmnopqrstuvwxyz
backup_count = 5 backup_count = 5
[add] [add]
......
...@@ -20,6 +20,7 @@ import os ...@@ -20,6 +20,7 @@ import os
import re import re
import shlex import shlex
from collections import OrderedDict
from itertools import accumulate from itertools import accumulate
from string import ascii_lowercase from string import ascii_lowercase
...@@ -70,6 +71,7 @@ class _Config: ...@@ -70,6 +71,7 @@ class _Config:
'filename': 'todo.txt', 'filename': 'todo.txt',
'archive_filename': 'done.txt', 'archive_filename': 'done.txt',
'identifiers': 'linenumber', 'identifiers': 'linenumber',
'identifier_alphabet': '0123456789abcdefghijklmnopqrstuvwxyz',
'backup_count': '5', 'backup_count': '5',
}, },
...@@ -474,6 +476,12 @@ class _Config: ...@@ -474,6 +476,12 @@ class _Config:
return shlex.split(result) return shlex.split(result)
def identifier_alphabet(self):
alphabet = self.cp.get('topydo', 'identifier_alphabet')
# deduplicate characters alphabet. Use a dictionary, but an ordered one
# to keep determinism.
return list(OrderedDict([(c, None) for c in alphabet]).keys())
def config(p_path=None, p_overrides=None): def config(p_path=None, p_overrides=None):
""" """
......
...@@ -21,48 +21,115 @@ value of each item. ...@@ -21,48 +21,115 @@ value of each item.
from hashlib import sha1 from hashlib import sha1
from topydo.lib.Config import config
_DEFAULT_ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz'
# a two-dimensional lookup table, the first dimension is the length of the
# configured alphabet, the second dimension is the width of the ID
# The values are prime numbers that are used for populating the hash table.
_TABLE_SIZES = { _TABLE_SIZES = {
# we choose a large table size to reduce the chance of collisions. 10: {3: 997, 4: 9973, 5: 99991, 6: 999983},
3: 46649, # largest prime under zzz_36 11: {3: 1327, 4: 14639, 5: 161047, 6: 1771559},
4: 1679609 # largest prime under zzzz_36 12: {3: 1723, 4: 20731, 5: 248827, 6: 2985979},
13: {3: 2179, 4: 28559, 5: 371291, 6: 4826797},
14: {3: 2741, 4: 38393, 5: 573811, 6: 7529519},
15: {3: 3373, 4: 50599, 5: 759371, 6: 11390593},
16: {3: 4093, 4: 65521, 5: 1048573},
17: {3: 4909, 4: 83497, 5: 1419839},
18: {3: 5827, 4: 104971, 5: 1889561},
19: {3: 6857, 4: 130307, 5: 2476081},
20: {3: 7993, 4: 159979, 5: 3199997},
21: {3: 9257, 4: 194479, 5: 4084081},
22: {3: 10639, 4: 245239, 5: 5153623},
23: {3: 12163, 4: 279823, 5: 6436327},
24: {3: 13807, 4: 331769, 5: 7962607},
25: {3: 15619, 4: 390581, 5: 9765619},
26: {3: 17573, 4: 456959, 5: 11881357},
27: {3: 19681, 4: 531383, 5: 14348891},
28: {3: 21943, 4: 614639, 5: 17210353},
29: {3: 24379, 4: 707279, 5: 20511143},
30: {3: 26993, 4: 809993, 5: 24299981},
31: {3: 29789, 4: 923513, 5: 28629149},
32: {3: 32749, 4: 1048573},
33: {3: 35933, 4: 1185907},
34: {3: 39301, 4: 1336333},
35: {3: 42863, 4: 1500619},
36: {3: 46649, 4: 1679609},
37: {3: 50651, 4: 1874153},
38: {3: 54869, 4: 2085133},
39: {3: 59281, 4: 2313439},
40: {3: 63997, 4: 2559989},
41: {3: 68917, 4: 2825759},
42: {3: 74077, 4: 3111679},
43: {3: 79493, 4: 3418799},
44: {3: 85159, 4: 3748079},
45: {3: 91121, 4: 4100611},
46: {3: 97327, 4: 4477453},
47: {3: 103813, 4: 4879669},
48: {3: 110587, 4: 5308379},
49: {3: 117643, 4: 5764799},
50: {3: 124991, 4: 6249989},
} }
def _to_base36(p_value): class _TableSizeException(Exception):
""" pass
Converts integer to base36 string.
Based on answer on def _get_table_size(p_alphabet, p_num):
https://stackoverflow.com/questions/1181919/python-base-36-encoding
""" """
alphabet = '0123456789abcdefghijklmnopqrstuvwxyz' Returns a prime number that is suitable for the hash table size. The size
is dependent on the alphabet used, and the number of items that need to be
hashed. The table size is at least 100 times larger than the number of
items to be hashed, to avoid collisions.
base36 = '' When the alphabet is too little or too large, then _TableSizeException is
while p_value: raised. Currently an alphabet of 10 to 40 characters is supported.
p_value, i = divmod(p_value, 36) """
base36 = alphabet[i] + base36 try:
for width, size in sorted(_TABLE_SIZES[len(p_alphabet)].items()):
return base36 or alphabet[0] if p_num < size * 0.01:
return width, size
except KeyError:
pass
raise _TableSizeException('Could not find appropriate table size for given alphabet')
def hash_list_values(p_list, p_key=lambda i: i): # pragma: no branch def hash_list_values(p_list, p_key=lambda i: i): # pragma: no branch
""" """
Calculates a unique value for each item in the list, these can be used as Calculates a unique value for each item in the list, these can be used as
identifiers. identifiers.
The value is based on hashing an item using the p_hash function. The value is based on hashing an item using the p_key function.
Suitable for lists not larger than approx. 16K items. Suitable for lists not larger than approx. 16K items.
Returns a tuple with the status and a list of tuples where each item is Returns a tuple with the status and a list of tuples where each item is
combined with the ID. combined with the ID.
""" """
def to_base(p_alphabet, p_value):
"""
Converts integer to text ID with characters from the given alphabet.
Based on answer at
https://stackoverflow.com/questions/1181919/python-base-36-encoding
"""
result = ''
while p_value:
p_value, i = divmod(p_value, len(p_alphabet))
result = p_alphabet[i] + result
return result or p_alphabet[0]
result = [] result = []
used = set() used = set()
alphabet = config().identifier_alphabet()
# choose a larger key size if there's >1% chance of collision try:
size = _TABLE_SIZES[3] \ _, size = _get_table_size(alphabet, len(p_list))
if len(p_list) < _TABLE_SIZES[3] * 0.01 else _TABLE_SIZES[4] except _TableSizeException:
alphabet = _DEFAULT_ALPHABET
_, size = _get_table_size(alphabet, len(p_list))
for item in p_list: for item in p_list:
# obtain the to-be-hashed value # obtain the to-be-hashed value
...@@ -78,6 +145,19 @@ def hash_list_values(p_list, p_key=lambda i: i): # pragma: no branch ...@@ -78,6 +145,19 @@ def hash_list_values(p_list, p_key=lambda i: i): # pragma: no branch
hash_value = (hash_value + 1) % size hash_value = (hash_value + 1) % size
used.add(hash_value) used.add(hash_value)
result.append((item, _to_base36(hash_value))) result.append((item, to_base(alphabet, hash_value)))
return result return result
def max_id_length(p_num):
"""
Returns the length of the IDs used, given the number of items that are
assigned an ID. Used for padding in lists.
"""
try:
alphabet = config().identifier_alphabet()
length, _ = _get_table_size(alphabet, p_num)
except _TableSizeException:
length, _ = _get_table_size(_DEFAULT_ALPHABET, p_num)
return length
...@@ -162,9 +162,9 @@ class ListFormatParser(object): ...@@ -162,9 +162,9 @@ class ListFormatParser(object):
# todo ID # todo ID
'i': lambda t: str(self.todolist.number(t)), 'i': lambda t: str(self.todolist.number(t)),
# todo ID pre-filled with 1 or 2 spaces if its length is <3 # todo ID, padded with spaces
'I': lambda t: _filler(str(self.todolist.number(t)), 3), 'I': lambda t: _filler(str(self.todolist.number(t)),
self.todolist.max_id_length()),
# list of tags (spaces) without hidden ones and due: and t: # list of tags (spaces) without hidden ones and due: and t:
'k': lambda t: ' '.join([u'{}:{}'.format(tag, value) 'k': lambda t: ' '.join([u'{}:{}'.format(tag, value)
...@@ -179,8 +179,9 @@ class ListFormatParser(object): ...@@ -179,8 +179,9 @@ class ListFormatParser(object):
# line number # line number
'n': lambda t: str(self.todolist.linenumber(t)), 'n': lambda t: str(self.todolist.linenumber(t)),
# line number, pre-filled with 1 or 2 spaces if its length <3 # line number, padded with spaces
'N': lambda t: _filler(str(self.todolist.linenumber(t)), 3), 'N': lambda t: _filler(str(self.todolist.linenumber(t)),
self.todolist.max_id_length()),
# priority # priority
'p': lambda t: t.priority() if t.priority() else '', 'p': lambda t: t.priority() if t.priority() else '',
...@@ -206,8 +207,9 @@ class ListFormatParser(object): ...@@ -206,8 +207,9 @@ class ListFormatParser(object):
# unique text ID # unique text ID
'u': lambda t: self.todolist.uid(t), 'u': lambda t: self.todolist.uid(t),
# unique text ID, pre-filled with 1 or 2 spaces if its length <3 # unique text ID, padded with spaces
'U': lambda t: _filler(self.todolist.uid(t), 3), 'U': lambda t: _filler(self.todolist.uid(t),
self.todolist.max_id_length()),
# absolute completion date # absolute completion date
'x': lambda t: 'x ' + t.completion_date().isoformat() if t.is_completed() else '', 'x': lambda t: 'x ' + t.completion_date().isoformat() if t.is_completed() else '',
......
...@@ -18,12 +18,13 @@ ...@@ -18,12 +18,13 @@
A list of todo items. A list of todo items.
""" """
import math
import re import re
from datetime import date from datetime import date
from topydo.lib import Filter from topydo.lib import Filter
from topydo.lib.Config import config from topydo.lib.Config import config
from topydo.lib.HashListValues import hash_list_values from topydo.lib.HashListValues import hash_list_values, max_id_length
from topydo.lib.printers.PrettyPrinter import PrettyPrinter from topydo.lib.printers.PrettyPrinter import PrettyPrinter
from topydo.lib.Todo import Todo from topydo.lib.Todo import Todo
from topydo.lib.View import View from topydo.lib.View import View
...@@ -275,6 +276,19 @@ class TodoListBase(object): ...@@ -275,6 +276,19 @@ class TodoListBase(object):
else: else:
return self.linenumber(p_todo) return self.linenumber(p_todo)
def max_id_length(self):
"""
Returns the maximum length of a todo ID, used for formatting purposes.
"""
if config().identifiers() == "text":
return max_id_length(len(self._todos))
else:
try:
return math.ceil(math.log(len(self._todos), 10))
except ValueError:
return 0
def _update_todo_ids(self): def _update_todo_ids(self):
# the idea is to have a hash that is independent of the position of the # the idea is to have a hash that is independent of the position of the
# todo. Use the text (without tags) of the todo to keep the id as # todo. Use the text (without tags) of the todo to keep the id as
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
import urwid import urwid
from topydo.lib.HashListValues import max_id_length
from topydo.lib.Utils import translate_key_to_config from topydo.lib.Utils import translate_key_to_config
from topydo.ui.columns.TodoWidget import TodoWidget from topydo.ui.columns.TodoWidget import TodoWidget
...@@ -89,6 +90,7 @@ class TodoListWidget(urwid.LineBox): ...@@ -89,6 +90,7 @@ class TodoListWidget(urwid.LineBox):
with this list. with this list.
""" """
old_focus_position = self.todolist.focus old_focus_position = self.todolist.focus
id_length = max_id_length(self.view.todolist.count())
del self.todolist[:] del self.todolist[:]
...@@ -99,7 +101,7 @@ class TodoListWidget(urwid.LineBox): ...@@ -99,7 +101,7 @@ class TodoListWidget(urwid.LineBox):
self.todolist.append(urwid.Divider('-')) self.todolist.append(urwid.Divider('-'))
for todo in todos: for todo in todos:
todowidget = TodoWidget.create(todo) todowidget = TodoWidget.create(todo, id_length)
todowidget.number = self.view.todolist.number(todo) todowidget.number = self.view.todolist.number(todo)
self.todolist.append(todowidget) self.todolist.append(todowidget)
self.todolist.append(urwid.Divider('-')) self.todolist.append(urwid.Divider('-'))
......
...@@ -53,7 +53,7 @@ def _markup(p_todo, p_focus): ...@@ -53,7 +53,7 @@ def _markup(p_todo, p_focus):
class TodoWidget(urwid.WidgetWrap): class TodoWidget(urwid.WidgetWrap):
def __init__(self, p_todo): def __init__(self, p_todo, p_id_width=4):
# clients use this to associate this widget with the given todo item # clients use this to associate this widget with the given todo item
self.todo = p_todo self.todo = p_todo
...@@ -101,7 +101,7 @@ class TodoWidget(urwid.WidgetWrap): ...@@ -101,7 +101,7 @@ class TodoWidget(urwid.WidgetWrap):
self.columns = urwid.Columns( self.columns = urwid.Columns(
[ [
(1, self.progress_bar), (1, self.progress_bar),
(4, self.id_widget), (p_id_width, self.id_widget),
(3, priority_widget), (3, priority_widget),
('weight', 1, self.text_widget), ('weight', 1, self.text_widget),
], ],
...@@ -159,7 +159,7 @@ class TodoWidget(urwid.WidgetWrap): ...@@ -159,7 +159,7 @@ class TodoWidget(urwid.WidgetWrap):
cache = {} cache = {}
@classmethod @classmethod
def create(p_class, p_todo): def create(p_class, p_todo, p_id_width=4):
""" """
Creates a TodoWidget instance for the given todo. Widgets are Creates a TodoWidget instance for the given todo. Widgets are
cached, the same object is returned for the same todo item. cached, the same object is returned for the same todo item.
...@@ -187,7 +187,7 @@ class TodoWidget(urwid.WidgetWrap): ...@@ -187,7 +187,7 @@ class TodoWidget(urwid.WidgetWrap):
if parent_progress_may_have_changed(p_todo): if parent_progress_may_have_changed(p_todo):
widget.update_progress() widget.update_progress()
else: else:
widget = p_class(p_todo) widget = p_class(p_todo, p_id_width)
p_class.cache[source] = widget p_class.cache[source] = widget
return widget return widget
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment