2021-08-24 18:45:25 +00:00
|
|
|
use re
|
|
|
|
use str
|
|
|
|
|
2021-12-11 21:09:02 +00:00
|
|
|
fn -value {|v|
|
2021-08-27 19:45:39 +00:00
|
|
|
var p = (re:find '^(\d+)\((\w+)\)$' $v)
|
2021-08-24 18:45:25 +00:00
|
|
|
if (and (has-key $p groups) (== (count $p[groups]) 3)) {
|
|
|
|
put [
|
|
|
|
&number=$p[groups][1][text]
|
|
|
|
&text=$p[groups][2][text]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-11 21:09:02 +00:00
|
|
|
fn -values {|v|
|
2021-08-27 19:45:39 +00:00
|
|
|
var vv = [ (str:split ',' $v) ]
|
2021-08-24 18:45:25 +00:00
|
|
|
if (== (count $vv) 1) {
|
|
|
|
-value $vv[0]
|
|
|
|
} else {
|
|
|
|
put [ (each $-value~ $vv) ]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-11 21:09:02 +00:00
|
|
|
fn -get-id {||
|
2021-08-27 19:45:39 +00:00
|
|
|
var id = [&]
|
2021-12-11 21:09:02 +00:00
|
|
|
str:split ' ' (id) | each {|e|
|
2021-08-27 19:45:39 +00:00
|
|
|
var p = [ (str:split '=' $e) ]
|
2021-08-24 18:45:25 +00:00
|
|
|
if (== (count $p) 2) {
|
2021-10-13 18:43:40 +00:00
|
|
|
set id[$p[0]] = (-values $p[1])
|
2021-08-24 18:45:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
put $id
|
|
|
|
}
|
|
|
|
|
2021-12-11 21:09:02 +00:00
|
|
|
fn -get {|k|
|
2021-08-27 19:45:39 +00:00
|
|
|
var id = (-get-id)
|
2021-08-24 18:45:25 +00:00
|
|
|
if (has-key $id $k) {
|
|
|
|
put $id[$k]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-11 21:09:02 +00:00
|
|
|
fn -is-root {||
|
2021-08-24 18:45:25 +00:00
|
|
|
== (-get uid)[number] 0
|
|
|
|
}
|
|
|
|
|
|
|
|
edit:add-var get-id~ $-get-id~
|
2021-12-11 21:09:02 +00:00
|
|
|
edit:add-var get-uid~ {|| -get uid }
|
|
|
|
edit:add-var get-gid~ {|| -get gid }
|
|
|
|
edit:add-var get-groups~ {|| -get groups; -get groupes }
|
2021-08-24 18:45:25 +00:00
|
|
|
edit:add-var is-root~ $-is-root~
|