Upgrade Python syntax with pyupgrade --py3-plus

This commit is contained in:
Hugo
2019-10-19 19:25:34 +03:00
parent c9027b446c
commit 7347d07624
9 changed files with 22 additions and 23 deletions
+6 -7
View File
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Tablib documentation build configuration file, created by
# sphinx-quickstart on Tue Oct 5 15:25:21 2010.
@@ -38,8 +37,8 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
project = u'Tablib'
copyright = u'2019 Jazzband'
project = 'Tablib'
copyright = '2019 Jazzband'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -181,8 +180,8 @@ htmlhelp_basename = 'Tablibdoc'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'Tablib.tex', u'Tablib Documentation',
u'Jazzband', 'manual'),
('index', 'Tablib.tex', 'Tablib Documentation',
'Jazzband', 'manual'),
]
latex_use_modindex = False
@@ -222,6 +221,6 @@ latex_use_parts = True
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'tablib', u'Tablib Documentation',
[u'Jazzband'], 1)
('index', 'tablib', 'Tablib Documentation',
['Jazzband'], 1)
]
+5 -5
View File
@@ -264,7 +264,7 @@ class Dataset:
else:
is_valid = (len(col) == self.height) if self.height else True
else:
is_valid = all((len(x) == self.width for x in self._data))
is_valid = all(len(x) == self.width for x in self._data)
if is_valid:
return True
@@ -423,7 +423,7 @@ class Dataset:
export_set, import_set = self._formats.get(format, (None, None))
if not import_set:
raise UnsupportedFormat('Format {0} cannot be imported.'.format(format))
raise UnsupportedFormat('Format {} cannot be imported.'.format(format))
import_set(self, in_stream, **kwargs)
return self
@@ -436,7 +436,7 @@ class Dataset:
"""
export_set, import_set = self._formats.get(format, (None, None))
if not export_set:
raise UnsupportedFormat('Format {0} cannot be exported.'.format(format))
raise UnsupportedFormat('Format {} cannot be exported.'.format(format))
return export_set(self, **kwargs)
@@ -1095,7 +1095,7 @@ class Databook:
export_book, import_book = self._formats.get(format, (None, None))
if not import_book:
raise UnsupportedFormat('Format {0} cannot be loaded.'.format(format))
raise UnsupportedFormat('Format {} cannot be loaded.'.format(format))
import_book(self, in_stream, **kwargs)
return self
@@ -1108,7 +1108,7 @@ class Databook:
"""
export_book, import_book = self._formats.get(format, (None, None))
if not export_book:
raise UnsupportedFormat('Format {0} cannot be exported.'.format(format))
raise UnsupportedFormat('Format {} cannot be exported.'.format(format))
return export_book(self, **kwargs)
+1 -1
View File
@@ -53,7 +53,7 @@ def export_book(databook):
for i, dset in enumerate(databook._datasets):
title = (dset.title if dset.title else 'Set %s' % (i))
wrapper.write('<%s>%s</%s>\n' % (BOOK_ENDINGS, title, BOOK_ENDINGS))
wrapper.write('<{}>{}</{}>\n'.format(BOOK_ENDINGS, title, BOOK_ENDINGS))
wrapper.write(dset.html)
wrapper.write('\n')
+4 -4
View File
@@ -19,7 +19,7 @@ def export_set(dataset):
header = _get_header(dataset.headers) if dataset.headers else ''
body = _get_body(dataset)
return '%s\n%s' % (header, body) if header else body
return '{}\n{}'.format(header, body) if header else body
def _get_body(dataset):
@@ -31,6 +31,6 @@ def _get_header(headers):
def _serialize_row(row, delimiter='|'):
return '%s%s%s' % (delimiter,
delimiter.join([str(item) if item else ' ' for item in row]),
delimiter)
return '{}{}{}'.format(delimiter,
delimiter.join([str(item) if item else ' ' for item in row]),
delimiter)
+1 -1
View File
@@ -34,7 +34,7 @@ def _max_word_len(text):
8
"""
return max((len(word) for word in text.split())) if text else 0
return max(len(word) for word in text.split()) if text else 0
def _get_column_string_lengths(dataset):
+1 -1
View File
@@ -112,7 +112,7 @@ def dset_sheet(dataset, ws, freeze_panes=True):
row_number = i + 1
for j, col in enumerate(row):
col_idx = get_column_letter(j + 1)
cell = ws['%s%s' % (col_idx, row_number)]
cell = ws['{}{}'.format(col_idx, row_number)]
# bold headers
if (row_number == 1) and dataset.headers:
+1 -1
View File
@@ -176,7 +176,7 @@ if __name__ == '__main__':
for i1 in range(len(dbft)):
rec = dbft[i1]
for fldName in dbft.fieldNames:
print('%s:\t %s' % (fldName, rec[fldName]))
print('{}:\t {}'.format(fldName, rec[fldName]))
print()
dbft.close()
+1 -1
View File
@@ -307,7 +307,7 @@ class DbfLogicalFieldDef(DbfFieldDef):
return False
if value in "YyTt":
return True
raise ValueError("[%s] Invalid logical value %r" % (self.name, value))
raise ValueError("[{}] Invalid logical value {!r}".format(self.name, value))
def encodeValue(self, value):
"""Return a character from the "TF?" set.
+2 -2
View File
@@ -1012,7 +1012,7 @@ class DBFTests(BaseTestCase):
for reg_char, data_char in zip(_dbf, data.dbf):
so_far += chr(data_char)
if reg_char != data_char and index not in [1, 2, 3]:
raise AssertionError('Failing at char %s: %s vs %s %s' % (
raise AssertionError('Failing at char {}: {} vs {} {}'.format(
index, reg_char, data_char, so_far))
index += 1
@@ -1055,7 +1055,7 @@ class DBFTests(BaseTestCase):
# found_so_far += chr(data_char)
if reg_char != data_char and index not in [1, 2, 3]:
raise AssertionError(
'Failing at char %s: %s vs %s (found %s)' % (
'Failing at char {}: {} vs {} (found {})'.format(
index, reg_char, data_char, found_so_far))
index += 1