qav package

Submodules

qav.filters module

class qav.filters.DynamicFilter(filterable_func)[source]

Bases: qav.filters.Filter

A Filter that can dynamically prune choices based off of whether filterable_func(choice[, table]) returns True or False.

filter(value, table=None)[source]

Return True if the value should be pruned; False otherwise.

If a table argument was provided, pass it to filterable_func.

class qav.filters.Filter(string)[source]

Bases: object

class qav.filters.PostFilter(string)[source]

Bases: qav.filters.Filter

filter(value, table=None)[source]
class qav.filters.PreFilter(string)[source]

Bases: qav.filters.Filter

filter(value, table=None)[source]
class qav.filters.SubFilter(string)[source]

Bases: qav.filters.Filter

filter(value, table=None)[source]

qav.listpack module

class qav.listpack.ListPack(lp, sep=': ', padding=' ', indentation=0, width=79)[source]

Bases: object

BOLD = '\x1b[1m'
OFF = '\x1b[0m'
append_item(item)[source]
bold(t)[source]
calc(t)[source]
prepend_item(item)[source]

qav.questions module

class qav.questions.Question(question, value, validator=None, multiple=False, printable_name=None)[source]

Bases: object

add(question)[source]
answer()[source]

Return the answer for the question from the validator.

This will ultimately only be called on the first validator if multiple validators have been added. Since we ultimately we and all the validators this should not cause any issues.

ask(answers=None)[source]

Ask the question, then ask any sub-questions.

This returns a dict with the {value: answer} pairs for the current question plus all decendent questions.

choices()[source]

Print the choices for this question.

This may be a empty string and in the case of a list of validators we will only show the first validator’s choices.

remove(question)[source]
validate(answer)[source]

Validate the answer with our Validator(s)

This will support one or more validator classes being applied to this question. If there are multiple, all validators must return True for the answer to be valid.

class qav.questions.QuestionSet[source]

Bases: object

add(question)[source]
ask()[source]
ask_and_confirm(additional_readonly_items=None, prepend_listpacking_items=True)[source]
remove(question)[source]

qav.utils module

qav.utils.bold(s)[source]

qav.validators module

class qav.validators.CompactListValidator(choices)[source]

Bases: qav.validators.Validator

Accepts a list of choices like ListValidator but doesn’t print validator choices.

validate(value)[source]
class qav.validators.DateValidator(blank=False, negate=False)[source]

Bases: qav.validators.Validator

Accepts dates in the format YYYYMMDD

date_regex = <_sre.SRE_Pattern object>
validate(value)[source]
class qav.validators.DomainNameValidator(blank=False, negate=False)[source]

Bases: qav.validators.Validator

validate(value)[source]

Attempts a forward lookup via the socket library and if successful will try to do a reverse lookup to verify DNS is returning both lookups.

class qav.validators.EmailValidator(blank=False, negate=False)[source]

Bases: qav.validators.Validator

email_regex = <_sre.SRE_Pattern object>
validate(value)[source]
class qav.validators.HashValidator(choices, filters=None, verbose=True)[source]

Bases: qav.validators.Validator

choices
print_choices()[source]
validate(value)[source]

Return a boolean if the choice is a number in the enumeration

class qav.validators.IPAddressValidator(blank=False, negate=False)[source]

Bases: qav.validators.Validator

validate(value)[source]

Return a boolean if the value is valid

class qav.validators.IPNetmaskValidator(blank=False, negate=False)[source]

Bases: qav.validators.Validator

validate(value)[source]

Return a boolean if the value is a valid netmask.

class qav.validators.ListValidator(choices, filters=None)[source]

Bases: qav.validators.Validator

choices
print_choices()[source]
validate(value)[source]

Return a boolean if the choice is a number in the enumeration

class qav.validators.MacAddressValidator(blank=False, negate=False)[source]

Bases: qav.validators.Validator

macaddr_regex = <_sre.SRE_Pattern object>
validate(value)[source]
class qav.validators.TupleValidator(choices, filters=None)[source]

Bases: qav.validators.Validator

choices
print_choices()[source]
validate(value)[source]

Return a boolean if the choice a number in the enumeration

class qav.validators.URIValidator(blank=False, negate=False)[source]

Bases: qav.validators.Validator

uri_regex = <_sre.SRE_Pattern object>
validate(value)[source]

Return a boolean indicating if the value is a valid URI

class qav.validators.Validator(blank=False, negate=False)[source]

Bases: object

choice()[source]
error()[source]
hints()[source]
print_choices()[source]
static stringify(value)[source]
validate(value)[source]

The most basic validation

class qav.validators.YesNoValidator(blank=False, negate=False)[source]

Bases: qav.validators.Validator

validate(value)[source]