add Domain category

This commit is contained in:
Marcus Stoegbauer 2024-05-03 15:17:40 +02:00
parent 1f12b78ef3
commit 206398ab8d
2 changed files with 16 additions and 5 deletions

View File

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "userconfig"
version = "2.0-1"
version = "2.0-2"
authors = [ {name = "Marcus Stoegbauer", email = "marcus@grmpf.org"} ]
maintainers = [ {name = "Marcus Stoegbauer", email = "marcus@grmpf.org"} ]
description = "Generate config files for user home"

View File

@ -2,22 +2,33 @@ import platform
def get_hostname():
hostname = platform.node()
if hostname.count("."):
hostname = hostname.split(".")[0]
return hostname
node_name = platform.node()
if node_name.count("."):
return node_name.split(".")[0]
else:
return node_name
def get_arch():
return platform.system()
def get_domain():
node_name = platform.node()
if node_name.count("."):
return '.'.join(node_name.split('.')[1:])
else:
return ''
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 category == 'Domain':
return get_domain() == value
elif value == '': # if value is empty, we cannot filter anything, so it matches always
return True
else: