1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 07:47:14 +03:00

switched to using SimpleSpec for constraints

This commit is contained in:
A_D 2020-10-26 18:48:28 +02:00 committed by Athanasius
parent 8dca6783fc
commit 6b75179199
2 changed files with 8 additions and 8 deletions

View File

@ -14,10 +14,10 @@ Killswitches are stored in a JSON file that is queried by EDMC on startup. The f
The `kill_switches` array contains kill switch objects. Each contains two fields:
| Key | Type | Description |
| --------: | :----------------: | :---------------------------------------------------------------------- |
| `version` | `semantic version` | The version of EDMC these kill switches apply to (Must be valid semver) |
| `kills` | `Dict[str, str]` | The different keys to disable, and the reason for the disable |
| Key | Type | Description |
| --------: | :--------------: | :--------------------------------------------------------------------------- |
| `version` | `version spec` | The version of EDMC these kill switches apply to (Must be valid semver spec) |
| `kills` | `Dict[str, str]` | The different keys to disable, and the reason for the disable |
An example follows:
```json
@ -37,7 +37,7 @@ An example follows:
### Versions
Versions are checked using equality checks on `semantic_version.Version` instances. Meaning that **all** fields are checked (ie, Major, Minor, Patch, Prerelease, and Build).
Versions are checked using contains checks on `semantic_version.SimpleSpec` instances.
## Plugin support

View File

@ -18,7 +18,7 @@ _current_version: semantic_version.Version = semantic_version.Version(config.app
class KillSwitch(NamedTuple):
"""One version's set of kill switches."""
version: semantic_version.Version
version: semantic_version.SimpleSpec
kills: Dict[str, str]
@ -44,7 +44,7 @@ class KillSwitchSet:
:return: a namedtuple indicating status and reason, if any
"""
for ks in self.kill_switches:
if version != ks.version:
if version not in ks.version:
continue
return DisabledResult(id in ks.kills, ks.kills.get(id, ""))
@ -120,7 +120,7 @@ def parse_kill_switches(data: KILL_SWITCH_JSON_DICT) -> List[KillSwitch]:
for idx, ks_data in enumerate(kill_switches):
try:
ver = semantic_version.Version(ks_data['version'])
ver = semantic_version.SimpleSpec(ks_data['version'])
except ValueError as e:
logger.warning(f'could not parse killswitch idx {idx}: {e}')