1
0
mirror of https://github.com/Ahp06/SUMO_Emissions.git synced 2024-11-22 03:26:30 +00:00

Added command constraints

This commit is contained in:
Ahp06 2019-01-23 17:01:42 +01:00
parent 4128060396
commit 54e9f0d422

View File

@ -194,10 +194,10 @@ def add_options(parser):
# Faire que -c soit requis si -run # Faire que -c soit requis si -run
parser.add_argument("-new_dump", "--new_dump", type=str, parser.add_argument("-new_dump", "--new_dump", type=str,
required=False, help='Load and create a new data dump with the configuration file chosen') help='Load and create a new data dump with the configuration file chosen')
parser.add_argument("-areas", "--areas", type=int, required=False, parser.add_argument("-areas", "--areas", type=int,
help='Will create a grid with "areas x areas" areas') help='Will create a grid with "areas x areas" areas')
parser.add_argument("-simulation_dir", "--simulation_dir", type=str, required=False, parser.add_argument("-simulation_dir", "--simulation_dir", type=str,
help='Choose the simulation directory') help='Choose the simulation directory')
parser.add_argument("-run", "--run", type=str, parser.add_argument("-run", "--run", type=str,
@ -211,6 +211,22 @@ def add_options(parser):
parser.add_argument("-csv", "--csv", action="store_true", parser.add_argument("-csv", "--csv", action="store_true",
help="Export all data emissions into a CSV file") help="Export all data emissions into a CSV file")
def check_user_entry(args):
"""
Check the user entry consistency
"""
if (args.new_dump is not None):
if(args.areas is None or args.simulation_dir is None):
print('The -new_dump argument requires the -areas and -simulation_dir options')
return False
if (args.run is not None):
if(args.c is None and args.c_dir is None):
print('The -run argument requires the -c or -c_dir')
return False
return True
def main(args): def main(args):
""" """
The entry point of the application The entry point of the application
@ -221,6 +237,8 @@ def main(args):
add_options(parser) add_options(parser)
args = parser.parse_args(args) args = parser.parse_args(args)
if(check_user_entry(args)):
if args.new_dump is not None: if args.new_dump is not None:
if (args.simulation_dir is not None) and (args.areas is not None): if (args.simulation_dir is not None) and (args.areas is not None):
create_dump(args.new_dump, args.simulation_dir, args.areas) create_dump(args.new_dump, args.simulation_dir, args.areas)