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.3.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for SearchableTree-1.0.3.tar.gz
Algorithm Hash digest
SHA256 9d9394bf275cf752cd35c998fd3240c4b3233eccb6bbdb586040329aacf795da
MD5 e465426c57f86a2ed78f6bee103971c0
BLAKE2b-256 672831b95f3b27468692c8905f190394273ce83ac28b1053102283af401aaace

See more details on using hashes here.

File details

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

File metadata

  • Download URL: SearchableTree-1.0.3-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.7.4

File hashes

Hashes for SearchableTree-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e2dd421da8f1d09e28d1ca5975857ed9148feb4d343b2e5ccc53d25498be652f
MD5 3f7e07b4fe3ac6c468aea71a44955944
BLAKE2b-256 a9bbf2affcaca7a920648ebaabfb286dd2e130654ce9dc5af676ffe29f5ebdf0

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