-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,33 @@ | ||
import fnmatch | ||
from typing import List | ||
|
||
from .. import utils | ||
|
||
|
||
# Represents the list of available tags. | ||
class Tags(utils.StrEnum): | ||
@utils.classproperty | ||
def All(cls) -> List[str]: | ||
all = [] | ||
|
||
for tag in dir(cls): | ||
if tag in ["All", "ALL"]: | ||
continue | ||
|
||
tag = getattr(cls, tag) | ||
if isinstance(tag, Tags): | ||
all.append(tag) | ||
|
||
return all | ||
|
||
@utils.classproperty | ||
def ALL(cls): | ||
""" | ||
Deprecated. Use As(<glob>) with unpacking. | ||
Example: tags=[*Tags.As("*")] | ||
""" | ||
return "*" | ||
|
||
@classmethod | ||
def As(cls, tag: str) -> List[str]: | ||
return [tag_ for tag_ in cls.All if fnmatch.filter([tag_], tag)] |