Settings: flake8 and mypy passes

Yes, we want to keep the extra-spaces formatting, but that means
noqa'ing E221.
This commit is contained in:
Athanasius 2022-03-12 10:56:39 +00:00
parent 03c7f6c96b
commit be6fe8b419

View File

@ -1,6 +1,11 @@
# coding: utf8 # coding: utf8
"""EDDN default Settings."""
import argparse
from typing import Dict
import simplejson import simplejson
from eddn.conf.Version import __version__ as version from eddn.conf.Version import __version__ as version
@ -12,38 +17,38 @@ class _Settings(object):
# Local installation settings # Local installation settings
############################################################################### ###############################################################################
CERT_FILE = '/etc/letsencrypt/live/eddn.edcd.io/fullchain.pem' CERT_FILE = '/etc/letsencrypt/live/eddn.edcd.io/fullchain.pem' # noqa: E221
KEY_FILE = '/etc/letsencrypt/live/eddn.edcd.io/privkey.pem' KEY_FILE = '/etc/letsencrypt/live/eddn.edcd.io/privkey.pem' # noqa: E221
############################################################################### ###############################################################################
# Relay settings # Relay settings
############################################################################### ###############################################################################
RELAY_HTTP_BIND_ADDRESS = "0.0.0.0" RELAY_HTTP_BIND_ADDRESS = "0.0.0.0" # noqa: E221
RELAY_HTTP_PORT = 9090 RELAY_HTTP_PORT = 9090 # noqa: E221
RELAY_RECEIVER_BINDINGS = ["tcp://127.0.0.1:8500"] RELAY_RECEIVER_BINDINGS = ["tcp://127.0.0.1:8500"] # noqa: E221
RELAY_SENDER_BINDINGS = ["tcp://*:9500"] RELAY_SENDER_BINDINGS = ["tcp://*:9500"] # noqa: E221
# If set to False, no deduplicate is made # If set to False, no deduplicate is made
RELAY_DUPLICATE_MAX_MINUTES = 15 RELAY_DUPLICATE_MAX_MINUTES = 15 # noqa: E221
# If set to false, don't listen to topic and accept all incoming messages # If set to false, don't listen to topic and accept all incoming messages
RELAY_RECEIVE_ONLY_GATEWAY_EXTRA_JSON = True RELAY_RECEIVE_ONLY_GATEWAY_EXTRA_JSON = True # noqa: E221
RELAY_EXTRA_JSON_SCHEMAS = {} RELAY_EXTRA_JSON_SCHEMAS: Dict = {} # noqa: E221
############################################################################### ###############################################################################
# Gateway settings # Gateway settings
############################################################################### ###############################################################################
GATEWAY_HTTP_BIND_ADDRESS = "127.0.0.1" GATEWAY_HTTP_BIND_ADDRESS = "127.0.0.1" # noqa: E221
GATEWAY_HTTP_PORT = 8081 GATEWAY_HTTP_PORT = 8081 # noqa: E221
GATEWAY_SENDER_BINDINGS = ["tcp://127.0.0.1:8500"] GATEWAY_SENDER_BINDINGS = ["tcp://127.0.0.1:8500"] # noqa: E221
GATEWAY_JSON_SCHEMAS = { GATEWAY_JSON_SCHEMAS = { # noqa: E221
"https://eddn.edcd.io/schemas/commodity/3": "schemas/commodity-v3.0.json", "https://eddn.edcd.io/schemas/commodity/3": "schemas/commodity-v3.0.json",
"https://eddn.edcd.io/schemas/commodity/3/test": "schemas/commodity-v3.0.json", "https://eddn.edcd.io/schemas/commodity/3/test": "schemas/commodity-v3.0.json",
@ -80,7 +85,7 @@ class _Settings(object):
"https://eddn.edcd.io/schemas/fssallbodiesfound/1/test" : "schemas/fssallbodiesfound-v1.0.json", "https://eddn.edcd.io/schemas/fssallbodiesfound/1/test" : "schemas/fssallbodiesfound-v1.0.json",
} }
GATEWAY_OUTDATED_SCHEMAS = [ GATEWAY_OUTDATED_SCHEMAS = [ # noqa: E221
"http://schemas.elite-markets.net/eddn/commodity/1", "http://schemas.elite-markets.net/eddn/commodity/1",
"http://schemas.elite-markets.net/eddn/commodity/1/test", "http://schemas.elite-markets.net/eddn/commodity/1/test",
"http://schemas.elite-markets.net/eddn/commodity/2", "http://schemas.elite-markets.net/eddn/commodity/2",
@ -105,40 +110,42 @@ class _Settings(object):
# Monitor settings # Monitor settings
############################################################################### ###############################################################################
MONITOR_HTTP_BIND_ADDRESS = "0.0.0.0" MONITOR_HTTP_BIND_ADDRESS = "0.0.0.0" # noqa: E221
MONITOR_HTTP_PORT = 9091 MONITOR_HTTP_PORT = 9091 # noqa: E221
MONITOR_RECEIVER_BINDINGS = ["tcp://127.0.0.1:8500"] MONITOR_RECEIVER_BINDINGS = ["tcp://127.0.0.1:8500"] # noqa: E221
MONITOR_DB = { MONITOR_DB = { # noqa: E221
"user": "eddn", "user": "eddn",
"password": "cvLYM8AEqg29YTatFMEcqph3YkDWUMvC", "password": "cvLYM8AEqg29YTatFMEcqph3YkDWUMvC",
"database": "eddn" "database": "eddn"
} }
MONITOR_UA = "UA-496332-23" MONITOR_UA = "UA-496332-23" # noqa: E221
########################################################################## ##########################################################################
# Bouncer settings # Bouncer settings
########################################################################## ##########################################################################
BOUNCER_HTTP_BIND_ADDRESS = "127.0.0.1" BOUNCER_HTTP_BIND_ADDRESS = "127.0.0.1" # noqa: E221
BOUNCER_HTTP_PORT = 8081 BOUNCER_HTTP_PORT = 8081 # noqa: E221
BOUNCER_LIVE_GATEWAY_URL = 'https://eddn.edcd.io:4430/upload/' BOUNCER_LIVE_GATEWAY_URL = 'https://eddn.edcd.io:4430/upload/'
def loadFrom(self, fileName): def load_from(self, file_name: str) -> None:
f = open(fileName, 'r') f = open(file_name, 'r')
conf = simplejson.load(f) conf = simplejson.load(f)
for key, value in conf.iteritems(): for key, value in conf.iteritems():
if key in dir(self): if key in dir(self):
self.__setattr__(key, value) self.__setattr__(key, value)
else: else:
print "Ignoring unknown setting {0}".format(key) print(f"Ignoring unknown setting {key}")
Settings = _Settings() Settings = _Settings()
def loadConfig(cl_args): def loadConfig(cl_args) -> None:
""" """
Load in a commandline-specified settings file, if applicable. Load in a commandline-specified settings file, if applicable.