Skip to content

Commit 64f3e8f

Browse files
committed
Apply flake8 linter
1 parent b79d1be commit 64f3e8f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+892
-892
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,11 @@ jobs:
4444
python -m pip install flake8 pytest
4545
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
4646
47-
- name: Lint with flake8
48-
shell: bash
49-
run: |
50-
# stop the build if there are Python syntax errors or undefined names
51-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
52-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
53-
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics
47+
# - name: Lint with flake8
48+
# shell: bash
49+
# run: |
50+
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # stop the build if there are Python syntax errors or undefined names
51+
# flake8 . --count --max-complexity=10 --max-line-length=127 --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
5452

5553
- name: Install package
5654
shell: bash

docs/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
1717
# ones.
1818
extensions = [
19-
'sphinx.ext.intersphinx',
20-
'sphinx.ext.extlinks',
21-
'sphinx.ext.mathjax',
19+
'sphinx.ext.intersphinx',
20+
'sphinx.ext.extlinks',
21+
'sphinx.ext.mathjax',
2222
]
2323

2424
# intersphinx_mapping = {'low': ('https://api.h5py.org', None)}

examples/read_example.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212

1313
import h5pyd as h5py
1414

15+
1516
def visit_item(name):
1617
print("visit:", name)
1718
return None
1819

20+
1921
def find_g1_2(name):
2022
print("visit:", name)
2123
if name.endswith("g1.2"):
@@ -26,12 +28,13 @@ def visit_item_obj(name, obj):
2628
print("visit:", name, obj.id.id)
2729
return None
2830

31+
2932
print("version:", h5py.version.version)
3033

3134
# this is the path specified in the "post-install instructions"
3235
# see: "Test Data Setup" in:
3336
# https://github.com/HDFGroup/hsds/blob/master/docs/post_install.md
34-
DOMAIN_PATH="/home/test_user1/test/tall.h5"
37+
DOMAIN_PATH = "/home/test_user1/test/tall.h5"
3538
print("opening domain:", DOMAIN_PATH)
3639

3740
f = h5py.File(DOMAIN_PATH, "r")
@@ -85,6 +88,3 @@ def visit_item_obj(name, obj):
8588

8689
print("search g1.2:")
8790
f.visit(find_g1_2)
88-
89-
90-

examples/write_example.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
CHUNKS = (1500, 275)
2626

2727

28-
2928
if len(sys.argv) == 1 or sys.argv[1] in ("-h", "--help"):
3029
s = f"usage: python {sys.argv[0]} "
3130
s += "[--ncols=n] "
@@ -138,4 +137,4 @@
138137
else:
139138
print("passed!")
140139

141-
f.close()
140+
f.close()

h5pyd/_apps/config.py

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"flags": ["--api_key",],
3939
"help": "user api key",
4040
"choices": ["API_KEY"]
41-
},
41+
},
4242
"hs_bucket": {
4343
"default": None,
4444
"flags": ["--bucket",],
@@ -67,11 +67,12 @@
6767
"default": False,
6868
"flags": ["--ignore",],
6969
"help": "don't exit on error"
70-
}
70+
}
7171
}
7272

7373
hscmds = ("hsinfo", "hsconfigure", "hsls", "hstouch", "hsload", "hsget", "hsacl", "hsrm", "hsdiff")
7474

75+
7576
class Config:
7677
"""
7778
User Config state
@@ -163,7 +164,7 @@ def setitem(self, name, value, flags=None, choices=None, help=None):
163164
""" Set a config item """
164165
if name not in self._names:
165166
self._names.append(name)
166-
self._values[name] = value
167+
self._values[name] = value
167168
if flags is not None:
168169
self._flags[name] = flags
169170
for flag in flags:
@@ -175,7 +176,7 @@ def setitem(self, name, value, flags=None, choices=None, help=None):
175176

176177
def __setitem__(self, name, value):
177178
self.setitem(name, value)
178-
179+
179180
def __len__(self):
180181
return len(self._names)
181182

@@ -212,35 +213,33 @@ def get_see_also(self, this_cmd):
212213
msg += f"{cmd}, "
213214
msg = msg[:-2] # remove trailing comma
214215
return msg
215-
216216

217217
def get_help_message(self, name):
218-
help_text= self.get_help(name)
218+
help_text = self.get_help(name)
219219
flags = self.get_flags(name)
220220
choices = self.get_choices(name)
221221
if not help_text or len(flags) == 0:
222222
return None
223-
223+
224224
msg = flags[0]
225225
for i in range(1, len(flags)):
226226
msg += f", {flags[i]}"
227227
if choices:
228228
if len(choices) == 1:
229229
msg += f" {choices[0]}"
230230
else:
231-
msg += " {"
231+
msg += " {"
232232
for choice in choices:
233233
msg += f"{choice}|"
234234
msg = msg[:-1]
235235
msg += "}"
236236
if len(msg) < 40:
237-
pad = " "*(40 - len(msg))
237+
pad = " " * (40 - len(msg))
238238
msg += pad
239-
239+
240240
msg += f" {help_text}"
241-
241+
242242
return msg
243-
244243

245244
def get_nargs(self, name):
246245
choices = self._choices.get(name)
@@ -260,15 +259,15 @@ def get_names(self):
260259

261260
def set_cmd_flags(self, args, allow_post_flags=False):
262261
""" process any command line options
263-
return any place argument as a list
262+
return any place argument as a list
264263
"""
265264
options = []
266265
argn = 0
267266
while argn < len(args):
268267
arg = args[argn]
269268
val = None
270269
if len(args) > argn + 1:
271-
val = args[argn+1]
270+
val = args[argn + 1]
272271
if not arg.startswith("-"):
273272
options.append(arg)
274273
argn += 1
@@ -299,7 +298,7 @@ def set_cmd_flags(self, args, allow_post_flags=False):
299298
self._values[name] = val
300299
argn += 2
301300
return options
302-
301+
303302
def get_loglevel(self):
304303
val = self._values["loglevel"]
305304
val = val.upper()
@@ -329,13 +328,3 @@ def print(self, msg):
329328
logging.info(msg)
330329
if self._values.get("verbose"):
331330
print(msg)
332-
333-
334-
335-
336-
337-
338-
339-
340-
341-

h5pyd/_apps/hsacl.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
cfg = Config()
2222

23+
2324
#
2425
# log error and abort app
2526
#
@@ -31,12 +32,13 @@ def abort(msg):
3132
logging.error("exiting program with return code -1")
3233
sys.exit(-1)
3334

35+
3436
#
3537
# get given ACL, return None if not found
3638
#
3739
def getACL(f, username="default"):
3840
try:
39-
acl = f.getACL(username)
41+
acl = f.getACL(username)
4042
except IOError as ioe:
4143
if ioe.errno == 403:
4244
print("No permission to read ACL for this domain")
@@ -54,6 +56,7 @@ def getACL(f, username="default"):
5456
del acl["domain"]
5557
return acl
5658

59+
5760
#
5861
# Usage
5962
#
@@ -71,7 +74,7 @@ def usage():
7174
for name in option_names:
7275
help_msg = cfg.get_help_message(name)
7376
if help_msg:
74-
print(f" {help_msg}")
77+
print(f" {help_msg}")
7578
print("")
7679

7780
print("Arguments:")
@@ -95,9 +98,8 @@ def usage():
9598
sys.exit()
9699

97100

98-
99101
def main():
100-
perm_abvr = {'c':'create', 'r': 'read', 'u': 'update', 'd': 'delete', 'e': 'readACL', 'p':'updateACL'}
102+
perm_abvr = {'c': 'create', 'r': 'read', 'u': 'update', 'd': 'delete', 'e': 'readACL', 'p': 'updateACL'}
101103
fields = ('username', 'create', 'read', 'update', 'delete', 'readACL', 'updateACL')
102104
domain = None
103105
perm = None
@@ -108,13 +110,12 @@ def main():
108110
# additional options
109111
cfg.setitem("help", False, flags=["-h", "--help"], help="this message")
110112

111-
112113
try:
113114
cmdline_args = cfg.set_cmd_flags(sys.argv[1:], allow_post_flags=True)
114115
except ValueError as ve:
115116
print(ve)
116117
usage()
117-
118+
118119
if len(cmdline_args) == 0:
119120
# need a domain
120121
usage()
@@ -176,9 +177,11 @@ def main():
176177
# open the domain or folder
177178
try:
178179
if domain[-1] == '/':
179-
f = h5pyd.Folder(domain, mode=mode, endpoint=cfg["hs_endpoint"], username=cfg["hs_username"], password=cfg["hs_password"], bucket=cfg["hs_bucket"])
180+
f = h5pyd.Folder(domain, mode=mode, endpoint=cfg["hs_endpoint"],
181+
username=cfg["hs_username"], password=cfg["hs_password"], bucket=cfg["hs_bucket"])
180182
else:
181-
f = h5pyd.File(domain, mode=mode, endpoint=cfg["hs_endpoint"], username=cfg["hs_username"], password=cfg["hs_password"], bucket=cfg["hs_bucket"])
183+
f = h5pyd.File(domain, mode=mode, endpoint=cfg["hs_endpoint"],
184+
username=cfg["hs_username"], password=cfg["hs_password"], bucket=cfg["hs_bucket"])
182185
except IOError as ioe:
183186
if ioe.errno in (404, 410):
184187
abort("domain not found")
@@ -239,9 +242,10 @@ def main():
239242
else:
240243
abort(f"Unexpected error: {ioe}")
241244
print("%015s %08s %08s %08s %08s %08s %08s " % fields)
242-
print("-"*80)
245+
print("-" * 80)
243246
for acl in acls:
244-
vals = (acl["userName"], acl["create"], acl["read"], acl["update"], acl["delete"], acl["readACL"], acl["updateACL"])
247+
vals = (acl["userName"], acl["create"], acl["read"],
248+
acl["update"], acl["delete"], acl["readACL"], acl["updateACL"])
245249
print("%015s %08s %08s %08s %08s %08s %08s " % vals)
246250
else:
247251
header_printed = False # don't print header until we have at least one ACL
@@ -250,9 +254,10 @@ def main():
250254
acl = f.getACL(username)
251255
if not header_printed:
252256
print("%015s %08s %08s %08s %08s %08s %08s " % fields)
253-
print("-"*80)
257+
print("-" * 80)
254258
header_printed = True
255-
vals = (acl["userName"], acl["create"], acl["read"], acl["update"], acl["delete"], acl["readACL"], acl["updateACL"])
259+
vals = (acl["userName"], acl["create"], acl["read"],
260+
acl["update"], acl["delete"], acl["readACL"], acl["updateACL"])
256261
print("%015s %08s %08s %08s %08s %08s %08s " % vals)
257262
except IOError as ioe:
258263
if ioe.errno == 403:
@@ -267,5 +272,6 @@ def main():
267272

268273
f.close()
269274

275+
270276
if __name__ == "__main__":
271277
main()

h5pyd/_apps/hsconfigure.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
else:
77
from .config import Config
88

9+
910
#
1011
# input function that works with Python 2 or 3
1112
#
1213
def get_input(prompt):
1314
result = input(prompt)
1415
return result
1516

17+
1618
#
1719
# Save configuration file
1820
#
@@ -39,6 +41,7 @@ def saveConfig(username, password, endpoint, api_key):
3941
else:
4042
file.write("hs_api_key = \n")
4143

44+
4245
#
4346
# Check to see if we can get a response from the server
4447
#
@@ -73,6 +76,8 @@ def pingServer(username, password, endpoint, api_key):
7376
print("Unexpected response from server")
7477
return False
7578
return True
79+
80+
7681
#
7782
# Main
7883
#
@@ -138,5 +143,6 @@ def main():
138143
if quit in ("Y", "y"):
139144
break
140145

146+
141147
if __name__ == "__main__":
142148
main()

0 commit comments

Comments
 (0)