refactor: minor clean-up

Remove unused imports; sort imports and globals; rename function

Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
This commit is contained in:
Christopher Arndt 2023-07-22 22:03:18 +02:00
parent 005427fbe1
commit 9c2331f84b
1 changed files with 5 additions and 5 deletions

View File

@ -10,12 +10,12 @@ Requires:
import argparse import argparse
import asyncio import asyncio
import logging
import json import json
import logging
import os import os
import sys import sys
from distutils.util import strtobool from distutils.util import strtobool
from os.path import exists, isdir, join from os.path import exists
from string import Template from string import Template
from nio import AsyncClient, LoginResponse from nio import AsyncClient, LoginResponse
@ -24,7 +24,6 @@ PROG = "matrixchat-notify"
CONFIG_FILENAME = f"{PROG}-config.json" CONFIG_FILENAME = f"{PROG}-config.json"
DEFAULT_TEMPLATE = "${DRONE_BUILD_STATUS}" DEFAULT_TEMPLATE = "${DRONE_BUILD_STATUS}"
DEFAULT_HOMESERVER = "https://matrix.org" DEFAULT_HOMESERVER = "https://matrix.org"
log = logging.getLogger(PROG)
SETTINGS_KEYS = ( SETTINGS_KEYS = (
"accesstoken", "accesstoken",
"deviceid", "deviceid",
@ -36,6 +35,7 @@ SETTINGS_KEYS = (
"template", "template",
"userid", "userid",
) )
log = logging.getLogger(PROG)
def tobool(s): def tobool(s):
@ -45,7 +45,7 @@ def tobool(s):
return False return False
def read_config_from_file(filename): def read_config_from_file_and_env(filename):
config = {} config = {}
if exists(filename): if exists(filename):
@ -148,7 +148,7 @@ def main(args=None):
) )
try: try:
config = read_config_from_file(args.config) config = read_config_from_file_and_env(args.config)
except Exception as exc: except Exception as exc:
return f"Could not parse configuration: {exc}" return f"Could not parse configuration: {exc}"