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

[Query] Validator for Input #72

Open
Ccortina opened this issue Oct 16, 2020 · 1 comment
Open

[Query] Validator for Input #72

Ccortina opened this issue Oct 16, 2020 · 1 comment

Comments

@Ccortina
Copy link

Ccortina commented Oct 16, 2020

Hi , im trying to extend the "Input" class to add a simple folder path validator, but the code seems to be ignoring my accept and valid methods.
What am I doing wrong?

from bullet import Input, keyhandler, styles
from bullet.charDef import NEWLINE_KEY
import os.path


class FolderPathCheck(Input):

    @keyhandler.register(NEWLINE_KEY)
    def accept(self):
        if self.valid():
            return super.accept()

    def valid(self, ans):
        return os.path.isdir(self.ans)

Thanks.

@a-luna
Copy link

a-luna commented Oct 21, 2020

super is a function, so accept should return super().accept() NOT super.accept() (notice the parentheses after both super and accept.

Hope that helps!

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

No branches or pull requests

2 participants