add Domain category
This commit is contained in:
parent
1f12b78ef3
commit
206398ab8d
@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "userconfig"
|
name = "userconfig"
|
||||||
version = "2.0-1"
|
version = "2.0-2"
|
||||||
authors = [ {name = "Marcus Stoegbauer", email = "marcus@grmpf.org"} ]
|
authors = [ {name = "Marcus Stoegbauer", email = "marcus@grmpf.org"} ]
|
||||||
maintainers = [ {name = "Marcus Stoegbauer", email = "marcus@grmpf.org"} ]
|
maintainers = [ {name = "Marcus Stoegbauer", email = "marcus@grmpf.org"} ]
|
||||||
description = "Generate config files for user home"
|
description = "Generate config files for user home"
|
||||||
|
@ -2,22 +2,33 @@ import platform
|
|||||||
|
|
||||||
|
|
||||||
def get_hostname():
|
def get_hostname():
|
||||||
hostname = platform.node()
|
node_name = platform.node()
|
||||||
if hostname.count("."):
|
if node_name.count("."):
|
||||||
hostname = hostname.split(".")[0]
|
return node_name.split(".")[0]
|
||||||
return hostname
|
else:
|
||||||
|
return node_name
|
||||||
|
|
||||||
|
|
||||||
def get_arch():
|
def get_arch():
|
||||||
return platform.system()
|
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):
|
def check_class(class_tuple):
|
||||||
(prio, category, value, path) = class_tuple
|
(prio, category, value, path) = class_tuple
|
||||||
if category == 'Arch':
|
if category == 'Arch':
|
||||||
return get_arch() == value
|
return get_arch() == value
|
||||||
elif category == 'Host':
|
elif category == 'Host':
|
||||||
return get_hostname() == value
|
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
|
elif value == '': # if value is empty, we cannot filter anything, so it matches always
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user