From 206398ab8dbe68cbc1cce71595c8f5d7e7069dac Mon Sep 17 00:00:00 2001 From: Marcus Stoegbauer Date: Fri, 3 May 2024 15:17:40 +0200 Subject: [PATCH] add Domain category --- pyproject.toml | 2 +- userconfig/checks.py | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f25f73e..96aef0d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/userconfig/checks.py b/userconfig/checks.py index d0d7941..3c2d667 100644 --- a/userconfig/checks.py +++ b/userconfig/checks.py @@ -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: