We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
oneof_schema in my case is for future use, to add new compression program, but now its only for 7zip. One of compression program must be set Code:
YAML_SCHEMA={ 'compression':{ 'type':'dict', 'required':True, 'oneof_schema':[ { '7z':{ 'type':'dict', 'required':True, 'schema':{ 'cmd_path':{'type':'string', 'required':True}, 'passwd':{'type':'string'}, 'compress_level':{'type': 'string', 'default':5, 'coerce': int}, 'attr':{ 'type':'list', 'contains':'y', # must cotain don't ask else will be hang 'default':['mmt', # enable multithreading 'ms', # solid archive (without appending files in feature) 'y', # don't ask, auto yes 'mhe=on',# hide file name in archive ]}, 'exlude_attr':{ 'type':'list', 'default':['r!$RECYCLE.BIN', # windows recycle.bin '!System*Volume*Information', # some other fat garbage 'r!*.mdf', # except database file from mssql 'r!*.ldf', # except log file from mssql '!.__sync__*' # except sync file from owncloud ] } } }, },] } } import yaml from cerberus import Validator v = Validator(YAML_SCHEMA) doc={'compression':{ '7z':{ 'cmd_path':'somewhere' }}} print(yaml.dump(v.normalized(doc), Dumper=yaml.Dumper))
Give me out:
compression: 7z: cmd_path: somewhere
When I change schema to:
YAML_SCHEMA={ 'compression':{ 'type':'dict', 'required':True, 'schema':{ '7z':{ 'type':'dict', 'required':True, 'schema':{ 'cmd_path':{'type':'string', 'required':True}, 'passwd':{'type':'string'}, 'compress_level':{'type': 'string', 'default':5, 'coerce': int}, 'attr':{ 'type':'list', 'contains':'y', # must cotain don't ask else will be hang 'default':['mmt', # enable multithreading 'ms', # solid archive (without appending files in feature) 'y', # don't ask, auto yes 'mhe=on',# hide file name in archive ]}, 'exlude_attr':{ 'type':'list', 'default':['r!$RECYCLE.BIN', # windows recycle.bin '!System*Volume*Information', # some other fat garbage 'r!*.mdf', # except database file from mssql 'r!*.ldf', # except log file from mssql '!.__sync__*' # except sync file from owncloud ] } } }, } } }
Output is correct:
compression: 7z: attr: - mmt - ms - y - mhe=on cmd_path: somewhere compress_level: 5 exlude_attr: - r!$RECYCLE.BIN - '!System*Volume*Information' - r!*.mdf - r!*.ldf - '!.__sync__*'
The text was updated successfully, but these errors were encountered:
No branches or pull requests
oneof_schema in my case is for future use, to add new compression program, but now its only for 7zip. One of compression program must be set
Code:
Give me out:
When I change schema to:
Output is correct:
The text was updated successfully, but these errors were encountered: