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

22
LINES

< > BotCompany Repo | #522 // tryCopyFromParents

Lua code

function tryCopyFromParents(newLines, annotations)
  local pat = "^ *([^ ]+) +(%d+) +(%d+)"
  pid2ann = {}
  for i=1, #newLines do
    if annotations[i] ~= nil and annotations[i] ~= '' then
      local _, _, user, pid, ppid = newLines[i]:find(pat)
      if pid then
        pid2ann[pid] = annotations[i]
        --print("pid2ann", pid, annotations[i])
      end
    end
  end

  for i=1, #newLines do
    if annotations[i] == nil or annotations[i] == '' then
      local _, _, user, pid, ppid = newLines[i]:find(pat)
      if ppid then
        annotations[i] = pid2ann[ppid]
      end
    end
  end
end

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: #522
Snippet name: tryCopyFromParents
Eternal ID of this version: #522/1
Text MD5: 6b270f7213600579904bbe234652b21a
Author: stefan
Category:
Type: Lua code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-03-11 18:51:55
Source code size: 623 bytes / 22 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 671 / 160
Referenced in: [show references]