mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
update schema
This commit is contained in:
@ -22,16 +22,15 @@ Schema:
|
|||||||
"private": boolean/null, # [0]
|
"private": boolean/null, # [0]
|
||||||
"unprivileged": boolean/null, # [0]
|
"unprivileged": boolean/null, # [0]
|
||||||
"chroot": boolean/null, # [0]
|
"chroot": boolean/null, # [0]
|
||||||
"wake_up_time": integer, # [1]
|
"wake_up_time": integer/null, # [0]
|
||||||
"no_wake_up_before_first_use": boolean/null, # [2]
|
"no_wake_up_before_first_use": boolean/null, # [1]
|
||||||
"process_limit": integer, # [1]
|
"process_limit": integer/null, # [0]
|
||||||
"command": string
|
"command": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
[0] '-' converted to null/None
|
[0] '-' converted to null/None
|
||||||
[1] '-' converted to -1
|
[1] null/None if `wake_up_time` is null/None
|
||||||
[2] null/None if `wake_up_time` is null/None
|
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
@ -71,36 +70,27 @@ def _process(proc_data: List[Dict]) -> List[Dict]:
|
|||||||
|
|
||||||
List of Dictionaries. Structured to conform to the schema.
|
List of Dictionaries. Structured to conform to the schema.
|
||||||
"""
|
"""
|
||||||
|
keys = ['private', 'unprivileged', 'chroot', 'wake_up_time', 'process_limit']
|
||||||
|
bools = ['private', 'unprivileged', 'chroot']
|
||||||
|
integers = ['wake_up_time', 'process_limit']
|
||||||
|
|
||||||
for item in proc_data:
|
for item in proc_data:
|
||||||
if item['private'] == '-':
|
|
||||||
item['private'] = None
|
|
||||||
else:
|
|
||||||
item['private'] = jc.utils.convert_to_bool(item['private'])
|
|
||||||
|
|
||||||
if item['unprivileged'] == '-':
|
|
||||||
item['unprivileged'] = None
|
|
||||||
else:
|
|
||||||
item['unprivileged'] = jc.utils.convert_to_bool(item['unprivileged'])
|
|
||||||
|
|
||||||
if item['chroot'] == '-':
|
|
||||||
item['chroot'] = None
|
|
||||||
else:
|
|
||||||
item['chroot'] = jc.utils.convert_to_bool(item['chroot'])
|
|
||||||
|
|
||||||
if item['wake_up_time'].endswith('?'):
|
if item['wake_up_time'].endswith('?'):
|
||||||
item['no_wake_up_before_first_use'] = True
|
item['no_wake_up_before_first_use'] = True
|
||||||
else:
|
else:
|
||||||
item['no_wake_up_before_first_use'] = False
|
item['no_wake_up_before_first_use'] = False
|
||||||
|
|
||||||
if item['wake_up_time'] == '-':
|
for key in keys:
|
||||||
item['wake_up_time'] = -1
|
if item[key] == '-':
|
||||||
else:
|
item[key] = None
|
||||||
item['wake_up_time'] = jc.utils.convert_to_int(item['wake_up_time'])
|
|
||||||
|
|
||||||
if item['process_limit'] == '-':
|
for key in bools:
|
||||||
item['process_limit'] = -1
|
if item[key] is not None:
|
||||||
else:
|
item[key] = jc.utils.convert_to_bool(item[key])
|
||||||
item['process_limit'] = jc.utils.convert_to_int(item['process_limit'])
|
|
||||||
|
for key in integers:
|
||||||
|
if item[key] is not None:
|
||||||
|
item[key] = jc.utils.convert_to_int(item[key])
|
||||||
|
|
||||||
return proc_data
|
return proc_data
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user