- Deprecate text alias and raise StreamlinkDeprecationWarning on access
- Add deprecation to docs
- Replace validate.text with str in remaining plugins
- Update test
- Remove `ValidationError` from package's `__init__` module.
It was never meant to be a public export. Update tests accordingly.
- Remove `context` argument from `ValidationError` and use the
exception's `__cause__` property instead, and add the "raise from"
statements to schema validations and validators where a context was
set previously. Explicitly "raise from None" where a context should
be suppressed.
- Fix unneeded type cast when printing `ValidationError` template string
- Fix length comparison in `length` validator
- Add supported `Element.xpath()` keywords to `validate.xml_xpath()`
- `namespaces` for defining prefix-namespace mappings
- `extensions` for defining custom XPath functions in Python
- `smart_strings` for disabling element tree references on any string
return values that will be kept in memory
- `**variables` for being able to define custom XPath variables
instead of having to embed strings in the XPath query itself
- Add `namespaces`, `extensions` and `**variables` keywords to
`validate.xml_xpath_string()` and always disable `smart_strings`
- Add `namespaces` to `validate.xml_find()`, `validate.xml_findall()`
and `validate.xml_findtext()`
- Handle XPath evaluation errors via `lxml.etree.XPathError`
and ElementPath syntax errors via `SyntaxError`
- Update error messages of ElementPath-based validators
- Remove unneeded `iselement` validation at the end of `xml_find()`
- Fix docstrings of both XPath- and ElementPath-based validators
- Add tests for the newly added keywords and XPath evaluation errors
This helps avoiding the validation pattern
```py
validate.any(None, validate.all(...))
```
and is useful for `re.Pattern` and `xml_xpath_string` validations,
where the validation result can be `None` and is usually used for
gracefully returning no validation results instead of raising an error.
Use the `search()` method and return `None` or a `re.Match` instance.
This avoids having to explicitly define the validation pattern
```py
validate.transform(re.compile(...).search)
```
In contrast to the `list` instance validation where sequence subsets
get validated, the `ListSchema` validates that the input list has the
same length and that all list items validate successfully according to
the defined schemas.
- Change signature of `ValidationError` to be able to pass template
strings and template variables which can get truncated individually.
- Make error messages consistent by using string representations for
template variables where it makes sense
- Implement `ValidationError`
- Inherit from `ValueError` to preserve backwards compatiblity
- Allow collecting multiple errors (AnySchema)
- Keep an error stack of parent `ValidationError`s or other exceptions
- Format error stack when converting error to string
- Raise `ValidationError` instead of `ValueError`
- Add error contexts where it makes sense
- Add schema names to error instances
- Add and update tests
Turn module into package with multiple logical sub-modules:
- Define a public interface in the package's `__init__` module
- Split validation schemas, validators and validate logic
- schemas: classes which register attributes used by their
respective `validate` implementations
- validators: functions which can internally call `validate`
and which return something that can be validated
- validate: singledispatch functions which implement the validation
logic for schemas and various other types
- Rename validation schemas for better internal references
- Rename singledispatch methods
Other clean-up work:
- Update comments and fix grammar
- Add type annotations
- Use f-strings
- Use `str` instead of the `text` alias
- Simplify some code blocks
- Rearrange classes and functions
- Rephrase certain error messages
- Add a few more tests for better code coverage
- add parse_{json,html,xml,qsd} validate.transform wrapper methods
- refactor utils module and move parse* methods into utils.parse
- refactor parse* methods and use common parsing + exception handling
- reformat all-export list in utils
- replace xml.etree from standard library with lxml.etree in
plugin.api.validate, utils.parse_xml, plugins and tests
- add validate.xml_xpath() and validate.xml_xpath_string() methods
- fix validate.get() and return attribute value for given attribute key
- refactor validate.xml_element() validation method
- fix and add tests
* tests: logger tests
* test: file stream
* test: missing sessions tests
* test: missing util tests
* tests: call can_handle_url for each plugin to ensure it won't error
* tests: speed up by 2 seconds, mocking sleep
* test for streamname lookups
* refactor test structure
* tests: rebase plugins tests
* tests: no need for Python 3.6 support
* tests: remove 2.6 from the travis build
* tests: rebase on master
* tests: rename plugin.api tests
* tests: add mock http resource
* move new plugin tests
* rebase master
* tests: coverage for ConsoleOutput