implement unrestraint for tiramisu-cmdline-parser
This commit is contained in:
parent
039e2e6b7b
commit
70389d70cd
|
@ -1,5 +1,5 @@
|
|||
from .api import Config
|
||||
|
||||
__version__ = "0.2"
|
||||
__version__ = "0.4"
|
||||
__all__ = ('Config',)
|
||||
|
||||
|
|
|
@ -644,6 +644,7 @@ class Config:
|
|||
# config
|
||||
def __init__(self,
|
||||
dico):
|
||||
self._unrestraint = False
|
||||
if DEBUG:
|
||||
from pprint import pprint
|
||||
pprint(dico)
|
||||
|
@ -668,6 +669,7 @@ class Config:
|
|||
self.root = first_path.rsplit('.', 1)[0]
|
||||
else:
|
||||
self.root = ''
|
||||
self.dico = dico
|
||||
|
||||
def __getattr__(self,
|
||||
subfunc: str) -> Any:
|
||||
|
@ -682,6 +684,11 @@ class Config:
|
|||
if subfunc == 'owner':
|
||||
return ContextOwner(self,
|
||||
self.schema)
|
||||
if subfunc == 'unrestraint':
|
||||
ret = Config(self.dico)
|
||||
ret._unrestraint = True
|
||||
ret.temp = self.temp
|
||||
return ret
|
||||
raise APIError(_('please specify a valid sub function ({})').format(subfunc))
|
||||
|
||||
def add_value(self,
|
||||
|
@ -847,6 +854,8 @@ class Config:
|
|||
path: str,
|
||||
index: Optional[int],
|
||||
permissive: bool=False) -> bool:
|
||||
if self._unrestraint:
|
||||
return False
|
||||
if permissive:
|
||||
property_ = 'hidden'
|
||||
needs = True
|
||||
|
|
Loading…
Reference in New Issue