1 2 3 4 5 6 7 8 9 10
# -*- coding: utf-8 -*- def parse_opts(dic, opts): for opt in re.split(r'\s*,\s*', opts): x = re.split(r'\s*=\s*', opt) if len(x) == 2 and x[0] and x[1]: dic[x[0]] = x[1] elif len(x) == 1 and x[0]: dic[x[0]] = True return dic