Mercurial > hg > webaudioevaluationtool
diff scripts/comment_parser.py @ 1066:a2a245542ae6
Scripts: test if folder name (default or provided via command line) exists
author | Brecht De Man <BrechtDeMan@users.noreply.github.com> |
---|---|
date | Tue, 11 Aug 2015 10:15:17 +0200 |
parents | 99cb3436759e |
children | 2ea78697aadf |
line wrap: on
line diff
--- a/scripts/comment_parser.py Mon Aug 10 18:45:45 2015 +0200 +++ b/scripts/comment_parser.py Tue Aug 11 10:15:17 2015 +0200 @@ -5,8 +5,31 @@ import os import csv -# XML results files location (modify as needed): -folder_name = "../saves" # Looks in 'saves/' folder from 'scripts/' folder + +# COMMAND LINE ARGUMENTS + +assert len(sys.argv)<3, "comment_parser takes at most 1 command line argument\n"+\ + "Use: python score_parser.py [rating_folder_location]" + +# XML results files location +if len(sys.argv) == 1: + folder_name = "../saves" # Looks in 'saves/' folder from 'scripts/' folder + print "Use: python comment_parser.py [XML_files_location]" + print "Using default path: " + folder_name +elif len(sys.argv) == 2: + folder_name = sys.argv[1] # First command line argument is folder + +# check if folder_name exists +if not os.path.exists(folder_name): + #the file is not there + print "Folder '"+folder_name+"' does not exist." + sys.exit() # terminate script execution +elif not os.access(os.path.dirname(folder_name), os.W_OK): + #the file does exist but write privileges are not given + print "No write privileges in folder '"+folder_name+"'." + + +# CODE # get every XML file in folder for file in os.listdir(folder_name):