Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
V
validata-ui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
20
Issues
20
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Validata
validata-ui
Commits
796cb9a3
Commit
796cb9a3
authored
Oct 11, 2018
by
Christophe Benz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove cache dir for schemas
parent
f75914a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
16 deletions
+3
-16
validata_ui/__init__.py
validata_ui/__init__.py
+1
-1
validata_ui/validate_helper.py
validata_ui/validate_helper.py
+2
-15
No files found.
validata_ui/__init__.py
View file @
796cb9a3
...
...
@@ -104,7 +104,7 @@ schemas_config = {
]
},
}
ValidatorHelper
.
init
(
schemas_config
,
Path
(
'/tmp'
)
)
ValidatorHelper
.
init
(
schemas_config
)
# Flask things
app
=
Flask
(
__name__
)
...
...
validata_ui/validate_helper.py
View file @
796cb9a3
...
...
@@ -20,10 +20,9 @@ class ValidatorHelper:
schema_dict
=
{}
@
classmethod
def
init
(
cls
,
schema_info
,
cache_dir
:
Path
):
def
init
(
cls
,
schema_info
):
""" Register and download schema and custom_checks info """
cls
.
schema_dict
=
{}
cls
.
cache_dir
=
cache_dir
for
code
in
schema_info
:
print
(
'Downloading schema {}'
.
format
(
code
))
schema
=
schema_info
[
code
].
copy
()
...
...
@@ -41,19 +40,7 @@ class ValidatorHelper:
@
classmethod
def
json_download
(
cls
,
url
,
filename
):
""" Download url content as JSON """
if
cls
.
cache_dir
is
None
:
return
requests
.
get
(
url
).
json
()
cache_file
=
cls
.
cache_dir
/
filename
if
cache_file
.
exists
():
with
cache_file
.
open
(
'rt'
,
encoding
=
'utf-8'
)
as
fd
:
return
json
.
load
(
fd
)
else
:
data
=
requests
.
get
(
url
).
json
()
with
cache_file
.
open
(
"wt"
,
encoding
=
'utf-8'
)
as
fd
:
json
.
dump
(
data
,
fd
,
ensure_ascii
=
False
,
sort_keys
=
True
,
indent
=
2
)
return
data
return
requests
.
get
(
url
).
json
()
@
classmethod
def
schema_exist
(
cls
,
schema_code
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment