Improved template handling

This commit is contained in:
2021-03-10 08:09:56 +01:00
parent 31515d2c3a
commit f4ca76d844
11 changed files with 201 additions and 86 deletions

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