Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
xml-validation
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
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
vaclab
xml-validation
Commits
d3898e0b
Commit
d3898e0b
authored
5 years ago
by
Rolf Niepraschk
Browse files
Options
Downloads
Patches
Plain Diff
remove '/version_xsd', '/update', '/update_xsd'
parent
502149bf
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server.py
+1
-31
1 addition, 31 deletions
server.py
utils.py
+0
-19
0 additions, 19 deletions
utils.py
with
1 addition
and
50 deletions
server.py
+
1
−
31
View file @
d3898e0b
...
@@ -18,37 +18,7 @@ def version():
...
@@ -18,37 +18,7 @@ def version():
return
utils
.
xml_response
(
ret
)
return
utils
.
xml_response
(
ret
)
@app.route
(
'
/version_xsd
'
,
methods
=
[
'
GET
'
])
# TODO: unnecessary?
@app.route
(
'
/validate
'
,
methods
=
[
'
POST
'
])
def
version_xsd
():
app
.
logger
.
debug
(
'
hit version_xsd
'
)
xsd_str
=
utils
.
get_xsd
(
config
)
version_str
=
utils
.
get_xsd_version
(
xsd_str
)
return
utils
.
xml_response
(
utils
.
return_version
(
version_str
))
@app.route
(
'
/update
'
,
methods
=
[
'
POST
'
])
def
update
():
app
.
logger
.
debug
(
'
hit update
'
)
#req = request.get_json()
git_cmd
.
pull
()
app
.
logger
.
info
(
"
pulled {log}
"
.
format
(
log
=
git_cmd
.
log
(
"
-n 1
"
)))
ret
=
utils
.
return_ok
()
return
utils
.
xml_response
(
ret
)
@app.route
(
'
/update_xsd
'
,
methods
=
[
'
POST
'
])
# TODO: unnecessary / problematic?
def
update_xsd
():
app
.
logger
.
debug
(
'
hit update xsd
'
)
xsd_str
=
utils
.
get_xsd
(
config
)
xsd_xml
=
utils
.
parse
(
xsd_str
)
if
xsd_xml
:
ret
=
utils
.
save_xsd
(
config
,
xsd_str
,
xsd_file_name
)
else
:
ret
=
utils
.
return_error
(
error
=
'
error on atempt to parse xsd file from server
'
)
return
utils
.
xml_response
(
ret
)
@app.route
(
'
/validate
'
,
methods
=
[
'
POST
'
])
# TODO: '?v=2.2.0'
def
validate
():
def
validate
():
app
.
logger
.
debug
(
'
hit validate
'
)
app
.
logger
.
debug
(
'
hit validate
'
)
xv
=
request
.
args
.
get
(
'
v
'
)
xv
=
request
.
args
.
get
(
'
v
'
)
...
...
This diff is collapsed.
Click to expand it.
utils.py
+
0
−
19
View file @
d3898e0b
...
@@ -8,8 +8,6 @@ import sys
...
@@ -8,8 +8,6 @@ import sys
from
urllib.parse
import
urlparse
from
urllib.parse
import
urlparse
from
pprint
import
pprint
from
pprint
import
pprint
ns
=
{
"
w3
"
:
"
http://www.w3.org/2001/XMLSchema
"
}
# https://stackoverflow.com/questions/7160737/python-how-to-validate-a-url-in-python-malformed-or-not
# https://stackoverflow.com/questions/7160737/python-how-to-validate-a-url-in-python-malformed-or-not
def
uri_validator
(
x
):
def
uri_validator
(
x
):
try
:
try
:
...
@@ -58,13 +56,6 @@ def get_xsd(cfg, xsd_version=None, xml_str = None):
...
@@ -58,13 +56,6 @@ def get_xsd(cfg, xsd_version=None, xml_str = None):
return
xsd_str
return
xsd_str
def
save_xsd
(
config
,
xsd_str
,
file_name
):
path_file
=
get_xsd_path_file
(
config
,
file_name
)
file
=
open
(
path_file
,
"
w
"
)
file
.
write
(
xsd_str
)
return
return_ok
()
def
parse
(
xml_str
):
def
parse
(
xml_str
):
try
:
try
:
tree
=
ET
.
fromstring
(
xml_str
)
tree
=
ET
.
fromstring
(
xml_str
)
...
@@ -72,16 +63,6 @@ def parse(xml_str):
...
@@ -72,16 +63,6 @@ def parse(xml_str):
tree
=
None
tree
=
None
return
tree
return
tree
def
get_xsd_version
(
xsd_str
):
"""
The version is tag is a declaration and so
not part of the parse tree
"""
root
=
parse
(
xsd_str
)
if
root
.
tag
.
endswith
(
"
schema
"
):
return
root
.
attrib
.
get
(
"
version
"
,
""
)
else
:
return
""
def
validate
(
xml_str
,
xsd_str
):
def
validate
(
xml_str
,
xsd_str
):
try
:
try
:
tree
=
parse
(
xml_str
)
tree
=
parse
(
xml_str
)
...
...
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