[elbe-devel] [PATCH 2/5] validate: add an option to validate urls
Manuel Traut
manut at linutronix.de
Wed Aug 23 17:08:22 CEST 2017
Signed-off-by: Manuel Traut <manut at linutronix.de>
---
elbepack/commands/validate.py | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/elbepack/commands/validate.py b/elbepack/commands/validate.py
index 58068d1f..f9ff4e86 100644
--- a/elbepack/commands/validate.py
+++ b/elbepack/commands/validate.py
@@ -17,25 +17,36 @@
# along with ELBE. If not, see <http://www.gnu.org/licenses/>.
import sys
+import os
from optparse import OptionParser
from elbepack.validate import validate_xml
-
+from elbepack.elbexml import ElbeXML, ValidationMode, ValidationError
def run_command( argv ):
oparser = OptionParser( usage="usage: %prog validate <xmlfile>")
- (opt,args) = oparser.parse_args(argv)
+ oparser.add_option ("--validate-urls", dest="validate_urls",
+ help="try to access specified repositories",
+ default=False, action="store_true")
+
+ (opt,args) = oparser.parse_args(sys.argv)
- if len(args) != 1:
- print "Wrong number of arguments"
+ if not os.path.exists(args[2]):
+ print ("%s - file not found" % args[2])
oparser.print_help()
sys.exit(20)
- validation = validate_xml (args[0])
- if len (validation) == 0:
- sys.exit (0)
- else:
+ validation = validate_xml (args[2])
+ if len (validation):
print "validation failed"
for i in validation:
print i
sys.exit(20)
+ if opt.validate_urls:
+ try:
+ xml = ElbeXML(args[2], url_validation=ValidationMode.CHECK_ALL)
+ except ValidationError as e:
+ print e
+ sys.exit(20)
+
+ sys.exit (0)
--
2.14.1
More information about the elbe-devel
mailing list