Check the command line parameters @param args: command line parameters @type args: string[] @param params: parameter storage class @type params: Parameters @return: if the parameters are valid : True, if not : False @rtype: boolean
(args, params)
| 250 | return ret |
| 251 | |
| 252 | def check_args(args, params): |
| 253 | ''' |
| 254 | Check the command line parameters |
| 255 | |
| 256 | @param args: command line parameters |
| 257 | @type args: string[] |
| 258 | |
| 259 | @param params: parameter storage class |
| 260 | @type params: Parameters |
| 261 | |
| 262 | @return: if the parameters are valid : True, if not : False |
| 263 | @rtype: boolean |
| 264 | ''' |
| 265 | |
| 266 | # Retrieve the parameters |
| 267 | parser_description = "json2cpp" |
| 268 | parser = argparse.ArgumentParser(description=parser_description) |
| 269 | parser.add_argument('-i', nargs=1, metavar='input_dir', required=True, |
| 270 | help='[string] Input directory') |
| 271 | parser.add_argument('-o', nargs=1, metavar='output_dir', required=True, |
| 272 | help='[string] Output directory (must exists)') |
| 273 | parser.add_argument('-t', nargs=1, metavar='templates_dir', required=False, |
| 274 | help='[string] Code templates directory') |
| 275 | parser.add_argument('-v', nargs=1, metavar='ocpp_version', required=True, |
| 276 | help='[string] OCPP version (ocpp20 or ocpp21)') |
| 277 | |
| 278 | # Display the software inline help |
| 279 | if (("-h" in args) or ("--help" in args)): |
| 280 | parser.print_help() |
| 281 | return False |
| 282 | |
| 283 | # Parse the parameters |
| 284 | args = parser.parse_args() |
| 285 | params.input_dir = args.i[0] |
| 286 | params.output_dir = args.o[0] |
| 287 | params.ocpp_version = args.v[0] |
| 288 | if args.t: |
| 289 | params.templates_dir = args.t[0] |
| 290 | else: |
| 291 | params.templates_dir = os.path.join(os.curdir, "templates") |
| 292 | |
| 293 | # Checks params |
| 294 | return check_dir_exists("Input directory", params.input_dir) and check_dir_exists("Output directory", params.output_dir) |
| 295 | |
| 296 | def read_code_templates(params) -> dict: |
| 297 | ''' |
no test coverage detected