Skip to content

Commit a0b0966

Browse files
d-w-moorealanking
authored andcommitted
[#615] reformat all Python source using black 24.10.0
1 parent 8199d2e commit a0b0966

88 files changed

Lines changed: 7856 additions & 5156 deletions

Some content is hidden

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

docker_build/iinit.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,48 @@
44
import os
55
import sys
66
from os import chmod
7-
from os.path import expanduser,exists,join
7+
from os.path import expanduser, exists, join
88
from getopt import getopt
99

1010

11-
home_env_path = expanduser('~/.irods')
12-
env_file_path = join(home_env_path,'irods_environment.json')
13-
auth_file_path = join(home_env_path,'.irodsA')
11+
home_env_path = expanduser("~/.irods")
12+
env_file_path = join(home_env_path, "irods_environment.json")
13+
auth_file_path = join(home_env_path, ".irodsA")
1414

1515

1616
def do_iinit(host, port, user, zone, password):
1717
if not exists(home_env_path):
1818
os.makedirs(home_env_path)
1919
else:
20-
raise RuntimeError('~/.irods already exists')
21-
22-
with open(env_file_path,'w') as env_file:
23-
json.dump ( { "irods_host": host,
24-
"irods_port": int(port),
25-
"irods_user_name": user,
26-
"irods_zone_name": zone }, env_file, indent=4)
27-
with open(auth_file_path,'w') as auth_file:
20+
raise RuntimeError("~/.irods already exists")
21+
22+
with open(env_file_path, "w") as env_file:
23+
json.dump(
24+
{
25+
"irods_host": host,
26+
"irods_port": int(port),
27+
"irods_user_name": user,
28+
"irods_zone_name": zone,
29+
},
30+
env_file,
31+
indent=4,
32+
)
33+
with open(auth_file_path, "w") as auth_file:
2834
auth_file.write(encode(password))
29-
chmod (auth_file_path,0o600)
35+
chmod(auth_file_path, 0o600)
3036

3137

3238
def get_kv_pairs_from_cmdline(*args):
3339
arglist = list(args)
3440
while arglist:
35-
k = arglist.pop(0)
36-
v = arglist.pop(0)
37-
yield k,v
41+
k = arglist.pop(0)
42+
v = arglist.pop(0)
43+
yield k, v
3844

3945

40-
if __name__ == '__main__':
46+
if __name__ == "__main__":
4147
import sys
48+
4249
args = sys.argv[1:]
43-
dct = {k:v for k,v in get_kv_pairs_from_cmdline(*args)}
50+
dct = {k: v for k, v in get_kv_pairs_from_cmdline(*args)}
4451
do_iinit(**dct)

irods/__init__.py

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,48 @@
11
import sys
22

3-
minimum_compatible_python = (3,6)
3+
minimum_compatible_python = (3, 6)
44

55
if sys.version_info < minimum_compatible_python:
6-
to_dotted_string = lambda version_tuple: '.'.join(str(_) for _ in version_tuple)
7-
version_message = "This library is only supported on Python {} and above.".format(to_dotted_string(minimum_compatible_python))
6+
to_dotted_string = lambda version_tuple: ".".join(str(_) for _ in version_tuple)
7+
version_message = "This library is only supported on Python {} and above.".format(
8+
to_dotted_string(minimum_compatible_python)
9+
)
810
raise RuntimeError(version_message)
911

1012
from .version import __version__, version_as_tuple, version_as_string
1113

1214
import logging
1315
import os
1416

17+
1518
def env_filename_from_keyword_args(kwargs):
1619
try:
17-
env_file = kwargs.pop('irods_env_file')
20+
env_file = kwargs.pop("irods_env_file")
1821
except KeyError:
1922
try:
20-
env_file = os.environ['IRODS_ENVIRONMENT_FILE']
23+
env_file = os.environ["IRODS_ENVIRONMENT_FILE"]
2124
except KeyError:
22-
env_file = os.path.expanduser('~/.irods/irods_environment.json')
25+
env_file = os.path.expanduser("~/.irods/irods_environment.json")
2326
return env_file
2427

28+
2529
def derived_auth_filename(env_filename):
2630
if not env_filename:
27-
return ''
28-
default_irods_authentication_file = os.path.join(os.path.dirname(env_filename),'.irodsA')
29-
return os.environ.get('IRODS_AUTHENTICATION_FILE', default_irods_authentication_file)
31+
return ""
32+
default_irods_authentication_file = os.path.join(
33+
os.path.dirname(env_filename), ".irodsA"
34+
)
35+
return os.environ.get(
36+
"IRODS_AUTHENTICATION_FILE", default_irods_authentication_file
37+
)
38+
3039

3140
logger = logging.getLogger(__name__)
3241
logger.addHandler(logging.NullHandler())
3342
gHandler = None
3443

35-
def client_logging(flag=True,handler=None):
44+
45+
def client_logging(flag=True, handler=None):
3646
"""
3747
Example of use:
3848
@@ -45,15 +55,19 @@ def client_logging(flag=True,handler=None):
4555
global gHandler
4656
if flag:
4757
if handler is not None:
48-
if gHandler: logger.removeHandler(gHandler)
49-
if not handler: handler = logging.StreamHandler()
58+
if gHandler:
59+
logger.removeHandler(gHandler)
60+
if not handler:
61+
handler = logging.StreamHandler()
5062
gHandler = handler
5163
logger.addHandler(handler)
5264
else:
53-
if gHandler: logger.removeHandler(gHandler)
65+
if gHandler:
66+
logger.removeHandler(gHandler)
5467
gHandler = None
5568
return gHandler
5669

70+
5771
# Magic Numbers
5872
MAX_PASSWORD_LENGTH = 50
5973
MAX_SQL_ATTR = 50
@@ -66,32 +80,36 @@ def client_logging(flag=True,handler=None):
6680
# https://stackoverflow.com/questions/45704243/value-of-c-pytime-t-in-python
6781
MAXIMUM_CONNECTION_TIMEOUT = 9223372036
6882

69-
AUTH_SCHEME_KEY = 'a_scheme'
70-
AUTH_USER_KEY = 'a_user'
71-
AUTH_PWD_KEY = 'a_pw'
72-
AUTH_TTL_KEY = 'a_ttl'
83+
AUTH_SCHEME_KEY = "a_scheme"
84+
AUTH_USER_KEY = "a_user"
85+
AUTH_PWD_KEY = "a_pw"
86+
AUTH_TTL_KEY = "a_ttl"
7387

74-
NATIVE_AUTH_SCHEME = 'native'
88+
NATIVE_AUTH_SCHEME = "native"
7589

76-
GSI_AUTH_PLUGIN = 'GSI'
90+
GSI_AUTH_PLUGIN = "GSI"
7791
GSI_AUTH_SCHEME = GSI_AUTH_PLUGIN.lower()
7892
GSI_OID = "1.3.6.1.4.1.3536.1.1" # taken from http://j.mp/2hDeczm
7993

80-
PAM_AUTH_PLUGIN = 'PAM'
94+
PAM_AUTH_PLUGIN = "PAM"
8195
PAM_AUTH_SCHEME = PAM_AUTH_PLUGIN.lower()
82-
PAM_AUTH_SCHEMES = (PAM_AUTH_SCHEME, 'pam_password')
96+
PAM_AUTH_SCHEMES = (PAM_AUTH_SCHEME, "pam_password")
97+
98+
DEFAULT_CONFIG_PATH = os.path.expanduser("~/.python_irodsclient")
99+
settings_path_environment_variable = "PYTHON_IRODSCLIENT_CONFIGURATION_PATH"
83100

84-
DEFAULT_CONFIG_PATH = os.path.expanduser('~/.python_irodsclient')
85-
settings_path_environment_variable = 'PYTHON_IRODSCLIENT_CONFIGURATION_PATH'
86101

87102
def get_settings_path():
88103
env_var = os.environ.get(settings_path_environment_variable)
89104
return DEFAULT_CONFIG_PATH if not env_var else env_var
90105

106+
91107
from . import client_configuration
92108

93109
client_configuration.preserve_defaults()
94110

95111
# If the settings path variable is not set in the environment, a value of None is passed,
96112
# and thus no settings file is auto-loaded.
97-
client_configuration.autoload(_file_to_load = os.environ.get(settings_path_environment_variable))
113+
client_configuration.autoload(
114+
_file_to_load=os.environ.get(settings_path_environment_variable)
115+
)

0 commit comments

Comments
 (0)