clog/utils/common.py
theonepath 5e922c5515
Added clog package modules
This commit is a continuation from commit [3746b773f4] which is a
separation of library modules into its own package from a larger
project.

Version control jump is significant in feature implementations due
simply to under-using commit control after minor feature
implementations. Project will receive better commit messages going
forward on changes to the package.
2022-05-03 14:51:57 +01:00

21 lines
591 B
Python

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"\"'"))
)