Release 2022.10 #112

Merged
edraft merged 51 commits from 2022.10 into master 2022-09-30 15:48:19 +02:00
7 changed files with 36 additions and 55 deletions
Showing only changes of commit f3a11f9791 - Show all commits

View File

@ -31,6 +31,16 @@ class VersionService(CommandABC):
:param args:
:return:
"""
packages = []
cpl_packages = []
dependencies = dict(tuple(str(ws).split()) for ws in pkg_resources.working_set)
for p in dependencies:
if str(p).startswith('cpl-'):
cpl_packages.append([p, dependencies[p]])
continue
packages.append([p, dependencies[p]])
Console.set_foreground_color(ForegroundColorEnum.yellow)
Console.banner('CPL CLI')
Console.set_foreground_color(ForegroundColorEnum.default)
@ -40,31 +50,8 @@ class VersionService(CommandABC):
Console.write_line(f'Python: ')
Console.write(f'{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}')
Console.write_line(f'OS: {platform.system()} {platform.processor()}')
Console.write_line('\nCPL packages:')
cpl_packages = [
'cpl_core',
'cpl_cli',
'cpl_query'
]
packages = []
for modname in cpl_packages:
module = pkgutil.find_loader(modname)
if module is None:
break
module = module.load_module(modname)
if '__version__' in dir(module):
packages.append([f'{modname}', module.__version__])
Console.table(['Name', 'Version'], packages)
Console.table(['Name', 'Version'], cpl_packages)
Console.write_line('\nPython packages:')
packages = []
dependencies = dict(tuple(str(ws).split()) for ws in pkg_resources.working_set)
for p in dependencies:
packages.append([p, dependencies[p]])
Console.table(['Name', 'Version'], packages)

View File

@ -10,7 +10,7 @@ from cpl_discord.helper.to_containers_converter import ToContainersConverter
from cpl_query.extension import List
class Guild(discord.Guild, Container):
class Guild(Container, discord.Guild):
def __init__(self, _t: discord.Guild):
self._object: discord.Guild = _t

View File

@ -10,8 +10,13 @@ class IterableABC(list, QueryableABC):
@abstractmethod
def __init__(self, t: type = None, values: Iterable = None):
values = [] if values is None else values
list.__init__(self, values)
if t is None and len(values) > 0:
t = type(values[0])
self._type = t
list.__init__(self, [] if values is None else values)
def __repr__(self):
return f'<{type(self).__name__} {list(self).__repr__()}>'

View File

@ -42,15 +42,25 @@ class VersionTestCase(unittest.TestCase):
if 7 <= index <= 9:
self._block_version += f'{line}\n'
if 10 <= index <= 15:
if 10 <= index <= 16:
self._block_cpl_packages += f'{line}\n'
if index >= 17:
if index >= 18:
self._block_packages += f'{line}\n'
index += 1
def test_version(self):
packages = []
cpl_packages = []
dependencies = dict(tuple(str(ws).split()) for ws in pkg_resources.working_set)
for p in dependencies:
if str(p).startswith('cpl-'):
cpl_packages.append([p, dependencies[p]])
continue
packages.append([p, dependencies[p]])
version = CLICommands.version()
self._get_version_output(version)
reference_banner = colored(text2art(self._name), ForegroundColorEnum.yellow.value).split('\n')
@ -63,32 +73,11 @@ class VersionTestCase(unittest.TestCase):
colored(f'OS: {colored(f"{platform.system()} {platform.processor()}")}') + '\n'
]
self.assertEqual('\n'.join(reference_version), self._block_version)
packages = []
cpl_packages = [
'cpl_core',
'cpl_cli',
'cpl_query'
]
for modname in cpl_packages:
module = pkgutil.find_loader(modname)
if module is None:
break
module = module.load_module(modname)
if '__version__' in dir(module):
packages.append([f'{modname}', module.__version__])
reference_cpl_packages = [
colored(colored(f'CPL packages:')),
colored(f'{tabulate(packages, headers=["Name", "Version"])}') + '\n'
colored(f'{tabulate(cpl_packages, headers=["Name", "Version"])}') + '\n'
]
self.assertEqual('\n'.join(reference_cpl_packages), self._block_cpl_packages)
packages = []
dependencies = dict(tuple(str(ws).split()) for ws in pkg_resources.working_set)
for p in dependencies:
packages.append([p, dependencies[p]])
reference_packages = [
colored(colored(f'Python packages:')),
colored(f'{tabulate(packages, headers=["Name", "Version"])}'),

View File

@ -181,7 +181,7 @@ class IterableQueryTestCase(unittest.TestCase):
res = self._tests.max(lambda u: u.address.nr)
self.assertEqual(res, self._t_user.address.nr)
tests = List(values=list(range(0, 100)))
tests = List(int, list(range(0, 100)))
self.assertEqual(99, tests.max())
def invalid():
@ -194,7 +194,7 @@ class IterableQueryTestCase(unittest.TestCase):
res = self._tests.min(lambda u: u.address.nr)
self.assertEqual(1, res)
tests = List(values=list(range(0, 100)))
tests = List(int, list(range(0, 100)))
self.assertEqual(0, tests.min())
def invalid():

View File

@ -5,8 +5,8 @@ import unittest
from cpl_query.enumerable import Enumerable
from cpl_query.iterable import Iterable
VALUES = 1000
COUNT = 75
VALUES = 10000
COUNT = 50
class PerformanceTestCase(unittest.TestCase):

View File

@ -23,7 +23,7 @@ class CLICommands:
@staticmethod
def _run_with_output(cmd: str, *args) -> str:
env_vars = os.environ
env_vars['CPL_IS_UNITTEST'] = 'NO'
# env_vars['CPL_IS_UNITTEST'] = 'NO'
command = ['python', CLI_PATH, cmd]
for arg in args: