Skip to content

Commit 61a0a40

Browse files
committed
code optimization
1 parent 90e5668 commit 61a0a40

File tree

7 files changed

+36
-22
lines changed

7 files changed

+36
-22
lines changed

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ Development steps for code changes
291291

292292
Upgrade your setup tools and pip. They are needed for development and testing only:
293293

294-
#. pip install --upgrade setuptools "pip==7.1"
294+
#. pip install --upgrade setuptools pip
295295

296296
Then install relevant development requirements:
297297

@@ -300,7 +300,7 @@ Then install relevant development requirements:
300300
#. pip install -r tests/requirements.txt
301301

302302

303-
In order to update test environment, and documentation, additional setps are
303+
In order to update test environment, and documentation, additional steps are
304304
required:
305305

306306
#. pip install moban
@@ -329,7 +329,7 @@ Although `nose` and `doctest` are both used in code testing, it is adviable that
329329

330330
On Linux/Unix systems, please launch your tests like this::
331331

332-
$ make test
332+
$ make
333333

334334
On Windows systems, please issue this command::
335335

docs/source/conf.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# -*- coding: utf-8 -*-
2+
DESCRIPTION = (
3+
'A wrapper library to read, manipulate and write data in ods format' +
4+
''
5+
)
26
extensions = [
37
'sphinx.ext.autodoc',
48
'sphinx.ext.doctest',
@@ -25,15 +29,19 @@
2529
htmlhelp_basename = 'pyexcel-ods3doc'
2630
latex_elements = {}
2731
latex_documents = [
28-
('index', 'pyexcel-ods3.tex', u'pyexcel-ods3 Documentation',
32+
('index', 'pyexcel-ods3.tex',
33+
'pyexcel-ods3 Documentation',
2934
'Onni Software Ltd.', 'manual'),
3035
]
3136
man_pages = [
32-
('index', 'pyexcel-ods3', u'pyexcel-ods3 Documentation',
37+
('index', 'pyexcel-ods3',
38+
'pyexcel-ods3 Documentation',
3339
[u'Onni Software Ltd.'], 1)
3440
]
3541
texinfo_documents = [
36-
('index', 'pyexcel-ods3', u'pyexcel-ods3 Documentation',
37-
'Onni Software Ltd.', 'pyexcel-ods3', 'One line description of project.',
42+
('index', 'pyexcel-ods3',
43+
'pyexcel-ods3 Documentation',
44+
'Onni Software Ltd.', 'pyexcel-ods3',
45+
DESCRIPTION,
3846
'Miscellaneous'),
3947
]

pyexcel_ods3/converter.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,17 @@ def time_value(value):
3737
"""convert to time value accroding the specification"""
3838
import re
3939
results = re.match('PT(\d+)H(\d+)M(\d+)S', value)
40-
hour = int(results.group(1))
41-
minute = int(results.group(2))
42-
second = int(results.group(3))
43-
if hour < 24:
44-
ret = datetime.time(hour, minute, second)
40+
if results:
41+
hour = int(results.group(1))
42+
minute = int(results.group(2))
43+
second = int(results.group(3))
44+
if hour < 24:
45+
ret = datetime.time(hour, minute, second)
46+
else:
47+
ret = datetime.timedelta(
48+
hours=hour, minutes=minute, seconds=second)
4549
else:
46-
ret = datetime.timedelta(hours=hour, minutes=minute, seconds=second)
50+
ret = None
4751
return ret
4852

4953

test.bat

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
2-
31
pip freeze
4-
nosetests --with-cov --cover-package pyexcel_ods3 --cover-package tests --with-doctest --doctest-extension=.rst tests README.rst docs/source pyexcel_ods3 && flake8 . --exclude=.moban.d --builtins=unicode,xrange,long
2+
nosetests --with-cov --cover-package pyexcel_ods3 --cover-package tests --with-doctest --doctest-extension=.rst README.rst tests docs/source pyexcel_ods3 && flake8 . --exclude=.moban.d --builtins=unicode,xrange,long

test.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
2-
31
pip freeze
4-
nosetests --with-cov --cover-package pyexcel_ods3 --cover-package tests --with-doctest --doctest-extension=.rst tests README.rst docs/source pyexcel_ods3 && flake8 . --exclude=.moban.d --builtins=unicode,xrange,long
2+
nosetests --with-cov --cover-package pyexcel_ods3 --cover-package tests --with-doctest --doctest-extension=.rst README.rst tests docs/source pyexcel_ods3 && flake8 . --exclude=.moban.d --builtins=unicode,xrange,long

tests/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import os
1+
import os # noqa
22
import pyexcel
3-
import datetime
4-
from nose.tools import raises, eq_
3+
import datetime # noqa
4+
from nose.tools import raises, eq_ # noqa
55

66

77
def create_sample_file1(file):

tests/test_bug_fixes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,9 @@ def test_issue_8():
8686
data = get_data(os.path.join("tests", "fixtures", test_file),
8787
skip_empty_rows=True)
8888
eq_(data['Sheet1'][0][0].days, 12)
89+
90+
91+
def test_issue_8_1():
92+
from pyexcel_ods3.converter import time_value
93+
result = time_value('PT1111')
94+
eq_(result, None)

0 commit comments

Comments
 (0)