Skip to content

Commit 37f968c

Browse files
committed
Merge branch 'develop'
2 parents 6ca695b + 670836f commit 37f968c

8 files changed

Lines changed: 66 additions & 66 deletions

File tree

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ env:
1212
- TASK_VERSION=v2.5.0
1313
- TASK_VERSION=v2.5.1
1414
python:
15-
- "2.7"
16-
- "3.4"
1715
- "3.5"
1816
- "3.6"
1917
- "3.7"

setup.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from setuptools import setup, find_packages
22

3-
install_requirements = ['six>=1.4', 'pytz', 'tzlocal']
3+
install_requirements = ['pytz', 'tzlocal']
44

5-
version = '1.3.0'
5+
version = '2.1.0'
66

77
try:
88
import importlib
@@ -26,12 +26,11 @@
2626
classifiers=[
2727
'Development Status :: 4 - Beta',
2828
'Programming Language :: Python',
29-
"Programming Language :: Python :: 2",
30-
"Programming Language :: Python :: 2.6",
31-
"Programming Language :: Python :: 2.7",
3229
"Programming Language :: Python :: 3",
33-
"Programming Language :: Python :: 3.2",
34-
"Programming Language :: Python :: 3.3",
30+
"Programming Language :: Python :: 3.5",
31+
"Programming Language :: Python :: 3.6",
32+
"Programming Language :: Python :: 3.7",
33+
"Programming Language :: Python :: 3.8",
3534
'License :: OSI Approved :: BSD License',
3635
'Topic :: Software Development :: Libraries :: Python Modules',
3736
'Intended Audience :: Developers',

tasklib/backends.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import logging
66
import os
77
import re
8-
import six
98
import subprocess
9+
from functools import lru_cache
1010

1111
from .task import Task, TaskQuerySet, ReadOnlyDictView
1212
from .filters import TaskWarriorFilter
@@ -84,15 +84,15 @@ class TaskWarriorException(Exception):
8484

8585
class TaskWarrior(Backend):
8686

87-
VERSION_2_1_0 = six.u('2.1.0')
88-
VERSION_2_2_0 = six.u('2.2.0')
89-
VERSION_2_3_0 = six.u('2.3.0')
90-
VERSION_2_4_0 = six.u('2.4.0')
91-
VERSION_2_4_1 = six.u('2.4.1')
92-
VERSION_2_4_2 = six.u('2.4.2')
93-
VERSION_2_4_3 = six.u('2.4.3')
94-
VERSION_2_4_4 = six.u('2.4.4')
95-
VERSION_2_4_5 = six.u('2.4.5')
87+
VERSION_2_1_0 = '2.1.0'
88+
VERSION_2_2_0 = '2.2.0'
89+
VERSION_2_3_0 = '2.3.0'
90+
VERSION_2_4_0 = '2.4.0'
91+
VERSION_2_4_1 = '2.4.1'
92+
VERSION_2_4_2 = '2.4.2'
93+
VERSION_2_4_3 = '2.4.3'
94+
VERSION_2_4_4 = '2.4.4'
95+
VERSION_2_4_5 = '2.4.5'
9696

9797
def __init__(self, data_location=None, create=True,
9898
taskrc_location=None, task_command='task',
@@ -142,8 +142,8 @@ def _get_command_args(self, args, config_override=None):
142142
for item in overrides.items():
143143
command_args.append('rc.{0}={1}'.format(*item))
144144
command_args.extend([
145-
x.decode('utf-8') if isinstance(x, six.binary_type)
146-
else six.text_type(x) for x in args
145+
x.decode('utf-8') if isinstance(x, bytes)
146+
else str(x) for x in args
147147
])
148148
return command_args
149149

@@ -168,10 +168,10 @@ def add_field(field):
168168
if serialized_value == '':
169169
escaped_serialized_value = ''
170170
else:
171-
escaped_serialized_value = six.u("'{0}'").format(
171+
escaped_serialized_value = "'{0}'".format(
172172
serialized_value)
173173

174-
format_default = lambda task: six.u("{0}:{1}").format(
174+
format_default = lambda task: "{0}:{1}".format(
175175
field, escaped_serialized_value)
176176

177177
format_func = getattr(self, 'format_{0}'.format(field),
@@ -223,7 +223,7 @@ def format_description(self, task):
223223
if self.version < self.VERSION_2_4_0:
224224
return task._data['description']
225225
else:
226-
return six.u("description:'{0}'").format(
226+
return "description:'{0}'".format(
227227
task._data['description'] or '',
228228
)
229229

@@ -321,6 +321,10 @@ def merge_with(self, path, push=False):
321321
def undo(self):
322322
self.execute_command(['undo'])
323323

324+
@lru_cache(maxsize=128)
325+
def get_task(self, uuid):
326+
return self.tasks.get(uuid=uuid)
327+
324328
# Backend interface implementation
325329

326330
def filter_tasks(self, filter_obj):

tasklib/filters.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import abc
2-
import six
32
from .serializing import SerializingObject
43

54

@@ -68,7 +67,7 @@ def add_filter_param(self, key, value):
6867
modifier = '.is' if value else '.none'
6968
key = key + modifier if '.' not in key else key
7069

71-
self.filter_params.append(six.u("{0}:{1}").format(key, value))
70+
self.filter_params.append("{0}:{1}".format(key, value))
7271

7372
def get_filter_params(self):
7473
return [f for f in self.filter_params if f]

tasklib/lazy.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ def replace(self):
7171
Performs conversion to the regular Task object, referenced by the
7272
stored UUID.
7373
"""
74-
75-
replacement = self._tw.tasks.get(uuid=self._uuid)
74+
replacement = self._tw.get_task(self._uuid)
7675
self.__class__ = replacement.__class__
7776
self.__dict__ = replacement.__dict__
7877

tasklib/serializing.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import importlib
33
import json
44
import pytz
5-
import six
65
import tzlocal
76

87

@@ -177,7 +176,7 @@ def serialize_tags(self, tags):
177176
return ','.join(tags) if tags else ''
178177

179178
def deserialize_tags(self, tags):
180-
if isinstance(tags, six.string_types):
179+
if isinstance(tags, str):
181180
return set(tags.split(',')) if tags else set()
182181
return set(tags or [])
183182

@@ -236,7 +235,7 @@ def datetime_normalizer(self, value):
236235
# If the value is already localized, there is no need to change
237236
# time zone at this point. Also None is a valid value too.
238237
localized = value
239-
elif isinstance(value, six.string_types):
238+
elif isinstance(value, str):
240239
localized = self.backend.convert_datetime_string(value)
241240
else:
242241
raise ValueError("Provided value could not be converted to "
@@ -247,7 +246,7 @@ def datetime_normalizer(self, value):
247246

248247
def normalize_uuid(self, value):
249248
# Enforce sane UUID
250-
if not isinstance(value, six.string_types) or value == '':
249+
if not isinstance(value, str) or value == '':
251250
raise ValueError("UUID must be a valid non-empty string, "
252251
"not: {}".format(value))
253252

tasklib/task.py

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import json
55
import logging
66
import os
7-
import six
87
import sys
98

109
from .serializing import SerializingObject
@@ -41,10 +40,10 @@ def __iter__(self):
4140
def __len__(self):
4241
return len(self.viewed_dict)
4342

44-
def __unicode__(self):
45-
return six.u('ReadOnlyDictView: {0}'.format(repr(self.viewed_dict)))
43+
def __str__(self):
44+
return 'ReadOnlyDictView: {0}'.format(repr(self.viewed_dict))
4645

47-
__repr__ = __unicode__
46+
__repr__ = __str__
4847

4948
def get(self, key, default=None):
5049
return copy.deepcopy(self.viewed_dict.get(key, default))
@@ -106,10 +105,7 @@ def __setitem__(self, key, value):
106105
self._data[key] = value
107106

108107
def __str__(self):
109-
s = six.text_type(self.__unicode__())
110-
if not six.PY3:
111-
s = s.encode('utf-8')
112-
return s
108+
return str(self['description'])
113109

114110
def __repr__(self):
115111
return str(self)
@@ -121,7 +117,7 @@ def export_data(self):
121117

122118
# We need to remove spaces for TW-1504, use custom separators
123119
data_tuples = ((key, self._serialize(key, value))
124-
for key, value in six.iteritems(self._data))
120+
for key, value in self._data.items())
125121

126122
# Empty string denotes empty serialized value, we do not want
127123
# to pass that to TaskWarrior.
@@ -160,9 +156,6 @@ def __init__(self, task, data=None):
160156
def remove(self):
161157
self.task.remove_annotation(self)
162158

163-
def __unicode__(self):
164-
return self['description']
165-
166159
def __eq__(self, other):
167160
# consider 2 annotations equal if they belong to the same task, and
168161
# their data dics are the same
@@ -171,8 +164,6 @@ def __eq__(self, other):
171164
def __ne__(self, other):
172165
return not self.__eq__(other)
173166

174-
__repr__ = __unicode__
175-
176167

177168
class Task(TaskResource):
178169
read_only_fields = ['id', 'entry', 'urgency', 'uuid', 'modified']
@@ -266,14 +257,14 @@ def __init__(self, backend, **kwargs):
266257

267258
# Rather unfortunate syntax due to python2.6 comaptiblity
268259
self._data = dict((key, self._normalize(key, value))
269-
for (key, value) in six.iteritems(kwargs))
260+
for (key, value) in kwargs.items())
270261
self._original_data = copy.deepcopy(self._data)
271262

272263
# Provide read only access to the original data
273264
self.original = ReadOnlyDictView(self._original_data)
274265

275-
def __unicode__(self):
276-
return self['description']
266+
def __str__(self):
267+
return str(self['description'])
277268

278269
def __eq__(self, other):
279270
if self['uuid'] and other['uuid']:
@@ -296,23 +287,23 @@ def __hash__(self):
296287

297288
@property
298289
def completed(self):
299-
return self['status'] == six.text_type('completed')
290+
return self['status'] == 'completed'
300291

301292
@property
302293
def deleted(self):
303-
return self['status'] == six.text_type('deleted')
294+
return self['status'] == 'deleted'
304295

305296
@property
306297
def waiting(self):
307-
return self['status'] == six.text_type('waiting')
298+
return self['status'] == 'waiting'
308299

309300
@property
310301
def pending(self):
311-
return self['status'] == six.text_type('pending')
302+
return self['status'] == 'pending'
312303

313304
@property
314305
def recurring(self):
315-
return self['status'] == six.text_type('recurring')
306+
return self['status'] == 'recurring'
316307

317308
@property
318309
def active(self):

0 commit comments

Comments
 (0)