Options
- pytidyhtml5.Option(Document document=None)
An option that effects how a document will be serialized or deserialized.
Getters
- Option.id
Returns the unique identifier for this option
- Returns:
pytidyhtml5.OptionId– The unique identifier for this option.int – The library returned an unknown value.
None – The option was not good anymore, see
__bool__().
- Option.name
Returns the name of the option.
- Returns:
str – The name of the option.
None – The option was not good anymore, see
__bool__().
- Option.type
Returns the value type of the option.
- Returns:
pytidyhtml5.OptionType– The value type of the option.int – The library returned an unknown value.
None – The option was not good anymore, see
__bool__().
- Option.is_list
Returns whether the options has a picklist of values to chose from.
See also:
iter_picklist().- Returns:
bool – Yes or no
None – The option was not good anymore, see
__bool__().
- Option.is_readonly
Returns whether the options is read-only.
- Returns:
bool – Yes or no
None – The option was not good anymore, see
__bool__().
- Option.category
Returns the category of the option.
- Returns:
pytidyhtml5.ConfigCategory– The category of the option.int – The library returned an unknown value.
None – The option was not good anymore, see
__bool__().
- Option.default
Returns the default value of the option.
See also:
reset().- Returns:
str|int|bool – The default value of the option.
None – The option was not good anymore, see
__bool__().
- Option.value
Return the current value of the option.
- Returns:
str|int|bool – The current value of the option.
None – The option was not good anymore, see
__bool__().
Setters
- Option.set_value(self, value)
Set the value of the option.
- Parameters:
value (str|bytes|int|bool|None) – The new value. None resets the option to its default value.
- Returns:
bool – True if the value was set.
None – The option was not good anymore, see
__bool__().
- Option.reset(self)
Reset the option to its default value.
- Returns:
bool – True if the value was reset.
None – The option was not good anymore, see
__bool__().
Iterators
- Option.__iter__()
A tuple of
pytidyhtml5.Option.get_name()andpytidyhtml5.Option.get_value().This function can be useful for debugging if want to see all options at once:
dict(document.iter_options()).- Returns:
tuple[str, str|int|bool] – The name and value of the option.
tuple[None, None] – The option was not good anymore, see
__bool__().
- Option.iter_picklist(self)
Yields possible values for the option if the option is a picklick:
is_picklist.- Yields:
str – A possible value. Warning: options that want an integral value return a string, too. The string contains a description and cannot be used verbatim in
pytidyhtml5.Option.set_value().
Miscellaneous
- Option.__bool__()
An Option is truthy if it has an assigned TidyOption (i.e. if it was created by some
Documentmethod), and the document has was not been released in the meantime.
- Option.__len__()
Returns if
__iter__()will be useful.- Returns:
2 if the option is good, otherwise 0.
- Return type:
- Option.__eq__()
Compares the underlying pointer.
If you get the same option twice from a document, you will will have two distinct
Optioninstances that compare equal.
- Option.__ne__()
Simply
not (self == other)
Getters as methods
All getters exist as methods, too:
|
Returns the unique identifier for this option |
|
Returns the name of the option. |
|
Returns the value type of the option. |
|
Returns whether the options has a picklist of values to chose from. |
|
Returns whether the options is read-only. |
|
Returns the category of the option. |
|
Returns the default value of the option. |
|
Return the current value of the option. |