Skip to content

Commit 71b15b4

Browse files
committed
Fix flake8 warning E124
Appears as: E124 closing bracket does not match visual indentation
1 parent 0ae22a9 commit 71b15b4

File tree

7 files changed

+89
-78
lines changed

7 files changed

+89
-78
lines changed

scripts/runxlrd.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,14 +327,15 @@ def main(cmd_args):
327327
PSYCO = 0
328328
try:
329329
t0 = time.time()
330-
bk = xlrd.open_workbook(fname,
330+
bk = xlrd.open_workbook(
331+
fname,
331332
verbosity=options.verbosity, logfile=logfile,
332333
use_mmap=mmap_arg,
333334
encoding_override=options.encoding,
334335
formatting_info=fmt_opt,
335336
on_demand=options.on_demand,
336337
ragged_rows=options.ragged_rows,
337-
)
338+
)
338339
t1 = time.time()
339340
if not options.suppress_timing:
340341
print("Open took %.2f seconds" % (t1-t0,))

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ universal = 1
33

44
[flake8]
55
ignore =
6-
E124,E125,E126,E128,
6+
E125,E126,E128,
77
E201,E202,E203,E221,E222,E225,E226,E231,E241,E251,E261,E262,E266,E271,E272,
88
E301,E302,E303,E305,
99
E501,

xlrd/__init__.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,14 @@
3030
USE_MMAP = MMAP_AVAILABLE
3131

3232
def open_workbook(filename=None,
33-
logfile=sys.stdout,
34-
verbosity=0,
35-
use_mmap=USE_MMAP,
36-
file_contents=None,
37-
encoding_override=None,
38-
formatting_info=False,
39-
on_demand=False,
40-
ragged_rows=False,
41-
):
33+
logfile=sys.stdout,
34+
verbosity=0,
35+
use_mmap=USE_MMAP,
36+
file_contents=None,
37+
encoding_override=None,
38+
formatting_info=False,
39+
on_demand=False,
40+
ragged_rows=False):
4241
"""
4342
Open a spreadsheet file for data extraction.
4443

xlrd/book.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,10 @@
6363
del _bin, _bic, _code_from_builtin_name
6464

6565
def open_workbook_xls(filename=None,
66-
logfile=sys.stdout, verbosity=0, use_mmap=USE_MMAP,
67-
file_contents=None,
68-
encoding_override=None,
69-
formatting_info=False, on_demand=False, ragged_rows=False,
70-
):
66+
logfile=sys.stdout, verbosity=0, use_mmap=USE_MMAP,
67+
file_contents=None,
68+
encoding_override=None,
69+
formatting_info=False, on_demand=False, ragged_rows=False):
7170
t0 = time.clock()
7271
if TOGGLE_GC:
7372
orig_gc_enabled = gc.isenabled()
@@ -116,11 +115,12 @@ def open_workbook_xls(filename=None,
116115
bk.get_sheets()
117116
bk.nsheets = len(bk._sheet_list)
118117
if biff_version == 45 and bk.nsheets > 1:
119-
fprintf(bk.logfile,
118+
fprintf(
119+
bk.logfile,
120120
"*** WARNING: Excel 4.0 workbook (.XLW) file contains %d worksheets.\n"
121121
"*** Book-level data will be that of the last worksheet.\n",
122122
bk.nsheets
123-
)
123+
)
124124
if TOGGLE_GC:
125125
if orig_gc_enabled:
126126
gc.enable()
@@ -227,10 +227,11 @@ def cell(self):
227227
ref3d.colxlo == ref3d.colxhi - 1):
228228
sh = self.book.sheet_by_index(ref3d.shtxlo)
229229
return sh.cell(ref3d.rowxlo, ref3d.colxlo)
230-
self.dump(self.book.logfile,
230+
self.dump(
231+
self.book.logfile,
231232
header="=== Dump of Name object ===",
232233
footer="======= End of dump =======",
233-
)
234+
)
234235
raise XLRDError("Not a constant absolute reference to a single cell")
235236

236237
def area2d(self, clipped=True):
@@ -269,10 +270,11 @@ def area2d(self, clipped=True):
269270
assert 0 <= rowxlo <= rowxhi <= sh.nrows
270271
assert 0 <= colxlo <= colxhi <= sh.ncols
271272
return sh, rowxlo, rowxhi, colxlo, colxhi
272-
self.dump(self.book.logfile,
273+
self.dump(
274+
self.book.logfile,
273275
header="=== Dump of Name object ===",
274276
footer="======= End of dump =======",
275-
)
277+
)
276278
raise XLRDError("Not a constant absolute reference to a single area in a single sheet")
277279

278280

@@ -586,12 +588,11 @@ def __init__(self):
586588
self.filestr = b''
587589

588590
def biff2_8_load(self, filename=None, file_contents=None,
589-
logfile=sys.stdout, verbosity=0, use_mmap=USE_MMAP,
590-
encoding_override=None,
591-
formatting_info=False,
592-
on_demand=False,
593-
ragged_rows=False,
594-
):
591+
logfile=sys.stdout, verbosity=0, use_mmap=USE_MMAP,
592+
encoding_override=None,
593+
formatting_info=False,
594+
on_demand=False,
595+
ragged_rows=False):
595596
# DEBUG = 0
596597
self.logfile = logfile
597598
self.verbosity = verbosity
@@ -699,11 +700,12 @@ def get_sheet(self, sh_number, update_pos=True):
699700
# It appears to work OK if the sheet version is ignored.
700701
# Confirmed by Daniel Rentz: happens when Excel does "save as"
701702
# creating an old version file; ignore version details on sheet BOF.
702-
sh = sheet.Sheet(self,
703-
self._position,
704-
self._sheet_names[sh_number],
705-
sh_number,
706-
)
703+
sh = sheet.Sheet(
704+
self,
705+
self._position,
706+
self._sheet_names[sh_number],
707+
sh_number,
708+
)
707709
sh.read(self)
708710
self._sheet_list[sh_number] = sh
709711
return sh

xlrd/formatting.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -717,9 +717,10 @@ def handle_xf(self, data):
717717
fill_in_standard_formats(self)
718718
if bv >= 80:
719719
unpack_fmt = '<HHHBBBBIiH'
720-
(xf.font_index, xf.format_key, pkd_type_par,
721-
pkd_align1, xf.alignment.rotation, pkd_align2,
722-
pkd_used, pkd_brdbkg1, pkd_brdbkg2, pkd_brdbkg3,
720+
(
721+
xf.font_index, xf.format_key, pkd_type_par,
722+
pkd_align1, xf.alignment.rotation, pkd_align2,
723+
pkd_used, pkd_brdbkg1, pkd_brdbkg2, pkd_brdbkg3,
723724
) = unpack(unpack_fmt, data[0:20])
724725
upkbits(xf.protection, pkd_type_par, (
725726
(0, 0x01, 'cell_locked'),
@@ -774,9 +775,10 @@ def handle_xf(self, data):
774775
))
775776
elif bv >= 50:
776777
unpack_fmt = '<HHHBBIi'
777-
(xf.font_index, xf.format_key, pkd_type_par,
778-
pkd_align1, pkd_orient_used,
779-
pkd_brdbkg1, pkd_brdbkg2,
778+
(
779+
xf.font_index, xf.format_key, pkd_type_par,
780+
pkd_align1, pkd_orient_used,
781+
pkd_brdbkg1, pkd_brdbkg2,
780782
) = unpack(unpack_fmt, data[0:16])
781783
upkbits(xf.protection, pkd_type_par, (
782784
(0, 0x01, 'cell_locked'),
@@ -819,9 +821,10 @@ def handle_xf(self, data):
819821
))
820822
elif bv >= 40:
821823
unpack_fmt = '<BBHBBHI'
822-
(xf.font_index, xf.format_key, pkd_type_par,
823-
pkd_align_orient, pkd_used,
824-
pkd_bkg_34, pkd_brd_34,
824+
(
825+
xf.font_index, xf.format_key, pkd_type_par,
826+
pkd_align_orient, pkd_used,
827+
pkd_bkg_34, pkd_brd_34,
825828
) = unpack(unpack_fmt, data[0:12])
826829
upkbits(xf.protection, pkd_type_par, (
827830
(0, 0x01, 'cell_locked'),
@@ -862,9 +865,10 @@ def handle_xf(self, data):
862865
))
863866
elif bv == 30:
864867
unpack_fmt = '<BBBBHHI'
865-
(xf.font_index, xf.format_key, pkd_type_prot,
866-
pkd_used, pkd_align_par,
867-
pkd_bkg_34, pkd_brd_34,
868+
(
869+
xf.font_index, xf.format_key, pkd_type_prot,
870+
pkd_used, pkd_align_par,
871+
pkd_bkg_34, pkd_brd_34,
868872
) = unpack(unpack_fmt, data[0:12])
869873
upkbits(xf.protection, pkd_type_prot, (
870874
(0, 0x01, 'cell_locked'),

xlrd/sheet.py

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -575,10 +575,11 @@ def col_types(self, colx, start_rowx=0, end_rowx=None):
575575

576576
def tidy_dimensions(self):
577577
if self.verbosity >= 3:
578-
fprintf(self.logfile,
578+
fprintf(
579+
self.logfile,
579580
"tidy_dimensions: nrows=%d ncols=%d \n",
580581
self.nrows, self.ncols,
581-
)
582+
)
582583
if 1 and self.merged_cells:
583584
nr = nc = 0
584585
umaxrows = self.utter_max_rows
@@ -601,15 +602,16 @@ def tidy_dimensions(self):
601602
self.put_cell(nr-1, 0, XL_CELL_EMPTY, UNICODE_LITERAL(''), -1)
602603
if (self.verbosity >= 1 and
603604
(self.nrows != self._dimnrows or self.ncols != self._dimncols)):
604-
fprintf(self.logfile,
605+
fprintf(
606+
self.logfile,
605607
"NOTE *** sheet %d (%r): DIMENSIONS R,C = %d,%d should be %d,%d\n",
606608
self.number,
607609
self.name,
608610
self._dimnrows,
609611
self._dimncols,
610612
self.nrows,
611613
self.ncols,
612-
)
614+
)
613615
if not self.ragged_rows:
614616
# fix ragged rows
615617
ncols = self.ncols
@@ -1077,10 +1079,11 @@ def read(self, bk):
10771079
if bv in (21, 30, 40) and self.book.xf_list and not self.book._xf_epilogue_done:
10781080
self.book.xf_epilogue()
10791081
if blah:
1080-
fprintf(self.logfile,
1082+
fprintf(
1083+
self.logfile,
10811084
"sheet %d(%r) DIMENSIONS: ncols=%d nrows=%d\n",
10821085
self.number, self.name, self._dimncols, self._dimnrows
1083-
)
1086+
)
10841087
elif rc == XL_HLINK:
10851088
self.handle_hlink(data)
10861089
elif rc == XL_QUICKTIP:
@@ -1146,39 +1149,42 @@ def read(self, bk):
11461149
num_CFs, needs_recalc, browx1, browx2, bcolx1, bcolx2 = \
11471150
unpack("<6H", data[0:12])
11481151
if self.verbosity >= 1:
1149-
fprintf(self.logfile,
1152+
fprintf(
1153+
self.logfile,
11501154
"\n*** WARNING: Ignoring CONDFMT (conditional formatting) record\n"
11511155
"*** in Sheet %d (%r).\n"
11521156
"*** %d CF record(s); needs_recalc_or_redraw = %d\n"
11531157
"*** Bounding box is %s\n",
11541158
self.number, self.name, num_CFs, needs_recalc,
11551159
rangename2d(browx1, browx2+1, bcolx1, bcolx2+1),
1156-
)
1160+
)
11571161
olist = [] # updated by the function
11581162
pos = unpack_cell_range_address_list_update_pos(
11591163
olist, data, 12, bv, addr_size=8)
11601164
# print >> self.logfile, repr(result), len(result)
11611165
if self.verbosity >= 1:
1162-
fprintf(self.logfile,
1166+
fprintf(
1167+
self.logfile,
11631168
"*** %d individual range(s):\n"
11641169
"*** %s\n",
11651170
len(olist),
11661171
", ".join(rangename2d(*coords) for coords in olist),
1167-
)
1172+
)
11681173
elif rc == XL_CF:
11691174
if not fmt_info: continue
11701175
cf_type, cmp_op, sz1, sz2, flags = unpack("<BBHHi", data[0:10])
11711176
font_block = (flags >> 26) & 1
11721177
bord_block = (flags >> 28) & 1
11731178
patt_block = (flags >> 29) & 1
11741179
if self.verbosity >= 1:
1175-
fprintf(self.logfile,
1180+
fprintf(
1181+
self.logfile,
11761182
"\n*** WARNING: Ignoring CF (conditional formatting) sub-record.\n"
11771183
"*** cf_type=%d, cmp_op=%d, sz1=%d, sz2=%d, flags=0x%08x\n"
11781184
"*** optional data blocks: font=%d, border=%d, pattern=%d\n",
11791185
cf_type, cmp_op, sz1, sz2, flags,
11801186
font_block, bord_block, patt_block,
1181-
)
1187+
)
11821188
# hex_char_dump(data, 0, data_len, fout=self.logfile)
11831189
pos = 12
11841190
if font_block:
@@ -1189,14 +1195,15 @@ def read(self, bk):
11891195
font_canc = (two_bits > 7) & 1
11901196
cancellation = (font_options > 7) & 1
11911197
if self.verbosity >= 1:
1192-
fprintf(self.logfile,
1198+
fprintf(
1199+
self.logfile,
11931200
"*** Font info: height=%d, weight=%d, escapement=%d,\n"
11941201
"*** underline=%d, colour_index=%d, esc=%d, underl=%d,\n"
11951202
"*** style=%d, posture=%d, canc=%d, cancellation=%d\n",
11961203
font_height, weight, escapement, underline,
11971204
font_colour_index, font_esc, font_underl,
11981205
font_style, posture, font_canc, cancellation,
1199-
)
1206+
)
12001207
pos += 118
12011208
if bord_block:
12021209
pos += 8
@@ -1205,17 +1212,13 @@ def read(self, bk):
12051212
fmla1 = data[pos:pos+sz1]
12061213
pos += sz1
12071214
if blah and sz1:
1208-
fprintf(self.logfile,
1209-
"*** formula 1:\n",
1210-
)
1215+
fprintf(self.logfile, "*** formula 1:\n")
12111216
dump_formula(bk, fmla1, sz1, bv, reldelta=0, blah=1)
12121217
fmla2 = data[pos:pos+sz2]
12131218
pos += sz2
12141219
assert pos == data_len
12151220
if blah and sz2:
1216-
fprintf(self.logfile,
1217-
"*** formula 2:\n",
1218-
)
1221+
fprintf(self.logfile, "*** formula 2:\n")
12191222
dump_formula(bk, fmla2, sz2, bv, reldelta=0, blah=1)
12201223
elif rc == XL_DEFAULTROWHEIGHT:
12211224
if data_len == 4:
@@ -1247,16 +1250,18 @@ def read(self, bk):
12471250
"MERGEDCELLS: pos=%d data_len=%d" % (pos, data_len)
12481251
elif rc == XL_WINDOW2:
12491252
if bv >= 80 and data_len >= 14:
1250-
(options,
1251-
self.first_visible_rowx, self.first_visible_colx,
1252-
self.gridline_colour_index,
1253-
self.cached_page_break_preview_mag_factor,
1254-
self.cached_normal_view_mag_factor
1253+
(
1254+
options,
1255+
self.first_visible_rowx, self.first_visible_colx,
1256+
self.gridline_colour_index,
1257+
self.cached_page_break_preview_mag_factor,
1258+
self.cached_normal_view_mag_factor
12551259
) = unpack("<HHHHxxHH", data[:14])
12561260
else:
12571261
assert bv >= 30 # BIFF3-7
1258-
(options,
1259-
self.first_visible_rowx, self.first_visible_colx,
1262+
(
1263+
options,
1264+
self.first_visible_rowx, self.first_visible_colx,
12601265
) = unpack("<HHH", data[:6])
12611266
self.gridline_colour_rgb = unpack("<BBB", data[6:9])
12621267
self.gridline_colour_index = nearest_colour_index(
@@ -1466,8 +1471,9 @@ def read(self, bk):
14661471
"panes_are_frozen", "show_zero_values")
14671472
for attr, char in zip(attr_names, data[0:5]):
14681473
setattr(self, attr, int(char != b'\0'))
1469-
(self.first_visible_rowx, self.first_visible_colx,
1470-
self.automatic_grid_line_colour,
1474+
(
1475+
self.first_visible_rowx, self.first_visible_colx,
1476+
self.automatic_grid_line_colour,
14711477
) = unpack("<HHB", data[5:10])
14721478
self.gridline_colour_rgb = unpack("<BBB", data[10:13])
14731479
self.gridline_colour_index = nearest_colour_index(

xlrd/xlsx.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,8 @@ def cell_name_to_rowx_colx(cell_name, letter_value=_UPPERCASE_1_REL_INDEX,
134134
IS_TAG = U_SSML12 + 'is' # cell child: inline string
135135

136136
def unescape(s,
137-
subber=re.compile(r'_x[0-9A-Fa-f]{4,4}_', re.UNICODE).sub,
138-
repl=lambda mobj: unichr(int(mobj.group(0)[2:6], 16)),
139-
):
137+
subber=re.compile(r'_x[0-9A-Fa-f]{4,4}_', re.UNICODE).sub,
138+
repl=lambda mobj: unichr(int(mobj.group(0)[2:6], 16))):
140139
if "_" in s:
141140
return subber(repl, s)
142141
return s

0 commit comments

Comments
 (0)