def _get_systemd_services():
 contextkey = 'systemd.systemd_services'
 if (contextkey in __context__):
  return __context__[contextkey]
 ret = set()
 for path in (SYSTEM_CONFIG_PATHS + (LOCAL_CONFIG_PATH,)):
  if (os.access(path, os.R_OK) and (not os.path.islink(path))):
   for fullname in os.listdir(path):
    try:
     (unit_name, unit_type) = fullname.rsplit('.', 1)
    except ValueError:
     continue
    if (unit_type in VALID_UNIT_TYPES):
     ret.add((unit_name if (unit_type == 'service') else fullname))
 __context__[contextkey] = copy.deepcopy(ret)
 return ret

def _get_systemd_services ( ) : contextkey = 'systemd.systemd_services' if ( contextkey in __context__ ) : return __context__ [ contextkey ] ret = set ( ) for path in ( SYSTEM_CONFIG_PATHS + ( LOCAL_CONFIG_PATH , ) ) : if ( os . access ( path , os . R_OK ) and ( not os . path . islink ( path ) ) ) : for fullname in os . listdir ( path ) : try : ( unit_name , unit_type ) = fullname . rsplit ( '.' , 1 ) except ValueError : continue if ( unit_type in VALID_UNIT_TYPES ) : ret . add ( ( unit_name if ( unit_type == 'service' ) else fullname ) ) __context__ [ contextkey ] = copy . deepcopy ( ret ) return ret
use os .