Commit 26371a66 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Merge branch 'drop-python2' into colorblock

Conflicts:
	setup.py
	topydo/lib/PrettyPrinterFilter.py
parents a0f4f64e 94c11692
sudo: false # run on new infrastructure sudo: false # run on new infrastructure
language: python language: python
python: python:
- "2.7"
- "3.2" - "3.2"
- "3.3" - "3.3"
- "3.4" - "3.4"
- "3.5" - "3.5"
- "pypy"
- "pypy3" - "pypy3"
matrix: matrix:
allow_failures: allow_failures:
- python: "3.2" - python: "3.2"
- python: "pypy"
- python: "pypy3"
install: install:
- "python -m pip install pip --upgrade" - "python -m pip install pip --upgrade"
- "pip install ." - "pip install ."
- "pip install .[ical]" - "pip install .[ical]"
- "pip install .[test]" - "pip install .[test]"
- "pip install pylint"
- "pip install codecov" - "pip install codecov"
script: script:
- "green -vvr" - "green -vvr"
......
[bdist_wheel]
universal = 1
...@@ -20,7 +20,6 @@ def find_version(*file_paths): ...@@ -20,7 +20,6 @@ def find_version(*file_paths):
return version_match.group(1) return version_match.group(1)
raise RuntimeError("Unable to find version string.") raise RuntimeError("Unable to find version string.")
setup( setup(
name = "topydo", name = "topydo",
packages = find_packages(exclude=["test"]), packages = find_packages(exclude=["test"]),
...@@ -30,21 +29,13 @@ setup( ...@@ -30,21 +29,13 @@ setup(
author_email = "me@bramschoenmakers.nl", author_email = "me@bramschoenmakers.nl",
url = "https://github.com/bram85/topydo", url = "https://github.com/bram85/topydo",
install_requires = [ install_requires = [
'six >= 1.9.0',
'arrow >= 0.7.0', 'arrow >= 0.7.0',
], ],
extras_require = { extras_require = {
':sys_platform=="win32"': ['colorama>=0.2.5'], ':sys_platform=="win32"': ['colorama>=0.2.5'],
# shutil.get_terminal_size() was introduced in Python 3.3
':python_version=="2.7"': [
'backports.shutil_get_terminal_size>=1.0.0',
'ushlex',
],
':python_version=="3.2"': ['backports.shutil_get_terminal_size>=1.0.0'],
'ical': ['icalendar'], 'ical': ['icalendar'],
'prompt-toolkit': ['prompt-toolkit >= 0.53'], 'prompt-toolkit': ['prompt-toolkit >= 0.53'],
'test': ['coverage', 'freezegun', 'green', ], 'test': ['coverage', 'freezegun', 'green', ],
'test:python_version=="2.7"': ['mock'],
'test:python_version!="3.2"': ['pylint'], 'test:python_version!="3.2"': ['pylint'],
}, },
entry_points= { entry_points= {
...@@ -56,10 +47,12 @@ setup( ...@@ -56,10 +47,12 @@ setup(
"Intended Audience :: End Users/Desktop", "Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Natural Language :: English", "Natural Language :: English",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Utilities", "Topic :: Utilities",
], ],
long_description = """\ long_description = """\
......
...@@ -18,8 +18,6 @@ import unittest ...@@ -18,8 +18,6 @@ import unittest
from datetime import date from datetime import date
from io import StringIO from io import StringIO
from six import u
from test.command_testcase import CommandTest from test.command_testcase import CommandTest
from topydo.commands import AddCommand, ListCommand from topydo.commands import AddCommand, ListCommand
from topydo.lib import TodoList from topydo.lib import TodoList
...@@ -298,29 +296,29 @@ class AddCommandTest(CommandTest): ...@@ -298,29 +296,29 @@ class AddCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n") self.assertEqual(self.errors, command.usage() + "\n")
def test_add_unicode(self): def test_add_unicode(self):
command = AddCommand.AddCommand([u("Special \u25c4")], self.todolist, command = AddCommand.AddCommand([u"Special \u25c4"], self.todolist,
self.out, self.error) self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output, self.assertEqual(self.output,
u("| 1| {} Special \u25c4\n").format(self.today)) u"| 1| {} Special \u25c4\n".format(self.today))
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
@mock.patch("topydo.commands.AddCommand.stdin", @mock.patch("topydo.commands.AddCommand.stdin",
StringIO(u("Fo\u00f3 due:tod id:1\nB\u0105r before:1"))) StringIO(u"Fo\u00f3 due:tod id:1\nB\u0105r before:1"))
def test_add_from_stdin(self): def test_add_from_stdin(self):
command = AddCommand.AddCommand(["-f", "-"], self.todolist, self.out, command = AddCommand.AddCommand(["-f", "-"], self.todolist, self.out,
self.error) self.error)
command.execute() command.execute()
self.assertEqual(self.output, u("| 1| {tod} Fo\u00f3 due:{tod} id:1\n| 2| {tod} B\u0105r p:1\n".format(tod=self.today))) self.assertEqual(self.output, u"| 1| {tod} Fo\u00f3 due:{tod} id:1\n| 2| {tod} B\u0105r p:1\n".format(tod=self.today))
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_add_from_file(self): def test_add_from_file(self):
command = AddCommand.AddCommand(["-f", "test/data/AddCommandTest-from_file.txt"], self.todolist, self.out, self.error) command = AddCommand.AddCommand(["-f", "test/data/AddCommandTest-from_file.txt"], self.todolist, self.out, self.error)
command.execute() command.execute()
self.assertEqual(self.output, u("| 1| {tod} Foo @fo\u00f3b\u0105r due:{tod} id:1\n| 2| {tod} Bar +baz t:{tod} p:1\n".format(tod=self.today))) self.assertEqual(self.output, u"| 1| {tod} Foo @fo\u00f3b\u0105r due:{tod} id:1\n| 2| {tod} Bar +baz t:{tod} p:1\n".format(tod=self.today))
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_add_task_without_date(self): def test_add_task_without_date(self):
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
import unittest import unittest
from six import u
from test.command_testcase import CommandTest from test.command_testcase import CommandTest
from topydo.commands.DeleteCommand import DeleteCommand from topydo.commands.DeleteCommand import DeleteCommand
from topydo.lib.Config import config from topydo.lib.Config import config
...@@ -179,14 +177,14 @@ class DeleteCommandTest(CommandTest): ...@@ -179,14 +177,14 @@ class DeleteCommandTest(CommandTest):
""" """
Throw an error with invalid argument containing special characters. Throw an error with invalid argument containing special characters.
""" """
command = DeleteCommand([u("Fo\u00d3B\u0105r"), "Bar"], self.todolist, command = DeleteCommand([u"Fo\u00d3B\u0105r", "Bar"], self.todolist,
self.out, self.error, None) self.out, self.error, None)
command.execute() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
self.assertEqual(self.output, "") self.assertEqual(self.output, "")
self.assertEqual(self.errors, self.assertEqual(self.errors,
u("Invalid todo number given: Fo\u00d3B\u0105r.\n")) u"Invalid todo number given: Fo\u00d3B\u0105r.\n")
def test_expr_del1(self): def test_expr_del1(self):
command = DeleteCommand(["-e", "@test"], self.todolist, self.out, command = DeleteCommand(["-e", "@test"], self.todolist, self.out,
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
import unittest import unittest
from six import u
from test.command_testcase import CommandTest from test.command_testcase import CommandTest
from topydo.commands.DepriCommand import DepriCommand from topydo.commands.DepriCommand import DepriCommand
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
...@@ -152,14 +150,14 @@ class DepriCommandTest(CommandTest): ...@@ -152,14 +150,14 @@ class DepriCommandTest(CommandTest):
""" """
Throw an error with invalid argument containing special characters. Throw an error with invalid argument containing special characters.
""" """
command = DepriCommand([u("Fo\u00d3B\u0105r"), "Bar"], self.todolist, command = DepriCommand([u"Fo\u00d3B\u0105r", "Bar"], self.todolist,
self.out, self.error, None) self.out, self.error, None)
command.execute() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
self.assertFalse(self.output) self.assertFalse(self.output)
self.assertEqual(self.errors, self.assertEqual(self.errors,
u("Invalid todo number given: Fo\u00d3B\u0105r.\n")) u"Invalid todo number given: Fo\u00d3B\u0105r.\n")
def test_empty(self): def test_empty(self):
command = DepriCommand([], self.todolist, self.out, self.error) command = DepriCommand([], self.todolist, self.out, self.error)
......
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
import unittest import unittest
from datetime import date, timedelta from datetime import date, timedelta
from six import u
from test.command_testcase import CommandTest from test.command_testcase import CommandTest
from topydo.commands.DoCommand import DoCommand from topydo.commands.DoCommand import DoCommand
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
...@@ -357,13 +355,13 @@ class DoCommandTest(CommandTest): ...@@ -357,13 +355,13 @@ class DoCommandTest(CommandTest):
""" """
Throw an error with invalid argument containing special characters. Throw an error with invalid argument containing special characters.
""" """
command = DoCommand([u("Fo\u00d3B\u0105r"), "Bar"], self.todolist, command = DoCommand([u"Fo\u00d3B\u0105r", "Bar"], self.todolist,
self.out, self.error, None) self.out, self.error, None)
command.execute() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
self.assertEqual(self.errors, self.assertEqual(self.errors,
u("Invalid todo number given: Fo\u00d3B\u0105r.\n")) u"Invalid todo number given: Fo\u00d3B\u0105r.\n")
def test_expr_do1(self): def test_expr_do1(self):
command = DoCommand(["-e", "@test"], self.todolist, self.out, command = DoCommand(["-e", "@test"], self.todolist, self.out,
......
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
import os import os
import unittest import unittest
from six import u
from test.command_testcase import CommandTest from test.command_testcase import CommandTest
from topydo.commands.EditCommand import EditCommand from topydo.commands.EditCommand import EditCommand
from topydo.lib.Config import config from topydo.lib.Config import config
...@@ -40,7 +38,7 @@ class EditCommandTest(CommandTest): ...@@ -40,7 +38,7 @@ class EditCommandTest(CommandTest):
"Foo id:1", "Foo id:1",
"Bar p:1 @test", "Bar p:1 @test",
"Baz @test", "Baz @test",
u("Fo\u00f3B\u0105\u017a"), u"Fo\u00f3B\u0105\u017a",
] ]
self.todolist = TodoList(todos) self.todolist = TodoList(todos)
...@@ -59,7 +57,7 @@ class EditCommandTest(CommandTest): ...@@ -59,7 +57,7 @@ class EditCommandTest(CommandTest):
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.todolist.print_todos(), u("Bar p:1 @test\nBaz @test\nFo\u00f3B\u0105\u017a\nFoo id:1")) self.assertEqual(self.todolist.print_todos(), u"Bar p:1 @test\nBaz @test\nFo\u00f3B\u0105\u017a\nFoo id:1")
@mock.patch('topydo.commands.EditCommand._is_edited') @mock.patch('topydo.commands.EditCommand._is_edited')
@mock.patch('topydo.commands.EditCommand.EditCommand._todos_from_temp') @mock.patch('topydo.commands.EditCommand.EditCommand._todos_from_temp')
...@@ -76,7 +74,7 @@ class EditCommandTest(CommandTest): ...@@ -76,7 +74,7 @@ class EditCommandTest(CommandTest):
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
self.assertEqual(self.todolist.print_todos(), u("Foo id:1\nBaz @test\nFo\u00f3B\u0105\u017a\nLazy Cat")) self.assertEqual(self.todolist.print_todos(), u"Foo id:1\nBaz @test\nFo\u00f3B\u0105\u017a\nLazy Cat")
def test_edit03(self): def test_edit03(self):
""" Throw an error after invalid todo number given as argument. """ """ Throw an error after invalid todo number given as argument. """
...@@ -100,13 +98,13 @@ class EditCommandTest(CommandTest): ...@@ -100,13 +98,13 @@ class EditCommandTest(CommandTest):
""" """
Throw an error with invalid argument containing special characters. Throw an error with invalid argument containing special characters.
""" """
command = EditCommand([u("Fo\u00d3B\u0105r"), "Bar"], self.todolist, command = EditCommand([u"Fo\u00d3B\u0105r", "Bar"], self.todolist,
self.out, self.error, None) self.out, self.error, None)
command.execute() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
self.assertEqual(self.errors, self.assertEqual(self.errors,
u("Invalid todo number given: Fo\u00d3B\u0105r.\n")) u"Invalid todo number given: Fo\u00d3B\u0105r.\n")
@mock.patch('topydo.commands.EditCommand._is_edited') @mock.patch('topydo.commands.EditCommand._is_edited')
@mock.patch('topydo.commands.EditCommand.EditCommand._todos_from_temp') @mock.patch('topydo.commands.EditCommand.EditCommand._todos_from_temp')
...@@ -117,14 +115,14 @@ class EditCommandTest(CommandTest): ...@@ -117,14 +115,14 @@ class EditCommandTest(CommandTest):
mock_todos_from_temp.return_value = [Todo('Lazy Cat')] mock_todos_from_temp.return_value = [Todo('Lazy Cat')]
mock_is_edited.return_value = True mock_is_edited.return_value = True
command = EditCommand([u("Fo\u00f3B\u0105\u017a")], self.todolist, command = EditCommand([u"Fo\u00f3B\u0105\u017a"], self.todolist,
self.out, self.error, None) self.out, self.error, None)
command.execute() command.execute()
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
self.assertEqual(self.todolist.print_todos(), self.assertEqual(self.todolist.print_todos(),
u("Foo id:1\nBar p:1 @test\nBaz @test\nLazy Cat")) u"Foo id:1\nBar p:1 @test\nBaz @test\nLazy Cat")
@mock.patch('topydo.commands.EditCommand._is_edited') @mock.patch('topydo.commands.EditCommand._is_edited')
@mock.patch('topydo.commands.EditCommand.EditCommand._todos_from_temp') @mock.patch('topydo.commands.EditCommand.EditCommand._todos_from_temp')
...@@ -141,7 +139,7 @@ class EditCommandTest(CommandTest): ...@@ -141,7 +139,7 @@ class EditCommandTest(CommandTest):
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
self.assertEqual(self.errors, "Editing aborted. Nothing to do.\n") self.assertEqual(self.errors, "Editing aborted. Nothing to do.\n")
self.assertEqual(self.todolist.print_todos(), u("Foo id:1\nBar p:1 @test\nBaz @test\nFo\u00f3B\u0105\u017a")) self.assertEqual(self.todolist.print_todos(), u"Foo id:1\nBar p:1 @test\nBaz @test\nFo\u00f3B\u0105\u017a")
@mock.patch('topydo.commands.EditCommand._is_edited') @mock.patch('topydo.commands.EditCommand._is_edited')
@mock.patch('topydo.commands.EditCommand.EditCommand._todos_from_temp') @mock.patch('topydo.commands.EditCommand.EditCommand._todos_from_temp')
...@@ -157,12 +155,12 @@ class EditCommandTest(CommandTest): ...@@ -157,12 +155,12 @@ class EditCommandTest(CommandTest):
self.error, None) self.error, None)
command.execute() command.execute()
expected = u("| 3| Lazy Cat\n| 4| Lazy Dog\n") expected = u"| 3| Lazy Cat\n| 4| Lazy Dog\n"
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
self.assertTrue(self.todolist.is_dirty()) self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.output, expected) self.assertEqual(self.output, expected)
self.assertEqual(self.todolist.print_todos(), u("Foo id:1\nFo\u00f3B\u0105\u017a\nLazy Cat\nLazy Dog")) self.assertEqual(self.todolist.print_todos(), u"Foo id:1\nFo\u00f3B\u0105\u017a\nLazy Cat\nLazy Dog")
@mock.patch('topydo.commands.EditCommand.check_call') @mock.patch('topydo.commands.EditCommand.check_call')
def test_edit_archive(self, mock_call): def test_edit_archive(self, mock_call):
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
import unittest import unittest
from six import u
from test.topydo_testcase import TopydoTest from test.topydo_testcase import TopydoTest
from topydo.Commands import get_subcommand from topydo.Commands import get_subcommand
from topydo.commands.AddCommand import AddCommand from topydo.commands.AddCommand import AddCommand
...@@ -60,7 +58,7 @@ class GetSubcommandTest(TopydoTest): ...@@ -60,7 +58,7 @@ class GetSubcommandTest(TopydoTest):
args = ["smile"] args = ["smile"]
real_cmd, final_args = get_subcommand(args) real_cmd, final_args = get_subcommand(args)
self.assertTrue(issubclass(real_cmd, ListCommand)) self.assertTrue(issubclass(real_cmd, ListCommand))
self.assertEqual(final_args, [u("\u263b")]) self.assertEqual(final_args, [u"\u263b"])
def test_default_cmd01(self): def test_default_cmd01(self):
args = ["bar"] args = ["bar"]
......
...@@ -18,8 +18,6 @@ import codecs ...@@ -18,8 +18,6 @@ import codecs
import re import re
import unittest import unittest
from six import u
from test.command_testcase import CommandTest 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
...@@ -330,13 +328,13 @@ class ListCommandUnicodeTest(CommandTest): ...@@ -330,13 +328,13 @@ class ListCommandUnicodeTest(CommandTest):
def test_list_unicode1(self): def test_list_unicode1(self):
""" Unicode filters.""" """ Unicode filters."""
command = ListCommand([u("\u25c4")], self.todolist, self.out, command = ListCommand([u"\u25c4"], self.todolist, self.out,
self.error) self.error)
command.execute() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_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)
......
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
import unittest import unittest
from datetime import date, timedelta from datetime import date, timedelta
from six import u
from test.command_testcase import CommandTest from test.command_testcase import CommandTest
from topydo.commands.PostponeCommand import PostponeCommand from topydo.commands.PostponeCommand import PostponeCommand
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
...@@ -252,14 +250,14 @@ class PostponeCommandTest(CommandTest): ...@@ -252,14 +250,14 @@ class PostponeCommandTest(CommandTest):
def test_postpone20(self): def test_postpone20(self):
""" Throw an error with invalid argument containing special characters. """ """ Throw an error with invalid argument containing special characters. """
command = PostponeCommand([u("Fo\u00d3B\u0105r"), "Bar", "1d"], command = PostponeCommand([u"Fo\u00d3B\u0105r", "Bar", "1d"],
self.todolist, self.out, self.error, None) self.todolist, self.out, self.error, None)
command.execute() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
self.assertEqual(self.output, "") self.assertEqual(self.output, "")
self.assertEqual(self.errors, self.assertEqual(self.errors,
u("Invalid todo number given: Fo\u00d3B\u0105r.\n")) u"Invalid todo number given: Fo\u00d3B\u0105r.\n")
def test_expr_postpone1(self): def test_expr_postpone1(self):
command = PostponeCommand(["-e", "due:tod", "2w"], self.todolist, command = PostponeCommand(["-e", "due:tod", "2w"], self.todolist,
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
import unittest import unittest
from six import u
from test.command_testcase import CommandTest from test.command_testcase import CommandTest
from topydo.commands.PriorityCommand import PriorityCommand from topydo.commands.PriorityCommand import PriorityCommand
from topydo.lib.TodoList import TodoList from topydo.lib.TodoList import TodoList
...@@ -198,14 +196,14 @@ class PriorityCommandTest(CommandTest): ...@@ -198,14 +196,14 @@ class PriorityCommandTest(CommandTest):
""" """
Throw an error with invalid argument containing special characters. Throw an error with invalid argument containing special characters.
""" """
command = PriorityCommand([u("Fo\u00d3B\u0105r"), "Bar", "C"], command = PriorityCommand([u"Fo\u00d3B\u0105r", "Bar", "C"],
self.todolist, self.out, self.error, None) self.todolist, self.out, self.error, None)
command.execute() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
self.assertEqual(self.output, "") self.assertEqual(self.output, "")
self.assertEqual(self.errors, self.assertEqual(self.errors,
u("Invalid todo number given: Fo\u00d3B\u0105r.\n")) u"Invalid todo number given: Fo\u00d3B\u0105r.\n")
def test_invalid8(self): def test_invalid8(self):
""" """
......
...@@ -20,7 +20,6 @@ import unittest ...@@ -20,7 +20,6 @@ import unittest
from datetime import date from datetime import date
from glob import glob from glob import glob
from six import u
from uuid import uuid4 from uuid import uuid4
from test.command_testcase import CommandTest from test.command_testcase import CommandTest
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
import unittest import unittest
from six import u
from test.facilities import load_file from test.facilities import load_file
from test.topydo_testcase import TopydoTest from test.topydo_testcase import TopydoTest
...@@ -32,7 +30,7 @@ class TodoFileTest(TopydoTest): ...@@ -32,7 +30,7 @@ class TodoFileTest(TopydoTest):
todofile = load_file('test/data/utf-8.txt') todofile = load_file('test/data/utf-8.txt')
self.assertEqual(todofile[0].source(), self.assertEqual(todofile[0].source(),
u('(C) \u25ba UTF-8 test \u25c4')) u'(C) \u25ba UTF-8 test \u25c4')
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
...@@ -21,8 +21,6 @@ I/O on the command-line. ...@@ -21,8 +21,6 @@ I/O on the command-line.
import getopt import getopt
import sys import sys
from six import PY2
from six.moves import input
MAIN_OPTS = "ac:d:ht:v" MAIN_OPTS = "ac:d:ht:v"
READ_ONLY_COMMANDS = ('List', 'ListContext', 'ListProject') READ_ONLY_COMMANDS = ('List', 'ListContext', 'ListProject')
...@@ -128,9 +126,6 @@ class CLIApplicationBase(object): ...@@ -128,9 +126,6 @@ class CLIApplicationBase(object):
def _process_flags(self): def _process_flags(self):
args = sys.argv[1:] args = sys.argv[1:]
if PY2:
args = [arg.decode('utf-8') for arg in args]
try: try:
opts, args = getopt.getopt(args, MAIN_OPTS) opts, args = getopt.getopt(args, MAIN_OPTS)
except getopt.GetoptError as e: except getopt.GetoptError as e:
...@@ -188,12 +183,6 @@ class CLIApplicationBase(object): ...@@ -188,12 +183,6 @@ class CLIApplicationBase(object):
else: else:
pass # TODO pass # TODO
def _input(self):
"""
Returns a function that retrieves user input.
"""
return input
def is_read_only(self, p_command): def is_read_only(self, p_command):
""" Returns True when the given command class is read-only. """ """ Returns True when the given command class is read-only. """
read_only_commands = tuple(cmd + 'Command' for cmd in ('Revert', ) + read_only_commands = tuple(cmd + 'Command' for cmd in ('Revert', ) +
...@@ -216,7 +205,7 @@ class CLIApplicationBase(object): ...@@ -216,7 +205,7 @@ class CLIApplicationBase(object):
self.todolist, self.todolist,
lambda o: write(sys.stdout, o), lambda o: write(sys.stdout, o),
error, error,
self._input()) input)
if command.execute() != False: if command.execute() != False:
return True return True
......
...@@ -24,13 +24,9 @@ from topydo.cli.CLIApplicationBase import CLIApplicationBase, error, usage ...@@ -24,13 +24,9 @@ from topydo.cli.CLIApplicationBase import CLIApplicationBase, error, usage
from topydo.cli.TopydoCompleter import TopydoCompleter from topydo.cli.TopydoCompleter import TopydoCompleter
from prompt_toolkit.shortcuts import prompt from prompt_toolkit.shortcuts import prompt
from prompt_toolkit.history import InMemoryHistory from prompt_toolkit.history import InMemoryHistory
from six import PY2
from topydo.lib.Config import config, ConfigError from topydo.lib.Config import config, ConfigError
if PY2:
import ushlex as shlex
# First thing is to poke the configuration and check whether it's sane # First thing is to poke the configuration and check whether it's sane
# The modules below may already read in configuration upon import, so # The modules below may already read in configuration upon import, so
# make sure to bail out if the configuration is invalid. # make sure to bail out if the configuration is invalid.
...@@ -84,8 +80,6 @@ class PromptApplication(CLIApplicationBase): ...@@ -84,8 +80,6 @@ class PromptApplication(CLIApplicationBase):
self.todolist = TodoList.TodoList(self.todofile.read()) self.todolist = TodoList.TodoList(self.todofile.read())
self.mtime = current_mtime self.mtime = current_mtime
# suppress upstream issue with Python 2.7
# pylint: disable=no-value-for-parameter
self.completer = TopydoCompleter(self.todolist) self.completer = TopydoCompleter(self.todolist)
def run(self): def run(self):
......
...@@ -18,8 +18,6 @@ import os ...@@ -18,8 +18,6 @@ import os
import tempfile import tempfile
from subprocess import CalledProcessError, check_call from subprocess import CalledProcessError, check_call
from six import u
from topydo.lib.Config import config from topydo.lib.Config import config
from topydo.lib.MultiCommand import MultiCommand from topydo.lib.MultiCommand import MultiCommand
from topydo.lib.prettyprinters.Numbers import PrettyPrinterNumbers from topydo.lib.prettyprinters.Numbers import PrettyPrinterNumbers
...@@ -97,7 +95,7 @@ class EditCommand(MultiCommand): ...@@ -97,7 +95,7 @@ class EditCommand(MultiCommand):
if len(self.invalid_numbers) > 1 or len(self.invalid_numbers) > 0 and len(self.todos) > 0: if len(self.invalid_numbers) > 1 or len(self.invalid_numbers) > 0 and len(self.todos) > 0:
for number in self.invalid_numbers: for number in self.invalid_numbers:
errors.append(u("Invalid todo number given: {}.").format(number)) errors.append(u"Invalid todo number given: {}.".format(number))
elif len(self.invalid_numbers) == 1 and len(self.todos) == 0: elif len(self.invalid_numbers) == 1 and len(self.todos) == 0:
errors.append("Invalid todo number given.") errors.append("Invalid todo number given.")
......
...@@ -14,16 +14,10 @@ ...@@ -14,16 +14,10 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import configparser
import os import os
import shlex import shlex
from six import iteritems, PY2
from six.moves import configparser
if PY2:
import ushlex as shlex
import codecs
class ConfigError(Exception): class ConfigError(Exception):
def __init__(self, p_text): def __init__(self, p_text):
self.text = p_text self.text = p_text
...@@ -121,7 +115,7 @@ class _Config: ...@@ -121,7 +115,7 @@ class _Config:
for section in self.defaults: for section in self.defaults:
self.cp.add_section(section) self.cp.add_section(section)
for option, value in iteritems(self.defaults[section]): for option, value in self.defaults[section].items():
self.cp.set(section, option, value) self.cp.set(section, option, value)
files = [ files = [
...@@ -137,16 +131,7 @@ class _Config: ...@@ -137,16 +131,7 @@ class _Config:
if p_path is not None: if p_path is not None:
files = [p_path] files = [p_path]
if PY2: self.cp.read(files)
for path in files:
try:
with codecs.open(path, 'r', encoding='utf-8') as f:
self.cp.readfp(f)
except IOError:
pass
else:
self.cp.read(files)
self._supplement_sections() self._supplement_sections()
if p_overrides: if p_overrides:
......
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
import arrow import arrow
import re import re
from six import u
from topydo.lib.Config import config from topydo.lib.Config import config
from topydo.lib.Colorblock import color_block from topydo.lib.Colorblock import color_block
from topydo.lib.Utils import get_terminal_size, escape_ansi from topydo.lib.Utils import get_terminal_size, escape_ansi
...@@ -163,13 +161,13 @@ class ListFormatParser(object): ...@@ -163,13 +161,13 @@ class ListFormatParser(object):
# 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)
for tag, value in sorted(t.tags()) if for tag, value in sorted(t.tags()) if
tag not in config().hidden_tags() + tag not in config().hidden_tags() +
[config().tag_start(), config().tag_due()]]), [config().tag_start(), config().tag_due()]]),
# list of all tags (spaces) # list of all tags (spaces)
'K': lambda t: ' '.join([u('{}:{}').format(tag, value) 'K': lambda t: ' '.join([u'{}:{}'.format(tag, value)
for tag, value in sorted(t.tags())]), for tag, value in sorted(t.tags())]),
# priority # priority
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from six import u
from topydo.lib.ExpressionCommand import ExpressionCommand from topydo.lib.ExpressionCommand import ExpressionCommand
from topydo.lib.TodoListBase import InvalidTodoException from topydo.lib.TodoListBase import InvalidTodoException
...@@ -90,7 +88,7 @@ class MultiCommand(ExpressionCommand): ...@@ -90,7 +88,7 @@ class MultiCommand(ExpressionCommand):
if len(self.invalid_numbers) > 1 or len(self.invalid_numbers) > 0 and len(self.todos) > 0: if len(self.invalid_numbers) > 1 or len(self.invalid_numbers) > 0 and len(self.todos) > 0:
for number in self.invalid_numbers: for number in self.invalid_numbers:
errors.append(u("Invalid todo number given: {}.").format(number)) errors.append(u"Invalid todo number given: {}.".format(number))
elif len(self.invalid_numbers) == 1 and len(self.todos) == 0: elif len(self.invalid_numbers) == 1 and len(self.todos) == 0:
errors.append("Invalid todo number given.") errors.append("Invalid todo number given.")
elif len(self.todos) == 0 and len(self.invalid_numbers) == 0: elif len(self.todos) == 0 and len(self.invalid_numbers) == 0:
......
...@@ -21,8 +21,6 @@ This module contains the class that represents a single todo item. ...@@ -21,8 +21,6 @@ This module contains the class that represents a single todo item.
import re import re
from datetime import date from datetime import date
from six import u
from topydo.lib.TodoParser import parse_line from topydo.lib.TodoParser import parse_line
from topydo.lib.Utils import is_valid_priority from topydo.lib.Utils import is_valid_priority
...@@ -218,7 +216,7 @@ class TodoBase(object): ...@@ -218,7 +216,7 @@ class TodoBase(object):
self.src = re.sub( self.src = re.sub(
r'^(x \d{4}-\d{2}-\d{2} |\([A-Z]\) )?(\d{4}-\d{2}-\d{2} )?(.*)$', r'^(x \d{4}-\d{2}-\d{2} |\([A-Z]\) )?(\d{4}-\d{2}-\d{2} )?(.*)$',
lambda m: lambda m:
u("{}{} {}").format(m.group(1) or '', p_date.isoformat(), u"{}{} {}".format(m.group(1) or '', p_date.isoformat(),
m.group(3)), self.src) m.group(3)), self.src)
def creation_date(self): def creation_date(self):
......
...@@ -21,8 +21,6 @@ A list of todo items. ...@@ -21,8 +21,6 @@ A list of todo items.
import re import re
from datetime import date from datetime import date
from six import text_type
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
...@@ -128,7 +126,7 @@ class TodoListBase(object): ...@@ -128,7 +126,7 @@ class TodoListBase(object):
if not result: if not result:
# convert integer to text so we pass on a valid regex # convert integer to text so we pass on a valid regex
result = todo_by_regexp(text_type(p_identifier)) result = todo_by_regexp(str(p_identifier))
return result return result
......
...@@ -59,10 +59,7 @@ def get_terminal_size(): ...@@ -59,10 +59,7 @@ def get_terminal_size():
Try to determine terminal size at run time. If that is not possible, Try to determine terminal size at run time. If that is not possible,
returns the default size of 80x24. returns the default size of 80x24.
""" """
try: from shutil import get_terminal_size # pylint: disable=no-name-in-module
from shutil import get_terminal_size # pylint: disable=no-name-in-module
except ImportError:
from backports.shutil_get_terminal_size import get_terminal_size
try: try:
sz = get_terminal_size() sz = get_terminal_size()
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
""" Provides a pretty printer filter that inserts todo numbers. """ """ Provides a pretty printer filter that inserts todo numbers. """
from six import u
from topydo.lib.PrettyPrinterFilter import PrettyPrinterFilter from topydo.lib.PrettyPrinterFilter import PrettyPrinterFilter
...@@ -30,5 +28,5 @@ class PrettyPrinterNumbers(PrettyPrinterFilter): ...@@ -30,5 +28,5 @@ class PrettyPrinterNumbers(PrettyPrinterFilter):
def filter(self, p_todo_str, p_todo): def filter(self, p_todo_str, p_todo):
""" Prepends the number to the todo string. """ """ Prepends the number to the todo string. """
return u("|{:>3}| {}").format(self.todolist.number(p_todo), p_todo_str) return "|{:>3}| {}".format(self.todolist.number(p_todo), p_todo_str)
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