Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
spec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
retribute.me
spec
Commits
4c8ba468
Verified
Commit
4c8ba468
authored
6 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Added CLI for validation
parent
908e8824
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
retribute_me/__init__.py
+0
-0
0 additions, 0 deletions
retribute_me/__init__.py
retribute_me/cli.py
+31
-0
31 additions, 0 deletions
retribute_me/cli.py
retribute_me/schemas.py
+13
-0
13 additions, 0 deletions
retribute_me/schemas.py
setup.cfg
+5
-0
5 additions, 0 deletions
setup.cfg
with
49 additions
and
0 deletions
retribute_me/__init__.py
0 → 100644
+
0
−
0
View file @
4c8ba468
This diff is collapsed.
Click to expand it.
retribute_me/cli.py
0 → 100644
+
31
−
0
View file @
4c8ba468
import
click
import
json
import
jsonschema
from
.
import
schemas
@click.group
()
def
cli
():
pass
@cli.command
()
@click.argument
(
"
document
"
,
type
=
click
.
File
(
"
r
"
))
@click.option
(
"
--version
"
,
"
-v
"
)
def
validate
(
document
,
version
):
content
=
document
.
read
()
payload
=
json
.
loads
(
content
)
if
not
version
:
try
:
version
=
payload
[
"
version
"
]
except
KeyError
:
version
=
schemas
.
latest_schema_version
schema
=
schemas
.
get
(
version
)
jsonschema
.
validate
(
instance
=
payload
,
schema
=
schema
)
click
.
echo
(
"
Schema is valid!
"
)
if
__name__
==
"
__main__
"
:
cli
()
This diff is collapsed.
Click to expand it.
retribute_me/schemas.py
0 → 100644
+
13
−
0
View file @
4c8ba468
import
json
import
os
SCHEMAS_DIR
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))),
"
schemas
"
)
latest_schema_version
=
"
0.1
"
def
get
(
version
):
with
open
(
os
.
path
.
join
(
SCHEMAS_DIR
,
version
,
"
schema.json
"
))
as
f
:
return
json
.
loads
(
f
.
read
())
This diff is collapsed.
Click to expand it.
setup.cfg
+
5
−
0
View file @
4c8ba468
...
@@ -20,6 +20,7 @@ include_package_data = True
...
@@ -20,6 +20,7 @@ include_package_data = True
packages
=
find:
packages
=
find:
install_requires
=
install_requires
=
jsonschema
jsonschema
click
[options.extras_require]
[options.extras_require]
...
@@ -27,6 +28,10 @@ dev =
...
@@ -27,6 +28,10 @@ dev =
ipdb
ipdb
pytest
pytest
[options.entry_points]
console_scripts
=
retribute-me
=
retribute_me.cli:cli
[options.packages.find]
[options.packages.find]
exclude
=
exclude
=
...
...
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