2021.4.post1 #31

Merged
edraft merged 92 commits from 2021.4.post1 into master 2021-05-19 09:00:40 +02:00
5 changed files with 41 additions and 17 deletions
Showing only changes of commit d51659db3e - Show all commits

View File

@ -109,7 +109,8 @@ class NewService(CommandABC):
'*/logs', '*/logs',
'*/tests' '*/tests'
], ],
BuildSettingsNameEnum.package_data.value: {} BuildSettingsNameEnum.package_data.value: {},
BuildSettingsNameEnum.project_references.value: []
} }
self._build.from_dict(self._build_dict) self._build.from_dict(self._build_dict)

View File

@ -23,6 +23,7 @@ class BuildSettings(ConfigurationModelABC):
self._included: Optional[list[str]] = None self._included: Optional[list[str]] = None
self._excluded: Optional[list[str]] = None self._excluded: Optional[list[str]] = None
self._package_data: Optional[dict[str, list[str]]] = None self._package_data: Optional[dict[str, list[str]]] = None
self._project_references: Optional[list[str]] = None
@property @property
def project_type(self): def project_type(self):
@ -60,6 +61,10 @@ class BuildSettings(ConfigurationModelABC):
def package_data(self) -> dict[str, list[str]]: def package_data(self) -> dict[str, list[str]]:
return self._package_data return self._package_data
@property
def project_references(self) -> list[str]:
return self._project_references
def from_dict(self, settings: dict): def from_dict(self, settings: dict):
try: try:
self._project_type = settings[BuildSettingsNameEnum.project_type.value] self._project_type = settings[BuildSettingsNameEnum.project_type.value]
@ -71,6 +76,7 @@ class BuildSettings(ConfigurationModelABC):
self._included = settings[BuildSettingsNameEnum.included.value] self._included = settings[BuildSettingsNameEnum.included.value]
self._excluded = settings[BuildSettingsNameEnum.excluded.value] self._excluded = settings[BuildSettingsNameEnum.excluded.value]
self._package_data = settings[BuildSettingsNameEnum.package_data.value] self._package_data = settings[BuildSettingsNameEnum.package_data.value]
self._project_references = settings[BuildSettingsNameEnum.project_references.value]
if sys.platform == 'win32': if sys.platform == 'win32':
self._source_path = str(self._source_path).replace('/', '\\') self._source_path = str(self._source_path).replace('/', '\\')

View File

@ -12,3 +12,4 @@ class BuildSettingsNameEnum(Enum):
included = 'Included' included = 'Included'
excluded = 'Excluded' excluded = 'Excluded'
package_data = 'PackageData' package_data = 'PackageData'
project_references = 'ProjectReferences'

View File

@ -42,5 +42,6 @@ class SettingsHelper:
BuildSettingsNameEnum.include_package_data.value: build.include_package_data, BuildSettingsNameEnum.include_package_data.value: build.include_package_data,
BuildSettingsNameEnum.included.value: build.included, BuildSettingsNameEnum.included.value: build.included,
BuildSettingsNameEnum.excluded.value: build.excluded, BuildSettingsNameEnum.excluded.value: build.excluded,
BuildSettingsNameEnum.package_data.value: build.package_data BuildSettingsNameEnum.package_data.value: build.package_data,
BuildSettingsNameEnum.project_references.value: build.project_references
} }

View File

@ -149,6 +149,28 @@ class PublisherService(PublisherABC):
return False return False
def _read_sources_from_path(self, path: str):
"""
Reads all source files from given path
:param path:
:return:
"""
for r, d, f in os.walk(path):
for file in f:
relative_path = os.path.relpath(r)
file_path = os.path.join(relative_path, os.path.relpath(file))
if self._is_file_excluded(file_path):
continue
if len(d) > 0:
for directory in d:
empty_dir = os.path.join(os.path.dirname(file_path), directory)
if len(os.listdir(empty_dir)) == 0:
self._included_dirs.append(empty_dir)
if not self._is_path_excluded(relative_path):
self._included_files.append(os.path.relpath(file_path))
def _read_sources(self): def _read_sources(self):
""" """
Reads all source files and save included files Reads all source files and save included files
@ -167,21 +189,16 @@ class PublisherService(PublisherABC):
elif os.path.isfile(rel_path): elif os.path.isfile(rel_path):
self._included_files.append(rel_path) self._included_files.append(rel_path)
for r, d, f in os.walk(self._source_path): self._read_sources_from_path(self._source_path)
for file in f:
relative_path = os.path.relpath(r)
file_path = os.path.join(relative_path, os.path.relpath(file))
if self._is_file_excluded(file_path):
continue
if len(d) > 0: for project in self._build_settings.project_references:
for directory in d: project = os.path.abspath(os.path.join(self._source_path, project))
empty_dir = os.path.join(os.path.dirname(file_path), directory) if not os.path.isfile(os.path.abspath(project)):
if len(os.listdir(empty_dir)) == 0: Console.error(f'Cannot import project: {project}')
self._included_dirs.append(empty_dir) return
if not self._is_path_excluded(relative_path): self.exclude(f'*/{os.path.basename(project)}')
self._included_files.append(os.path.relpath(file_path)) self._read_sources_from_path(os.path.dirname(project))
def _create_packages(self): def _create_packages(self):
""" """
@ -196,8 +213,6 @@ class PublisherService(PublisherABC):
title = self._get_module_name_from_dirs(file) title = self._get_module_name_from_dirs(file)
if title == '': if title == '':
title = self._project_settings.name title = self._project_settings.name
elif not title.__contains__('.'):
title = f'{self._project_settings.name}.{title}'
module_py_lines: list[str] = [] module_py_lines: list[str] = []
imports = '' imports = ''