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

Create CheckDependencies class #75

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

nano-labs
Copy link

This class extends Check adding a dependency tree so when an item is checked it automatically checks all it's dependencies. Also, if an item is unchecked it automatically unchecks all it's dependants. The effect cascades to dependencies of dependencies.

Here's an example:

from bullet import CheckDependencies
from pprint import pprint
dependency_tree = (
    ("Option A", ("Option B",)),
    ("Option B", ("Option C",)),
    ("Option C", ()),
    ("Option D", ("Option C", "Option E")),
    ("Option E", ()),
)
pprint(dependency_tree)
print()
cli = CheckDependencies("Check some options", dep_tree=dependency_tree)
print(cli.launch())

checkdependency.gif

Or a different usage:

from bullet import CheckDependencies
from pprint import pprint
dependency_tree = (
    ("Option A", ()),
    ("Option B", ()),
    ("Option C", ()),
    ("Option D", ()),
    ("Option E", ()),
    ("ALL ABOVE", ("Option A", "Option B", "Option C", "Option D", "Option E")),
)
pprint(dependency_tree)
print()
cli = CheckDependencies("Check some options", dep_tree=dependency_tree)
print(cli.launch())

allabove.gif

@nano-labs
Copy link
Author

Im already using this on my own project: https://github.com/nano-labs/dstart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant