Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.7.0: Remove deprecated plugins; Remove python2 declaration #217

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,13 @@ on:
branches: [ "master" ]

jobs:
build-pre37:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["2.7"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-t-pre37.txt ]; then pip install -r requirements-t-pre37.txt; fi
- name: Test with nosetests
run: |
./scripts/testing.sh

build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12.0-rc.1"]

steps:
- uses: actions/checkout@v3
Expand Down
8 changes: 3 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup

__version__ = "1.6.5"
__version__ = "1.7.0"


setup(
Expand All @@ -9,21 +9,19 @@
url="https://github.com/caesar0301/treelib",
author="Xiaming Chen",
author_email="chenxm35@gmail.com",
description="A Python 2/3 implementation of tree structure.",
description="A Python implementation of tree structure.",
long_description="""This is a simple tree data structure implementation in python.""",
license="Apache License, Version 2.0",
packages=["treelib"],
keywords=["data structure", "tree", "tools"],
install_requires=["six"],
classifiers=[
"Development Status :: 4 - Beta",
"Development Status :: 5 - Production",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
Expand Down
113 changes: 0 additions & 113 deletions tests/test_plugins.py

This file was deleted.

35 changes: 0 additions & 35 deletions treelib/plugins.py

This file was deleted.

19 changes: 12 additions & 7 deletions treelib/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ def write(line):
print("Tree is empty")

if stdout:
print(self._reader.encode('utf-8'))
print(self._reader.encode("utf-8"))
else:
return self._reader

Expand Down Expand Up @@ -1131,12 +1131,12 @@ def to_graphviz(

@classmethod
def from_map(cls, child_parent_dict, id_func=None, data_func=None):
'''
"""
takes a dict with child:parent, and form a tree
'''
"""
tree = Tree()
if tree is None or tree.size() > 0:
raise ValueError('need to pass in an empty tree')
raise ValueError("need to pass in an empty tree")
id_func = id_func if id_func else lambda x: x
data_func = data_func if data_func else lambda x: None
parent_child_dict = {}
Expand All @@ -1145,20 +1145,25 @@ def from_map(cls, child_parent_dict, id_func=None, data_func=None):
if v is None and root_node is None:
root_node = k
elif v is None and root_node is not None:
raise ValueError('invalid input, more than 1 child has no parent')
raise ValueError("invalid input, more than 1 child has no parent")
else:
if v in parent_child_dict:
parent_child_dict[v].append(k)
else:
parent_child_dict[v] = [k]
if root_node is None:
raise ValueError('cannot find root')
raise ValueError("cannot find root")

tree.create_node(root_node, id_func(root_node), data=data_func(root_node))
queue = [root_node]
while len(queue) > 0:
parent_node = queue.pop()
for child in parent_child_dict.get(parent_node, []):
tree.create_node(child, id_func(child), parent=id_func(parent_node), data=data_func(child))
tree.create_node(
child,
id_func(child),
parent=id_func(parent_node),
data=data_func(child),
)
queue.append(child)
return tree