eww.parser¶
We need to make some modifications to optparse for our environment. This module creates a subclass of optparse with the necessary changes.
- class eww.parser.Opt(*opts, **attrs)[source]¶
Bases: optparse.Option
We don’t need to change anything here; we’re subclassing this for consistency.
- class eww.parser.Parser(*args, **kwargs)[source]¶
Bases: optparse.OptionParser
Our lightly modified version of optparse.
- __init__(*args, **kwargs)[source]¶
Init. The only change here is forcing the help option off. We could do this at instantiation, but it’s cleaner to do it here.
- error(msg)[source]¶
We override error here to prevent us from exiting. Optparse does not expect this to return, but that’s not really a problem for us since each command can be abstractly considered a different, new script.
Parameters: msg (str) – The error message that will be passed to the ParserError exception. Raises: ParserError – Raised when a command cannot be parsed.
- exception eww.parser.ParserError[source]¶
Bases: exceptions.Exception
We create a custom exception here to be raised on error. That way we can safely handle parser errors and do something useful with them.
- __weakref__¶
list of weak references to the object (if defined)