diff --git a/src/sh_edraft/configuration/configuration.py b/src/sh_edraft/configuration/configuration.py index 6bc844d4..f4007ada 100644 --- a/src/sh_edraft/configuration/configuration.py +++ b/src/sh_edraft/configuration/configuration.py @@ -8,8 +8,8 @@ from sh_edraft.configuration.model.configuration_variable_name import Configurat from sh_edraft.environment.base.environment_base import EnvironmentBase from sh_edraft.environment.hosting_environment import HostingEnvironment from sh_edraft.environment.model.environment_name import EnvironmentName -from sh_edraft.utils.console.console import Console -from sh_edraft.utils.console.model.foreground_color import ForegroundColor +from sh_edraft.console.console import Console +from sh_edraft.console.model import ForegroundColor class Configuration(ConfigurationBase): diff --git a/src/sh_edraft/utils/console/__init__.py b/src/sh_edraft/console/__init__.py similarity index 100% rename from src/sh_edraft/utils/console/__init__.py rename to src/sh_edraft/console/__init__.py diff --git a/src/sh_edraft/utils/console/console.py b/src/sh_edraft/console/console.py similarity index 81% rename from src/sh_edraft/utils/console/console.py rename to src/sh_edraft/console/console.py index deb7bc50..fb4612d9 100644 --- a/src/sh_edraft/utils/console/console.py +++ b/src/sh_edraft/console/console.py @@ -1,12 +1,9 @@ -import contextlib -import io import os -import sys from typing import Union, Optional from termcolor import colored -from sh_edraft.utils.console.model.background_color import BackgroundColor -from sh_edraft.utils.console.model.foreground_color import ForegroundColor +from sh_edraft.console.model.background_color import BackgroundColor +from sh_edraft.console.model.foreground_color import ForegroundColor class Console: @@ -93,17 +90,24 @@ class Console: @staticmethod def close(): - Console.read_line('\nPress any key to continue...') + Console.reset() + Console.write('\n\n\nPress any key to continue...') + Console.read_line() exit() - @staticmethod - def read(output: str = None) -> str: - user_input = input(output if output else '') - return user_input[0] + @classmethod + def read(cls, output: str = None) -> str: + if output is not None: + cls.write(output) - @staticmethod - def read_line(output: str = None) -> str: - return input(output if output else '') + return input()[0] + + @classmethod + def read_line(cls, output: str = None) -> str: + if output is not None: + cls.write(output) + + return input() @classmethod def reset(cls): @@ -118,14 +122,16 @@ class Console: @classmethod def write_at(cls, x: int, y: int, *args): string = ' '.join(map(str, args)) - cls._output(string, x, y) + cls._output(string, x, y, end='') @classmethod def write_line(cls, *args): string = ' '.join(map(str, args)) - cls._output(string) + cls._output('') + cls._output(string, end='') @classmethod def write_line_at(cls, x: int, y: int, *args): string = ' '.join(map(str, args)) - cls._output(string, x, y) + cls._output('', end='') + cls._output(string, x, y, end='') diff --git a/src/sh_edraft/utils/console/model/__init__.py b/src/sh_edraft/console/model/__init__.py similarity index 100% rename from src/sh_edraft/utils/console/model/__init__.py rename to src/sh_edraft/console/model/__init__.py diff --git a/src/sh_edraft/utils/console/model/background_color.py b/src/sh_edraft/console/model/background_color.py similarity index 100% rename from src/sh_edraft/utils/console/model/background_color.py rename to src/sh_edraft/console/model/background_color.py diff --git a/src/sh_edraft/utils/console/model/foreground_color.py b/src/sh_edraft/console/model/foreground_color.py similarity index 100% rename from src/sh_edraft/utils/console/model/foreground_color.py rename to src/sh_edraft/console/model/foreground_color.py diff --git a/src/sh_edraft/database/connection/database_connection.py b/src/sh_edraft/database/connection/database_connection.py index 5878f2c0..b3397113 100644 --- a/src/sh_edraft/database/connection/database_connection.py +++ b/src/sh_edraft/database/connection/database_connection.py @@ -5,8 +5,8 @@ from sqlalchemy.orm import Session, sessionmaker from sh_edraft.database.connection.base.database_connection_base import DatabaseConnectionBase from sh_edraft.database.model.database_settings import DatabaseSettings -from sh_edraft.utils.console.console import Console -from sh_edraft.utils.console.model.foreground_color import ForegroundColor +from sh_edraft.console.console import Console +from sh_edraft.console.model.foreground_color import ForegroundColor class DatabaseConnection(DatabaseConnectionBase): diff --git a/src/sh_edraft/database/context/database_context.py b/src/sh_edraft/database/context/database_context.py index 0a3790ad..436ed53e 100644 --- a/src/sh_edraft/database/context/database_context.py +++ b/src/sh_edraft/database/context/database_context.py @@ -6,8 +6,8 @@ from sh_edraft.database.connection.base.database_connection_base import Database from sh_edraft.database.context.base.database_context_base import DatabaseContextBase from sh_edraft.database.model.dbmodel import DBModel from sh_edraft.database.model.database_settings import DatabaseSettings -from sh_edraft.utils.console.console import Console -from sh_edraft.utils.console.model.foreground_color import ForegroundColor +from sh_edraft.console.console import Console +from sh_edraft.console.model.foreground_color import ForegroundColor class DatabaseContext(DatabaseContextBase): diff --git a/src/sh_edraft/database/model/database_settings.py b/src/sh_edraft/database/model/database_settings.py index da3dc590..aed39e5f 100644 --- a/src/sh_edraft/database/model/database_settings.py +++ b/src/sh_edraft/database/model/database_settings.py @@ -3,8 +3,8 @@ from typing import Optional from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase from sh_edraft.database.model.database_settings_name import DatabaseSettingsName -from sh_edraft.utils.console.console import Console -from sh_edraft.utils.console.model.foreground_color import ForegroundColor +from sh_edraft.console.console import Console +from sh_edraft.console.model.foreground_color import ForegroundColor class DatabaseSettings(ConfigurationModelBase): diff --git a/src/sh_edraft/hosting/application_host.py b/src/sh_edraft/hosting/application_host.py index 339916c6..9709c2c1 100644 --- a/src/sh_edraft/hosting/application_host.py +++ b/src/sh_edraft/hosting/application_host.py @@ -8,7 +8,7 @@ from sh_edraft.hosting.application_runtime import ApplicationRuntime from sh_edraft.hosting.base.application_host_base import ApplicationHostBase from sh_edraft.service.providing.service_provider import ServiceProvider from sh_edraft.service.providing.base.service_provider_base import ServiceProviderBase -from sh_edraft.utils.console import Console +from sh_edraft.console import Console class ApplicationHost(ApplicationHostBase): diff --git a/src/sh_edraft/logging/logger.py b/src/sh_edraft/logging/logger.py index 21e91c01..ec96469e 100644 --- a/src/sh_edraft/logging/logger.py +++ b/src/sh_edraft/logging/logger.py @@ -8,8 +8,8 @@ from sh_edraft.logging.base.logger_base import LoggerBase from sh_edraft.logging.model.logging_settings import LoggingSettings from sh_edraft.logging.model.logging_level import LoggingLevel from sh_edraft.time.model.time_format_settings import TimeFormatSettings -from sh_edraft.utils.console.console import Console -from sh_edraft.utils.console.model.foreground_color import ForegroundColor +from sh_edraft.console.console import Console +from sh_edraft.console.model.foreground_color import ForegroundColor class Logger(LoggerBase): diff --git a/src/sh_edraft/logging/model/logging_settings.py b/src/sh_edraft/logging/model/logging_settings.py index b884f944..563369cc 100644 --- a/src/sh_edraft/logging/model/logging_settings.py +++ b/src/sh_edraft/logging/model/logging_settings.py @@ -4,8 +4,8 @@ from typing import Optional from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase from sh_edraft.logging.model.logging_settings_name import LoggingSettingsName from sh_edraft.logging.model.logging_level import LoggingLevel -from sh_edraft.utils.console.console import Console -from sh_edraft.utils.console.model.foreground_color import ForegroundColor +from sh_edraft.console.console import Console +from sh_edraft.console.model.foreground_color import ForegroundColor class LoggingSettings(ConfigurationModelBase): diff --git a/src/sh_edraft/publishing/model/publish_settings_model.py b/src/sh_edraft/publishing/model/publish_settings_model.py index 3b9ed148..4111d7fc 100644 --- a/src/sh_edraft/publishing/model/publish_settings_model.py +++ b/src/sh_edraft/publishing/model/publish_settings_model.py @@ -4,8 +4,8 @@ from typing import Optional from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase from sh_edraft.publishing.model.template import Template from sh_edraft.publishing.model.publish_settings_name import PublishSettingsName -from sh_edraft.utils.console.console import Console -from sh_edraft.utils.console.model.foreground_color import ForegroundColor +from sh_edraft.console.console import Console +from sh_edraft.console.model.foreground_color import ForegroundColor class PublishSettings(ConfigurationModelBase): diff --git a/src/sh_edraft/time/model/time_format_settings.py b/src/sh_edraft/time/model/time_format_settings.py index 55366710..664192a4 100644 --- a/src/sh_edraft/time/model/time_format_settings.py +++ b/src/sh_edraft/time/model/time_format_settings.py @@ -3,8 +3,8 @@ from typing import Optional from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase from sh_edraft.time.model.time_format_settings_names import TimeFormatSettingsNames -from sh_edraft.utils.console.console import Console -from sh_edraft.utils.console.model.foreground_color import ForegroundColor +from sh_edraft.console.console import Console +from sh_edraft.console.model.foreground_color import ForegroundColor class TimeFormatSettings(ConfigurationModelBase): diff --git a/src/sh_edraft/utils/__init__.py b/src/sh_edraft/utils/__init__.py index 10d2e9e5..db025911 100644 --- a/src/sh_edraft/utils/__init__.py +++ b/src/sh_edraft/utils/__init__.py @@ -20,7 +20,6 @@ __version__ = '2020.12.5' from collections import namedtuple # imports: -from .console import Console from .credential_manager import CredentialManager VersionInfo = namedtuple('VersionInfo', 'major minor micro') diff --git a/src/tests_dev/program.py b/src/tests_dev/program.py index c9d1574a..391a44ef 100644 --- a/src/tests_dev/program.py +++ b/src/tests_dev/program.py @@ -1,6 +1,7 @@ from typing import Optional from sh_edraft.configuration.base import ConfigurationBase +from sh_edraft.console import Console from sh_edraft.database.context import DatabaseContext from sh_edraft.database.model import DatabaseSettings from sh_edraft.hosting import ApplicationHost @@ -8,7 +9,7 @@ from sh_edraft.hosting.base import ApplicationBase from sh_edraft.logging import Logger from sh_edraft.logging.base import LoggerBase from sh_edraft.service.providing.base import ServiceProviderBase -from sh_edraft.utils import CredentialManager, Console +from sh_edraft.utils import CredentialManager from tests_dev.db.user_repo import UserRepo from tests_dev.db.user_repo_base import UserRepoBase @@ -65,10 +66,13 @@ class Program(ApplicationBase): Console.set_background_color('green') Console.set_cursor_position(5, 5) Console.write_line('Error') - Console.write_line_at(10, 10, 'Error') + Console.write_line_at(10, 5, 'Error') + Console.write_at(15, 5, 'Error') Console.reset_cursor_position() Console.set_foreground_color('green') Console.set_background_color('default') - Console.write('Test') - Console.write_line('1') + Console.write_line('Test') + Console.write('1') + # Console.write('x: ') + # Console.read_line('Test> ') Console.write_line(Console.foreground_color)