diff --git a/.github/workflows/python_package_mac_recommended.yml b/.github/workflows/python_package_mac_recommended.yml deleted file mode 100644 index 55988d7..0000000 --- a/.github/workflows/python_package_mac_recommended.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Pytest Package MAC OS with recommended installations -on: [push] -jobs: - Explore-Pytest-Action: - runs-on: macos-latest - strategy: - fail-fast: false - matrix: - # older version do not work (blist compile fails); but they work with original blist package - - python-version: ["3.9","3.10","3.11"] - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Switch to Current Branch - run: git checkout ${{ env.BRANCH }} - - name: Install the package - run: | - python setup.py install - pip install --upgrade pip - pip install pytest - pip install pytest-cov - pip install ojson - pip install ./dist/blist_br_1.3.7b1.tar.gz - pip install numpy - # temporarily install numpy, bug in module's dependencies. - - name: GitHub Action for pytest - run: | - #python -m pytest ./tests - pytest ./tests/ --show-capture=all --capture=tee-sys --doctest-modules --junitxml=junit/test-results-${{ matrix.python-version }}.xml - - name: Upload pytest test results - uses: actions/upload-artifact@v4 - with: - name: pytest-results-${{ matrix.python-version }}.xml - path: junit/test-results-${{ matrix.python-version }}.xml \ No newline at end of file diff --git a/.github/workflows/python_package_recommended.yml b/.github/workflows/python_package_recommended.yml deleted file mode 100644 index e8b218d..0000000 --- a/.github/workflows/python_package_recommended.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Pytest Package UBUNTU with recommended installations -on: [push] -jobs: - Explore-Pytest-Action: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - - python-version: ["3.7","3.8", "3.9","3.10","3.11"] #blist compile not working on python 3.10 - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Switch to Current Branch - run: git checkout ${{ env.BRANCH }} - - name: Install the package - run: | - python setup.py install - pip install --upgrade pip - pip install pytest - pip install ojson - pip install ./dist/blist_br_1.3.7b1.tar.gz - pip install numpy - # temporarily install numpy, bug in module's dependencies. - - name: GitHub Action for pytest - run: | - #python -m pytest ./tests - pytest ./tests/ --show-capture=all --capture=tee-sys --doctest-modules --junitxml=junit/test-results-${{ matrix.python-version }}.xml - - name: Upload pytest test results - uses: actions/upload-artifact@v4 - with: - name: pytest-results-${{ matrix.python-version }}.xml - path: junit/test-results-${{ matrix.python-version }}.xml diff --git a/.github/workflows/python_package_standard.yml b/.github/workflows/python_package_standard.yml index 610db10..96edee5 100644 --- a/.github/workflows/python_package_standard.yml +++ b/.github/workflows/python_package_standard.yml @@ -1,4 +1,4 @@ -name: Pytest Package UBUNTU with standard installation +name: Pytest Package Linux with standard installation on: [push] jobs: Explore-Pytest-Action: @@ -6,8 +6,7 @@ jobs: strategy: fail-fast: false matrix: - - python-version: ["3.7","3.8", "3.9","3.10","3.11"] + python-version: ["3.8", "3.9","3.10","3.11"] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -18,9 +17,10 @@ jobs: run: git checkout ${{ env.BRANCH }} - name: Install the package run: | - python setup.py install pip install --upgrade pip pip install pytest + pip install setuptools + python setup.py install - name: GitHub Action for pytest run: | #python -m pytest ./tests diff --git a/.github/workflows/python_package_win_recommended.yml b/.github/workflows/python_package_win_recommended.yml deleted file mode 100644 index 18b8da8..0000000 --- a/.github/workflows/python_package_win_recommended.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Pytest Package WINDOWS with recommended installations -on: [push] -jobs: - Explore-Pytest-Action: - runs-on: windows-latest - strategy: - fail-fast: false - matrix: - python-version: ["3.7","3.8", "3.9","3.10", "3.11"] #blist compile not working on python 3.10 - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Switch to Current Branch - run: git checkout ${{ env.BRANCH }} - - name: Install the package - run: | - python setup.py install - pip install --upgrade pip - pip install pytest - pip install pytest-cov - pip install ojson - pip install ./dist/blist_br_1.3.7b1.tar.gz - pip install numpy - # temporarily install numpy, bug in module's dependencies. - - name: GitHub Action for pytest - run: | - #python -m pytest ./tests - pytest ./tests/ --show-capture=all --capture=tee-sys --doctest-modules --junitxml=junit/test-results-${{ matrix.python-version }}.xml - - name: Upload pytest test results - uses: actions/upload-artifact@v4 - with: - name: pytest-results-${{ matrix.python-version }}.xml - path: junit/test-results-${{ matrix.python-version }}.xml diff --git a/.github/workflows/python_package_win_standard.yml b/.github/workflows/python_package_win_standard.yml index e52c6ce..8913f14 100644 --- a/.github/workflows/python_package_win_standard.yml +++ b/.github/workflows/python_package_win_standard.yml @@ -7,7 +7,7 @@ jobs: fail-fast: false matrix: - python-version: ["3.7","3.8", "3.9","3.10","3.11"] + python-version: ["3.6.8","3.7.9","3.8.10", "3.9.13","3.10.11","3.11.9","3.12.10","3.13.7"] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -18,9 +18,10 @@ jobs: run: git checkout ${{ env.BRANCH }} - name: Install the package run: | - python setup.py install pip install --upgrade pip pip install pytest + pip install setuptools + python setup.py install - name: GitHub Action for pytest run: | #python -m pytest ./tests diff --git a/README.md b/README.md index 7bdf01e..4e54d85 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ![Static Badge](https://img.shields.io/badge/python-%3E%3D3.4-green) [![Static Badge](https://img.shields.io/badge/licence-MIT(hpp)-green)](https://github.com/BR1py/itertree/blob/main/LICENSE) [![Static Badge](https://img.shields.io/badge/documenation-https%3A%2F%2Fitertree.readthedocs.io%2Fen%2Flatest%2F-yellow?logo=readthedocs)](https://itertree.readthedocs.io/en/latest/) -![GitHub Release 1.1.3 - Published_At](https://img.shields.io/github/release-date/Br1py/itertree) +![GitHub Release 1.2.0 - Published_At](https://img.shields.io/github/release-date/Br1py/itertree) # itertree python package @@ -11,7 +11,7 @@ ## Welcome to itertree python package -Release 1.1.3 - released +Release 1.2.0 - released * Do you have to store data in a tree like structure? * Do you need good performance and a reach feature set in the tree object? @@ -53,14 +53,14 @@ are obviously only possible if the other packages are available. But we have two recommendations which give the package additional performance: -* blist - *Highly recommended!* This will speedup the iTree performance in huge trees especially for inserting and lefthandside operations +* blist - *Highly recommended!* This will speed up the iTree performance in huge trees especially for inserting and lefthandside operations * package link: https://pypi.org/project/blist/ * documentation: http://stutzbachenterprises.com/blist/. -> in case the package is not found normal list object will be used instead - -> If you like to utilize blist under Python 3.10 and 3.11 read the installation hints in the + -> If you like to utilize blist under Python >3.10 read the installation hints in the Introduction of the itertree documentation. @@ -146,7 +146,7 @@ of the parent sub-tree (like `append()` in lists). Each `iTree`-object has a tag which is the main part of the identifier of the object. For tags you can use any type of hashable objects. -Different than the keys in dictionaries the given tags must not be unique! The user should understand that in general +Different as the keys in dictionaries the given tags must not be unique! The user should understand that in general `iTree`-objects behave more like nested lists than nested dicts: >>> root.append(iTree('child', 5)) diff --git a/build_helpers/build_wheel.cmd b/build_helpers/build_wheel.cmd index d79c469..1b22b83 100644 --- a/build_helpers/build_wheel.cmd +++ b/build_helpers/build_wheel.cmd @@ -1,4 +1,4 @@ -c:\tools\python\python39\python -m build +c:\tools\python\python311\python -m build rem For PyPi upload use: rem c:\tools\python\python35\python -m twine upload dist/* diff --git a/build_helpers/commit_to_pypi.txt b/build_helpers/commit_to_pypi.txt index 083fa94..a653453 100644 --- a/build_helpers/commit_to_pypi.txt +++ b/build_helpers/commit_to_pypi.txt @@ -1,10 +1,11 @@ workflow -1. ensure that all version informations in th epackage are updated properly +1. ensure that all version information in the package are updated properly 1b. Check especially in README.md! 2. build the wheel via build_wheel.cmd 3. PyPi upload: -c:\tools\python\python35\python -m twine upload dist/* +temporary remove the blist package +c:\tools\python\python311\python -m twine upload dist/* 4. push dev to main on git 5. recheck if readthedocs was properly updated 6. Create the release on GIT and tag it diff --git a/build_helpers/update_version.py b/build_helpers/update_version.py index ca62908..9feba6c 100644 --- a/build_helpers/update_version.py +++ b/build_helpers/update_version.py @@ -1,6 +1,28 @@ -# -*- coding: utf-8 -*- +""" +This code is taken from the itertree package: + + ___ _____ _____ ____ _____ ____ _____ _____ + |_ _|_ _| ____| _ \_ _| _ \| ____| ____| + | | | | | _| | |_) || | | |_) | _| | _| + | | | | | |___| _ < | | | _ <| |___| |___ + |___| |_| |_____|_| \_\|_| |_| \_\_____|_____| + + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +This helper script is used to replace the version information in the whole source package +""" import os -VERSION='1.1.3' +VERSION='1.2.0' def replacer(filename,pre_tag,post_tag): print('Update version in %s' % filepath) @@ -35,6 +57,8 @@ def replacer(filename,pre_tag,post_tag): print('Write version: %s into the files\n'%VERSION) +os.chdir('..') + filepath = 'src/itertree/__init__.py' pre_tag=b'__version__ = \'' post_tag=b'\'' diff --git a/dist/itertree-1.1.3-py3-none-any.whl b/dist/itertree-1.1.3-py3-none-any.whl deleted file mode 100644 index da264b0..0000000 Binary files a/dist/itertree-1.1.3-py3-none-any.whl and /dev/null differ diff --git a/dist/itertree-1.1.3.tar.gz b/dist/itertree-1.1.3.tar.gz deleted file mode 100644 index 55875eb..0000000 Binary files a/dist/itertree-1.1.3.tar.gz and /dev/null differ diff --git a/dist/itertree-1.2.0-py3-none-any.whl b/dist/itertree-1.2.0-py3-none-any.whl new file mode 100644 index 0000000..eba91d9 Binary files /dev/null and b/dist/itertree-1.2.0-py3-none-any.whl differ diff --git a/dist/itertree-1.2.0.tar.gz b/dist/itertree-1.2.0.tar.gz new file mode 100644 index 0000000..e5f3ce7 Binary files /dev/null and b/dist/itertree-1.2.0.tar.gz differ diff --git a/docs/conf.py b/docs/conf.py index 00b2701..9b6d685 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -50,7 +50,7 @@ # General information about the project. project = u'itertree' -copyright = u'%d, B.R. MIT Licence (human protect patch)' % (time.gmtime().tm_year,) +copyright = u'%d, B.R. MIT Licence' % (time.gmtime().tm_year,) # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -59,7 +59,7 @@ # The short X.Y version. # The full version, including alpha/beta/rc tags. -release = '1.1.3' +release = '1.2.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/docs/background.rst b/docs/docs/background.rst index 0c1d4c4..4b1dbf2 100644 --- a/docs/docs/background.rst +++ b/docs/docs/background.rst @@ -232,44 +232,3 @@ related to the given key or index in the `iTree.value` and again the method will You might have a look in the examples/itree_data_models.py file to get a better idea what a data-model is in this contents. - -.. _background_licence: - -******************************** -Short words about the licencing -******************************** - -This Software and it's artifacts are licenced under MIT licence with an extension that protects human lives. - -Therefore the condition: - -" -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed." - -was added to the licence. - -The author is aware about the situation that in practices this might not be controlled or even judged. - -But it should be clear that from the point of view of the author such an usage is illegal. The author is not willing -to spend his lifetime and creativity for the propose of killing people. We think the user should respect the -intense of the author if he uses his knowledge and objectives. - -Of course the point can be discussed and we respect here other meanings but please consider and -respect this as a personal opinion. - -In practices people will always find good arguments for utilizing things also to harm people (e.g. control terrorism). -But from our point of view in a modern, enlightened society we should find better answers. - -E.g. we also think that the possibility of winning a war is a total illusion. Beside raising fears the lie of -winning wars is most often used to utilize large amount of resources which make few people richer or more powerful. -But all the targeted people on both sides of such conflicts loose lives, freedom, truth, etc.. To protect us from -such situations we need globally respected rules and less national intentions. This is the direction -were we must put our resources and effort. - -At least: People should take responsibility for the objectives they are delivering and publishing. They should -give conditions for usage. And the global law should respect such conditions given by the authors even -if it is against the national interests and the interests of the majority. - -So please respect the authors meaning even if you have other opinion about this content. diff --git a/docs/docs/changelog.rst b/docs/docs/changelog.rst index 5f75080..a79ff16 100644 --- a/docs/docs/changelog.rst +++ b/docs/docs/changelog.rst @@ -1,14 +1,21 @@ .. _changelog: -************************************ +Version 1.2.0 +=============== + +Changed the modified MIT licence back to standard MIT + +Fix missing import in one of the test scripts + +Removed parameter "up_to_low" in iterators (no more depreciation warning generated). + Version 1.1.3 -************************************ +=============== Bugfix added missing folder in package -************************************ Version 1.1.2 -************************************ +=============== New iteration features: @@ -18,9 +25,8 @@ Beside this the inheritence of the iTree class as a super class of another objec The test suite is enlarged. -************************************ Version 1.0.3 -************************************ +=============== This version contains minor changes related to comments and the test setup. @@ -31,16 +37,15 @@ We appended a new version of blist which can be used in python 3.10 and 3.11 env Issues #21,#22 solved. -************************************ Version 1.0.5 -************************************ +=============== + Minor bugfix (escapes). And correct issues related wrong commit in 1.0.3 -************************************ Version 1.0.3 -************************************ +=============== This version contains minor changes related to comments and the test setup. @@ -51,9 +56,8 @@ We appended a new version of blist which can be used in python 3.10 and 3.11 env Issues #21,#22 solved. -************************************ Version 1.0.1 -************************************ +=============== Full released @@ -108,9 +112,8 @@ The MIT licence was extended by a "human protect patch". To symbolize the stability and also the final fix of the interface we decided to create the first full released version. The testsuite is largely expanded for this step. -************************************ Version 0.8.2 -************************************ +=============== We reworked the itertree data module so that iData class behaves much better like a dict. All overloaded methods are improved to match the dict interface. Also `iTDataModel` is changed and is now a class that must be overloaded. @@ -139,9 +142,8 @@ official 1.0.0 release. Still Beta SW -> but release candidate! -************************************ Version 0.7.3 -************************************ +=============== Bugfixes in repr() and render() @@ -149,9 +151,8 @@ Extended examples Still Beta SW -> but release candidate! -************************************ Version 0.7.2 -************************************ +=============== Improved Interval class (dynamic limits in all levels) @@ -159,17 +160,15 @@ Adapted some tests and the documentation Still Beta SW -> but release candidate! -************************************ Version 0.7.1 -************************************ +=============== Bigger bugfix on 0.7.0 which was really not well tested! Still Beta SW -> but release candidate! -************************************ Version 0.7.0 -************************************ +=============== Recursive functions are rewritten to use an iterative approach (recursion limit exception should be avoided) @@ -183,9 +182,8 @@ Examples regarding data models added Still Beta SW -> but release candidate! -************************************ Version 0.6.0 -************************************ +=============== Improved interface and performance @@ -198,9 +196,8 @@ Examples still missing Beta SW! -************************************ Version 0.5.0 -************************************ +=============== First released version diff --git a/docs/docs/licence.rst b/docs/docs/licence.rst index b9bfa35..3b19e6e 100644 --- a/docs/docs/licence.rst +++ b/docs/docs/licence.rst @@ -3,28 +3,56 @@ Licence ======== -The code is published under **MIT license incl. human protect patch**: +The code is published under **MIT license**: -The MIT License (MIT) incl. human protect patch -Copyright © 2022 +MIT License -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: +Copyright (c) 2025 B.R. -*Human protect patch*: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. For more information see: https://en.wikipedia.org/wiki/MIT_License +.. _background_licence: + +Human protection +**************** + +In older versions we added the human protect patch to the MIT licence. +The patch was removed from the licence from version 1.2.0 on. + +This is just made for compatibility reasons related to other software projects using this package. +For the authors the human protect patch would still make sense. But we believe that a wider usage +of the package brings more positive effects then negative effects (related to human protection too). + +To express our intention we finally ask every user to consider the following extension +on an **optional voluntarily** base (even that the additional article is no more part of the license): + +*Human protection*: +The program and its derivative work will neither be modified or executed to harm any human being nor through +inaction permit any human being to be harmed. +At least in our opinion people should take more responsibility for the objectives they are delivering and publishing. +The global society should find new and better regulations for such proposes. Currently we see on the one hand side +nearly total freedom to use any artifact for the users advantage (like MIT) and on the other hand we have relative +high protected areas (copyrights, patents) which limits the usage mainly to protect the owners advantages related +to his benefit (win money, win force, etc.). We need here additional possibilities, like free patents +and a more detailed control related to the usage of these objectives +(like human protection or non exclusive rights only). Related to open source licences a cascade setup +of licence regulations might be possible. diff --git a/docs/docs/tutorial.rst b/docs/docs/tutorial.rst index 7f0d5ef..8772d13 100644 --- a/docs/docs/tutorial.rst +++ b/docs/docs/tutorial.rst @@ -13,8 +13,13 @@ It's recommended to have a look on the related examples too (stored in the examp **Status and compatibility information:** -The original implementation is done in python 3.9 and it is tested under python 3.5, 3.9 and 3.11. It should work for -all Python-versions >= 3.4. +The original implementation is done in Python 3.9. + +This release is tested in different OS for the Python versions: + +3.6, 3.7, 3.8, 3.9, 3.11, 3.12, 3.13 + +It should work for all Python versions >= 3.4. From version 1.0.0 on we see the package as released and stable. The unit and integration test suite should target a huge amount of functionalities and use cases. We will try to keep the interface stable too. @@ -28,7 +33,7 @@ Quick start - the basics We really hope that the usage of the itertree package is intuitive. If the user is familiar with `list` and `dict` objects the basic functionality should be easy to understand. If you extend the functions to nested lists or dicts you already get a tree like structure. What is really a bit complex are the functions related to tree iterations -and filterings but of course the "simple" iteration like in the other objects are available too. +and filtering but of course the "simple" iteration like in the other objects are available too. Build the object ++++++++++++++++ @@ -196,7 +201,7 @@ Additional in-depth functionalities (especially deep-iterators) can be found in >>> # flatten iterators over all in-depth items: >>> [i for i in root.deep] # up-down order [iTree('item0', value=0), iTree('item1', value=1, subtree=[iTree('sub_item0', value=0.1)]), iTree('sub_item0', value=0.1), iTree((1, 2), value=3), iTree('item1', value={'value1': 2, 'value2': 3}, subtree=[iTree('sub_item0', value=4.1)]), iTree('sub_item0', value=4.1)] - >>> [i for i in root.deep.tag_idx_paths(up_to_low=False)] # tag_idx related iterator; down-up order + >>> [i for i in root.deep.tag_idx_paths(options=ITER.UP)] # tag_idx related iterator; down-up order [((('item0', 0),), iTree('item0', value=0)), ((('item1', 0), ('sub_item0', 0)), iTree('sub_item0', value=0.1)), ((('item1', 0),), iTree('item1', value=1, subtree=[iTree('sub_item0', value=0.1)])), ((((1, 2), 0),), iTree((1, 2), value=3)), ((('item1', 1), ('sub_item0', 0)), iTree('sub_item0', value=4.1)), ((('item1', 1),), iTree('item1', value={'value1': 2, 'value2': 3}, subtree=[iTree('sub_item0', value=4.1)]))] @@ -1994,8 +1999,24 @@ Most in-depth iteration-methods have additional parameters: * `filter_method` filter parameter which allows the hierarchical-filtering inside the iteration loops. - * `up_to_low` allows to select the - direction of the iteration top->down or bottom-> up (default: `up_to_low=True`). + * `options` allows to select the + direction of the iteration via flags: + + * ITER.DOWN - top to down level iteration (default) + + * ITER.UP - down to top level iteration + + * ITER.REVERSE - + The children of a item are iterated in the reversed direction (high index to zero index). + The default iteration direction for the children is zero index to highest index) + + * ITER.SELF - + In the iteration the calling object (self) will be included. + The default is that the calling object is not part of the iteration + + * ITER.FILTER_ANY - + This flag has effect if a filter_method is given. It enables the pythons + build_in `filter()` on any iterated object. The default is a hierarchical filtering. All the **in-depth** iteration-methods are reached via the helper class `iTree.deep`: @@ -2026,11 +2047,6 @@ We have several options which influences the way we iterate over the tree they c build_in `filter()` on any iterated object (non hierarchical filtering). The default is a hierarchical filtering. - .. note:: Only for downward compatibility with the depreciated positional `up_to_low`-parameter the option - `ITER.DOWN` and 0 (~ ITER.UP) exists too. If `ITER.DOWN | ITER.UP` is combined the option - `ITER.DOWN` will be ignored. In general we can say that using ITER.DOWN is not recommended. - - The named argument `up_to_low` still exists too. But if used a depreciation warning will be given. .. start: tutorial-code 20 @@ -2043,9 +2059,9 @@ We have several options which influences the way we iterate over the tree they c subitem = item.append(iTree('%i_%i' % (i,ii), i*10+ii)) for iii in range(2): subitem.append(iTree('%i_%i_%i' % (i, ii,iii), i * 100 + ii*10+iii)) - >>> [i for i in root.deep.iter(up_to_low=True)][0:5] # show just a part + >>> [i for i in root.deep.iter(options=ITER.DOWN)][0:5] # show just a part [iTree('0', value=0, subtree=[iTree('0_0', value=0, subtree=[iTree('0_0_0', value=0), iTree('0_0_1', value=1)]), iTree('0_1', value=1, subtree=[iTree('0_1_0', value=10), iTree('0_1_1', value=11)])]), iTree('0_0', value=0, subtree=[iTree('0_0_0', value=0), iTree('0_0_1', value=1)]), iTree('0_0_0', value=0), iTree('0_0_1', value=1), iTree('0_1', value=1, subtree=[iTree('0_1_0', value=10), iTree('0_1_1', value=11)])] - >>> [i for i in root.deep.iter(up_to_low=False)][0:5] # show just a part + >>> [i for i in root.deep.iter(options=ITER.UP)][0:5] # show just a part [iTree('0_0_0', value=0), iTree('0_0_1', value=1), iTree('0_0', value=0, subtree=[iTree('0_0_0', value=0), iTree('0_0_1', value=1)]), iTree('0_1_0', value=10), iTree('0_1_1', value=11)] .. end - entry created: 2023-06-22T21:38:27 @@ -2371,7 +2387,7 @@ In the following example we create based on the in-depth generators lists and di >>> # deep iterators: >>> list(root.deep) # deep counterpart of level1 __iter__() iterator [iTree('one', value=1, subtree=[iTree('subone', value=1.1), iTree('subtwo', value=1.2)]), iTree('subone', value=1.1), iTree('subtwo', value=1.2), iTree('two', value=2), iTree('three', value=3)] - >>> list(root.deep.iter(up_to_low=False)) # changed iteration order bottom-> up + >>> list(root.deep.iter(options=ITER.UP)) # changed iteration order bottom-> up [iTree('subone', value=1.1), iTree('subtwo', value=1.2), iTree('one', value=1, subtree=[iTree('subone', value=1.1), iTree('subtwo', value=1.2)]), iTree('two', value=2), iTree('three', value=3)] >>> list(root.deep.tag_idx_paths()) # deep counterpart of level1 items() iterator [((('one', 0),), iTree('one', value=1, subtree=[iTree('subone', value=1.1), iTree('subtwo', value=1.2)])), ((('one', 0), ('subone', 0)), iTree('subone', value=1.1)), ((('one', 0), ('subtwo', 0)), iTree('subtwo', value=1.2)), ((('two', 0),), iTree('two', value=2)), ((('three', 0),), iTree('three', value=3))] diff --git a/docs/index.rst b/docs/index.rst index 4e17c26..8b1569e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -16,6 +16,7 @@ docs/examples docs/comparison docs/background + docs/changelog docs/licence docs/changelog @@ -88,7 +89,7 @@ Status and compatibility information Please use the `github issues `_ to ask questions report problems. -.. |release| replace:: Version | 1.1.3| +.. |release| replace:: Version | 1.2.0| .. _release: https://pypi.python.org/pypi/itertree/ The original implementation is done in Python 3.9 and it is tested under Python 3.5, 3.6 and 3.9. The package @@ -96,8 +97,8 @@ should work for all Python >= 3.4 environments. The actual development status is "*released*" and stable. -The Software and all related documents are published under MIT license extended by a human protect patch -(see :ref:`Background Licence `). +The Software and all related documents are published under MIT license +(for some additional remarks related to the usage of the package see :ref:`Licence+Human Protection `). ************************************ Feature Overview diff --git a/setup.cfg b/setup.cfg index 50a3d1f..36db7ae 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [metadata] # replace with your username: name = itertree-B_R -version = 1.1.3 +version = 1.2.0 author = B.R. author_email = br_development@posteo.org description = A package for creating tree structures and related data diff --git a/setup.py b/setup.py index 0be5d5b..d3c4e89 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,29 @@ +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +setup.py for builds and installation +""" + from setuptools import setup setup( name='itertree', - version='1.1.3', + version='1.2.0', packages=['itertree', 'itertree.examples', 'itertree.itree_serializer','itertree.itree_indepth_helpers'], package_dir={'': 'src'}, url='https://github.com/BR1py/itertree', diff --git a/src/itertree/__init__.py b/src/itertree/__init__.py index 619e8f5..f9924fe 100644 --- a/src/itertree/__init__.py +++ b/src/itertree/__init__.py @@ -1,36 +1,20 @@ -# -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: This part of code contains the initialization and publishing of the iTree related classes of the itertree package. """ @@ -38,8 +22,8 @@ from __future__ import absolute_import __package__ = 'itertree' -__version__ = '1.1.3' -__licence__ = 'MIT incl. human protect patch' +__version__ = '1.2.0' +__licence__ = 'MIT' __author__ = 'B.R.' __url__ = 'https://github.com/BR1py/itertree' __description__ = 'Python tree structure for data storage and iterations' @@ -49,6 +33,7 @@ from .itree_main import iTree from . import itree_data as Data +itree_data=Data from . import itree_filters as Filters from .itree_serializer.itree_render_dot import _iTreeRenderDot diff --git a/src/itertree/examples/calendar_example.py b/src/itertree/examples/calendar_example.py index d82bbfe..1d844ac 100644 --- a/src/itertree/examples/calendar_example.py +++ b/src/itertree/examples/calendar_example.py @@ -1,38 +1,21 @@ # -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License - -######################################################################################################################## +CONTENT DESCRIPTION: This file contains an example for the usage of iTree: Calendar diff --git a/src/itertree/examples/itree_data_models.py b/src/itertree/examples/itree_data_models.py index e4e90a3..bc12c31 100644 --- a/src/itertree/examples/itree_data_models.py +++ b/src/itertree/examples/itree_data_models.py @@ -1,36 +1,22 @@ # -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: + This file contains some examples of data models that might be modified or used for determine the data stored in the iTData object diff --git a/src/itertree/examples/itree_docu_examples.py b/src/itertree/examples/itree_docu_examples.py index 1065e9b..7cce148 100644 --- a/src/itertree/examples/itree_docu_examples.py +++ b/src/itertree/examples/itree_docu_examples.py @@ -1,40 +1,25 @@ -"""# -*- coding: utf-8 -*-#""" -from __future__ import absolute_import - +# -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: + This file contains teh examples presented in the itertree related documentation """ +from __future__ import absolute_import import os import sys @@ -223,7 +208,7 @@ def exec_and_print(command_series, name=None): "len(root.deep)", "# flatten iterators over all in-depth items:", "[i for i in root.deep] # up-down order", - "[i for i in root.deep.tag_idx_paths(up_to_low=False)] # tag_idx related iterator; down-up order", + "[i for i in root.deep.tag_idx_paths(options=ITER.UP)] # tag_idx related iterator; down-up order", "", '# .. start: tutorial-code QS6', @@ -645,7 +630,7 @@ def exec_and_print(command_series, name=None): "", "# deep iterators:", "list(root.deep) # deep counterpart of level1 __iter__() iterator", - "list(root.deep.iter(up_to_low=False)) # changed iteration order bottom-> up", + "list(root.deep.iter(options=ITER.UP)) # changed iteration order bottom-> up", "list(root.deep.tag_idx_paths()) # deep counterpart of level1 items() iterator", "[(k,i.value) for k,i in root.deep.tag_idx_paths()] # deep counterpart of level1 items(values_only=True) iterator", "[k for k,_ in root.deep.tag_idx_paths()] # deep counterpart level1 to keys() iterator", @@ -817,8 +802,8 @@ def exec_and_print(command_series, name=None): " subitem = item.append(iTree('%i_%i' % (i,ii), i*10+ii))\n" " for iii in range(2):\n" " subitem.append(iTree('%i_%i_%i' % (i, ii,iii), i * 100 + ii*10+iii))", - "[i for i in root.deep.iter(up_to_low=True)][0:5] # show just a part", - "[i for i in root.deep.iter(up_to_low=False)][0:5] # show just a part", + "[i for i in root.deep.iter(options=ITER.DOWN)][0:5] # show just a part", + "[i for i in root.deep.iter(options=ITER.UP)][0:5] # show just a part", ] exec_and_print(tutorial_20, 'tutorial_20') diff --git a/src/itertree/examples/itree_like_anytree.py b/src/itertree/examples/itree_like_anytree.py index 0ed1c79..d6b89e5 100644 --- a/src/itertree/examples/itree_like_anytree.py +++ b/src/itertree/examples/itree_like_anytree.py @@ -1,42 +1,26 @@ -# -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License -""" -# This example shows how the tree related functions from anytree can be realized in itertree -# we show here two ways -# 1. use replacement functions for itertree -# 2. Create a new class NodeIT() with super class iTree and integrate the missing functions +CONTENT DESCRIPTION: +This example shows how the tree related functions from anytree can be realized in itertree +we show here two ways +1. use replacement functions for itertree +2. Create a new class NodeIT() with super class iTree and integrate the missing functions +""" from anytree import Node # example works only if anytree package is available from anytree.iterators import PreOrderIter,PostOrderIter,LevelOrderIter from itertree import * @@ -73,7 +57,7 @@ def preorder(self): return self.iter(add_self=True) def postorder(self): - return self.iter(up_to_low=False,add_self=True) + return self.iter(options=ITER.UP,add_self=True) def levelorder(self): return self.iter_levels(start_levels=0) @@ -216,7 +200,7 @@ def __str__(self): print('Get postorder iterator') result_at=[n.name for n in PostOrderIter(root_at)] -result_it=[n.tag for n in chain(root_it.deep.iter(up_to_low=False),[root_it])] +result_it=[n.tag for n in chain(root_it.deep.iter(options=ITER.UP),[root_it])] result_it2=[n.name for n in root_it2.deep.postorder()] diff --git a/src/itertree/examples/itree_link_example1.py b/src/itertree/examples/itree_link_example1.py index d6abe72..1ec7967 100644 --- a/src/itertree/examples/itree_link_example1.py +++ b/src/itertree/examples/itree_link_example1.py @@ -1,42 +1,23 @@ -# -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License - +CONTENT DESCRIPTION: This part of code contains some examples for the usage of itertree module - """ - from __future__ import absolute_import import os import shutil diff --git a/src/itertree/examples/itree_usage_example1.py b/src/itertree/examples/itree_usage_example1.py index b38c293..85c3839 100644 --- a/src/itertree/examples/itree_usage_example1.py +++ b/src/itertree/examples/itree_usage_example1.py @@ -1,41 +1,24 @@ -"""# -*- coding: utf-8 -*-#""" -from __future__ import absolute_import """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License - +CONTENT DESCRIPTION: This part of code contains the profiling of nested iTree structures """ +from __future__ import absolute_import import os import sys diff --git a/src/itertree/examples/itree_usage_example2.py b/src/itertree/examples/itree_usage_example2.py index 64b4a49..d0c71c1 100644 --- a/src/itertree/examples/itree_usage_example2.py +++ b/src/itertree/examples/itree_usage_example2.py @@ -1,41 +1,24 @@ -"""# -*- coding: utf-8 -*-#""" -from __future__ import absolute_import """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License - +CONTENT DESCRIPTION: This part of code contains the profiling of nested iTree structures """ +from __future__ import absolute_import import os import sys diff --git a/src/itertree/examples/performance_analysis/base_performance.py b/src/itertree/examples/performance_analysis/base_performance.py index df06275..93a7910 100644 --- a/src/itertree/examples/performance_analysis/base_performance.py +++ b/src/itertree/examples/performance_analysis/base_performance.py @@ -1,3 +1,25 @@ +# -*- coding: utf-8 -*- +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +Some code to check the performance of the itertree implementation. +""" + import abc import timeit diff --git a/src/itertree/examples/performance_analysis/test_append.py b/src/itertree/examples/performance_analysis/check_append.py similarity index 92% rename from src/itertree/examples/performance_analysis/test_append.py rename to src/itertree/examples/performance_analysis/check_append.py index 152c51e..12e5f78 100644 --- a/src/itertree/examples/performance_analysis/test_append.py +++ b/src/itertree/examples/performance_analysis/check_append.py @@ -1,8 +1,37 @@ -import pytest +# -*- coding: utf-8 -*- +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| -from itertree.examples.performance_analysis.base_performance import BasePerformance +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html -class TestBuildByAppendL1(BasePerformance): +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +Appends other packages to the performance tests. +""" + +import os +import sys + +root_path = os.path.dirname(os.path.dirname(__file__)) +print('ROOT_PATH', root_path) +if root_path not in sys.path: + sys.path.append(root_path) + +import itertree.examples.performance_analysis.base_performance +BasePerformance=itertree.examples.performance_analysis.base_performance.BasePerformance + +class AnalyseBuildByAppendL1(BasePerformance): def get_header(self): out = 'Build tree via append operation' diff --git a/src/itertree/examples/performance_analysis/test_compare.py b/src/itertree/examples/performance_analysis/check_compare.py similarity index 93% rename from src/itertree/examples/performance_analysis/test_compare.py rename to src/itertree/examples/performance_analysis/check_compare.py index e116cd6..a734058 100644 --- a/src/itertree/examples/performance_analysis/test_compare.py +++ b/src/itertree/examples/performance_analysis/check_compare.py @@ -1,3 +1,25 @@ +# -*- coding: utf-8 -*- +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +Compares other packages with itertree. +""" + import pytest import itertools diff --git a/src/itertree/examples/performance_analysis/test_copy.py b/src/itertree/examples/performance_analysis/check_copy.py similarity index 96% rename from src/itertree/examples/performance_analysis/test_copy.py rename to src/itertree/examples/performance_analysis/check_copy.py index e3bad5e..b31794d 100644 --- a/src/itertree/examples/performance_analysis/test_copy.py +++ b/src/itertree/examples/performance_analysis/check_copy.py @@ -1,3 +1,25 @@ +# -*- coding: utf-8 -*- +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +Test copy() performace. +""" + import pytest import itertools import copy diff --git a/src/itertree/examples/performance_analysis/test_delete.py b/src/itertree/examples/performance_analysis/check_delete.py similarity index 96% rename from src/itertree/examples/performance_analysis/test_delete.py rename to src/itertree/examples/performance_analysis/check_delete.py index 95b6cfe..18f1eda 100644 --- a/src/itertree/examples/performance_analysis/test_delete.py +++ b/src/itertree/examples/performance_analysis/check_delete.py @@ -1,3 +1,25 @@ +# -*- coding: utf-8 -*- +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +Test delete() performance. +""" + import pytest import itertools import copy diff --git a/src/itertree/examples/performance_analysis/test_extend.py b/src/itertree/examples/performance_analysis/check_extend.py similarity index 89% rename from src/itertree/examples/performance_analysis/test_extend.py rename to src/itertree/examples/performance_analysis/check_extend.py index 6e4b156..dc4c006 100644 --- a/src/itertree/examples/performance_analysis/test_extend.py +++ b/src/itertree/examples/performance_analysis/check_extend.py @@ -1,3 +1,25 @@ +# -*- coding: utf-8 -*- +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +Test extend() performance +""" + import pytest import collections from itertree.examples.performance_analysis.base_performance import BasePerformance diff --git a/src/itertree/examples/performance_analysis/test_get_by_idx.py b/src/itertree/examples/performance_analysis/check_get_by_idx.py similarity index 96% rename from src/itertree/examples/performance_analysis/test_get_by_idx.py rename to src/itertree/examples/performance_analysis/check_get_by_idx.py index e05aea0..35f141b 100644 --- a/src/itertree/examples/performance_analysis/test_get_by_idx.py +++ b/src/itertree/examples/performance_analysis/check_get_by_idx.py @@ -1,3 +1,25 @@ +# -*- coding: utf-8 -*- +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +Test get item by index performance. +""" + import pytest import itertools diff --git a/src/itertree/examples/performance_analysis/test_get_by_idx_slice.py b/src/itertree/examples/performance_analysis/check_get_by_idx_slice.py similarity index 93% rename from src/itertree/examples/performance_analysis/test_get_by_idx_slice.py rename to src/itertree/examples/performance_analysis/check_get_by_idx_slice.py index aa83ef8..55e7c5e 100644 --- a/src/itertree/examples/performance_analysis/test_get_by_idx_slice.py +++ b/src/itertree/examples/performance_analysis/check_get_by_idx_slice.py @@ -1,3 +1,25 @@ +# -*- coding: utf-8 -*- +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +Test get items by index slice performance. +""" + import pytest import itertools diff --git a/src/itertree/examples/performance_analysis/test_get_by_key.py b/src/itertree/examples/performance_analysis/check_get_by_key.py similarity index 97% rename from src/itertree/examples/performance_analysis/test_get_by_key.py rename to src/itertree/examples/performance_analysis/check_get_by_key.py index 696715f..9ba12e4 100644 --- a/src/itertree/examples/performance_analysis/test_get_by_key.py +++ b/src/itertree/examples/performance_analysis/check_get_by_key.py @@ -1,3 +1,25 @@ +# -*- coding: utf-8 -*- +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +Test get items by key (or tag) performance. +""" + import pytest import itertools diff --git a/src/itertree/examples/performance_analysis/test_insert.py b/src/itertree/examples/performance_analysis/check_insert.py similarity index 89% rename from src/itertree/examples/performance_analysis/test_insert.py rename to src/itertree/examples/performance_analysis/check_insert.py index 3d5f444..a0d59d0 100644 --- a/src/itertree/examples/performance_analysis/test_insert.py +++ b/src/itertree/examples/performance_analysis/check_insert.py @@ -1,3 +1,25 @@ +# -*- coding: utf-8 -*- +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +Test insert() item performance. +""" + import pytest import collections from itertree.examples.performance_analysis.base_performance import BasePerformance diff --git a/src/itertree/examples/performance_analysis/test_iter.py b/src/itertree/examples/performance_analysis/check_iter.py similarity index 94% rename from src/itertree/examples/performance_analysis/test_iter.py rename to src/itertree/examples/performance_analysis/check_iter.py index 934fccd..e44a019 100644 --- a/src/itertree/examples/performance_analysis/test_iter.py +++ b/src/itertree/examples/performance_analysis/check_iter.py @@ -1,3 +1,25 @@ +# -*- coding: utf-8 -*- +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +Test performance of iterations (iter()). +""" + import pytest import itertools diff --git a/src/itertree/examples/performance_analysis/test_itree_specific.py b/src/itertree/examples/performance_analysis/check_itree_specific.py similarity index 96% rename from src/itertree/examples/performance_analysis/test_itree_specific.py rename to src/itertree/examples/performance_analysis/check_itree_specific.py index a3c79b4..597086a 100644 --- a/src/itertree/examples/performance_analysis/test_itree_specific.py +++ b/src/itertree/examples/performance_analysis/check_itree_specific.py @@ -1,3 +1,25 @@ +# -*- coding: utf-8 -*- +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +Test performance of itertree specific methods. +""" + import pytest import itertools import pickle diff --git a/src/itertree/examples/performance_analysis/test_save_load.py b/src/itertree/examples/performance_analysis/check_save_load.py similarity index 92% rename from src/itertree/examples/performance_analysis/test_save_load.py rename to src/itertree/examples/performance_analysis/check_save_load.py index 3bfedcf..c2f86b5 100644 --- a/src/itertree/examples/performance_analysis/test_save_load.py +++ b/src/itertree/examples/performance_analysis/check_save_load.py @@ -1,3 +1,25 @@ +# -*- coding: utf-8 -*- +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +Test the performance of save and load functionalities in itertree. +""" + import os.path import pytest diff --git a/src/itertree/examples/performance_analysis/exec_peformance.py b/src/itertree/examples/performance_analysis/exec_peformance.py index 4fdf5ba..0cb2752 100644 --- a/src/itertree/examples/performance_analysis/exec_peformance.py +++ b/src/itertree/examples/performance_analysis/exec_peformance.py @@ -1,3 +1,25 @@ +# -*- coding: utf-8 -*- +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +Execution code for the performance analysis. +""" + from __future__ import absolute_import import pickle @@ -26,8 +48,8 @@ ] CREATE_DOCS = [1] # EXEC_CONTROL = ['Ln_100','Ln_500','Ln_1000'] -EXEC_CONTROL = ['L1_500000','Ln_1000'] -SUB_EXEC_CONTROL = [1] +#EXEC_CONTROL = ['L1_500000','Ln_1000'] +#SUB_EXEC_CONTROL = [1] # EXEC_CONTROL = ['L1_5000', 'L1_50000', 'L1_500000','Ln_100','Ln_500','Ln_1000'] # SUB_EXEC_CONTROL = [1,6] @@ -164,18 +186,18 @@ trees = {} trees2 = {} -from itertree.examples.performance_analysis.test_append import TestBuildByAppendL1, TestBuildByAppendLn -from itertree.examples.performance_analysis.test_extend import TestBuildByExtendL1 -from itertree.examples.performance_analysis.test_insert import TestBuildByInsertL1 -from itertree.examples.performance_analysis.test_copy import TestCopyL1, TestCopyLn -from itertree.examples.performance_analysis.test_compare import TestCompareL1 -from itertree.examples.performance_analysis.test_get_by_idx import TestGetByIdxL1, TestGetByIdxLn -from itertree.examples.performance_analysis.test_get_by_key import TestGetByKeyL1, TestGetByKeyLn -from itertree.examples.performance_analysis.test_get_by_idx_slice import TestGetByIdxSliceL1 -from itertree.examples.performance_analysis.test_iter import TestIterL1, TestIterLn -from itertree.examples.performance_analysis.test_save_load import TestSaveLoadL1 -from itertree.examples.performance_analysis.test_itree_specific import TestiTreeSpecificL1, TestiTreeSpecificLn -from itertree.examples.performance_analysis.test_delete import TestDeleteL1 +from itertree.examples.performance_analysis.check_append import AnalyseBuildByAppendL1, TestBuildByAppendLn +from itertree.examples.performance_analysis.check_extend import TestBuildByExtendL1 +from itertree.examples.performance_analysis.check_insert import TestBuildByInsertL1 +from itertree.examples.performance_analysis.check_copy import TestCopyL1, TestCopyLn +from itertree.examples.performance_analysis.check_compare import TestCompareL1 +from itertree.examples.performance_analysis.check_get_by_idx import TestGetByIdxL1, TestGetByIdxLn +from itertree.examples.performance_analysis.check_get_by_key import TestGetByKeyL1, TestGetByKeyLn +from itertree.examples.performance_analysis.check_get_by_idx_slice import TestGetByIdxSliceL1 +from itertree.examples.performance_analysis.check_iter import TestIterL1, TestIterLn +from itertree.examples.performance_analysis.check_save_load import TestSaveLoadL1 +from itertree.examples.performance_analysis.check_itree_specific import TestiTreeSpecificL1, TestiTreeSpecificLn +from itertree.examples.performance_analysis.check_delete import TestDeleteL1 class Test_level1_tree(): @@ -217,7 +239,7 @@ def instance_test_item(self, test_class): ) def test1_append_level1_tree(self): - test_item = self.instance_test_item(TestBuildByAppendL1) + test_item = self.instance_test_item(AnalyseBuildByAppendL1) if self.exec_test(1): self.trees, self.trees2 = test_item.test_exec() else: diff --git a/src/itertree/itree_data.py b/src/itertree/itree_data.py index bb34498..5ad7588 100644 --- a/src/itertree/itree_data.py +++ b/src/itertree/itree_data.py @@ -1,36 +1,20 @@ -# -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: This part of code contains the helper functions related to the `iTree` data attribute """ diff --git a/src/itertree/itree_filters.py b/src/itertree/itree_filters.py index a349948..c2268a0 100644 --- a/src/itertree/itree_filters.py +++ b/src/itertree/itree_filters.py @@ -1,37 +1,20 @@ -# -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License - +CONTENT DESCRIPTION: This part of code contains the iTree filter classes diff --git a/src/itertree/itree_getitem.py b/src/itertree/itree_getitem.py index 2920de0..9ec2d00 100644 --- a/src/itertree/itree_getitem.py +++ b/src/itertree/itree_getitem.py @@ -1,36 +1,20 @@ -# -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: This part of code contains the specific get methods for the iTree object diff --git a/src/itertree/itree_helpers.py b/src/itertree/itree_helpers.py index b0250df..a786bef 100644 --- a/src/itertree/itree_helpers.py +++ b/src/itertree/itree_helpers.py @@ -1,36 +1,20 @@ -# -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: This part of code contains helper classes used in DataTree object diff --git a/src/itertree/itree_indepth.py b/src/itertree/itree_indepth.py index 07caea5..0051b35 100644 --- a/src/itertree/itree_indepth.py +++ b/src/itertree/itree_indepth.py @@ -1,36 +1,20 @@ -# -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: This part of code contains the main iTree object """ @@ -577,7 +561,7 @@ def __iter__(self): del iterators[-1] - def iter(self, filter_method=None, options=DOWN, up_to_low=None): + def iter(self, filter_method=None, options=DOWN): """ In-depth iterator that iterates over all items in the nested `iTree`-structure. The iterator flattens the @@ -622,14 +606,6 @@ def iter(self, filter_method=None, options=DOWN, up_to_low=None): # ITER.DOWN exists only for downward compatibility if options == 0: options = options | UP - if up_to_low is not None: - if not up_to_low: - options = options | UP - warnings.warn( - "The parameter up_to_low will be removed soon. Use options=ITER.UP instead.", - DeprecationWarning, - stacklevel=2, - ) if ITER.valid_option(UP | DOWN | REVERSE | SELF | FILTER_ANY): raise AttributeError(ITER.valid_option(options)) if options & FILTER_ANY: @@ -913,7 +889,7 @@ def levels(levels, options): yielded_items.add(id(i)) - def idx_paths(self, filter_method=None, options=DOWN, up_to_low=None): + def idx_paths(self, filter_method=None, options=DOWN): """ Call via: **iTree().deep.idx_paths()** @@ -958,14 +934,6 @@ def idx_paths(self, filter_method=None, options=DOWN, up_to_low=None): # ITER.DOWN exists only for downward compatibility if options == 0: options = options | UP - if up_to_low is not None: - if not up_to_low: - options = options | UP - warnings.warn( - "The parameter up_to_low will be removed soon. Use options=ITER.UP instead.", - DeprecationWarning, - stacklevel=2, - ) if ITER.valid_option(UP | DOWN | REVERSE | SELF | FILTER_ANY): raise AttributeError(ITER.valid_option(options)) if options & FILTER_ANY: @@ -980,7 +948,7 @@ def idx_paths(self, filter_method=None, options=DOWN, up_to_low=None): # ToDo: - def tag_idx_paths(self, filter_method=None, options=DOWN, up_to_low=None): + def tag_idx_paths(self, filter_method=None, options=DOWN): """ Call via: **iTree().deep.tag_idx_paths()** @@ -1025,14 +993,6 @@ def tag_idx_paths(self, filter_method=None, options=DOWN, up_to_low=None): # ITER.DOWN exists only for downward compatibility if options == 0: options = options | UP - if up_to_low is not None: - if not up_to_low: - options = options | UP - warnings.warn( - "The parameter up_to_low will be removed soon. Use options=ITER.UP instead.", - DeprecationWarning, - stacklevel=2, - ) if ITER.valid_option(UP | DOWN | REVERSE | SELF | FILTER_ANY): raise AttributeError(ITER.valid_option(options)) if options & FILTER_ANY: diff --git a/src/itertree/itree_indepth_helpers/itree_indepth_iter.py b/src/itertree/itree_indepth_helpers/itree_indepth_iter.py index a89f271..b9d662d 100644 --- a/src/itertree/itree_indepth_helpers/itree_indepth_iter.py +++ b/src/itertree/itree_indepth_helpers/itree_indepth_iter.py @@ -1,3 +1,24 @@ +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +Main part of itertree containing helper functions related to the not recursive in depth iterators. +""" + import sys from collections import deque from ..itree_helpers import ITER diff --git a/src/itertree/itree_indepth_helpers/itree_indepth_levels.py b/src/itertree/itree_indepth_helpers/itree_indepth_levels.py index fff5403..af1be92 100644 --- a/src/itertree/itree_indepth_helpers/itree_indepth_levels.py +++ b/src/itertree/itree_indepth_helpers/itree_indepth_levels.py @@ -1,3 +1,24 @@ +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +This part of code contains the level access functions of nested iTree structures +""" + import sys from collections import deque from ..itree_helpers import ITER,itree_list diff --git a/src/itertree/itree_indepth_helpers/itree_indepth_siblings.py b/src/itertree/itree_indepth_helpers/itree_indepth_siblings.py index 1196794..40559f6 100644 --- a/src/itertree/itree_indepth_helpers/itree_indepth_siblings.py +++ b/src/itertree/itree_indepth_helpers/itree_indepth_siblings.py @@ -1,3 +1,24 @@ +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +This part of code contains the access function targeting the siblings in a tree of the nested iTree structures +""" + import sys from collections import deque from ..itree_helpers import ITER diff --git a/src/itertree/itree_main.py b/src/itertree/itree_main.py index 18f1ef2..f77e3fb 100644 --- a/src/itertree/itree_main.py +++ b/src/itertree/itree_main.py @@ -1,41 +1,22 @@ -# -*- coding: utf-8 -*- - """ - This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: This part of code contains the main iTree object - """ from __future__ import absolute_import diff --git a/src/itertree/itree_mathsets.py b/src/itertree/itree_mathsets.py index 7aef7fe..7d32b3c 100644 --- a/src/itertree/itree_mathsets.py +++ b/src/itertree/itree_mathsets.py @@ -1,35 +1,20 @@ -# -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: This part of code contains helper classes used in DataTree object diff --git a/src/itertree/itree_private.py b/src/itertree/itree_private.py index 4dde511..9f0e28e 100644 --- a/src/itertree/itree_private.py +++ b/src/itertree/itree_private.py @@ -1,36 +1,20 @@ -# -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: This part of code contains the private helper functions in iTree object diff --git a/src/itertree/itree_serializer/itree_json_converter.py b/src/itertree/itree_serializer/itree_json_converter.py index 0203808..4455d2d 100644 --- a/src/itertree/itree_serializer/itree_json_converter.py +++ b/src/itertree/itree_serializer/itree_json_converter.py @@ -1,36 +1,20 @@ -# -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: This part of code contains the standard iTree serializers (JSON and rendering) """ diff --git a/src/itertree/itree_serializer/itree_json_serialize.py b/src/itertree/itree_serializer/itree_json_serialize.py index 3fb83a7..c4607b9 100644 --- a/src/itertree/itree_serializer/itree_json_serialize.py +++ b/src/itertree/itree_serializer/itree_json_serialize.py @@ -1,36 +1,20 @@ -# -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: This part of code contains the standard iTree serializers (JSON and rendering) """ @@ -39,6 +23,7 @@ import gzip import hashlib +import traceback from collections import OrderedDict, deque # For serializing we (try) to import some modules: @@ -83,8 +68,9 @@ class nparray(): np_loaded = False from ..itree_helpers import * +import itertree -DT_SERIALIZE_VERSION = "2.0.0" +DT_SERIALIZE_VERSION = "2.0.1" DT_SERIALIZE_MAJOR_VERSION = "2.0" @@ -209,6 +195,7 @@ def convert_it_type(self, o): module_name = o[3] if module_name.endswith('itree_data'): try: + Data=itertree.Data object_class = eval('Data.%s' % class_name) except: pass diff --git a/src/itertree/itree_serializer/itree_render_dot.py b/src/itertree/itree_serializer/itree_render_dot.py index 7930c09..ceb0d3c 100644 --- a/src/itertree/itree_serializer/itree_render_dot.py +++ b/src/itertree/itree_serializer/itree_render_dot.py @@ -1,37 +1,22 @@ -# -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License -This is a class wihch translates an iTree in a dot graph +CONTENT DESCRIPTION: + +This is a class which translates an iTree in a dot graph This part of code contains the standard iTree serializers (JSON and rendering) """ diff --git a/src/itertree/itree_serializer/itree_renderer.py b/src/itertree/itree_serializer/itree_renderer.py index 537f2c4..617c203 100644 --- a/src/itertree/itree_serializer/itree_renderer.py +++ b/src/itertree/itree_serializer/itree_renderer.py @@ -1,37 +1,20 @@ -# -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License - +CONTENT DESCRIPTION: This part of code contains the standard iTree serializers (JSON and rendering) """ diff --git a/tests/manual_tests/__init__.py b/tests/manual_tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/manualtest/test_itertree_examples.py b/tests/manual_tests/check_examples.py similarity index 69% rename from manualtest/test_itertree_examples.py rename to tests/manual_tests/check_examples.py index 6a6c903..7f78816 100644 --- a/manualtest/test_itertree_examples.py +++ b/tests/manual_tests/check_examples.py @@ -1,37 +1,20 @@ -# -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License - +CONTENT DESCRIPTION: The main goal of this test is that the examples run without any exception """ @@ -39,14 +22,17 @@ import os import sys import shutil +import importlib +import sys + import collections # import timeit import pytest -from itertree import * - root_path = os.path.dirname(os.path.dirname(__file__)) print('ROOT_PATH', root_path) +if root_path not in sys.path: + sys.path.append(root_path) tmp_dir=os.path.join(os.path.dirname(__file__),'tmp') if os.path.exists(tmp_dir): @@ -55,6 +41,16 @@ print('TMP_DIR', tmp_dir) +def import_from_path(module_name, file_path): + spec = importlib.util.spec_from_file_location(module_name, file_path) + module = importlib.util.module_from_spec(spec) + sys.modules[module_name] = module + spec.loader.exec_module(module) + return module + +import itertree +from itertree import * + print('Test start') @pytest.fixture(scope="session") diff --git a/tests/run_test.py b/tests/run_test.py index 800824b..33e681e 100644 --- a/tests/run_test.py +++ b/tests/run_test.py @@ -7,7 +7,6 @@ import sys if os.getenv('JOB_NAME') is None: - # No execution in JenkinsJobs #pytest.main(['-v', '../..']) #pytest.main(['--pep8', '../..']) #pytest.main(['-pylint', '../..']) diff --git a/tests/test_itertree_base1.py b/tests/test_itertree_base1.py index 2f2db90..2f5346c 100644 --- a/tests/test_itertree_base1.py +++ b/tests/test_itertree_base1.py @@ -1,39 +1,25 @@ # -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: This part of code contains the integration tests related to the base iTree functionalities + """ import os @@ -51,9 +37,26 @@ np = None import pickle +import sys import timeit +import importlib from types import GeneratorType from collections import OrderedDict +import pathlib +root_path = os.path.dirname(os.path.dirname(__file__))+'/src' +print('ROOT_PATH', root_path) +if root_path not in sys.path: + sys.path.append(root_path) + +def import_from_path(module_name, file_path): + spec = importlib.util.spec_from_file_location(module_name, file_path) + module = importlib.util.module_from_spec(spec) + sys.modules[module_name] = module + spec.loader.exec_module(module) + return module + +#itertree=import_from_path('itertree',root_path+'/itertree/.__init__.py') +import itertree from itertree import * from itertree.itree_helpers import itree_list, BLIST_ACTIVE diff --git a/tests/test_itertree_base_old.py b/tests/test_itertree_base_old.py index 43bbc7b..8cea1a3 100644 --- a/tests/test_itertree_base_old.py +++ b/tests/test_itertree_base_old.py @@ -1,36 +1,21 @@ # -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: This part of code contains the integration tests related to the base iTree functionalities @@ -42,6 +27,7 @@ import collections import timeit import pytest +import time try: import numpy as np @@ -216,7 +202,7 @@ def test1_dt_base_test(self): # down->top iter lookup = [0, 1, 2, 3, -1, -1, 0, 1, 2, 3, 4, -1, 0, 1, 2, -1] - for i, item in enumerate(root.deep.iter(up_to_low=False)): + for i, item in enumerate(root.deep.iter(options=ITER.UP)): # print(item,i,lookup[i]) if i < len(lookup): assert item.value['level'][1] == lookup[i] @@ -825,6 +811,19 @@ def test10_std_save_load(self): target_path = root_data_path + '/out.itz' target_path2 = root_data_path + '/out.itr' target_path3 = root_data_path + '/out2.itz' + # to find a valid dir for GITHUB action we search a bit: + if not os.path.exists(root_data_path): + os.makedirs(root_data_path) + time.sleep(1) + if not os.path.exists(root_data_path): + root_data_path=os.path.dirname(root_data_path) + if not os.path.exists(root_data_path): + os.makedirs(root_data_path) + time.sleep(1) + if not os.path.exists(root_data_path): + root_data_path = os.path.dirname(root_data_path) + if not os.path.exists(root_data_path): + os.makedirs(root_data_path) print('Outputfile: %s' % os.path.abspath(target_path)) @@ -832,6 +831,7 @@ def test10_std_save_load(self): if np is not None: root += iTree('NUMPY', value={'myarray': np.array([1.5, 4, 3.6, 467])}) root += iTree('OD', value={'od': collections.OrderedDict([('C', 'c'), ('A', 'a'), ('B', 'b')])}) + root.dump(target_path, overwrite=True) root.dump(target_path2, pack=False, overwrite=True) diff --git a/tests/test_itertree_flags.py b/tests/test_itertree_flags.py index 55db0d2..1efc0f8 100644 --- a/tests/test_itertree_flags.py +++ b/tests/test_itertree_flags.py @@ -1,37 +1,21 @@ # -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License - +CONTENT DESCRIPTION: This part of code contains the integration tests related to the base iTree functionalities diff --git a/tests/test_itertree_full_feature_trees.py b/tests/test_itertree_full_feature_trees.py index 0a70bc0..4b34ae0 100644 --- a/tests/test_itertree_full_feature_trees.py +++ b/tests/test_itertree_full_feature_trees.py @@ -1,3 +1,26 @@ +# -*- coding: utf-8 -*- +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +This part of code contains +the integration tests related to "full featured" trees +""" + import os import sys import timeit @@ -8,6 +31,7 @@ # import timeit import pytest + try: import numpy as np # only needed in case of numpy arrays in data @@ -19,13 +43,15 @@ import timeit from types import GeneratorType from collections import OrderedDict + from itertree import * from itertree.itree_helpers import BLIST_ACTIVE - root_path = os.path.dirname(__file__) print('ROOT_PATH', root_path) +#itertree.itree_data=import('itree_data',root_path+'../src/') + def get_relpath_to_root(item_path): new_path = item_path.replace(root_path, '') if new_path.startswith('\\'): diff --git a/tests/test_itertree_helpers.py b/tests/test_itertree_helpers.py index 32dfe14..e5a3494 100644 --- a/tests/test_itertree_helpers.py +++ b/tests/test_itertree_helpers.py @@ -1,36 +1,21 @@ # -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: This part of code contains THe test of the functions in itree_helpers.py diff --git a/tests/test_itertree_intervals.py b/tests/test_itertree_intervals.py index b96e5a3..a9ebbc4 100644 --- a/tests/test_itertree_intervals.py +++ b/tests/test_itertree_intervals.py @@ -1,37 +1,21 @@ # -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License - +CONTENT DESCRIPTION: This part of code contains the integration tests related to the base iTree functionalities diff --git a/tests/test_itertree_iter.py b/tests/test_itertree_iter.py index ff8f192..bf30178 100644 --- a/tests/test_itertree_iter.py +++ b/tests/test_itertree_iter.py @@ -1,36 +1,21 @@ # -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: This part of code contains the integration tests related to the base iTree functionalities @@ -696,7 +681,7 @@ def test1c_iTree_iterators_deep(self): # standard iter_deep i = 1 - item_list = list(tree.deep.iter(up_to_low=False)) + item_list = list(tree.deep.iter(options=ITER.UP)) #for i in item_list: # print(i) assert len(item_list) == size @@ -711,24 +696,24 @@ def test1c_iTree_iterators_deep(self): iter_method = tree.deep.iter method_name = 'tree.deep.iter' - s = len(list(i for i in iter_method(up_to_low=False))) - t = calc_timeit(lambda: list(i for i in iter_method(up_to_low=False)), number=timeit_number) + s = len(list(i for i in iter_method(options=ITER.UP))) + t = calc_timeit(lambda: list(i for i in iter_method(options=ITER.UP)), number=timeit_number) print('%s(top_down=False) -> iteration-time over %s items: %es' % (method_name, s, t)) - s = len(list(i for i in iter_method(lambda i: True,up_to_low=False))) - t = calc_timeit(lambda: list(i for i in iter_method(lambda i: True,up_to_low=False)), number=timeit_number) + s = len(list(i for i in iter_method(lambda i: True,options=ITER.UP))) + t = calc_timeit(lambda: list(i for i in iter_method(lambda i: True,options=ITER.UP)), number=timeit_number) print('%s(lambda i: True) -> iteration-time over %s items: %es' % (method_name, s, t)) - s = len(list(i for i in filter(lambda i: True, iter_method(up_to_low=False)))) - t = calc_timeit(lambda: list(i for i in filter(lambda i: True, iter_method(up_to_low=False))), number=timeit_number) + s = len(list(i for i in filter(lambda i: True, iter_method(options=ITER.UP)))) + t = calc_timeit(lambda: list(i for i in filter(lambda i: True, iter_method(options=ITER.UP))), number=timeit_number) print('filter(lambda i: True,%s()) -> iteration-time over %s items: %es' % (method_name, s, t)) - s = len(list(i for i in iter_method(test_filter,up_to_low=False))) - t = calc_timeit(lambda: list(i for i in iter_method(test_filter,up_to_low=False)), number=timeit_number) + s = len(list(i for i in iter_method(test_filter,options=ITER.UP))) + t = calc_timeit(lambda: list(i for i in iter_method(test_filter,options=ITER.UP)), number=timeit_number) print('%s(test_filter) -> iteration-time over %s items: %es' % (method_name, s, t)) - s = len(list(i for i in filter(test_filter,iter_method(up_to_low=False)))) - t = calc_timeit(lambda: list(i for i in filter(test_filter,iter_method(up_to_low=False))), number=timeit_number) + s = len(list(i for i in filter(test_filter,iter_method(options=ITER.UP)))) + t = calc_timeit(lambda: list(i for i in filter(test_filter,iter_method(options=ITER.UP))), number=timeit_number) print('filter(test_filter,%s()) -> iteration-time over %s items: %es' % (method_name, s, t)) @@ -774,12 +759,12 @@ def test1d_iTree_iterators_idx_paths(self): for (idx_path,_), item in zip(filter(lambda i: test_filter(i[1]), tree.deep.idx_paths()), filter(test_filter, tree.deep.iter())): assert idx_path == item.idx_path, 'Issue in item %s' % (item) - for (idx_path,_), item in zip(tree.deep.idx_paths(up_to_low=False), tree.deep.iter(up_to_low=False)): + for (idx_path,_), item in zip(tree.deep.idx_paths(options=ITER.UP), tree.deep.iter(options=ITER.UP)): assert idx_path == item.idx_path, 'Issue in item %s' % (item) - for (idx_path,_), item in zip(tree.deep.idx_paths(test_filter, up_to_low=False), tree.deep.iter(test_filter, up_to_low=False)): + for (idx_path,_), item in zip(tree.deep.idx_paths(test_filter, options=ITER.UP), tree.deep.iter(test_filter, options=ITER.UP)): assert idx_path == item.idx_path, 'Issue in item %s' % (item) - for (idx_path,_), item in zip(filter(lambda i: test_filter(i[1]), tree.deep.idx_paths(up_to_low=False)), - filter(test_filter, tree.deep.iter(up_to_low=False))): + for (idx_path,_), item in zip(filter(lambda i: test_filter(i[1]), tree.deep.idx_paths(options=ITER.UP)), + filter(test_filter, tree.deep.iter(options=ITER.UP))): assert idx_path == item.idx_path, 'Issue in item %s' % (item) print('.deep.idx_paths() -> all parameter combinations check with success!') @@ -818,23 +803,23 @@ def test1d_iTree_iterators_idx_paths(self): s = len(list(i for i in iter_method())) # manipulate last item to get in update path! - t1 = t = calc_timeit(lambda: list(i for i in iter_method(up_to_low=True)), number=timeit_number) + t1 = t = calc_timeit(lambda: list(i for i in iter_method(options=ITER.DOWN)), number=timeit_number) print('%s()-> iteration-time over %s items: %es' % (method_name, s, t)) - s = len(list(i for i in iter_method(lambda i: True,up_to_low=True))) - t = calc_timeit(lambda: list(i for i in iter_method(lambda i: True,up_to_low=True)), number=timeit_number) + s = len(list(i for i in iter_method(lambda i: True,options=ITER.DOWN))) + t = calc_timeit(lambda: list(i for i in iter_method(lambda i: True,options=ITER.DOWN)), number=timeit_number) print('%s(lambda i: True) -> iteration-time over %s items: %es' % (method_name, s, t)) - s = len(list(i for i in filter(lambda i: True, iter_method(up_to_low=True)))) - t = calc_timeit(lambda: list(i for i in filter(lambda i: True, iter_method(up_to_low=True))), number=timeit_number) + s = len(list(i for i in filter(lambda i: True, iter_method(options=ITER.DOWN)))) + t = calc_timeit(lambda: list(i for i in filter(lambda i: True, iter_method(options=ITER.DOWN))), number=timeit_number) print('filter(lambda i: True,%s()) -> iteration-time over %s items: %es' % (method_name, s, t)) - s = len(list(i for i in iter_method(test_filter,up_to_low=True))) - t = calc_timeit(lambda: list(i for i in iter_method(test_filter,up_to_low=True)), number=timeit_number) + s = len(list(i for i in iter_method(test_filter,options=ITER.DOWN))) + t = calc_timeit(lambda: list(i for i in iter_method(test_filter,options=ITER.DOWN)), number=timeit_number) print('%s(test_filter) -> iteration-time over %s items: %es' % (method_name, s, t)) - s = len(list(i for i in filter(test_filter_outside,iter_method(up_to_low=True)))) - t = calc_timeit(lambda: list(i for i in filter(test_filter_outside,iter_method(up_to_low=True))), number=timeit_number) + s = len(list(i for i in filter(test_filter_outside,iter_method(options=ITER.DOWN)))) + t = calc_timeit(lambda: list(i for i in filter(test_filter_outside,iter_method(options=ITER.DOWN))), number=timeit_number) print('filter(test_filter,%s()) -> iteration-time over %s items: %es' % (method_name, s, t)) @@ -870,12 +855,12 @@ def test1e_iTree_iterators_key_paths(self): for (key_path,_), item in zip(filter(lambda i: test_filter(i[1]), tree.deep.tag_idx_paths()), filter(test_filter, tree.deep.iter())): assert key_path == item.tag_idx_path, 'Issue in item %s' % (item) - for (key_path,_), item in zip(tree.deep.tag_idx_paths(up_to_low=False), tree.deep.iter(up_to_low=False)): + for (key_path,_), item in zip(tree.deep.tag_idx_paths(options=ITER.UP), tree.deep.iter(options=ITER.UP)): assert key_path == item.tag_idx_path, 'Issue in item %s' % (item) - for (key_path,_), item in zip(tree.deep.tag_idx_paths(test_filter, up_to_low=False), tree.deep.iter(test_filter, up_to_low=False)): + for (key_path,_), item in zip(tree.deep.tag_idx_paths(test_filter, options=ITER.UP), tree.deep.iter(test_filter, options=ITER.UP)): assert key_path == item.tag_idx_path, 'Issue in item %s' % (item) - for (key_path,_), item in zip(filter(lambda i: test_filter(i[1]), tree.deep.tag_idx_paths(up_to_low=False)), - filter(test_filter, tree.deep.iter(up_to_low=False))): + for (key_path,_), item in zip(filter(lambda i: test_filter(i[1]), tree.deep.tag_idx_paths(options=ITER.UP)), + filter(test_filter, tree.deep.iter(options=ITER.UP))): assert key_path == item.tag_idx_path, 'Issue in item %s' % (item) print('.deep.key_paths() -> all parameter combinations check with success!') @@ -914,23 +899,23 @@ def test1e_iTree_iterators_key_paths(self): s = len(list(i for i in iter_method())) # manipulate last item to get in update path! - t1 = t = calc_timeit(lambda: list(i for i in iter_method(up_to_low=True)), number=timeit_number) + t1 = t = calc_timeit(lambda: list(i for i in iter_method(options=ITER.DOWN)), number=timeit_number) print('%s()-> iteration-time over %s items: %es' % (method_name, s, t)) - s = len(list(i for i in iter_method(lambda i: True,up_to_low=True))) - t = calc_timeit(lambda: list(i for i in iter_method(lambda i: True,up_to_low=True)), number=timeit_number) + s = len(list(i for i in iter_method(lambda i: True,options=ITER.DOWN))) + t = calc_timeit(lambda: list(i for i in iter_method(lambda i: True,options=ITER.DOWN)), number=timeit_number) print('%s(lambda i: True) -> iteration-time over %s items: %es' % (method_name, s, t)) - s = len(list(i for i in filter(lambda i: True, iter_method(up_to_low=True)))) - t = calc_timeit(lambda: list(i for i in filter(lambda i: True, iter_method(up_to_low=True))), number=timeit_number) + s = len(list(i for i in filter(lambda i: True, iter_method(options=ITER.DOWN)))) + t = calc_timeit(lambda: list(i for i in filter(lambda i: True, iter_method(options=ITER.DOWN))), number=timeit_number) print('filter(lambda i: True,%s()) -> iteration-time over %s items: %es' % (method_name, s, t)) - s = len(list(i for i in iter_method(test_filter,up_to_low=True))) - t = calc_timeit(lambda: list(i for i in iter_method(test_filter,up_to_low=True)), number=timeit_number) + s = len(list(i for i in iter_method(test_filter,options=ITER.DOWN))) + t = calc_timeit(lambda: list(i for i in iter_method(test_filter,options=ITER.DOWN)), number=timeit_number) print('%s(test_filter) -> iteration-time over %s items: %es' % (method_name, s, t)) - s = len(list(i for i in filter(test_filter_outside,iter_method(up_to_low=True)))) - t = calc_timeit(lambda: list(i for i in filter(test_filter_outside,iter_method(up_to_low=True))), number=timeit_number) + s = len(list(i for i in filter(test_filter_outside,iter_method(options=ITER.DOWN)))) + t = calc_timeit(lambda: list(i for i in filter(test_filter_outside,iter_method(options=ITER.DOWN))), number=timeit_number) print('filter(test_filter,%s()) -> iteration-time over %s items: %es' % (method_name, s, t)) print('\nRESULT OF TEST: iTree deep key_paths iterators -> PASS') diff --git a/tests/test_itertree_iter2.py b/tests/test_itertree_iter2.py index 7829f9a..cd9c150 100644 --- a/tests/test_itertree_iter2.py +++ b/tests/test_itertree_iter2.py @@ -1,40 +1,25 @@ # -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: This part of code contains -Testcase checking all variations of iteration options -Some of the testcases can be found in the diagrams of the tutorial +testcases checking all variations of iteration options. +Some of the testcases are related to the diagrams found in the tutorial. """ import os @@ -1171,142 +1156,6 @@ def test4_iTree_levels_minus_start_plus_stop_slices(self): class Test4_iTree_deep_iter_idxpath_tagidx_options: - def idx_paths_old(self,itree, filter_method=None, up_to_low=True): - """ - old idx_paths method - """ - if itree: - iterators = iter_list((itree.__iter__(),)) # in Python 3.9 lists are quicker than deque - indexes = [-1] - if filter_method: - if up_to_low: - none_tuple = NONE_TUPLE - while iterators: - for item in iterators[-1]: - if item: - # In next line we update the cache too - item._itree_prt_idx[1] = indexes[-1] = indexes[-1] + 1 - if filter_method(item): - yield tuple(indexes), item - iterators.extend((none_tuple, item.__iter__())) - indexes.append(-1) - break - elif item is None: - del indexes[-1] - del iterators[-1] - break - else: - item._itree_prt_idx[1] = indexes[-1] = indexes[-1] + 1 - if filter_method(item): - yield tuple(indexes), item - else: # for loop is finished and not broken - del iterators[-1] - else: - while iterators: - for item in iterators[-1]: - if item: - item._itree_prt_idx[1] = indexes[-1] = indexes[-1] + 1 - if filter_method(item): - iterators.extend(((None, (tuple(indexes), item)), item.__iter__())) - indexes.append(-1) - break - elif item is None: - yield iterators.pop()[-1] - del indexes[-1] - break - else: - item._itree_prt_idx[1] = indexes[-1] = indexes[-1] + 1 - if filter_method(item): - yield tuple(indexes), item - else: # for loop is finished and not broken - del iterators[-1] - else: - if up_to_low: - none_tuple = NONE_TUPLE - while iterators: - for item in iterators[-1]: - if item: - # In next line we update the cache too - item._itree_prt_idx[1] = indexes[-1] = indexes[-1] + 1 - yield tuple(indexes), item - iterators.extend((none_tuple, item.__iter__())) - indexes.append(-1) - break - elif item is None: - del indexes[-1] - del iterators[-1] - break - else: - item._itree_prt_idx[1] = indexes[-1] = indexes[-1] + 1 - yield tuple(indexes), item - else: # for loop is finished and not broken - del iterators[-1] - else: - iterators = iter_list((itree.__iter__(),)) - while iterators: - for item in iterators[-1]: - if item: - item._itree_prt_idx[1] = indexes[-1] = indexes[-1] + 1 - iterators.extend(((None, (tuple(indexes), item)), item.__iter__())) - indexes.append(-1) - break - elif item is None: - yield iterators.pop()[-1] - del indexes[-1] - break - else: - item._itree_prt_idx[1] = indexes[-1] = indexes[-1] + 1 - yield tuple(indexes), item - else: # for loop is finished and not broken - del iterators[-1] - - - def test1_iTree_iter_idxpath_old_new(self): - # filters are tested in a special test - print('\nRESULT OF TEST: iter idxpath old/new') - # build teh standard tree - root = iTree('root') - r0 = root.append(iTree('0')) - r00 = r0.append(iTree('00')) - r000 = r00.append(iTree('000')) - r01 = r0.append(iTree('01')) - r010 = r01.append(iTree('010')) - r011 = r01.append(iTree('011')) - r1 = root.append(iTree('1')) - r10 = r1.append(iTree('10')) - r100 = r10.append(iTree('100')) - r11 = r1.append(iTree('11')) - r2 = root.append(iTree('2')) - r20 = r2.append(iTree('20')) - r200 = r20.append(iTree('200')) - r201 = r20.append(iTree('201')) - r21 = r2.append(iTree('21')) - r0100 = r010.append(iTree('0100')) - r0101 = r010.append(iTree('0101')) - r1000 = r100.append(iTree('0100')) - r1001 = r100.append(iTree('0101')) - r2000 = r200.append(iTree('2000')) - - new_list=list(root.deep.idx_paths()) - old_list=list(self.idx_paths_old(root)) - for new,old in zip(new_list,old_list): - assert new==old - new_list=list(root.deep.idx_paths(options=UP)) - old_list=list(self.idx_paths_old(root,up_to_low=False)) - for new,old in zip(new_list,old_list): - assert new==old - - myfilter = lambda i: i.idx and i.idx%2 - new_list=list(root.deep.idx_paths(myfilter)) - old_list=list(self.idx_paths_old(root,myfilter)) - for new,old in zip(new_list,old_list): - assert new==old - new_list=list(root.deep.idx_paths(myfilter,options=UP)) - old_list=list(self.idx_paths_old(root,myfilter,up_to_low=False)) - for new,old in zip(new_list,old_list): - assert new==old - - def test2_iTree_iter_idxpath_full(self): # filters are tested in a special test print('\nRESULT OF TEST: iter idxpath full') @@ -1359,181 +1208,6 @@ def test2_iTree_iter_idxpath_full(self): print(ITER.get_option_str(key)+' tested-> pass') - def tag_idx_paths_old(self,itree, filter_method=None, up_to_low=True): - """ - old idx_paths method - """ - if itree: - tag_indexes = [None] - iterators = iter_list((itree.__iter__(),)) - if filter_method: - if up_to_low: - none_tuple = NONE_TUPLE - tag_index_dict = [{tag: -1 for tag in itree._families.keys()}] - while iterators: - for item in iterators[-1]: - if item: - tag = item._tag - tag_dict = tag_index_dict[-1] - item._itree_prt_idx[2] = tag_dict[tag] = idx = tag_dict[tag] + 1 - tag_indexes[-1] = (tag, idx) - if filter_method(item): - yield tuple(tag_indexes), item - iterators.extend((none_tuple, filter(filter_method, item.__iter__()))) - tag_indexes.append(None) - tag_index_dict.append({tag: -1 for tag in item._families.keys()}) - break - elif item is None: - del tag_indexes[-1] - del tag_index_dict[-1] - del iterators[-1] - break - else: - tag = item._tag - tag_dict = tag_index_dict[-1] - item._itree_prt_idx[2] = tag_dict[tag] = c = tag_dict[tag] + 1 - tag_indexes[-1] = (tag, c) - if filter_method(item): - yield tuple(tag_indexes), item - else: # for loop is finished and not broken - del iterators[-1] - else: - tag_index_dict = [{tag: -1 for tag in itree._families.keys()}] - while iterators: - for item in iterators[-1]: - if item: - tag = item._tag - tag_dict = tag_index_dict[-1] - item._itree_prt_idx[2] = tag_dict[tag] = idx = tag_dict[tag] + 1 - tag_indexes[-1] = (tag, idx) - if filter_method(item): - iterators.extend( - ((None, (tuple(tag_indexes), item)), filter(filter_method, item.__iter__()))) - tag_indexes.append(None) - tag_index_dict.append({tag: -1 for tag in item._families.keys()}) - break - elif item is None: - yield iterators.pop()[-1] - del tag_indexes[-1] - del tag_index_dict[-1] - break - else: - tag = item._tag - tag_dict = tag_index_dict[-1] - item._itree_prt_idx[2] = tag_dict[tag] = c = tag_dict[tag] + 1 - tag_indexes[-1] = (tag, c) - if filter_method(item): - yield tuple(tag_indexes), item - else: # for loop is finished and not broken - del iterators[-1] - else: - if up_to_low: - none_tuple = NONE_TUPLE - tag_index_dict = [{tag: -1 for tag in itree._families.keys()}] - while iterators: - for item in iterators[-1]: - if item: - tag = item._tag - tag_dict = tag_index_dict[-1] - item._itree_prt_idx[2] = tag_dict[tag] = idx = tag_dict[tag] + 1 - tag_indexes[-1] = (tag, idx) - yield tuple(tag_indexes), item - iterators.extend((none_tuple, item.__iter__())) - tag_indexes.append(None) - tag_index_dict.append({tag: -1 for tag in item._families.keys()}) - break - elif item is None: - del tag_indexes[-1] - del tag_index_dict[-1] - del iterators[-1] - break - else: - tag = item._tag - tag_dict = tag_index_dict[-1] - try: - item._itree_prt_idx[2] = tag_dict[tag] = c = tag_dict[tag] + 1 - except KeyError: - item._itree_prt_idx[2] = tag_dict[tag] = c = 0 - tag_indexes[-1] = (tag, c) - yield tuple(tag_indexes), item - else: # for loop is finished and not broken - del iterators[-1] - else: - tag_index_dict = [dict.fromkeys(itree._families.keys(),-1)] - while iterators: - for item in iterators[-1]: - if item: - tag = item._tag - tag_dict = tag_index_dict[-1] - item._itree_prt_idx[2] = tag_dict[tag] = idx = tag_dict[tag] + 1 - tag_indexes[-1] = (tag, idx) - iterators.extend(((None, (tuple(tag_indexes), item)), item.__iter__())) - tag_indexes.append(None) - tag_index_dict.append({tag: -1 for tag in item._families.keys()}) - break - elif item is None: - yield iterators.pop()[-1] - del tag_indexes[-1] - del tag_index_dict[-1] - break - else: - tag = item._tag - tag_dict = tag_index_dict[-1] - try: - item._itree_prt_idx[2] = tag_dict[tag] = c = tag_dict[tag] + 1 - except KeyError: - item._itree_prt_idx[2] = tag_dict[tag] = c = 0 - tag_indexes[-1] = (tag, c) - yield tuple(tag_indexes), item - else: # for loop is finished and not broken - del iterators[-1] - - - def test3_iTree_iter_tagidxpath_old_new(self): - # filters are tested in a special test - print('\nRESULT OF TEST: iter tag_idx_path old/new') - # build teh standard tree - root = iTree('root') - r0 = root.append(iTree('0')) - r00 = r0.append(iTree('00')) - r000 = r00.append(iTree('000')) - r01 = r0.append(iTree('01')) - r010 = r01.append(iTree('010')) - r011 = r01.append(iTree('011')) - r1 = root.append(iTree('1')) - r10 = r1.append(iTree('10')) - r100 = r10.append(iTree('100')) - r11 = r1.append(iTree('11')) - r2 = root.append(iTree('2')) - r20 = r2.append(iTree('20')) - r200 = r20.append(iTree('200')) - r201 = r20.append(iTree('201')) - r21 = r2.append(iTree('21')) - r0100 = r010.append(iTree('0100')) - r0101 = r010.append(iTree('0101')) - r1000 = r100.append(iTree('0100')) - r1001 = r100.append(iTree('0101')) - r2000 = r200.append(iTree('2000')) - - new_list=list(root.deep.tag_idx_paths()) - old_list=list(self.tag_idx_paths_old(root)) - for new,old in zip(new_list,old_list): - assert new==old - new_list=list(root.deep.tag_idx_paths(options=UP)) - old_list=list(self.tag_idx_paths_old(root,up_to_low=False)) - for new,old in zip(new_list,old_list): - assert new==old - - myfilter = lambda i: i.idx and i.idx%2 or True - new_list=list(root.deep.tag_idx_paths(myfilter)) - old_list=list(self.tag_idx_paths_old(root,myfilter)) - for new,old in zip(new_list,old_list): - assert new==old - new_list=list(root.deep.tag_idx_paths(myfilter,options=UP)) - old_list=list(self.tag_idx_paths_old(root,myfilter,up_to_low=False)) - for new,old in zip(new_list,old_list): - assert new==old - def test4_iTree_iter_tagidxpath_full(self): # filters are tested in a special test print('\nRESULT OF TEST: iter tag_idx_path full') diff --git a/tests/test_itertree_links.py b/tests/test_itertree_links.py index 21da436..7d68e6e 100644 --- a/tests/test_itertree_links.py +++ b/tests/test_itertree_links.py @@ -1,36 +1,21 @@ # -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: This test suite focuses on the linking and "covering mechanisms" available in iTree """ diff --git a/tests/test_itertree_mathsets.py b/tests/test_itertree_mathsets.py index 8d90818..ef58bb6 100644 --- a/tests/test_itertree_mathsets.py +++ b/tests/test_itertree_mathsets.py @@ -1,37 +1,21 @@ # -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License - +CONTENT DESCRIPTION: This part of code contains the integration tests related to the base iTree functionalities diff --git a/tests/test_itertree_serialize.py b/tests/test_itertree_serialize.py index d930585..6119df5 100644 --- a/tests/test_itertree_serialize.py +++ b/tests/test_itertree_serialize.py @@ -1,36 +1,21 @@ # -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License +CONTENT DESCRIPTION: This part of code contains the integration tests related to the base iTree functionalities diff --git a/tests/test_itertree_value_models.py b/tests/test_itertree_value_models.py index 1fa957d..e6d45a2 100644 --- a/tests/test_itertree_value_models.py +++ b/tests/test_itertree_value_models.py @@ -1,37 +1,21 @@ # -*- coding: utf-8 -*- """ This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + https://pypi.org/project/itertree/ GIT Home: https://github.com/BR1py/itertree The documentation can be found here: https://itertree.readthedocs.io/en/latest/index.html -The code is published under MIT license incl. human protect patch: - -The MIT License (MIT) incl. human protect patch -Copyright © 2022 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the “Software”), to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -Human protect patch: -The program and its derivative work will neither be modified or executed to harm any human being nor through -inaction permit any human being to be harmed. - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +The code is published under MIT license For more information see: https://en.wikipedia.org/wiki/MIT_License - +CONTENT DESCRIPTION: This part of code contains the integration tests related to the base iTree functionalities diff --git a/tests/unit/test_itree_data.py b/tests/unit/test_itree_data.py index 64e11f1..a27de42 100644 --- a/tests/unit/test_itree_data.py +++ b/tests/unit/test_itree_data.py @@ -1,5 +1,26 @@ -# -*- coding: utf-8 -*- +""" +This code is taken from the itertree package: + _ _____ _____ _____ _____ _____ _____ _____ + | |_ _| __| __ |_ _| __ | __| __| + |-| | | | __| -| | | | -| __| __| + |_| |_| |_____|__|__| |_| |__|__|_____|_____| + +https://pypi.org/project/itertree/ +GIT Home: +https://github.com/BR1py/itertree +The documentation can be found here: +https://itertree.readthedocs.io/en/latest/index.html + +The code is published under MIT license +For more information see: https://en.wikipedia.org/wiki/MIT_License + +CONTENT DESCRIPTION: + +Unit tests related to the itertree data types +""" + import pytest +import sys from itertree import * __argument__ = 'FAKE' @@ -68,7 +89,7 @@ def test_is_empty_property(self, setup_no_argument, setup_fake_argument): def test_value_property(self, setup_no_argument, setup_fake_argument): assert setup_no_argument.value is NoValue - assert setup_fake_argument.value is __argument__ + assert setup_fake_argument.value == __argument__ class TestiTDataModelMethods: @@ -76,7 +97,7 @@ class TestiTDataModelMethods: (False, None)] def test_clear_value(self, setup_fake_argument): - assert setup_fake_argument.clear() is __argument__ + assert setup_fake_argument.clear() == __argument__ assert setup_fake_argument.value is NoValue def test_clear_value_empty_value(self, setup_no_argument): @@ -87,14 +108,14 @@ def test_emptyformatter_empty(self, setup_no_argument): assert setup_no_argument.formatter() == 'None' def test_emptyformatter_not_empty(self, setup_fake_argument): - assert setup_fake_argument.formatter() is 'FAKE' + assert setup_fake_argument.formatter() == 'FAKE' def test_formatter_empty(self, setup_no_argument): - assert setup_no_argument.formatter('Kraftfahrzeug-Haftpflichtversicherung') is \ + assert setup_no_argument.formatter('Kraftfahrzeug-Haftpflichtversicherung') == \ 'Kraftfahrzeug-Haftpflichtversicherung' def test_formatter_empty_not_empty(self, setup_fake_argument): - assert setup_fake_argument.formatter('Massenkommunikationsdienstleistungsunternehmen') is \ + assert setup_fake_argument.formatter('Massenkommunikationsdienstleistungsunternehmen') == \ 'Massenkommunikationsdienstleistungsunternehmen' @pytest.mark.parametrize("state, expected", state_data) @@ -124,10 +145,10 @@ def test_not_contains_empty(self, setup_no_argument): assert __argument__ not in setup_no_argument def test_format_empty_no_format_spec(self, setup_no_argument): - assert format(setup_no_argument) is 'None' + assert format(setup_no_argument) == 'None' def test_no_format_spec(self, setup_fake_argument): - assert format(setup_fake_argument) is __argument__ + assert format(setup_fake_argument) == __argument__ def test_inequality(self, setup_no_argument, setup_fake_argument): assert setup_no_argument != setup_fake_argument @@ -147,7 +168,7 @@ def test_equality_2(self, setup_fake_argument): @pytest.mark.xfail(reason='Issue in formatter') def test_format_spec(self): # Failing here. - assert format(ObservableiDataModel(10), 'x') is 'a' + assert format(ObservableiDataModel(10), 'x') == 'a' def test_repr_empty(self, setup_no_argument): assert str(setup_no_argument) == 'ObservableiDataModel()' @@ -296,9 +317,11 @@ def test__setitem___model(self, iTData_setup): assert object_under_test[__raw_data__] == 10 def test_setitem_key_exception(self, iTData_setup_no_argument): - with pytest.raises(TypeError): - object_under_test = iTData_setup_no_argument - object_under_test.__setitem__(key=slice(6), value=10) + if int(sys.version.split('.')[1])<12: + # This exception comes only in python versions < 3.12 + with pytest.raises(TypeError): + object_under_test = iTData_setup_no_argument + object_under_test.__setitem__(key=slice(6), value=10) class TestiTDataGetItemMethod: @@ -604,15 +627,15 @@ def test_method_fromkeys_with_values(self): assert (values == {5}) def test_method_get(self, iTData_as_dict): - assert iTData_as_dict.get('two', 3) is 2 - assert iTData_as_dict.get('ten', 3) is 3 + assert iTData_as_dict.get('two', 3) == 2 + assert iTData_as_dict.get('ten', 3) == 3 def test_method___get_item__exception(self, iTData_as_dict): with pytest.raises(KeyError): iTData_as_dict.__getitem__('ten') def test_method___get_item__(self, iTData_as_dict): - assert iTData_as_dict.__getitem__('two') is 2 + assert iTData_as_dict.__getitem__('two') == 2 def test_method_items(self, iTData_as_dict): view = iTData_as_dict.items()