livery.toolroom.store._requirement¶
livery.toolroom.store._requirement ¶
The one requirement grammar: name[option,...]?>=floor@scope, parsed once.
Every site that names a tool or an extension spells it the same way, and livery.toolroom.store.Spec is the one parser:
[...]names options: a tool's profile, or an extension's switches;?marks the requirement optional;>=flooris the lowest version that satisfies;@scopelimits it to some hosts: comma-separated platforms (windows) or host keys (windows-x64), each excluded with a leading!.
The parser enforces the grammar alone. What a site allows of it (a
floor, options, ?) is the site's own rule, so a refusal there names
the site. livery.toolroom.store.Scope resolves a scope against
the hosts a workspace supports.
Classes:
| Name | Description |
|---|---|
SpecError |
A spelling the requirement grammar does not read; the message names why. |
Scope |
The hosts a requirement is limited to, as written after |
Spec |
One requirement as the grammar spells it: |
SpecError ¶
Bases: ValueError
A spelling the requirement grammar does not read; the message names why.
Scope
dataclass
¶
The hosts a requirement is limited to, as written after @.
Attributes:
| Name | Type | Description |
|---|---|---|
include |
tuple[str, ...]
|
The platforms and host keys named without |
exclude |
tuple[str, ...]
|
The platforms and host keys named with |
Methods:
| Name | Description |
|---|---|
parse |
The scope comma-separated text spells, every token checked. |
hosts |
The hosts of supported this scope reaches, in their order. |
__bool__ |
Whether the scope limits anything: false for every host. |
__str__ |
The scope as written after |
parse
classmethod
¶
The scope comma-separated text spells, every token checked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The tokens after |
required |
where
|
str
|
The site a refusal names. |
'a requirement'
|
spelled
|
str
|
The whole spelling the scope came from, for a refusal; text itself when empty. |
''
|
Raises:
| Type | Description |
|---|---|
SpecError
|
for a scope naming no token, or a token that is neither a platform nor a host key. |
Source code in packages/toolroom-store/src/livery/toolroom/store/_requirement.py
hosts ¶
The hosts of supported this scope reaches, in their order.
No inclusion reaches every supported host; an exclusion then removes its hosts, so a scope of exclusions alone starts from every supported host.
Source code in packages/toolroom-store/src/livery/toolroom/store/_requirement.py
Spec
dataclass
¶
Spec(name: str, options: tuple[str, ...] = (), optional: bool = False, floor: str = '', scope: Scope = Scope())
One requirement as the grammar spells it: name[options]?>=floor@scope.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The tool's or the extension's name. |
options |
tuple[str, ...]
|
The names inside |
optional |
bool
|
Whether |
floor |
str
|
The lowest version that satisfies; empty for any. |
scope |
Scope
|
The hosts it is limited to; empty for every host. |
Methods:
| Name | Description |
|---|---|
parse |
The requirement text spells. |
__str__ |
The requirement as the grammar spells it. |
parse
classmethod
¶
The requirement text spells.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
|
required |
where
|
str
|
The site a refusal names: the one that declared it. |
'a requirement'
|
Raises:
| Type | Description |
|---|---|
SpecError
|
for a spelling the grammar does not read, an empty or malformed option, or a scope livery.toolroom.store.Scope.parse refuses. |