Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
1fdebbdf
Commit
1fdebbdf
authored
5 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
line length
parent
3a9b0c87
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
satella/configuration/schema/descriptors.py
+14
-9
14 additions, 9 deletions
satella/configuration/schema/descriptors.py
with
14 additions
and
9 deletions
satella/configuration/schema/descriptors.py
+
14
−
9
View file @
1fdebbdf
...
...
@@ -103,7 +103,8 @@ def _make_boolean(v: tp.Any) -> bool:
elif
v
.
upper
()
==
'
FALSE
'
:
return
False
else
:
raise
ConfigurationValidationError
(
'
Unknown value of
"
%s
"
posing to be a bool
'
%
(
v
,))
raise
ConfigurationValidationError
(
'
Unknown value of
"
%s
"
posing to be a bool
'
%
(
v
,))
else
:
return
bool
(
v
)
...
...
@@ -138,10 +139,11 @@ class String(Descriptor):
class
Regexp
(
String
):
"""
Base class for declaring regexp-based descriptors. Overload it
'
s attribute REGEXP. Use as following:
Base class for declaring regexp-based descriptors. Overload it
'
s attribute REGEXP. Use as
following:
class IPv6(Regexp):
REGEXP =
'
(\A([0-9a-f]{1,4}:)
'
...
>>>
class
IPv6
(
Regexp
):
>>>
REGEXP
=
'
(\A([0-9a-f]{1,4}:)
'
...
"""
REGEXP
=
r
'
.*
'
...
...
@@ -155,7 +157,8 @@ class Regexp(String):
match
=
self
.
REGEXP
.
match
(
value
)
if
not
match
:
raise
ConfigurationValidationError
(
'
value does not match %s
'
%
(
self
.
REGEXP
.
pattern
,),
value
)
raise
ConfigurationValidationError
(
'
value does not match %s
'
%
(
self
.
REGEXP
.
pattern
,),
value
)
return
match
.
group
(
0
)
...
...
@@ -230,7 +233,8 @@ class Dict(Descriptor):
value
=
super
().
__call__
(
value
)
if
not
isinstance
(
value
,
dict
):
raise
ConfigurationValidationError
(
'
value received from descriptor was not a dict: %s
'
%
(
value
,))
raise
ConfigurationValidationError
(
'
value received from descriptor was not a dict: %s
'
%
(
value
,))
output
=
{}
...
...
@@ -273,8 +277,8 @@ class Union(Descriptor):
raise
ConfigurationValidationError
(
'
Could not match value %s to a descriptor
'
%
(
value
,))
BASE_LOOKUP_TABLE
=
{
'
int
'
:
Integer
,
'
float
'
:
Float
,
'
str
'
:
String
,
'
ipv4
'
:
IPv4
,
'
list
'
:
List
,
'
dict
'
:
Dict
,
'
any
'
:
Descriptor
,
'
bool
'
:
Boolean
,
'
union
'
:
Union
}
BASE_LOOKUP_TABLE
=
{
'
int
'
:
Integer
,
'
float
'
:
Float
,
'
str
'
:
String
,
'
ipv4
'
:
IPv4
,
'
list
'
:
List
,
'
dict
'
:
Dict
,
'
any
'
:
Descriptor
,
'
bool
'
:
Boolean
,
'
union
'
:
Union
}
def
_get_descriptor_for
(
key
:
str
,
value
:
tp
.
Any
)
->
Descriptor
:
...
...
@@ -309,7 +313,8 @@ def _get_descriptor_for(key: str, value: tp.Any) -> Descriptor:
def
register_custom_descriptor
(
name
:
str
):
"""
A decorator used for registering custom descriptors in order to be loadable via descriptor_from_dict
A decorator used for registering custom descriptors in order to be loadable via
descriptor_from_dict
Use like:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment