Skip to content

Commit ba3d46a

Browse files
authored
Merge pull request #349 from OpenDataServices/black-isort
black-isort: Apply
2 parents da3f714 + a094fea commit ba3d46a

35 files changed

+5865
-4824
lines changed

.isort.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# From https://black.readthedocs.io/en/stable/the_black_code_style.html?highlight=isort#how-black-wraps-lines
2+
[settings]
3+
multi_line_output=3
4+
include_trailing_comma=True
5+
force_grid_wrap=0
6+
use_parentheses=True
7+
line_length=88

.travis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,11 @@ python:
88
- "3.8"
99
install:
1010
- pip install --upgrade -r requirements_dev.txt
11-
script: py.test --cov .
11+
# Black only runs under Python >= 3.6
12+
- if [[ $TRAVIS_PYTHON_VERSION != 3.5 ]]; then pip install black==19.10b0; fi
13+
script:
14+
- if [[ $TRAVIS_PYTHON_VERSION != 3.5 ]]; then black --check *.py */; fi
15+
- isort --check-only --recursive *.py */
16+
- flake8
17+
- py.test --cov .
1218
after_success: coveralls

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
10+
### Changed
11+
12+
- All code has had black and isort applied. These have been added to Travis.
13+
914
## [0.11.0] - 2020-02-21
1015

1116
### Added

docs/conf.py

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -33,42 +33,42 @@
3333
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3434
# ones.
3535
extensions = [
36-
'sphinx.ext.autodoc',
37-
'sphinx.ext.doctest',
38-
'sphinx.ext.todo',
39-
'sphinx.ext.coverage',
40-
'sphinx.ext.viewcode',
36+
"sphinx.ext.autodoc",
37+
"sphinx.ext.doctest",
38+
"sphinx.ext.todo",
39+
"sphinx.ext.coverage",
40+
"sphinx.ext.viewcode",
4141
]
4242

4343
# Add any paths that contain templates here, relative to this directory.
44-
templates_path = ['_templates']
44+
templates_path = ["_templates"]
4545

4646
# The suffix(es) of source filenames.
4747
# You can specify multiple suffix as a list of string:
4848
#
4949
# source_suffix = ['.rst', '.md']
50-
source_suffix = '.rst'
50+
source_suffix = ".rst"
5151

5252
# The encoding of source files.
5353
#
5454
# source_encoding = 'utf-8-sig'
5555

5656
# The master toctree document.
57-
master_doc = 'index'
57+
master_doc = "index"
5858

5959
# General information about the project.
60-
project = 'Flatten Tool'
61-
copyright = '2016-2020, Open Data Services'
62-
author = 'Open Data Services'
60+
project = "Flatten Tool"
61+
copyright = "2016-2020, Open Data Services"
62+
author = "Open Data Services"
6363

6464
# The version info for the project you're documenting, acts as replacement for
6565
# |version| and |release|, also used in various other places throughout the
6666
# built documents.
6767
#
6868
# The short X.Y version.
69-
version = '0.0.0'
69+
version = "0.0.0"
7070
# The full version, including alpha/beta/rc tags.
71-
release = '0.0.0'
71+
release = "0.0.0"
7272

7373
# The language for content autogenerated by Sphinx. Refer to documentation
7474
# for a list of supported languages.
@@ -89,7 +89,7 @@
8989
# List of patterns, relative to source directory, that match files and
9090
# directories to ignore when looking for source files.
9191
# This patterns also effect to html_static_path and html_extra_path
92-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
92+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
9393

9494
# The reST default role (used for this markup: `text`) to use for all
9595
# documents.
@@ -111,7 +111,7 @@
111111
# show_authors = False
112112

113113
# The name of the Pygments (syntax highlighting) style to use.
114-
pygments_style = 'sphinx'
114+
pygments_style = "sphinx"
115115

116116
# A list of ignored prefixes for module index sorting.
117117
# modindex_common_prefix = []
@@ -165,7 +165,7 @@
165165
# Add any paths that contain custom static files (such as style sheets) here,
166166
# relative to this directory. They are copied after the builtin static files,
167167
# so a file named "default.css" will overwrite the builtin "default.css".
168-
html_static_path = ['_static']
168+
html_static_path = ["_static"]
169169

170170
# Add any extra paths that contain custom files (such as robots.txt or
171171
# .htaccess) here, relative to this directory. These files are copied
@@ -245,34 +245,36 @@
245245
# html_search_scorer = 'scorer.js'
246246

247247
# Output file base name for HTML help builder.
248-
htmlhelp_basename = 'FlattenTooldoc'
248+
htmlhelp_basename = "FlattenTooldoc"
249249

250250
# -- Options for LaTeX output ---------------------------------------------
251251

252252
latex_elements = {
253-
# The paper size ('letterpaper' or 'a4paper').
254-
#
255-
# 'papersize': 'letterpaper',
256-
257-
# The font size ('10pt', '11pt' or '12pt').
258-
#
259-
# 'pointsize': '10pt',
260-
261-
# Additional stuff for the LaTeX preamble.
262-
#
263-
# 'preamble': '',
264-
265-
# Latex figure (float) alignment
266-
#
267-
# 'figure_align': 'htbp',
253+
# The paper size ('letterpaper' or 'a4paper').
254+
#
255+
# 'papersize': 'letterpaper',
256+
# The font size ('10pt', '11pt' or '12pt').
257+
#
258+
# 'pointsize': '10pt',
259+
# Additional stuff for the LaTeX preamble.
260+
#
261+
# 'preamble': '',
262+
# Latex figure (float) alignment
263+
#
264+
# 'figure_align': 'htbp',
268265
}
269266

270267
# Grouping the document tree into LaTeX files. List of tuples
271268
# (source start file, target name, title,
272269
# author, documentclass [howto, manual, or own class]).
273270
latex_documents = [
274-
(master_doc, 'FlattenTool.tex', 'Flatten Tool Documentation',
275-
'Open Data Services', 'manual'),
271+
(
272+
master_doc,
273+
"FlattenTool.tex",
274+
"Flatten Tool Documentation",
275+
"Open Data Services",
276+
"manual",
277+
),
276278
]
277279

278280
# The name of an image file (relative to this directory) to place at the top of
@@ -306,10 +308,7 @@
306308

307309
# One entry per manual page. List of tuples
308310
# (source start file, name, description, authors, manual section).
309-
man_pages = [
310-
(master_doc, 'flattentool', 'Flatten Tool Documentation',
311-
[author], 1)
312-
]
311+
man_pages = [(master_doc, "flattentool", "Flatten Tool Documentation", [author], 1)]
313312

314313
# If true, show URL addresses after external links.
315314
#
@@ -322,9 +321,15 @@
322321
# (source start file, target name, title, author,
323322
# dir menu entry, description, category)
324323
texinfo_documents = [
325-
(master_doc, 'FlattenTool', 'Flatten Tool Documentation',
326-
author, 'FlattenTool', 'One line description of project.',
327-
'Miscellaneous'),
324+
(
325+
master_doc,
326+
"FlattenTool",
327+
"Flatten Tool Documentation",
328+
author,
329+
"FlattenTool",
330+
"One line description of project.",
331+
"Miscellaneous",
332+
),
328333
]
329334

330335
# Documents to append as an appendix to all manuals.

flattentool/ODSReader.py

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
# Thanks to grt for the fixes
1616
# https://github.com/marcoconti83/read-ods-with-odfpy
1717

18-
import odf.opendocument
19-
from odf.table import Table, TableRow, TableCell
20-
from odf.text import P
21-
from collections import OrderedDict
2218
import re
19+
from collections import OrderedDict
20+
21+
import odf.opendocument
22+
from odf.table import Table, TableCell, TableRow
2323

2424

2525
# http://stackoverflow.com/a/4544699/1846474
2626
class GrowingList(list):
2727
def __setitem__(self, index, value):
2828
if index >= len(self):
29-
self.extend([None]*(index + 1 - len(self)))
29+
self.extend([None] * (index + 1 - len(self)))
3030
list.__setitem__(self, index, value)
3131

3232

@@ -49,7 +49,7 @@ def readSheet(self, sheet):
4949

5050
# for each row
5151
for row in rows:
52-
row_comment = ""
52+
row_comment = "" # noqa
5353
arrCells = GrowingList()
5454
cells = row.getElementsByType(TableCell)
5555

@@ -58,26 +58,38 @@ def readSheet(self, sheet):
5858
for cell in cells:
5959
# repeated value?
6060
repeat = cell.getAttribute("numbercolumnsrepeated")
61-
if(not repeat):
61+
if not repeat:
6262
repeat = 1
63-
spanned = int(cell.getAttribute('numbercolumnsspanned') or 0)
63+
spanned = int(cell.getAttribute("numbercolumnsspanned") or 0)
6464
# clone spanned cells
6565
if self.clonespannedcolumns is not None and spanned > 1:
6666
repeat = spanned
6767

6868
for rr in range(int(repeat)): # repeated?
6969
if str(cell):
70-
value_type = cell.attributes.get(('urn:oasis:names:tc:opendocument:xmlns:office:1.0', 'value-type'))
71-
if value_type == 'float':
72-
if '.' in str(cell):
70+
value_type = cell.attributes.get(
71+
(
72+
"urn:oasis:names:tc:opendocument:xmlns:office:1.0",
73+
"value-type",
74+
)
75+
)
76+
if value_type == "float":
77+
if "." in str(cell):
7378
arrCells[count] = float(str(cell))
7479
else:
7580
arrCells[count] = int(str(cell))
76-
elif value_type == 'date':
77-
date_value = cell.attributes.get(('urn:oasis:names:tc:opendocument:xmlns:office:1.0', 'date-value'))
81+
elif value_type == "date":
82+
date_value = cell.attributes.get(
83+
(
84+
"urn:oasis:names:tc:opendocument:xmlns:office:1.0",
85+
"date-value",
86+
)
87+
)
7888
# Add UTC timezone to naive datetime strings
79-
if re.match(r'^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d$', date_value):
80-
date_value += 'Z'
89+
if re.match(
90+
r"^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d$", date_value
91+
):
92+
date_value += "Z"
8193
arrCells[count] = date_value
8294
else:
8395
arrCells[count] = str(cell)

0 commit comments

Comments
 (0)