import os import re class LogLevel: NORMAL = 0 PASS = 1 DEBUG = 2 WARN = 3 ERROR = 4 def isPathspec(path_spec: str) -> bool: __OS: str = os.name # define the path spec pattern depending on OS __REGEX_PAT = re.compile(r'^(.+)[\\]([^\\]+)\\*$') \ if __OS == "nt" else re.compile(r'^(.+)[\/]([^\/]+)$') ## perform a regex match to ensure that the given path is a ## valid pathspec for the system. return bool(re.match( __REGEX_PAT, path_spec.strip(r"\"'")) or \ re.match(r'^[\w\d\-_]+$', path_spec.strip(r"\"'")) )