Formatted files with black
This commit is contained in:
@@ -11,16 +11,16 @@ Tool project to clean build project files
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'post_build'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
|
||||
__version__ = '1.0.0'
|
||||
__title__ = "post_build"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 sh-edraft.de"
|
||||
__version__ = "1.0.0"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
|
||||
# imports:
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='1', minor='0', micro='0')
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0")
|
||||
|
@@ -8,7 +8,6 @@ from post_build.service.remove_config import RemoveConfig
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, config, services)
|
||||
|
||||
@@ -19,8 +18,6 @@ class Application(ApplicationABC):
|
||||
pass
|
||||
|
||||
def main(self):
|
||||
Console.write_line('KDB Post-Build:')
|
||||
Console.spinner(f'Removing unnecessary configs', self._remove_config.remove)
|
||||
Console.spinner(f'Creating requirements file for pip', self._deps.create)
|
||||
|
||||
|
||||
Console.write_line("KDB Post-Build:")
|
||||
Console.spinner(f"Removing unnecessary configs", self._remove_config.remove)
|
||||
Console.spinner(f"Creating requirements file for pip", self._deps.create)
|
||||
|
@@ -10,5 +10,5 @@ def main():
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@@ -5,7 +5,6 @@ from cpl_core.console import Console
|
||||
|
||||
|
||||
class PostBuildSettings(ConfigurationModelABC):
|
||||
|
||||
def __init__(self):
|
||||
ConfigurationModelABC.__init__(self)
|
||||
|
||||
@@ -15,15 +14,15 @@ class PostBuildSettings(ConfigurationModelABC):
|
||||
@property
|
||||
def keep_config(self) -> list[str]:
|
||||
return self._keep_config
|
||||
|
||||
|
||||
@property
|
||||
def config_paths(self) -> list[str]:
|
||||
return self._config_paths
|
||||
|
||||
def from_dict(self, settings: dict):
|
||||
try:
|
||||
self._keep_config = settings['KeepConfigs']
|
||||
self._config_paths = settings['ConfigPaths']
|
||||
self._keep_config = settings["KeepConfigs"]
|
||||
self._config_paths = settings["ConfigPaths"]
|
||||
except Exception as e:
|
||||
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings')
|
||||
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
|
||||
Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings")
|
||||
Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")
|
||||
|
@@ -11,16 +11,16 @@ Tool project to clean build project files
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'post_build.service'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
|
||||
__version__ = '1.0.0'
|
||||
__title__ = "post_build.service"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 sh-edraft.de"
|
||||
__version__ = "1.0.0"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
|
||||
# imports
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='1', minor='0', micro='0')
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="1", minor="0", micro="0")
|
||||
|
@@ -9,15 +9,14 @@ from post_build.post_build_settings import PostBuildSettings
|
||||
|
||||
|
||||
class Dependencies:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
config: ConfigurationABC,
|
||||
env: ApplicationEnvironmentABC,
|
||||
ws: WorkspaceSettings,
|
||||
project: ProjectSettings,
|
||||
build: BuildSettings,
|
||||
post_build: PostBuildSettings
|
||||
self,
|
||||
config: ConfigurationABC,
|
||||
env: ApplicationEnvironmentABC,
|
||||
ws: WorkspaceSettings,
|
||||
project: ProjectSettings,
|
||||
build: BuildSettings,
|
||||
post_build: PostBuildSettings,
|
||||
):
|
||||
self._config = config
|
||||
self._env = env
|
||||
@@ -31,12 +30,12 @@ class Dependencies:
|
||||
def _add_dependencies(self, deps: list[str]):
|
||||
for d in deps:
|
||||
d_name = d
|
||||
if '>=' in d:
|
||||
d_name = d.split('>=')[0]
|
||||
if '<=' in d:
|
||||
d_name = d.split('<=')[0]
|
||||
if '==' in d:
|
||||
d_name = d.split('==')[0]
|
||||
if ">=" in d:
|
||||
d_name = d.split(">=")[0]
|
||||
if "<=" in d:
|
||||
d_name = d.split("<=")[0]
|
||||
if "==" in d:
|
||||
d_name = d.split("==")[0]
|
||||
|
||||
if d_name in self._dependencies:
|
||||
continue
|
||||
@@ -44,13 +43,15 @@ class Dependencies:
|
||||
self._dependencies[d_name] = d
|
||||
|
||||
def create(self):
|
||||
dist_path = os.path.abspath(os.path.join(
|
||||
self._env.working_directory,
|
||||
os.path.dirname(self._workspace.projects[self._project.name]),
|
||||
self._build.output_path,
|
||||
self._project.name,
|
||||
'build'
|
||||
))
|
||||
dist_path = os.path.abspath(
|
||||
os.path.join(
|
||||
self._env.working_directory,
|
||||
os.path.dirname(self._workspace.projects[self._project.name]),
|
||||
self._build.output_path,
|
||||
self._project.name,
|
||||
"build",
|
||||
)
|
||||
)
|
||||
|
||||
for project in self._workspace.projects:
|
||||
project_file = os.path.join(self._env.working_directory, self._workspace.projects[project])
|
||||
@@ -58,7 +59,7 @@ class Dependencies:
|
||||
project: ProjectSettings = self._config.get_configuration(ProjectSettings)
|
||||
self._add_dependencies(project.dependencies)
|
||||
|
||||
with open(f'{dist_path}/requirements.txt', 'w+', encoding='utf-8') as f:
|
||||
with open(f"{dist_path}/requirements.txt", "w+", encoding="utf-8") as f:
|
||||
for dependency in self._dependencies:
|
||||
f.write(f'{self._dependencies[dependency]}\n')
|
||||
f.write(f"{self._dependencies[dependency]}\n")
|
||||
f.close()
|
||||
|
@@ -8,8 +8,14 @@ from post_build.post_build_settings import PostBuildSettings
|
||||
|
||||
|
||||
class RemoveConfig:
|
||||
|
||||
def __init__(self, env: ApplicationEnvironmentABC, ws: WorkspaceSettings, project: ProjectSettings, build: BuildSettings, post_build: PostBuildSettings):
|
||||
def __init__(
|
||||
self,
|
||||
env: ApplicationEnvironmentABC,
|
||||
ws: WorkspaceSettings,
|
||||
project: ProjectSettings,
|
||||
build: BuildSettings,
|
||||
post_build: PostBuildSettings,
|
||||
):
|
||||
|
||||
self._env = env
|
||||
self._workspace = ws
|
||||
@@ -18,19 +24,18 @@ class RemoveConfig:
|
||||
self._post_build = post_build
|
||||
|
||||
def remove(self):
|
||||
dist_path = os.path.abspath(os.path.join(
|
||||
self._env.working_directory,
|
||||
os.path.dirname(self._workspace.projects[self._project.name]),
|
||||
self._build.output_path,
|
||||
self._project.name,
|
||||
'build'
|
||||
))
|
||||
dist_path = os.path.abspath(
|
||||
os.path.join(
|
||||
self._env.working_directory,
|
||||
os.path.dirname(self._workspace.projects[self._project.name]),
|
||||
self._build.output_path,
|
||||
self._project.name,
|
||||
"build",
|
||||
)
|
||||
)
|
||||
|
||||
for cfg_path in self._post_build.config_paths:
|
||||
config_path = os.path.join(
|
||||
dist_path,
|
||||
cfg_path
|
||||
)
|
||||
config_path = os.path.join(dist_path, cfg_path)
|
||||
for r, d, f in os.walk(config_path):
|
||||
for file in f:
|
||||
if file in self._post_build.keep_config:
|
||||
|
@@ -11,20 +11,23 @@ from post_build.service.remove_config import RemoveConfig
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
||||
configuration.add_json_file(f'appsettings.json', optional=False, output=False)
|
||||
environment.set_working_directory(os.path.abspath(os.path.join(environment.working_directory, '../../')))
|
||||
configuration.add_json_file(f'cpl-workspace.json', optional=False, output=False)
|
||||
def configure_configuration(
|
||||
self, configuration: ConfigurationABC, environment: ApplicationEnvironment
|
||||
) -> ConfigurationABC:
|
||||
configuration.add_json_file(f"appsettings.json", optional=False, output=False)
|
||||
environment.set_working_directory(os.path.abspath(os.path.join(environment.working_directory, "../../")))
|
||||
configuration.add_json_file(f"cpl-workspace.json", optional=False, output=False)
|
||||
ws: WorkspaceSettings = configuration.get_configuration(WorkspaceSettings)
|
||||
configuration.add_json_file(ws.projects[ws.default_project], optional=False, output=False)
|
||||
|
||||
return configuration
|
||||
|
||||
def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
||||
def configure_services(
|
||||
self, services: ServiceCollectionABC, environment: ApplicationEnvironment
|
||||
) -> ServiceProviderABC:
|
||||
services.add_transient(RemoveConfig)
|
||||
services.add_transient(Dependencies)
|
||||
|
||||
|
Reference in New Issue
Block a user