Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
result=[]
ATTRIBUTES=[i.strip() for i in line.split('|') if i.strip()]
for item in ATTRIBUTES:
opts = {'args': [], 'kwargs': {}, 'name': ''}
# re search attributes like set(), upper, joinchar(',','-')
try:
itemDict = re.search(r'^(?P\S+?)\s?(\((?P.*)\))?$', item).groupdict()
except AttributeError as e:
log.critical("ttp.get_attributes failed to parse attributes for: '{}' with error: {};\nExiting...".format(item, e))
raise SystemExit()
opts['name'] = itemDict['name']
options = itemDict['options']
# create options list from options string using eval:
if options:
try:
args_kwargs = eval("_get_args_kwargs({})".format(options), _UndefSubst(globals()))
except:
exc_type, exc_value, exc_traceback = sys.exc_info()
traceback_error = "".join(traceback.format_exception(exc_type, exc_value, exc_traceback))
log.critical("""Failed to load arg/kwargs from line '{}' for options '{}', traceback:\n{}""".format(line, options, traceback_error))
raise SystemExit()
opts.update(args_kwargs)
result.append(opts)
return result