Added split function
This commit is contained in:
parent
85f75b4677
commit
002ba6b4e0
@ -20,10 +20,10 @@
|
|||||||
"hello-world": "echo 'Hello World'",
|
"hello-world": "echo 'Hello World'",
|
||||||
|
|
||||||
"sv": "cpl set-version",
|
"sv": "cpl set-version",
|
||||||
"set-version": "cpl run set-version $ARGS; echo '';",
|
"set-version": "cpl run set-version --dev $ARGS; echo '';",
|
||||||
|
|
||||||
"spu": "cpl set-pip-urls",
|
"spu": "cpl set-pip-urls",
|
||||||
"set-pip-urls": "cpl run set-pip-urls $ARGS; echo '';",
|
"set-pip-urls": "cpl run set-pip-urls --dev $ARGS; echo '';",
|
||||||
|
|
||||||
"docs-build": "echo 'Build Documentation'; cpl db-core; cpl db-discord; cpl db-query; cpl db-translation; cd docs/; make clean; make html; # rm source/cpl_query.tests.rst;",
|
"docs-build": "echo 'Build Documentation'; cpl db-core; cpl db-discord; cpl db-query; cpl db-translation; cd docs/; make clean; make html; # rm source/cpl_query.tests.rst;",
|
||||||
"db-core": "cd docs/; sphinx-apidoc -o source/ ../src/cpl_core; cd ../",
|
"db-core": "cd docs/; sphinx-apidoc -o source/ ../src/cpl_core; cd ../",
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
cpl-discord sh-edraft Common Python library Discord
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
sh-edraft Common Python library link between discord.py and CPL
|
||||||
|
|
||||||
|
:copyright: (c) 2021 - 2022 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'cpl_discord'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||||
|
__version__ = '2022.12.0'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major='2022', minor='12', micro='0')
|
@ -15,7 +15,7 @@ __title__ = 'cpl_query'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.1.post1'
|
__version__ = '2022.12.1.post2'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='1.post1')
|
version_info = VersionInfo(major='2022', minor='12', micro='1.post2')
|
||||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_query.base'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.1.post1'
|
__version__ = '2022.12.1.post2'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='1.post1')
|
version_info = VersionInfo(major='2022', minor='12', micro='1.post2')
|
||||||
|
@ -475,6 +475,39 @@ class QueryableABC(Sequence):
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def split(self, _func: Callable) -> 'QueryableABC':
|
||||||
|
r"""Splits the list by given function
|
||||||
|
|
||||||
|
|
||||||
|
Parameter
|
||||||
|
---------
|
||||||
|
func: :class:`Callable`
|
||||||
|
seperator
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
:class: `cpl_query.base.queryable_abc.QueryableABC`
|
||||||
|
"""
|
||||||
|
groups = []
|
||||||
|
group = []
|
||||||
|
for x in self:
|
||||||
|
v = _func(x)
|
||||||
|
if x == v:
|
||||||
|
groups.append(group)
|
||||||
|
group = []
|
||||||
|
|
||||||
|
group.append(x)
|
||||||
|
|
||||||
|
groups.append(group)
|
||||||
|
|
||||||
|
query_groups = []
|
||||||
|
for g in groups:
|
||||||
|
if len(g) == 0:
|
||||||
|
continue
|
||||||
|
query_groups.append(type(self)(self._type, g))
|
||||||
|
|
||||||
|
return type(self)(self._type, query_groups)
|
||||||
|
|
||||||
def take(self, _index: int) -> 'QueryableABC':
|
def take(self, _index: int) -> 'QueryableABC':
|
||||||
r"""Takes all elements from index
|
r"""Takes all elements from index
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"Version": {
|
"Version": {
|
||||||
"Major": "2022",
|
"Major": "2022",
|
||||||
"Minor": "12",
|
"Minor": "12",
|
||||||
"Micro": "1.post1"
|
"Micro": "0"
|
||||||
},
|
},
|
||||||
"Author": "Sven Heidemann",
|
"Author": "Sven Heidemann",
|
||||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_query.enumerable'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.1.post1'
|
__version__ = '2022.12.1.post2'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -25,4 +25,4 @@ from .enumerable import Enumerable
|
|||||||
from .enumerable_abc import EnumerableABC
|
from .enumerable_abc import EnumerableABC
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='1.post1')
|
version_info = VersionInfo(major='2022', minor='12', micro='1.post2')
|
||||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_query.extension'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.1.post1'
|
__version__ = '2022.12.1.post2'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -24,4 +24,4 @@ from collections import namedtuple
|
|||||||
from .list import List
|
from .list import List
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='1.post1')
|
version_info = VersionInfo(major='2022', minor='12', micro='1.post2')
|
||||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_query.iterable'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.1.post1'
|
__version__ = '2022.12.1.post2'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -25,4 +25,4 @@ from .iterable_abc import IterableABC
|
|||||||
from .iterable import Iterable
|
from .iterable import Iterable
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='1.post1')
|
version_info = VersionInfo(major='2022', minor='12', micro='1.post2')
|
||||||
|
Loading…
Reference in New Issue
Block a user