snakemake-interface-common 1.2.0__tar.gz → 1.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {snakemake_interface_common-1.2.0 → snakemake_interface_common-1.3.1}/PKG-INFO +1 -1
- {snakemake_interface_common-1.2.0 → snakemake_interface_common-1.3.1}/pyproject.toml +1 -1
- snakemake_interface_common-1.3.1/snakemake_interface_common/settings.py +38 -0
- snakemake_interface_common-1.2.0/snakemake_interface_common/settings.py +0 -47
- {snakemake_interface_common-1.2.0 → snakemake_interface_common-1.3.1}/LICENSE +0 -0
- {snakemake_interface_common-1.2.0 → snakemake_interface_common-1.3.1}/README.md +0 -0
- {snakemake_interface_common-1.2.0 → snakemake_interface_common-1.3.1}/snakemake_interface_common/__init__.py +0 -0
- {snakemake_interface_common-1.2.0 → snakemake_interface_common-1.3.1}/snakemake_interface_common/exceptions.py +0 -0
- {snakemake_interface_common-1.2.0 → snakemake_interface_common-1.3.1}/snakemake_interface_common/rules.py +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
from typing import List, Set, TypeVar, Union
|
|
3
|
+
|
|
4
|
+
TSettingsEnumBase = TypeVar("TSettingsEnumBase", bound="SettingsEnumBase")
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class SettingsEnumBase(Enum):
|
|
8
|
+
@classmethod
|
|
9
|
+
def choices(cls) -> List[str]:
|
|
10
|
+
return sorted(item.item_to_choice() for item in cls)
|
|
11
|
+
|
|
12
|
+
@classmethod
|
|
13
|
+
def all(cls) -> Set[TSettingsEnumBase]:
|
|
14
|
+
return {item for item in cls}
|
|
15
|
+
|
|
16
|
+
@classmethod
|
|
17
|
+
def parse_choices_list(self, choices: List[str]) -> List[TSettingsEnumBase]:
|
|
18
|
+
return self._parse_choices_into(choices, list)
|
|
19
|
+
|
|
20
|
+
@classmethod
|
|
21
|
+
def parse_choices_set(self, choices: List[str]) -> Set[TSettingsEnumBase]:
|
|
22
|
+
return self._parse_choices_into(choices, set)
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def _parse_choices_into(
|
|
26
|
+
cls, choices: str, container: Union[List, Set]
|
|
27
|
+
) -> List[TSettingsEnumBase]:
|
|
28
|
+
return container(cls.parse_choice(choice) for choice in choices)
|
|
29
|
+
|
|
30
|
+
@classmethod
|
|
31
|
+
def parse_choice(cls, choice: str) -> TSettingsEnumBase:
|
|
32
|
+
return cls[choice.replace("-", "_").upper()]
|
|
33
|
+
|
|
34
|
+
def item_to_choice(self) -> str:
|
|
35
|
+
return self.name.replace("_", "-").lower()
|
|
36
|
+
|
|
37
|
+
def __str__(self):
|
|
38
|
+
return self.item_to_choice()
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
from enum import Enum
|
|
3
|
-
from typing import List, Self, Set
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class ParseChoicesType(Enum):
|
|
7
|
-
SET = 0
|
|
8
|
-
LIST = 1
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class SettingsEnumBase(ABC):
|
|
12
|
-
parse_choices_type: ParseChoicesType = ParseChoicesType.SET
|
|
13
|
-
|
|
14
|
-
@classmethod
|
|
15
|
-
def choices(cls) -> List[str]:
|
|
16
|
-
return sorted(item.item_to_choice() for item in cls)
|
|
17
|
-
|
|
18
|
-
@classmethod
|
|
19
|
-
def all(cls) -> Set[Self]:
|
|
20
|
-
return {item for item in cls}
|
|
21
|
-
|
|
22
|
-
@classmethod
|
|
23
|
-
def parse_choices(cls, choices: str) -> List[Self]:
|
|
24
|
-
container = set if cls.parse_choices_type == ParseChoicesType.SET else list
|
|
25
|
-
return container(cls.parse_choice(choice) for choice in choices)
|
|
26
|
-
|
|
27
|
-
@classmethod
|
|
28
|
-
def parse_choice(cls, choice: str) -> Self:
|
|
29
|
-
return choice.replace("-", "_").upper()
|
|
30
|
-
|
|
31
|
-
def item_to_choice(self) -> str:
|
|
32
|
-
return self.name.replace("_", "-").lower()
|
|
33
|
-
|
|
34
|
-
def __str__(self):
|
|
35
|
-
return self.item_to_choice()
|
|
36
|
-
|
|
37
|
-
@abstractmethod
|
|
38
|
-
def __iter__(self):
|
|
39
|
-
...
|
|
40
|
-
|
|
41
|
-
@abstractmethod
|
|
42
|
-
def name(self) -> str:
|
|
43
|
-
...
|
|
44
|
-
|
|
45
|
-
@abstractmethod
|
|
46
|
-
def value(self) -> str:
|
|
47
|
-
...
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|