Skip to main content

Simple tree struct with search and traversal utilities

Project description

SearchableTree

Simple list intended for simplifying traversal & node search Does not support deletion

Example:

tree = SearchableTree("root", SearchableNode)
root = tree.root()
l1 = root.appendChild('l1')
l11 = root.appendChild('l11')
l12 = root.appendChild('l12')
l2 = root.appendChild('l2')
l21 = root.appendChild('l21')
l22 = root.appendChild('l22')
root.upsert("l1.l11.l111")
root.upsert("l1.l11.l112")

for el in root.traverse(): #Traverse all nodes
	print(el)

print(tree) #Pretty print tree
print(tree.find("l112")) #Get node by name
print(tree.find("root.l1.l11")) #Get node by path
for el in l2.ancestors(): #Get node ancestors
	print(el)

Extend SearchableNode to add custom funcionality

Author

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SearchableTree-1.0.4.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

SearchableTree-1.0.4-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file SearchableTree-1.0.4.tar.gz.

File metadata

  • Download URL: SearchableTree-1.0.4.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.12

File hashes

Hashes for SearchableTree-1.0.4.tar.gz
Algorithm Hash digest
SHA256 8c9c3eb82bc71400511fd41ec37637bc6f79056116fc8af5a4b7207f7b0b2661
MD5 0decbd46fee33e8c245b39aee2775d8b
BLAKE2b-256 3e591c3b0237b524e3d29d9535b56252f098152959c81906cfdbd835ae82f3b4

See more details on using hashes here.

File details

Details for the file SearchableTree-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: SearchableTree-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.12

File hashes

Hashes for SearchableTree-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e162a310ac68742ca909654ca09e96850503acd87da9c9d397c29cb450c0b504
MD5 d89becad3ff458f6e767c7ee65bd1100
BLAKE2b-256 d88e3f3d0b0ccc6d4456e90a649ad24e32353b01a05ba52b793a3be1c3ee93c8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page