Formatted files with black
This commit is contained in:
@@ -11,16 +11,16 @@ CPL internal tool to set version from branch name
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'get_version'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
|
||||
__version__ = '1.0.0'
|
||||
__title__ = "get_version"
|
||||
__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")
|
||||
|
@@ -6,7 +6,6 @@ from cpl_core.dependency_injection.service_provider_abc import ServiceProviderAB
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, config, services)
|
||||
|
||||
|
@@ -10,5 +10,5 @@ def main():
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@@ -8,17 +8,20 @@ from cpl_core.environment import ApplicationEnvironment
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
||||
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:
|
||||
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:
|
||||
return services.build_service_provider()
|
||||
|
@@ -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)
|
||||
|
||||
|
@@ -11,16 +11,16 @@ CPL internal tool to set version from branch name
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'set_version'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
|
||||
__version__ = '2022.7.0'
|
||||
__title__ = "set_version"
|
||||
__author__ = "Sven Heidemann"
|
||||
__license__ = "MIT"
|
||||
__copyright__ = "Copyright (c) 2022 sh-edraft.de"
|
||||
__version__ = "2022.7.0"
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
|
||||
# imports:
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2022', minor='7', micro='0')
|
||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
||||
version_info = VersionInfo(major="2022", minor="7", micro="0")
|
||||
|
@@ -16,7 +16,6 @@ from set_version.version_setter_service import VersionSetterService
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, config, services)
|
||||
|
||||
@@ -30,15 +29,15 @@ class Application(ApplicationABC):
|
||||
self._configuration.parse_console_arguments(self._services)
|
||||
|
||||
def main(self):
|
||||
Console.write_line('Set versions:')
|
||||
Console.write_line("Set versions:")
|
||||
|
||||
args = self._configuration.additional_arguments
|
||||
version = {}
|
||||
branch = ""
|
||||
suffix = ""
|
||||
force = False
|
||||
if '--force' in args:
|
||||
args.remove('--force')
|
||||
if "--force" in args:
|
||||
args.remove("--force")
|
||||
force = True
|
||||
|
||||
if len(args) > 1:
|
||||
@@ -50,44 +49,46 @@ class Application(ApplicationABC):
|
||||
|
||||
try:
|
||||
branch = self._git_service.get_active_branch_name()
|
||||
Console.write_line(f'Found branch: {branch}')
|
||||
Console.write_line(f"Found branch: {branch}")
|
||||
except Exception as e:
|
||||
Console.error('Branch not found', traceback.format_exc())
|
||||
Console.error("Branch not found", traceback.format_exc())
|
||||
return
|
||||
|
||||
try:
|
||||
if branch.startswith('#'):
|
||||
self._configuration.add_json_file(self._workspace.projects[self._workspace.default_project], optional=False, output=False)
|
||||
if branch.startswith("#"):
|
||||
self._configuration.add_json_file(
|
||||
self._workspace.projects[self._workspace.default_project], optional=False, output=False
|
||||
)
|
||||
ps: ProjectSettings = self._configuration.get_configuration(ProjectSettings)
|
||||
|
||||
version[VersionSettingsNameEnum.major.value] = ps.version.major
|
||||
version[VersionSettingsNameEnum.minor.value] = ps.version.minor
|
||||
version[VersionSettingsNameEnum.micro.value] = f'dev{branch.split("#")[1]}'
|
||||
else:
|
||||
version[VersionSettingsNameEnum.major.value] = branch.split('.')[0]
|
||||
version[VersionSettingsNameEnum.minor.value] = branch.split('.')[1]
|
||||
if len(branch.split('.')) == 2:
|
||||
if suffix == '':
|
||||
suffix = '0'
|
||||
version[VersionSettingsNameEnum.micro.value] = f'{suffix}'
|
||||
version[VersionSettingsNameEnum.major.value] = branch.split(".")[0]
|
||||
version[VersionSettingsNameEnum.minor.value] = branch.split(".")[1]
|
||||
if len(branch.split(".")) == 2:
|
||||
if suffix == "":
|
||||
suffix = "0"
|
||||
version[VersionSettingsNameEnum.micro.value] = f"{suffix}"
|
||||
else:
|
||||
if not suffix.startswith('.') and suffix != '':
|
||||
suffix = f'.{suffix}'
|
||||
if not suffix.startswith(".") and suffix != "":
|
||||
suffix = f".{suffix}"
|
||||
version[VersionSettingsNameEnum.micro.value] = f'{branch.split(".")[2]}{suffix}'
|
||||
except Exception as e:
|
||||
Console.error(f'Branch {branch} does not contain valid version')
|
||||
Console.error(f"Branch {branch} does not contain valid version")
|
||||
return
|
||||
|
||||
diff_paths = []
|
||||
for file in self._git_service.get_diff_files():
|
||||
if 'kdb-bot/src' in file:
|
||||
file = file.replace('kdb-bot/src', '')
|
||||
if "kdb-bot/src" in file:
|
||||
file = file.replace("kdb-bot/src", "")
|
||||
|
||||
if file.startswith('tools') or 'kdb-web/src' in file:
|
||||
if file.startswith("tools") or "kdb-web/src" in file:
|
||||
continue
|
||||
|
||||
if '/' in file:
|
||||
file = file.split('/')[1]
|
||||
if "/" in file:
|
||||
file = file.split("/")[1]
|
||||
else:
|
||||
file = os.path.basename(os.path.dirname(file))
|
||||
|
||||
@@ -104,12 +105,16 @@ class Application(ApplicationABC):
|
||||
skipped.append(project)
|
||||
continue
|
||||
|
||||
Console.write_line(f'Set dependencies {self._version_pipe.transform(version)} for {project}')
|
||||
self._version_setter.set_dependencies(self._workspace.projects[project], version, 'Dependencies', skipped=skipped)
|
||||
self._version_setter.set_dependencies(self._workspace.projects[project], version, 'DevDependencies', skipped=skipped)
|
||||
Console.write_line(f"Set dependencies {self._version_pipe.transform(version)} for {project}")
|
||||
self._version_setter.set_dependencies(
|
||||
self._workspace.projects[project], version, "Dependencies", skipped=skipped
|
||||
)
|
||||
self._version_setter.set_dependencies(
|
||||
self._workspace.projects[project], version, "DevDependencies", skipped=skipped
|
||||
)
|
||||
|
||||
Console.write_line(f'Set version {self._version_pipe.transform(version)} for {project}')
|
||||
Console.write_line(f"Set version {self._version_pipe.transform(version)} for {project}")
|
||||
self._version_setter.set_version(self._workspace.projects[project], version)
|
||||
except Exception as e:
|
||||
Console.error('Version could not be set', traceback.format_exc())
|
||||
Console.error("Version could not be set", traceback.format_exc())
|
||||
return
|
||||
|
@@ -5,10 +5,9 @@ from git import Repo
|
||||
|
||||
|
||||
class GitService:
|
||||
|
||||
def __init__(self, env: ApplicationEnvironmentABC):
|
||||
self._env = env
|
||||
self._repo = Repo(os.path.abspath(os.path.join(env.working_directory, '../')))
|
||||
self._repo = Repo(os.path.abspath(os.path.join(env.working_directory, "../")))
|
||||
|
||||
def get_active_branch_name(self) -> str:
|
||||
branch = self._repo.active_branch
|
||||
|
@@ -10,5 +10,5 @@ def main():
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@@ -11,19 +11,22 @@ from set_version.version_setter_service import VersionSetterService
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
||||
configuration.add_json_file('cpl-workspace.json', optional=True, output=False)
|
||||
def configure_configuration(
|
||||
self, configuration: ConfigurationABC, environment: ApplicationEnvironment
|
||||
) -> ConfigurationABC:
|
||||
configuration.add_json_file("cpl-workspace.json", optional=True, output=False)
|
||||
if configuration.get_configuration(WorkspaceSettings) is None:
|
||||
environment.set_working_directory(os.path.join(environment.working_directory, '../../'))
|
||||
configuration.add_json_file('cpl-workspace.json', optional=False, output=False)
|
||||
environment.set_working_directory(os.path.join(environment.working_directory, "../../"))
|
||||
configuration.add_json_file("cpl-workspace.json", 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_pipes()
|
||||
services.add_singleton(GitService)
|
||||
services.add_transient(VersionSetterService)
|
||||
|
@@ -7,13 +7,12 @@ from cpl_core.utils import String
|
||||
|
||||
|
||||
class VersionSetterService:
|
||||
|
||||
def __init__(self, env: ApplicationEnvironmentABC):
|
||||
self._env = env
|
||||
|
||||
def _read_file(self, file: str) -> dict:
|
||||
project_json = {}
|
||||
with open(os.path.join(self._env.working_directory, file), 'r', encoding='utf-8') as f:
|
||||
with open(os.path.join(self._env.working_directory, file), "r", encoding="utf-8") as f:
|
||||
# load json
|
||||
project_json = json.load(f)
|
||||
f.close()
|
||||
@@ -21,37 +20,43 @@ class VersionSetterService:
|
||||
return project_json
|
||||
|
||||
def _write_file(self, file: str, project_json: dict):
|
||||
with open(os.path.join(self._env.working_directory, file), 'w', encoding='utf-8') as f:
|
||||
with open(os.path.join(self._env.working_directory, file), "w", encoding="utf-8") as f:
|
||||
f.write(json.dumps(project_json, indent=2))
|
||||
f.close()
|
||||
|
||||
def set_version(self, file: str, version: dict):
|
||||
project_json = self._read_file(file)
|
||||
project_json['ProjectSettings']['Version'] = version
|
||||
project_json["ProjectSettings"]["Version"] = version
|
||||
self._write_file(file, project_json)
|
||||
|
||||
def set_dependencies(self, file: str, version: dict, key: str, skipped=None):
|
||||
project_json = self._read_file(file)
|
||||
if key not in project_json['ProjectSettings']:
|
||||
project_json['ProjectSettings'][key] = []
|
||||
if key not in project_json["ProjectSettings"]:
|
||||
project_json["ProjectSettings"][key] = []
|
||||
|
||||
dependencies = project_json['ProjectSettings'][key]
|
||||
dependencies = project_json["ProjectSettings"][key]
|
||||
new_deps = []
|
||||
for dependency in dependencies:
|
||||
if not dependency.startswith('cpl-'):
|
||||
if not dependency.startswith("cpl-"):
|
||||
new_deps.append(dependency)
|
||||
continue
|
||||
|
||||
dep_version = dependency.split('=')[1]
|
||||
dep_name = dependency.split('=')[0]
|
||||
if dep_name[len(dep_name)-1] not in ascii_letters:
|
||||
dep_name = dep_name[:len(dep_name)-1]
|
||||
dep_version = dependency.split("=")[1]
|
||||
dep_name = dependency.split("=")[0]
|
||||
if dep_name[len(dep_name) - 1] not in ascii_letters:
|
||||
dep_name = dep_name[: len(dep_name) - 1]
|
||||
|
||||
if skipped is not None and (dep_name in skipped or String.convert_to_snake_case(dep_name) in skipped) or dep_version == '':
|
||||
if (
|
||||
skipped is not None
|
||||
and (dep_name in skipped or String.convert_to_snake_case(dep_name) in skipped)
|
||||
or dep_version == ""
|
||||
):
|
||||
new_deps.append(dependency)
|
||||
continue
|
||||
|
||||
new_deps.append(dependency.replace(dep_version, f'{version["Major"]}.{version["Minor"]}.{version["Micro"]}'))
|
||||
new_deps.append(
|
||||
dependency.replace(dep_version, f'{version["Major"]}.{version["Minor"]}.{version["Micro"]}')
|
||||
)
|
||||
|
||||
project_json['ProjectSettings'][key] = new_deps
|
||||
project_json["ProjectSettings"][key] = new_deps
|
||||
self._write_file(file, project_json)
|
||||
|
Reference in New Issue
Block a user