So I’m trying to parse raw strings into a list (many actually) so let’s say I have:
|[nothing detected] www.neopets.com/
|status: (referer=http://www.google.com)saved 55189 bytes /fetch_d4cd213a56276ca726ddd437a1e75f1024ab7799
|file: fetch_d4cd213a56276ca726ddd437a1e75f1024ab7799: 55189 bytes
|file: decoding_367af53b4963986ecdeb9c09ce1a405b5b1ecd91: 68 bytes
|[nothing detected] (script) images.neopets.com/js/common.js?v=6
|status: (referer=http://www.google.com)saved 1523 bytes /fetch_8eeadcc08d4cb48c02dedf18648510b75190d1d7failure: [Errno 13] Permission denied: '/tmp/tmpsha1_8d7fb3ff1ef087c7ea2bf044dee294735a76ed4b.js'
|file: fetch_8eeadcc08d4cb48c02dedf18648510b75190d1d7: 1523 bytes
And it follows a similar pattern so on and so forth. Let’s assume the depth of tabs is at most 3. I’m trying to find a way to parse this into each sublist, so in this particular case it would be a list containing the first ‘nothing detected’ followed by a list containing status, file, file, and a list containing the next nothing detected along its status/file result. (I know my wording isn’t the best, sorry). Thanks!
So far, I’ve tried counting the ‘\t’ in each line, and iterating through the whole thing, but I’m pretty confused since I can’t go back in my iteration.
I think you want a data structure which can be traversed each way — i.e. a list which knows about the list that contains it — Here’s my attempt: