Pass modes as keyword arguments

This commit is contained in:
László Károlyi 2022-02-15 19:25:01 +01:00
parent 112bfa61ad
commit 772cb0cbb7
Signed by: karolyi
GPG Key ID: 2DCAF25E55735BFE
6 changed files with 14 additions and 14 deletions

View File

@ -16,5 +16,5 @@ _PATH_CONF = Path(_CONFPATH)
if not _PATH_CONF.exists():
raise FileNotFoundError(_CONFPATH)
with _PATH_CONF.open() as fd:
with _PATH_CONF.open(mode='r') as fd:
CONFIG = load(stream=fd, Loader=Loader)

View File

@ -83,7 +83,7 @@ def _amazon_load_v4():
global _PATH4_MTIME, _IP4_DICT
_PATH4_MTIME = _PATH_MY_DATA_V4.stat().st_mtime
my_ip4dict: Ip4DictType = {}
with _PATH_MY_DATA_V4.open('r') as fd:
with _PATH_MY_DATA_V4.open(mode='r') as fd:
data = load(stream=fd, Loader=Loader)
if type(data) is list:
for item in data:
@ -96,7 +96,7 @@ def _amazon_load_v6():
'Load amazon IPv6 ranges.'
global _IP6_DICT, _PATH6_MTIME
my_ip6dict: Ip6DictType = {}
with _PATH_MY_DATA_V6.open('r') as fd:
with _PATH_MY_DATA_V6.open(mode='r') as fd:
data = load(stream=fd, Loader=Loader)
if type(data) is list:
for item in data:
@ -122,7 +122,7 @@ def amazon_download():
network=ip4_items["ip_prefix"], reason=(
f'Amazon: {ip4_items["service"]} '
f'{ip4_items["network_border_group"]}')))
with _PATH_MY_DATA_V4.open('w') as fd:
with _PATH_MY_DATA_V4.open(mode='w') as fd:
dump(data=ip_list, stream=fd, Dumper=Dumper)
# IPv6
ip_list = list()
@ -131,5 +131,5 @@ def amazon_download():
network=ip_items["ipv6_prefix"], reason=(
f'Amazon: {ip_items["service"]} '
f'{ip_items["network_border_group"]}')))
with _PATH_MY_DATA_V6.open('w') as fd:
with _PATH_MY_DATA_V6.open(mode='w') as fd:
dump(data=ip_list, stream=fd, Dumper=Dumper)

View File

@ -55,7 +55,7 @@ def reload_asns():
global _ASN_BLDICT, _ASN_WLDICT, _PATH_MTIME
_PATH_MTIME = _PATH_CONF.stat().st_mtime
_ASN_WLDICT = _ASN_BLDICT = dict()
with _PATH_CONF.open() as fd:
with _PATH_CONF.open(mode='r') as fd:
_ASN_CONFIG = load(stream=fd, Loader=Loader)
if type(_ASN_CONFIG) is not dict:
return

View File

@ -79,7 +79,7 @@ def _custom_load_bl_v4():
global _IP4_DICT, _PATH4_MTIME
_PATH4_MTIME = _PATH_MY_DATA_V4.stat().st_mtime
my_ip4dict: Ip4DictType = {}
with _PATH_MY_DATA_V4.open('r') as fd:
with _PATH_MY_DATA_V4.open(mode='r') as fd:
data = load(stream=fd, Loader=Loader)
if type(data) is list:
for item in data:
@ -93,7 +93,7 @@ def _custom_load_bl_v6():
global _IP6_DICT, _PATH6_MTIME
_PATH6_MTIME = _PATH_MY_DATA_V6.stat().st_mtime
my_ip6dict: Ip6DictType = {}
with _PATH_MY_DATA_V6.open('r') as fd:
with _PATH_MY_DATA_V6.open(mode='r') as fd:
data = load(stream=fd, Loader=Loader)
if type(data) is list:
for item in data:

View File

@ -79,7 +79,7 @@ def _custom_load_wl_v4():
global _IP4_DICT, _PATH4_MTIME
_PATH4_MTIME = _PATH_MY_DATA_V4.stat().st_mtime
my_ip4dict: Ip4DictType = {}
with _PATH_MY_DATA_V4.open('r') as fd:
with _PATH_MY_DATA_V4.open(mode='r') as fd:
data = load(stream=fd, Loader=Loader)
if type(data) is list:
for item in data:
@ -93,7 +93,7 @@ def _custom_load_wl_v6():
global _IP6_DICT, _PATH6_MTIME
_PATH6_MTIME = _PATH_MY_DATA_V6.stat().st_mtime
my_ip6dict: Ip6DictType = {}
with _PATH_MY_DATA_V6.open('r') as fd:
with _PATH_MY_DATA_V6.open(mode='r') as fd:
data = load(stream=fd, Loader=Loader)
if type(data) is list:
for item in data:

View File

@ -83,7 +83,7 @@ def _google_load_v4():
global _IP4_DICT, _PATH4_MTIME
_PATH4_MTIME = _PATH_MY_DATA_V4.stat().st_mtime
my_ip4dict: Ip4DictType = {}
with _PATH_MY_DATA_V4.open('r') as fd:
with _PATH_MY_DATA_V4.open(mode='r') as fd:
data = load(stream=fd, Loader=Loader)
if type(data) is list:
for item in data:
@ -97,7 +97,7 @@ def _google_load_v6():
global _IP6_DICT, _PATH6_MTIME
_PATH6_MTIME = _PATH_MY_DATA_V6.stat().st_mtime
my_ip6dict: Ip6DictType = {}
with _PATH_MY_DATA_V6.open('r') as fd:
with _PATH_MY_DATA_V6.open(mode='r') as fd:
data = load(stream=fd, Loader=Loader)
if type(data) is list:
for item in data:
@ -146,7 +146,7 @@ def google_download():
ip6_data = list()
_goolag_1_dl(ip4_data=ip4_data, ip6_data=ip6_data)
_goolag_2_dl(ip4_data=ip4_data, ip6_data=ip6_data)
with _PATH_MY_DATA_V4.open('w') as fd:
with _PATH_MY_DATA_V4.open(mode='w') as fd:
dump(data=ip4_data, stream=fd, Dumper=Dumper)
with _PATH_MY_DATA_V6.open('w') as fd:
with _PATH_MY_DATA_V6.open(mode='w') as fd:
dump(data=ip6_data, stream=fd, Dumper=Dumper)