I have a list of 'directory-tree-like' strings. I want to convert it into a nested list (or another kind of data structure), to emphasize the dependencies. for example, the input:
hierarchy_list
dir1
dir1/dir1.1
dir1/dir1.2
dir1/dir1.3/dir1.3.1/dir1.3.1.1
dir1/dir1.1/dir1.1.1
dir1/dir1.1/dir1.1.2
need to be converted to:
dir1 ->
dir1.1 -> dir1.1.1 , dir1.1.2
dir1.2
dir1.3 -> dir1.3.1 , dir1.3.2
where the '->' symbolize 'contains' (in a form of array attribute or equivalent).
dir1 contains list of dir1.1 , 1.2 , 1.3
dir1.1 contains list of dir1.1.1 , dir1.1.2
and so on...
Does someone have an idea how to do it in Python (algorithm and implementation)?