pyuserconfig/userconfig/checks.py

25 lines
568 B
Python

import platform
def get_hostname():
hostname = platform.node()
if hostname.count("."):
hostname = hostname.split(".")[0]
return hostname
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