srecord VNStatData( S lastMonthTotal, S thisMonthTotal, S thisMonthEstimated, S yesterdayTotal, S todayTotal, S todayEstimated ) {} static VNStatData parse_vnstat(S output) { LS lines = lines(output); new VNStatData data; int i = indexOfContaining(lines, "monthly"); if (i >= 0) { i = indexOfContaining(lines, i, "---")+1; i = indexOfContaining(lines, i, "---")+1; LS lastMonth = splitAtVerticalBar(get(lines, i-3)); LS thisMonth = splitAtVerticalBar(get(lines, i-2)); LS estimated = splitAtVerticalBar(get(lines, i)); data.lastMonthTotal = get(lastMonth, 2); data.thisMonthTotal = get(thisMonth, 2); data.thisMonthEstimated = get(estimated, 2); } i = indexOfContaining(lines, "daily"); if (i >= 0) { i = indexOfContaining(lines, i, "---")+1; i = indexOfContaining(lines, i, "---")+1; LS yesterday = splitAtVerticalBar(get(lines, i-3)); LS today = splitAtVerticalBar(get(lines, i-2)); LS estimated = splitAtVerticalBar(get(lines, i)); data.yesterdayTotal = get(yesterday, 2); data.todayTotal = get(today, 2); data.todayEstimated = get(estimated, 2); } ret data; }
download show line numbers debug dex old transpilations
Travelled to 9 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, jozkyjcghlvl, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1020624 |
| Snippet name: | parse_vnstat |
| Eternal ID of this version: | #1020624/5 |
| Text MD5: | 58cd8346ca6523e6562a6061bdc244e9 |
| Author: | stefan |
| Category: | javax / gui |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-12-28 21:27:17 |
| Source code size: | 1199 bytes / 37 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 570 / 583 |
| Version history: | 4 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |