Complex matching

This commit is contained in:
Bottersnike 2022-02-04 15:12:14 +00:00
parent 0c5e00068d
commit d2d8cd6b6f
3 changed files with 11 additions and 4 deletions

View File

@ -16,3 +16,7 @@ class DecodeError(CheckFailed):
class EncodeError(CheckFailed):
pass
class InvalidModel(EAAPIException):
pass

View File

@ -1,7 +1,7 @@
import inspect
import re
from .exception import CheckFailed
from .exception import CheckFailed, InvalidModel
def assert_true(check, reason, exc=CheckFailed):
@ -20,8 +20,11 @@ def py_encoding(name):
def parse_model(model):
# e.g. KFC:J:A:A:2019020600
gamecode, dest, spec, rev, version = re.match(r"([A-Z0-9]{3}):([A-Z]):([A-Z]):([A-Z])(?::(\d{8}))?", model).groups()
return gamecode, dest, spec, rev, version
match = re.match(r"^([A-Z0-9]{3}):([A-Z]):([A-Z]):([A-Z])(?::(\d{10}))?$", model)
if match is None:
raise InvalidModel
gamecode, dest, spec, rev, datecode = match.groups()
return gamecode, dest, spec, rev, datecode
def pack(data, width):

@ -1 +1 @@
Subproject commit 4b0e64341fa7c7aa2db4b57b53283308997fede7
Subproject commit 9d190125536449fb01f963976ae6919c929e955d