mirror of
https://github.com/yavook/kiwi-scp.git
synced 2024-11-24 13:43:01 +00:00
DOC
This commit is contained in:
parent
b568e449f5
commit
fdedf20ba3
1 changed files with 11 additions and 1 deletions
|
@ -62,6 +62,8 @@ class _Project(BaseModel):
|
||||||
@validator("override_storage", pre=True)
|
@validator("override_storage", pre=True)
|
||||||
@classmethod
|
@classmethod
|
||||||
def unify_storage(cls, value):
|
def unify_storage(cls, value):
|
||||||
|
"""parse different storage notations"""
|
||||||
|
|
||||||
if value is None or isinstance(value, dict):
|
if value is None or isinstance(value, dict):
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
@ -300,18 +302,23 @@ class Config(BaseModel):
|
||||||
"""parse different storage notations"""
|
"""parse different storage notations"""
|
||||||
|
|
||||||
if value is None:
|
if value is None:
|
||||||
|
# empty storage
|
||||||
raise ValueError("No Storage Given")
|
raise ValueError("No Storage Given")
|
||||||
|
|
||||||
elif isinstance(value, dict):
|
elif isinstance(value, dict):
|
||||||
|
# native dict format
|
||||||
return value
|
return value
|
||||||
|
|
||||||
elif isinstance(value, str):
|
elif isinstance(value, str):
|
||||||
|
# just the directory string
|
||||||
return {"directory": value}
|
return {"directory": value}
|
||||||
|
|
||||||
elif isinstance(value, list) and len(value) == 1:
|
elif isinstance(value, list) and len(value) == 1 and isinstance(value[0], str):
|
||||||
|
# directory string as a single-item list
|
||||||
return {"directory": value[0]}
|
return {"directory": value[0]}
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
# undefined format
|
||||||
raise ValueError("Invalid Storage Format")
|
raise ValueError("Invalid Storage Format")
|
||||||
|
|
||||||
@validator("network", pre=True)
|
@validator("network", pre=True)
|
||||||
|
@ -320,11 +327,14 @@ class Config(BaseModel):
|
||||||
"""parse different network notations"""
|
"""parse different network notations"""
|
||||||
|
|
||||||
if value is None:
|
if value is None:
|
||||||
|
# empty network
|
||||||
raise ValueError("No Network Given")
|
raise ValueError("No Network Given")
|
||||||
|
|
||||||
elif isinstance(value, dict):
|
elif isinstance(value, dict):
|
||||||
|
# native dict format
|
||||||
return value
|
return value
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
# undefined format
|
||||||
raise ValueError("Invalid Network Format")
|
raise ValueError("Invalid Network Format")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue