extended msd api for future otg

This commit is contained in:
Devaev Maxim
2019-09-25 03:15:20 +03:00
parent 5d437c58e3
commit 5c4e8f7962
7 changed files with 118 additions and 44 deletions

View File

@@ -20,10 +20,13 @@
# ========================================================================== #
import re
from typing import Any
from .. import keymap
from . import check_not_none_string
from . import check_string_in_list
from .basic import valid_number
@@ -38,6 +41,18 @@ def valid_atx_button(arg: Any) -> str:
return check_string_in_list(arg, "ATX button", ["power", "power_long", "reset"])
def valid_msd_image_name(arg: Any) -> str:
if len(str(arg).strip()) == 0:
arg = None
arg = check_not_none_string(arg, "MSD image name", strip=True)
arg = re.sub(r"[^\w\.+@()\[\]-]", "_", arg)
if arg == ".":
arg = "_"
if arg == "..":
arg = "__"
return arg[:255]
def valid_log_seek(arg: Any) -> int:
return int(valid_number(arg, min=0, name="log seek"))