2
This commit is contained in:
@ -16,10 +16,12 @@ You should have received a copy of the GNU General Public License along with
|
||||
this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import abc
|
||||
import dataclasses
|
||||
import re
|
||||
from typing import ClassVar, Optional
|
||||
from typing import ClassVar
|
||||
|
||||
__all__ = [
|
||||
"ArcaeaApkAsset",
|
||||
@ -35,27 +37,28 @@ class ArcaeaApkAsset(metaclass=abc.ABCMeta):
|
||||
zip_filename: str
|
||||
|
||||
@classmethod
|
||||
def _get_match(cls, string: str) -> Optional[re.Match]:
|
||||
def _get_match(cls, string: str) -> re.Match | None:
|
||||
return cls.PATTERN.match(string)
|
||||
|
||||
@classmethod
|
||||
@abc.abstractmethod
|
||||
def from_zip_filename(
|
||||
cls, asset_zip_filename: str
|
||||
) -> Optional["ArcaeaApkAsset"]: ...
|
||||
cls,
|
||||
asset_zip_filename: str,
|
||||
) -> ArcaeaApkAsset | None: ...
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class ArcaeaApkAssetJacket(ArcaeaApkAsset):
|
||||
PATTERN = re.compile(
|
||||
r"^assets/songs/(?P<raw_song_id>.*)/(1080_)?(?P<raw_rating_class>\d|base)(_(?P<lang>.*))?\.(jpg|png)"
|
||||
r"^assets/songs/(?P<raw_song_id>.*)/(1080_)?(?P<raw_rating_class>\d|base)(_(?P<lang>.*))?\.(jpg|png)",
|
||||
)
|
||||
song_id: str
|
||||
rating_class: Optional[str]
|
||||
lang: Optional[str]
|
||||
rating_class: str | None
|
||||
lang: str | None
|
||||
|
||||
@classmethod
|
||||
def from_zip_filename(cls, asset_zip_filename: str):
|
||||
def from_zip_filename(cls, asset_zip_filename: str) -> ArcaeaApkAssetJacket | None:
|
||||
match = cls._get_match(asset_zip_filename)
|
||||
if match is None:
|
||||
return None
|
||||
@ -78,7 +81,10 @@ class ArcaeaApkAssetPartnerIcon(ArcaeaApkAsset):
|
||||
char_id: str
|
||||
|
||||
@classmethod
|
||||
def from_zip_filename(cls, asset_zip_filename: str):
|
||||
def from_zip_filename(
|
||||
cls,
|
||||
asset_zip_filename: str,
|
||||
) -> ArcaeaApkAssetPartnerIcon | None:
|
||||
match = cls._get_match(asset_zip_filename)
|
||||
if match is None:
|
||||
return None
|
||||
@ -95,7 +101,7 @@ class ArcaeaApkAssetList(ArcaeaApkAsset):
|
||||
filename: str
|
||||
|
||||
@classmethod
|
||||
def from_zip_filename(cls, asset_zip_filename: str):
|
||||
def from_zip_filename(cls, asset_zip_filename: str) -> ArcaeaApkAssetList | None:
|
||||
match = cls._get_match(asset_zip_filename)
|
||||
if match is None:
|
||||
return None
|
||||
|
Reference in New Issue
Block a user