Skip to content

Commit 0a00ca1

Browse files
author
alexquali
committed
Removing py2 support
1 parent d597678 commit 0a00ca1

105 files changed

Lines changed: 1730 additions & 1678 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
repos:
2+
- repo: https://github.com/asottile/pyupgrade
3+
rev: v3.3.1
4+
hooks:
5+
- id: pyupgrade
6+
exclude: "docs"
27
- repo: https://github.com/timothycrosley/isort
38
rev: 5.12.0
49
hooks:
510
- id: isort
11+
exclude: "docs"
612
- repo: https://github.com/python/black
713
rev: 22.12.0
814
hooks:
915
- id: black
16+
exclude: "docs"
1017
- repo: https://github.com/pycqa/flake8
1118
rev: 5.0.4
1219
hooks:
@@ -17,4 +24,9 @@ repos:
1724
flake8-comprehensions,
1825
flake8-print,
1926
flake8-eradicate,
27+
flake8-requirements,
2028
]
29+
exclude: "docs"
30+
args: [
31+
"--known-modules=cloudshell-rest-api:[cloudshell.rest]"
32+
]

HISTORY.rst

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
=======
22
History
33
=======
4+
2.0.0 (2025-03-30)
5+
-------------------
6+
7+
* Removed support for Python 2.7
8+
* Removed support for Python 3.7
9+
* Removed support for Python 3.8
10+
* Added support for Python 3.10
11+
* Added support for Python 3.11
12+
* Added support for Python 3.12
13+
* Added support for Python 3.13
14+
15+
1.2.27 (2024-10-04)
16+
-------------------
17+
18+
* Fixed for XMLRPC error "Unexpected error during shellfoundry version check." raised during execution of list and new commands
19+
* Fixed for AttributeError: "PackagingRestApiClient" when running generate command
20+
421
1.2.25 (2024-07-30)
522
-------------------
623

@@ -66,7 +83,7 @@ History
6683
1.2.9 (2019-03-27)
6784
------------------
6885

69-
* Added possibility to download dependencies from local CS repository during 'shellfoundry dist' command
86+
* Added possibility to download dependencies from local CS repository during "shellfoundry dist" command
7087

7188
1.2.8 (2019-03-05)
7289
------------------
@@ -230,7 +247,7 @@ History
230247
------------------
231248

232249
* Show command was added to view all available versions of a template
233-
* A new option was added to the 'new' command. Please welcome --version. It enables template versioning on shellfoundry.
250+
* A new option was added to the "new" command. Please welcome --version. It enables template versioning on shellfoundry.
234251

235252
0.0.44 (2016-12-12)
236253
-------------------

dev_requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
pre-commit
22
tox
3-
tox-factor
43
-r test_requirements.txt
54
-r requirements.txt

requirements.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
attrs>=21,<24
12
requests
2-
cookiecutter~=1.7.2
3-
click~=7.1.2
3+
cookiecutter~=2.6.0
4+
click~=8.1.0
45
pyyaml
56
terminaltables
67
cloudshell-rest-api~=9.0.0
78
colorama
8-
giturlparse.py
9+
giturlparse
910
ruamel.yaml
1011
cryptography
1112
setuptools; python_version >= '3.12'
13+
packaging

setup.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
1-
#!/usr/bin/env python
2-
31
from setuptools import find_packages, setup
42

5-
with open("version.txt") as version_file:
6-
version_from_file = version_file.read().strip()
7-
8-
with open("requirements.txt") as f_required:
9-
required = f_required.read().splitlines()
10-
11-
with open("test_requirements.txt") as f_tests:
12-
required_for_tests = f_tests.read().splitlines()
13-
143

154
def get_file_content(file_name):
165
with open(file_name) as f:
176
return f.read()
187

198

9+
readme = get_file_content("README.rst")
10+
history = get_file_content("HISTORY.rst")
11+
version = get_file_content("version.txt").strip()
12+
13+
2014
setup(
2115
name="shellfoundry",
22-
version=version_from_file,
16+
version=version,
2317
description="shellfoundry - Quali tool for creating, "
2418
"building and installing CloudShell shells",
25-
long_description=get_file_content("README.rst")
26-
+ "\n\n"
27-
+ get_file_content("HISTORY.rst"),
19+
long_description=f"{readme}\n\n{history}",
2820
long_description_content_type="text/markdown",
2921
author="Quali",
3022
author_email="info@quali.com",
@@ -33,19 +25,22 @@ def get_file_content(file_name):
3325
package_data={"shellfoundry": ["data/*.yml", "data/*.json"]},
3426
entry_points={"console_scripts": ["shellfoundry = shellfoundry.bootstrap:cli"]},
3527
include_package_data=True,
36-
install_requires=required,
37-
tests_require=required_for_tests,
28+
install_requires=get_file_content("requirements.txt"),
29+
tests_require=get_file_content("test_requirements.txt"),
3830
license="Apache Software License 2.0",
3931
zip_safe=False,
4032
keywords="shellfoundry sandbox cloud virtualization "
4133
"vcenter cmp cloudshell quali command-line cli",
4234
classifiers=[
4335
"Development Status :: 5 - Production/Stable",
44-
"Programming Language :: Python :: 2.7",
45-
"Programming Language :: Python :: 3.7",
36+
"Programming Language :: Python :: 3.9",
37+
"Programming Language :: Python :: 3.10",
38+
"Programming Language :: Python :: 3.11",
39+
"Programming Language :: Python :: 3.12",
40+
"Programming Language :: Python :: 3.13",
4641
"Topic :: Software Development :: Libraries",
4742
"License :: OSI Approved :: Apache Software License",
4843
],
49-
python_requires=">=2.7",
44+
python_requires=">=3.9, <3.14",
5045
test_suite="tests",
5146
)

shellfoundry/__init__.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +0,0 @@
1-
from os.path import dirname, join
2-
3-
ALTERNATIVE_TEMPLATES_PATH = join(dirname(__file__), "data", "templates.yml")
4-
ALTERNATIVE_STANDARDS_PATH = join(dirname(__file__), "data", "standards.json")
5-
6-
MASTER_BRANCH_NAME = "master"
7-
8-
PACKAGE_NAME = __package__.split(".")[0]

shellfoundry/__main__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
3-
41
"""bootstrap.cli: executed when bootstrap directory is called as script."""
52
from .bootstrap import cli
63

shellfoundry/bootstrap.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#!/usr/bin/python
2-
# -*- coding: utf-8 -*-
1+
from __future__ import annotations
2+
3+
from importlib.metadata import version
34

45
import click
5-
import pkg_resources
66

77
from shellfoundry.commands.config_command import ConfigCommandExecutor
88
from shellfoundry.commands.delete_command import DeleteCommandExecutor
@@ -15,8 +15,8 @@
1515
from shellfoundry.commands.new_command import NewCommandExecutor
1616
from shellfoundry.commands.pack_command import PackCommandExecutor
1717
from shellfoundry.commands.show_command import ShowCommandExecutor
18-
from shellfoundry.decorators import shellfoundry_version_check
19-
from shellfoundry.utilities import GEN_ONE, GEN_TWO, LAYER_ONE, NO_FILTER
18+
from shellfoundry.decorators.version_check import shellfoundry_version_check
19+
from shellfoundry.utilities.filters import GEN_ONE, GEN_TWO, LAYER_ONE, NO_FILTER
2020

2121

2222
@click.group()
@@ -25,11 +25,9 @@ def cli():
2525

2626

2727
@cli.command()
28-
def version():
28+
def version(): # noqa: F811
2929
"""Displays the shellfoundry version."""
30-
click.echo(
31-
"shellfoundry version " + pkg_resources.get_distribution("shellfoundry").version
32-
)
30+
click.echo(f"shellfoundry version {version('shellfoundry')}")
3331

3432

3533
@cli.command() # noqa: A001

shellfoundry/commands/config_command.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#!/usr/bin/python
2-
# -*- coding: utf-8 -*-
1+
from __future__ import annotations
32

43
import click
4+
from attrs import define, field
55

66
from shellfoundry.utilities.config.config_context import ConfigContext
77
from shellfoundry.utilities.config.config_file_creation import ConfigFileCreation
@@ -15,50 +15,51 @@
1515
DEFAULTS_CHAR = "*"
1616

1717

18-
class ConfigCommandExecutor(object):
19-
def __init__(self, global_cfg, cfg_creation=None):
20-
self.global_cfg = global_cfg
21-
self.cfg_creation = cfg_creation or ConfigFileCreation()
18+
@define
19+
class ConfigCommandExecutor:
20+
global_cfg: bool
21+
cfg_creation: ConfigFileCreation = field(factory=ConfigFileCreation)
2222

23-
def config(self, kv=(None, None), key_to_remove=None):
23+
def config(
24+
self,
25+
kv: tuple[str | None, str | None] = (None, None),
26+
key_to_remove: str = None,
27+
) -> None:
2428
config_file_path = self._get_config_file_path(self.global_cfg)
25-
if self._should_remove_key(key_to_remove):
29+
if key_to_remove is not None: # remove key
2630
context = ConfigContext(config_file_path)
2731
ConfigRecord(key_to_remove).delete(context)
28-
elif self._should_append_key(kv):
29-
field, name = kv
30-
if not name:
31-
raise click.BadArgumentUsage(
32-
"Field '{}' can not be empty".format(field)
33-
)
32+
elif None not in kv: # append key
33+
config_key, config_value = kv
34+
if not config_value:
35+
raise click.BadArgumentUsage(f"Field '{config_key}' can not be empty")
3436
else:
3537
self.cfg_creation.create(config_file_path)
3638
context = ConfigContext(config_file_path)
3739
ConfigRecord(*kv).save(context)
3840
else:
3941
self._echo_config(config_file_path)
4042

41-
def _should_append_key(self, kv):
42-
return None not in kv
43-
44-
def _should_remove_key(self, key_to_remove):
45-
return key_to_remove is not None
46-
47-
def _echo_config(self, config_file_path):
48-
43+
def _echo_config(self, config_file_path: str) -> None:
44+
"""Print current configuration."""
4945
config_data = Configuration.readall(
5046
config_file_path, mark_defaults=DEFAULTS_CHAR
5147
)
5248
table = self._format_config_as_table(config_data, DEFAULTS_CHAR)
5349
click.echo(table)
5450
click.echo("")
5551
click.echo(
56-
"* Value marked with '{}' is actually the default value and has not been override by the user.".format( # noqa: E501
57-
DEFAULTS_CHAR
58-
)
52+
f"* Value marked with '{DEFAULTS_CHAR}' "
53+
f"is actually the default value and has not been override by the user."
5954
)
6055

61-
def _format_config_as_table(self, config_data, defaults_char):
56+
@staticmethod
57+
def _format_config_as_table(
58+
config_data: dict[str, dict], defaults_char: str
59+
) -> str:
60+
"""Format configuration in readable table view."""
61+
import terminaltables
62+
6263
from shellfoundry.utilities.modifiers.configuration.password_modification import ( # noqa: E501
6364
PasswordModification,
6465
)
@@ -72,15 +73,14 @@ def _format_config_as_table(self, config_data, defaults_char):
7273
if key in PasswordModification.HANDLING_KEYS:
7374
value = "[encrypted]"
7475
table_data.append([key, value, default_val])
75-
import terminaltables
7676

7777
table = terminaltables.AsciiTable(table_data)
7878
table.outer_border = False
7979
table.inner_column_border = False
8080
return table.table
8181

8282
@staticmethod
83-
def _get_config_file_path(is_global_flag):
83+
def _get_config_file_path(is_global_flag: bool) -> str:
8484
if is_global_flag:
8585
cfg_provider = GlobalConfigProvider()
8686
return cfg_provider.get_config_path()

shellfoundry/commands/delete_command.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
# !/usr/bin/python
2-
# -*- coding: utf-8 -*-
1+
from __future__ import annotations
32

43
import click
4+
from attrs import define, field
55

66
from shellfoundry.exceptions import FatalError
77
from shellfoundry.utilities.shell_package_installer import ShellPackageInstaller
88

99

10-
class DeleteCommandExecutor(object):
11-
def __init__(self, shell_package_installer=None):
12-
self.shell_package_installer = (
13-
shell_package_installer or ShellPackageInstaller()
14-
)
10+
@define
11+
class DeleteCommandExecutor:
12+
shell_package_installer: ShellPackageInstaller = field(
13+
factory=ShellPackageInstaller
14+
)
1515

16-
def delete(self, shell_name):
16+
def delete(self, shell_name: str) -> None:
1717
try:
1818
self.shell_package_installer.delete(shell_name=shell_name)
1919
except FatalError as err:
20-
2120
msg = err.message if hasattr(err, "message") else err.args[0]
2221
click.ClickException(msg)
2322

0 commit comments

Comments
 (0)