Improved template handling
This commit is contained in:
25
src/cpl_cli/templates/__init__.py
Normal file
25
src/cpl_cli/templates/__init__.py
Normal 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)
|
25
src/cpl_cli/templates/build/__init__.py
Normal file
25
src/cpl_cli/templates/build/__init__.py
Normal 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)
|
35
src/cpl_cli/templates/build/init.py
Normal file
35
src/cpl_cli/templates/build/init.py
Normal 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)
|
@@ -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)
|
@@ -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)
|
||||
|
25
src/cpl_cli/templates/publish/__init__.py
Normal file
25
src/cpl_cli/templates/publish/__init__.py
Normal 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)
|
31
src/cpl_cli/templates/publish/setup.py
Normal file
31
src/cpl_cli/templates/publish/setup.py
Normal 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)
|
@@ -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
|
||||
)
|
14
src/cpl_cli/templates/template.py
Normal file
14
src/cpl_cli/templates/template.py
Normal 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
|
Reference in New Issue
Block a user