Commit 2d272b44 authored by Devaev Maxim's avatar Devaev Maxim

Replace over re.sub

parent c89e1a49
......@@ -167,7 +167,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
local_groups_shared = shared.Functions.shared(LOCAL_GROUPS_SHARED_NAME)
group_count = 0
for group_name in self.localGroups() :
dbus_group_name = group_name.replace("-", "_")
dbus_group_name = re.sub(r"[^\w\d_]", "_", group_name)
local_groups_shared.addSharedObject(dbus_group_name, LocalGroup(group_name,
tools.dbus.joinPath(SERVICE_NAME, dbus_group_name), self))
group_count += 1
......@@ -211,7 +211,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
return
group_names_list = self.localGroups()
dbus_group_names_list = [ item.replace("-", "_") for item in group_names_list ]
dbus_group_names_list = [ re.sub(r"[^\w\d_]", "_", item) for item in group_names_list ]
local_groups_shared = shared.Functions.shared(LOCAL_GROUPS_SHARED_NAME)
......
......@@ -228,7 +228,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
local_users_shared = shared.Functions.shared(LOCAL_USERS_SHARED_NAME)
user_count = 0
for user_name in self.localUsers() :
dbus_user_name = user_name.replace("-", "_")
dbus_user_name = re.sub(r"[^\w\d_]", "_", user_name)
local_users_shared.addSharedObject(dbus_user_name, LocalUser(user_name,
tools.dbus.joinPath(SERVICE_NAME, dbus_user_name), self))
user_count += 1
......@@ -272,7 +272,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
return
user_names_list = self.localUsers()
dbus_user_names_list = [ item.replace("-", "_") for item in user_names_list ]
dbus_user_names_list = [ re.sub(r"[^\w\d_]", "_", item) for item in user_names_list ]
local_users_shared = shared.Functions.shared(LOCAL_USERS_SHARED_NAME)
......
......@@ -220,7 +220,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
nss_roles_shared = shared.Functions.shared(NSS_ROLES_SHARED_NAME)
role_count = 0
for role_name in self.nssRoles() :
dbus_role_name = role_name.replace("-", "_")
dbus_role_name = re.sub(r"[^\w\d_]", "_", role_name)
nss_roles_shared.addSharedObject(dbus_role_name, NssRole(role_name,
tools.dbus.joinPath(SERVICE_NAME, dbus_role_name), self))
role_count += 1
......@@ -261,7 +261,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
return
role_names_list = self.nssRoles()
dbus_role_names_list = [ item.replace("-", "_") for item in role_names_list ]
dbus_role_names_list = [ re.sub(r"[^\w\d_]", "_", item) for item in role_names_list ]
nss_roles_shared = shared.Functions.shared(NSS_ROLES_SHARED_NAME)
......
......@@ -159,7 +159,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
for system_service_name in os.listdir(initd_dir_path) :
st_mode = os.stat(os.path.join(initd_dir_path, system_service_name)).st_mode
if st_mode & stat.S_IEXEC and st_mode & stat.S_IFREG :
dbus_system_service_name = re.sub(r"-|\.", "_", system_service_name)
dbus_system_service_name = re.sub(r"[^\w\d_]", "_", system_service_name)
system_services_shared.addSharedObject(dbus_system_service_name, SystemService(system_service_name,
tools.dbus.joinPath(SERVICE_NAME, dbus_system_service_name), self))
......@@ -199,7 +199,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
if event.dir :
return
dbus_system_service_name = re.sub(r"-|\.", "_", event.name)
dbus_system_service_name = re.sub(r"[^\w\d_]", "_", event.name)
system_services_shared = shared.Functions.shared(SERVICE_NAME)
if event.maskname == "IN_CREATE" :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment