+ def convert_mask(mask):
+ # convert mask from {aa,bb,xxx{yyy}} structure to aa,bbxxx/yyy
+ stack = []
+ result = []
+ word = ''
+ for ch in mask:
+ if ch == '{':
+ if word:
+ stack.append(word)
+ word = ''
+ elif ch == '}':
+ if word:
+ result.append('/'.join(stack + [word]))
+ word = ''
+ if stack:
+ stack.pop()
+ elif ch == ',':
+ if word:
+ result.append('/'.join(stack + [word]))
+ word = ''
+ else:
+ word += ch
+ if word:
+ result.append(word)
+ return ','.join(result)
+