Changeset View
Changeset View
Standalone View
Standalone View
pykolab/utils.py
Show First 20 Lines • Show All 358 Lines • ▼ Show 20 Lines | elif type(_object) == dict: | ||||
except: | except: | ||||
return value | return value | ||||
for key in _object: | for key in _object: | ||||
if type(_object[key]) == list: | if type(_object[key]) == list: | ||||
if _object[key] is None: | if _object[key] is None: | ||||
continue | continue | ||||
# Dont run strip anything from attributes which | |||||
# hold byte strings | |||||
if key.lower() in constants.BINARY_ATTRS: | |||||
val = _object[key] | |||||
else: | |||||
val = map(_strip, _object[key]) | val = map(_strip, _object[key]) | ||||
if len(val) == 1: | if len(val) == 1: | ||||
result[key.lower()] = ''.join(val) | result[key.lower()] = ''.join(val) | ||||
else: | else: | ||||
result[key.lower()] = val | result[key.lower()] = val | ||||
else: | else: | ||||
if _object[key] is None: | if _object[key] is None: | ||||
▲ Show 20 Lines • Show All 220 Lines • ▼ Show 20 Lines | def is_service(services): | ||||
for service in services: | for service in services: | ||||
if os.path.isfile(os.path.join(constants.RC_DIR, service)): | if os.path.isfile(os.path.join(constants.RC_DIR, service)): | ||||
if _service == '': | if _service == '': | ||||
_service = service | _service = service | ||||
else: | else: | ||||
_other_services.append(service) | _other_services.append(service) | ||||
return (_service,_other_services) | return (_service,_other_services) | ||||
def find_template(file_name=None): | |||||
""" | |||||
Function to find template file. | |||||
""" | |||||
for template_location in constants.TEMPLATE_LOCATIONS: | |||||
if os.path.isfile('%s/%s' % (template_location, file_name)): | |||||
template_file = '%s/%s' % (template_location, file_name) | |||||
return template_file | |||||
import errno | |||||
raise IOError( | |||||
errno.ENOENT, os.strerror(errno.ENOENT), file_name) | |||||
log.error(_("Template %s not found.") % file_name) |