2021.4.6 #25

Merged
edraft merged 57 commits from 2021.4.6 into 2021.4.post1 2021-04-11 15:54:38 +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',
'*/tests'
],
BuildSettingsNameEnum.package_data.value: {}
BuildSettingsNameEnum.package_data.value: {},
BuildSettingsNameEnum.project_references.value: []
}
self._build.from_dict(self._build_dict)

View File

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

View File

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

View File

@ -42,5 +42,6 @@ class SettingsHelper:
BuildSettingsNameEnum.include_package_data.value: build.include_package_data,
BuildSettingsNameEnum.included.value: build.included,
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
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):
"""
Reads all source files and save included files
@ -167,21 +189,16 @@ class PublisherService(PublisherABC):
elif os.path.isfile(rel_path):
self._included_files.append(rel_path)
for r, d, f in os.walk(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
self._read_sources_from_path(self._source_path)
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)
for project in self._build_settings.project_references:
project = os.path.abspath(os.path.join(self._source_path, project))
if not os.path.isfile(os.path.abspath(project)):
Console.error(f'Cannot import project: {project}')
return
if not self._is_path_excluded(relative_path):
self._included_files.append(os.path.relpath(file_path))
self.exclude(f'*/{os.path.basename(project)}')
self._read_sources_from_path(os.path.dirname(project))
def _create_packages(self):
"""
@ -196,8 +213,6 @@ class PublisherService(PublisherABC):
title = self._get_module_name_from_dirs(file)
if title == '':
title = self._project_settings.name
elif not title.__contains__('.'):
title = f'{self._project_settings.name}.{title}'
module_py_lines: list[str] = []
imports = ''