bullet
bullet copied to clipboard
[Query] Validator for Input
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.
super
is a function, so accept
should return super().accept()
NOT super.accept()
(notice the parentheses after both super
and accept
.
Hope that helps!