add Domain category
This commit is contained in:
parent
1f12b78ef3
commit
206398ab8d
@ -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"
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user