Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

29
LINES

< > BotCompany Repo | #536 // Return reference tree (without bridge stuff & invalidated)

Lua code

1  
get("#175") -- tableToString
2  
get("#349") -- table functions
3  
4  
startID = input or error("Need snippet ID as input")
5  
6  
function printReferenceTree(id, indent, seen, result)
7  
  if seen[id] then
8  
    table.insert(result, indent..id.." (see above)")
9  
  else
10  
    title = getSnippetTitle(id)
11  
    if not (title:find("^Need bridge ") or title:find("^A bridge ") or title:find("^A master bridge ") or hasNTTitle("Invalidate "..id)) then
12  
      table.insert(result, indent..id.. " - "..title)
13  
      seen[id] = true
14  
      
15  
      local refs = getTitleReferences(id)
16  
      --print("Refs: "..tableToString(refs))
17  
      for r in all(refs) do
18  
        printReferenceTree(r, indent.."  ", seen, result)
19  
      end
20  
    end
21  
  end
22  
end
23  
24  
result = {}
25  
table.insert(result, "Shortened reference tree for "..startID.." (without bridge stuff & invalidated):\n")
26  
printReferenceTree(startID, "", {}, result)
27  
result = table.concat(result, "\n")
28  
print("\n"..result)
29  
return result

Author comment

Began life as a copy of #528

test run  test run with input  download  show line numbers   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #536
Snippet name: Return reference tree (without bridge stuff & invalidated)
Eternal ID of this version: #536/1
Text MD5: a119aa86b492b6f3d07846747225bf81
Author: stefan
Category:
Type: Lua code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-03-15 17:23:45
Source code size: 967 bytes / 29 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 705 / 158
Referenced in: [show references]