X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Futils.py;h=c7d966e7750cd19558bf9ffa8ab88603e1fd0fa5;hb=e72710b0ac189586e822a71a611f87fdce6a917d;hp=00f6f2d200947692cfe64da9636f928ef39d5329;hpb=05a8b7bc29197345f9718796c110d6cf3c2ad176;p=osm%2FRO.git diff --git a/osm_ro/utils.py b/osm_ro/utils.py index 00f6f2d2..c7d966e7 100644 --- a/osm_ro/utils.py +++ b/osm_ro/utils.py @@ -178,4 +178,21 @@ def check_valid_uuid(uuid): except js_e.ValidationError: return False return False - + + +def expand_brackets(text): + """ + Change a text with TEXT[ABC..] into a list with [TEXTA, TEXTB, TEXC, ... + if no bracket is used it just return the a list with the single text + It uses recursivity to allow several [] in the text + :param text: + :return: + """ + start = text.find("[") + end = text.find("]") + if start < 0 or end < 0: + return [text] + text_list = [] + for char in text[start+1:end]: + text_list += expand_brackets(text[:start] + char + text[end+1:]) + return text_list