From 62dd881b97de1ec413402e008fe97e552beaf3bf Mon Sep 17 00:00:00 2001 From: Jan Scotka Date: Jul 10 2017 07:59:37 +0000 Subject: improved name handling replacing bad chanracters --- diff --git a/moduleframework/common.py b/moduleframework/common.py index de22390..a01fba0 100644 --- a/moduleframework/common.py +++ b/moduleframework/common.py @@ -200,3 +200,17 @@ def get_if_module(): """ rreps = os.environ.get('MTF_DISABLE_MODULE') return not bool(rreps) + + +def normalize_text(text, replacement="_"): + """ + Improve string, replace all bad characters with another one expecially with "_" + + :param text: string + :return: string + """ + out = text + badchars=["/", ";", "&", ">", "<", "|"] + for foo in badchars: + out = out.replace(foo, replacement) + return out \ No newline at end of file diff --git a/moduleframework/module_framework.py b/moduleframework/module_framework.py index f46eec3..98639c4 100755 --- a/moduleframework/module_framework.py +++ b/moduleframework/module_framework.py @@ -140,7 +140,7 @@ class CommonFunctions(object): """ try: self.config = get_config() - self.moduleName = self.config['name'] + self.moduleName = normalize_text(self.config['name']) self.source = self.config.get('source') if self.config.get( 'source') else self.config['module']['rpm'].get('source') except ValueError: