pyuserconfig/userconfig/checks.py

25 lines
568 B
Python
Raw Normal View History

import platform
2024-03-31 22:20:47 +02:00
def get_hostname():
hostname = platform.node()
if hostname.count("."):
hostname = hostname.split(".")[0]
return hostname
2024-03-31 22:20:47 +02:00
def get_arch():
return platform.system()
def check_class(class_tuple):
(prio, category, value, path) = class_tuple
if category == 'Arch':
return get_arch() == value
elif category == 'Host':
return get_hostname() == value
elif value == '': # if value is empty, we cannot filter anything, so it matches always
return True
else:
return False