Skip to content

Commit

Permalink
Merge f476636 into 3429c3d
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewshadura committed Sep 23, 2020
2 parents 3429c3d + f476636 commit 75c07af
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 62 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: python
python:
- 2.7
- 3.5
- 3.6
- 3.7
Expand Down
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ environment:
matrix:
# https://www.appveyor.com/docs/installed-software#python lists available
# versions
- PYTHON: "C:\\Python27"
- PYTHON: "C:\\Python35"
- PYTHON: "C:\\Python36"
- PYTHON: "C:\\Python37"
Expand Down
9 changes: 2 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ def read(filename):
])

tests_require = ['freezegun']
if sys.version_info < (3,):
# Python 2 doesn't have unittest.mock
tests_require.append('mock')
if sys.version_info < (3, 5, 0):
sys.exit("Python 3.5 is the minimum required version")

setup(
name='gtimelog',
Expand All @@ -64,7 +63,6 @@ def read(filename):
'Development Status :: 4 - Beta',
'Environment :: X11 Applications :: GTK',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
Expand All @@ -84,9 +82,6 @@ def read(filename):
'test': [
'freezegun',
],
'test:python_version == "2.7"': [
'mock',
],
},
zip_safe=False,
entry_points="""
Expand Down
2 changes: 0 additions & 2 deletions src/gtimelog/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""An application for keeping track of your time."""
from __future__ import print_function, absolute_import

import time
import sys

Expand Down
26 changes: 5 additions & 21 deletions src/gtimelog/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
import locale
import os

try:
from configparser import RawConfigParser
PY3 = True
except ImportError:
from ConfigParser import RawConfigParser
PY3 = False
from configparser import RawConfigParser


from gtimelog.timelog import parse_time
Expand Down Expand Up @@ -101,8 +96,8 @@ def _config(self):
config = RawConfigParser()
config.add_section('gtimelog')
config.set('gtimelog', 'list-email', self.email)
config.set('gtimelog', 'name', self.from_unicode(self.name))
config.set('gtimelog', 'sender', self.from_unicode(self.sender))
config.set('gtimelog', 'name', self.name)
config.set('gtimelog', 'sender', self.sender)
config.set('gtimelog', 'editor', self.editor)
config.set('gtimelog', 'mailer', self.mailer)
config.set('gtimelog', 'spreadsheet', self.spreadsheet)
Expand All @@ -126,25 +121,14 @@ def _config(self):
config.set('gtimelog', 'start_in_tray', str(self.start_in_tray))
return config

if PY3: # pragma: PY3
def to_unicode(self, value):
return value # ConfigParser already gives us unicode
def from_unicode(self, value):
return value # ConfigParser already accepts unicode
else: # pragma: PY2
def to_unicode(self, value):
return value.decode(self._encoding)
def from_unicode(self, value):
return value.encode(self._encoding)

def load(self, filename=None):
if filename is None:
filename = self.get_config_file()
config = self._config()
config.read([filename])
self.email = config.get('gtimelog', 'list-email')
self.name = self.to_unicode(config.get('gtimelog', 'name'))
self.sender = self.to_unicode(config.get('gtimelog', 'sender'))
self.name = config.get('gtimelog', 'name')
self.sender = config.get('gtimelog', 'sender')
self.editor = config.get('gtimelog', 'editor')
self.mailer = config.get('gtimelog', 'mailer')
self.spreadsheet = config.get('gtimelog', 'spreadsheet')
Expand Down
7 changes: 1 addition & 6 deletions src/gtimelog/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
import textwrap
import unittest

try:
# Python 3
from unittest import mock
except ImportError:
# Python 2
import mock
from unittest import mock


gi = mock.MagicMock()
Expand Down
12 changes: 2 additions & 10 deletions src/gtimelog/tests/test_timelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,10 @@
import time
import unittest
import sys
try:
from cStringIO import StringIO
except ImportError:
from io import StringIO
from io import StringIO

import freezegun
try:
# Python 3
from unittest import mock
except ImportError:
# Python 2
import mock
from unittest import mock

from gtimelog.timelog import (
TimeLog, Reports, ReportRecord, Exports, TaskList, TimeCollection,
Expand Down
14 changes: 2 additions & 12 deletions src/gtimelog/timelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
from operator import itemgetter


PY3 = sys.version_info[0] >= 3


def as_minutes(duration):
"""Convert a datetime.timedelta to an integer number of minutes."""
return duration.days * 24 * 60 + duration.seconds // 60
Expand Down Expand Up @@ -1134,15 +1131,8 @@ class CSVWriter(object):
def __init__(self, *args, **kw):
self._writer = csv.writer(*args, **kw)

if PY3: # pragma: PY3
def writerow(self, row):
self._writer.writerow(row)
else: # pragma: PY2
def writerow(self, row):
self._writer.writerow([
s.encode('UTF-8') if isinstance(s, unicode) else s # noqa: F821
for s in row
])
def writerow(self, row):
self._writer.writerow(row)

def writerows(self, rows):
for row in rows:
Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[tox]
envlist =
py27,py35,py36,py37,py38,pypy,pypy3,flake8
py35,py36,py37,py38,pypy,pypy3,flake8

[testenv]
setenv =
LC_ALL=C
deps =
freezegun
py27: mock
pypy: mock
skip_install = true
commands =
Expand Down

0 comments on commit 75c07af

Please sign in to comment.