2021.4 #19

Merged
edraft merged 237 commits from 2021.4 into master 2021-04-01 10:13:33 +02:00
11 changed files with 201 additions and 86 deletions
Showing only changes of commit f4ca76d844 - Show all commits

View File

@ -39,16 +39,6 @@
"*/logs", "*/logs",
"*/tests" "*/tests"
], ],
"PackageData": { "PackageData": {}
"cpl_cli": [
"templates/*",
"templates/build/*",
"templates/new/*",
"templates/new/console/*",
"templates/new/console/src/*",
"templates/new/console/src/tests/*",
"templates/publish/*"
]
}
} }
} }

View File

@ -11,6 +11,8 @@ from cpl.console.console import Console
from cpl_cli.configuration.build_settings import BuildSettings from cpl_cli.configuration.build_settings import BuildSettings
from cpl_cli.configuration.project_settings import ProjectSettings from cpl_cli.configuration.project_settings import ProjectSettings
from cpl_cli.publish.publisher_abc import PublisherABC from cpl_cli.publish.publisher_abc import PublisherABC
from cpl_cli.templates.build.init import Init
from cpl_cli.templates.publish.setup import Setup
class Publisher(PublisherABC): class Publisher(PublisherABC):
@ -113,7 +115,7 @@ class Publisher(PublisherABC):
def _create_packages(self): def _create_packages(self):
for file in self._included_files: for file in self._included_files:
if file.endswith('console_src_tests.__init__.py'): if file.endswith('__init__.py'):
template_content = '' template_content = ''
module_file_lines: list[str] = [] module_file_lines: list[str] = []
@ -144,8 +146,7 @@ class Publisher(PublisherABC):
if len(module_py_lines) > 0: if len(module_py_lines) > 0:
imports = '\n'.join(module_py_lines) imports = '\n'.join(module_py_lines)
with open(os.path.join(self._runtime.runtime_directory, 'templates/build/init.txt'), 'r') as template: template_content = stringTemplate(Init.get_init_py()).substitute(
template_content = stringTemplate(template.read()).substitute(
Name=self._project_settings.name, Name=self._project_settings.name,
Description=self._project_settings.description, Description=self._project_settings.description,
LongDescription=self._project_settings.long_description, LongDescription=self._project_settings.long_description,
@ -227,16 +228,6 @@ class Publisher(PublisherABC):
if os.path.isfile(setup_file): if os.path.isfile(setup_file):
os.remove(setup_file) os.remove(setup_file)
template_path = os.path.join(self._runtime.runtime_directory, 'templates/publish/setup.txt')
if not os.path.isfile(template_path):
Console.error(__name__, f'setup.py template not found in {template_path}')
return
template_string = ''
with open(template_path, 'r') as template_file:
template_string = template_file.read()
template_file.close()
main = None main = None
try: try:
main = importlib.import_module(self._build_settings.main) main = importlib.import_module(self._build_settings.main)
@ -248,7 +239,7 @@ class Publisher(PublisherABC):
return return
with open(setup_file, 'w+') as setup_py: with open(setup_file, 'w+') as setup_py:
setup_string = stringTemplate(template_string).substitute( setup_string = stringTemplate(Setup.get_setup_py()).substitute(
Name=self._project_settings.name, Name=self._project_settings.name,
Version=self._project_settings.version.to_str(), Version=self._project_settings.version.to_str(),
Packages=setuptools.find_packages(where=self._output_path, exclude=self._build_settings.excluded), Packages=setuptools.find_packages(where=self._output_path, exclude=self._build_settings.excluded),

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
sh_cpl sh-edraft Common Python library
~~~~~~~~~~~~~~~~~~~
sh-edraft Common Python library
:copyright: (c) 2020 - 2021 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'cpl_cli.templates'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2021, minor=4, micro=1)

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
sh_cpl sh-edraft Common Python library
~~~~~~~~~~~~~~~~~~~
sh-edraft Common Python library
:copyright: (c) 2020 - 2021 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'cpl_cli.templates.build'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2021, minor=4, micro=1)

View File

@ -0,0 +1,35 @@
from cpl_cli.templates.template import Template
class Init:
@staticmethod
def get_init_py() -> str:
string = """# -*- coding: utf-8 -*-
\"\"\"
$Name $Description
~~~~~~~~~~~~~~~~~~~
$LongDescription
:copyright: (c) $CopyrightDate $CopyrightName
:license: $LicenseDescription
\"\"\"
__title__ = '$Title'
__author__ = '$Author'
__license__ = '$LicenseName'
__copyright__ = 'Copyright (c) $CopyrightDate $CopyrightName'
__version__ = '$Version'
from collections import namedtuple
$Imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=$Major, minor=$Minor, micro=$Micro)
"""
return Template.build_template_string(string)

View File

@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
"""
$Name $Description
~~~~~~~~~~~~~~~~~~~
$LongDescription
:copyright: (c) $CopyrightDate $CopyrightName
:license: $LicenseDescription
"""
__title__ = '$Title'
__author__ = '$Author'
__license__ = '$LicenseName'
__copyright__ = 'Copyright (c) $CopyrightDate $CopyrightName'
__version__ = '$Version'
from collections import namedtuple
$Imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=$Major, minor=$Minor, micro=$Micro)

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
sh_cpl sh-edraft Common Python library
~~~~~~~~~~~~~~~~~~~
sh-edraft Common Python library
:copyright: (c) 2020 - 2021 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'cpl_cli.templates.new.console.src.tests'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2021, minor=4, micro=1)

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
sh_cpl sh-edraft Common Python library
~~~~~~~~~~~~~~~~~~~
sh-edraft Common Python library
:copyright: (c) 2020 - 2021 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'cpl_cli.templates.publish'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2021, minor=4, micro=1)

View File

@ -0,0 +1,31 @@
from cpl_cli.templates.template import Template
class Setup:
@staticmethod
def get_setup_py() -> str:
string = """\"\"\"
This file is generated by CPL CLI
\"\"\"
import setuptools
setuptools.setup(
name='$Name',
version='$Version',
packages=$Packages,
url='$URL',
license='$LicenseName',
author='$Author',
author_email='$AuthorMail',
include_package_data=$IncludePackageData,
description='$Description',
python_requires='$PyRequires',
install_requires=$Dependencies,
entry_points=$EntryPoints,
package_data=$PackageData
)
"""
return Template.build_template_string(string)

View File

@ -1,21 +0,0 @@
"""
This file is generated by CPL CLI
"""
import setuptools
setuptools.setup(
name='$Name',
version='$Version',
packages=$Packages,
url='$URL',
license='$LicenseName',
author='$Author',
author_email='$AuthorMail',
include_package_data=$IncludePackageData,
description='$Description',
python_requires='$PyRequires',
install_requires=$Dependencies,
entry_points=$EntryPoints,
package_data=$PackageData
)

View File

@ -0,0 +1,14 @@
class Template:
@staticmethod
def build_template_string(string: str) -> str:
return_value = ''
for i in range(0, len(string.splitlines())):
line = string.splitlines()[i]
if i == len(string.splitlines())-1:
return_value += f'{line.strip()}'
break
return_value += f'{line.strip()}\n'
return return_value