refactor: rename modules to reflect pep8 recommendations (#19)

This commit is contained in:
Robert Kaussow 2021-01-03 15:36:04 +01:00 committed by GitHub
parent ab5823c8c9
commit 4a6e468e1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 43 additions and 43 deletions

View File

@ -6,9 +6,9 @@ import docker.errors
import requests.exceptions import requests.exceptions
import docker import docker
from dockertidy.Config import SingleConfig from dockertidy.config import SingleConfig
from dockertidy.Logger import SingleLog from dockertidy.logger import SingleLog
from dockertidy.Parser import timedelta from dockertidy.parser import timedelta
class AutoStop: class AutoStop:

View File

@ -3,13 +3,13 @@
import argparse import argparse
import dockertidy.Exception import dockertidy.exception
from dockertidy import __version__ from dockertidy import __version__
from dockertidy.Autostop import AutoStop from dockertidy.autostop import AutoStop
from dockertidy.Config import SingleConfig from dockertidy.config import SingleConfig
from dockertidy.GarbageCollector import GarbageCollector from dockertidy.garbage_collector import GarbageCollector
from dockertidy.Logger import SingleLog from dockertidy.logger import SingleLog
from dockertidy.Parser import timedelta_validator from dockertidy.parser import timedelta_validator
class DockerTidy: class DockerTidy:
@ -124,7 +124,7 @@ class DockerTidy:
def _get_config(self): def _get_config(self):
try: try:
config = SingleConfig(args=self.args) config = SingleConfig(args=self.args)
except dockertidy.Exception.ConfigError as e: except dockertidy.exception.ConfigError as e:
self.log.sysexit_with_message(e) self.log.sysexit_with_message(e)
try: try:

View File

@ -10,11 +10,11 @@ import ruamel.yaml
from appdirs import AppDirs from appdirs import AppDirs
from jsonschema._utils import format_as_index from jsonschema._utils import format_as_index
import dockertidy.Exception import dockertidy.exception
import dockertidy.Parser import dockertidy.parser
from dockertidy.Parser import env from dockertidy.parser import env
from dockertidy.Utils import Singleton from dockertidy.utils import Singleton
from dockertidy.Utils import dict_intersect from dockertidy.utils import dict_intersect
config_dir = AppDirs("docker-tidy").user_config_dir config_dir = AppDirs("docker-tidy").user_config_dir
default_config_file = os.path.join(config_dir, "config.yml") default_config_file = os.path.join(config_dir, "config.yml")
@ -162,7 +162,7 @@ class Config():
if '"{}" not set'.format(envname) in str(e): if '"{}" not set'.format(envname) in str(e):
pass pass
else: else:
raise dockertidy.Exception.ConfigError( raise dockertidy.exception.ConfigError(
"Unable to read environment variable", str(e) "Unable to read environment variable", str(e)
) )
@ -194,7 +194,7 @@ class Config():
normalized = ruamel.yaml.safe_load(s) normalized = ruamel.yaml.safe_load(s)
except (ruamel.yaml.composer.ComposerError, ruamel.yaml.scanner.ScannerError) as e: except (ruamel.yaml.composer.ComposerError, ruamel.yaml.scanner.ScannerError) as e:
message = "{} {}".format(e.context, e.problem) message = "{} {}".format(e.context, e.problem)
raise dockertidy.Exception.ConfigError( raise dockertidy.exception.ConfigError(
"Unable to read config file {}".format(config), message "Unable to read config file {}".format(config), message
) )
@ -236,7 +236,7 @@ class Config():
schema=format_as_index(list(e.relative_schema_path)[:-1]), schema=format_as_index(list(e.relative_schema_path)[:-1]),
message=e.message message=e.message
) )
raise dockertidy.Exception.ConfigError("Configuration error", schema_error) raise dockertidy.exception.ConfigError("Configuration error", schema_error)
return True return True

View File

@ -9,9 +9,9 @@ import docker.errors
import requests.exceptions import requests.exceptions
import docker import docker
from dockertidy.Config import SingleConfig from dockertidy.config import SingleConfig
from dockertidy.Logger import SingleLog from dockertidy.logger import SingleLog
from dockertidy.Parser import timedelta from dockertidy.parser import timedelta
class GarbageCollector: class GarbageCollector:

View File

@ -8,8 +8,8 @@ import sys
import colorama import colorama
from pythonjsonlogger import jsonlogger from pythonjsonlogger import jsonlogger
from dockertidy.Utils import Singleton from dockertidy.utils import Singleton
from dockertidy.Utils import to_bool from dockertidy.utils import to_bool
CONSOLE_FORMAT = "{}[%(levelname)s]{} %(message)s" CONSOLE_FORMAT = "{}[%(levelname)s]{} %(message)s"
JSON_FORMAT = "(asctime) (levelname) (message)" JSON_FORMAT = "(asctime) (levelname) (message)"

View File

@ -3,7 +3,7 @@
import pytest import pytest
import docker import docker
from dockertidy import Autostop from dockertidy import autostop
pytest_plugins = [ pytest_plugins = [
"dockertidy.test.fixtures.fixtures", "dockertidy.test.fixtures.fixtures",
@ -11,28 +11,28 @@ pytest_plugins = [
@pytest.fixture @pytest.fixture
def autostop(mocker): def autostop_fixture(mocker):
mocker.patch.object( mocker.patch.object(
Autostop.AutoStop, autostop.AutoStop,
"_get_docker_client", "_get_docker_client",
return_value=mocker.create_autospec(docker.APIClient) return_value=mocker.create_autospec(docker.APIClient)
) )
stop = Autostop.AutoStop() stop = autostop.AutoStop()
return stop return stop
def test_stop_container(autostop, mocker): def test_stop_container(autostop_fixture, mocker):
client = mocker.create_autospec(docker.APIClient) client = mocker.create_autospec(docker.APIClient)
cid = "asdb" cid = "asdb"
autostop._stop_container(client, cid) autostop_fixture._stop_container(client, cid)
client.stop.assert_called_once_with(cid) client.stop.assert_called_once_with(cid)
def test_build_container_matcher(autostop, mocker): def test_build_container_matcher(autostop_fixture, mocker):
prefixes = ["one_", "two_"] prefixes = ["one_", "two_"]
matcher = autostop._build_container_matcher(prefixes) matcher = autostop_fixture._build_container_matcher(prefixes)
assert matcher("one_container") assert matcher("one_container")
assert matcher("two_container") assert matcher("two_container")
@ -40,9 +40,9 @@ def test_build_container_matcher(autostop, mocker):
assert not matcher("one") assert not matcher("one")
def test_has_been_running_since_true(autostop, container, later_time): def test_has_been_running_since_true(autostop_fixture, container, later_time):
assert autostop._has_been_running_since(container, later_time) assert autostop_fixture._has_been_running_since(container, later_time)
def test_has_been_running_since_false(autostop, container, earlier_time): def test_has_been_running_since_false(autostop_fixture, container, earlier_time):
assert not autostop._has_been_running_since(container, earlier_time) assert not autostop_fixture._has_been_running_since(container, earlier_time)

View File

@ -4,7 +4,7 @@ import pytest
import requests import requests
import docker import docker
from dockertidy import GarbageCollector from dockertidy import garbage_collector
pytest_plugins = [ pytest_plugins = [
"dockertidy.test.fixtures.fixtures", "dockertidy.test.fixtures.fixtures",
@ -14,12 +14,12 @@ pytest_plugins = [
@pytest.fixture @pytest.fixture
def gc(mocker): def gc(mocker):
mocker.patch.object( mocker.patch.object(
GarbageCollector.GarbageCollector, garbage_collector.GarbageCollector,
"_get_docker_client", "_get_docker_client",
return_value=mocker.create_autospec(docker.APIClient) return_value=mocker.create_autospec(docker.APIClient)
) )
gc = GarbageCollector.GarbageCollector() gc = garbage_collector.GarbageCollector()
return gc return gc

6
poetry.lock generated
View File

@ -362,7 +362,7 @@ python-versions = "*"
[[package]] [[package]]
name = "isort" name = "isort"
version = "5.6.4" version = "5.7.0"
description = "A Python utility / library to sort Python imports." description = "A Python utility / library to sort Python imports."
category = "dev" category = "dev"
optional = false optional = false
@ -976,8 +976,8 @@ ipaddress = [
{file = "ipaddress-1.0.23.tar.gz", hash = "sha256:b7f8e0369580bb4a24d5ba1d7cc29660a4a6987763faf1d8a8046830e020e7e2"}, {file = "ipaddress-1.0.23.tar.gz", hash = "sha256:b7f8e0369580bb4a24d5ba1d7cc29660a4a6987763faf1d8a8046830e020e7e2"},
] ]
isort = [ isort = [
{file = "isort-5.6.4-py3-none-any.whl", hash = "sha256:dcab1d98b469a12a1a624ead220584391648790275560e1a43e54c5dceae65e7"}, {file = "isort-5.7.0-py3-none-any.whl", hash = "sha256:fff4f0c04e1825522ce6949973e83110a6e907750cd92d128b0d14aaaadbffdc"},
{file = "isort-5.6.4.tar.gz", hash = "sha256:dcaeec1b5f0eca77faea2a35ab790b4f3680ff75590bfcb7145986905aab2f58"}, {file = "isort-5.7.0.tar.gz", hash = "sha256:c729845434366216d320e936b8ad6f9d681aab72dc7cbc2d51bedc3582f3ad1e"},
] ]
jsonschema = [ jsonschema = [
{file = "jsonschema-3.2.0-py2.py3-none-any.whl", hash = "sha256:4e5b3cf8216f577bee9ce139cbe72eca3ea4f292ec60928ff24758ce626cd163"}, {file = "jsonschema-3.2.0-py2.py3-none-any.whl", hash = "sha256:4e5b3cf8216f577bee9ce139cbe72eca3ea4f292ec60928ff24758ce626cd163"},

View File

@ -77,7 +77,7 @@ pytest-mock = "^3.3.1"
yapf = "^0.30.0" yapf = "^0.30.0"
[tool.poetry.scripts] [tool.poetry.scripts]
docker-tidy = "dockertidy.Cli:main" docker-tidy = "dockertidy.cli:main"
[tool.poetry-dynamic-versioning] [tool.poetry-dynamic-versioning]
enable = true enable = true
@ -92,7 +92,7 @@ sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
skip_glob = ["**/.env*", "**/env/*", "**/docs/*"] skip_glob = ["**/.env*", "**/env/*", "**/docs/*"]
[tool.pytest.ini_options] [tool.pytest.ini_options]
addopts = "--cov=dockertidy --cov-report xml:coverage.xml --cov-append --no-cov-on-fail" addopts = "dockertidy --cov=dockertidy --cov-report=xml:coverage.xml --cov-report=term --cov-append --no-cov-on-fail"
filterwarnings = [ filterwarnings = [
"ignore::FutureWarning", "ignore::FutureWarning",
"ignore:.*collections.*:DeprecationWarning", "ignore:.*collections.*:DeprecationWarning",