Commit 703b60e2 authored by Devaev Maxim's avatar Devaev Maxim

Refactoring, using re.sub() instead str.replace()

parent 52a876f9
...@@ -14,7 +14,6 @@ from settingsd import logger ...@@ -14,7 +14,6 @@ from settingsd import logger
##### Private constants ##### ##### Private constants #####
SERVICE_NAME = "services" SERVICE_NAME = "services"
SHARED_SERVICE_NAME = "Services"
RUNLEVELS = "0123456" RUNLEVELS = "0123456"
...@@ -157,15 +156,15 @@ class Service(service.Service) : ...@@ -157,15 +156,15 @@ class Service(service.Service) :
raise SubprocessFailure("Error while execute \"%s\"\nStdout: %s\nStderr: %s" % (proc_args, proc_stdout, proc_stderr)) raise SubprocessFailure("Error while execute \"%s\"\nStdout: %s\nStderr: %s" % (proc_args, proc_stdout, proc_stderr))
system_service_count = 0 system_service_count = 0
shared.Functions.addShared(SHARED_SERVICE_NAME) shared.Functions.addShared(SERVICE_NAME)
for system_service_record in proc_stdout.split("\n") : for system_service_record in proc_stdout.split("\n") :
system_service_record_list = re.split(r"\s+", system_service_record) system_service_record_list = re.split(r"\s+", system_service_record)
if len(system_service_record_list) != len(RUNLEVELS) + 1 : if len(system_service_record_list) != len(RUNLEVELS) + 1 :
continue continue
system_service_name = system_service_record_list[0] system_service_name = system_service_record_list[0]
dbus_system_service_name = system_service_name.replace("-", "_").replace(".", "_") dbus_system_service_name = re.sub(r"-|\.", "_", system_service_name)
shared.Functions.shared(SHARED_SERVICE_NAME).addSharedObject(dbus_system_service_name, SystemService(system_service_name, shared.Functions.shared(SERVICE_NAME).addSharedObject(dbus_system_service_name, SystemService(system_service_name,
dbus_tools.joinPath(SERVICE_NAME, dbus_system_service_name), self)) dbus_tools.joinPath(SERVICE_NAME, dbus_system_service_name), self))
system_service_count += 1 system_service_count += 1
......
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