Read the code templates @param params: Command line parameters @type params: Parameters @return: Content of the code template files if they exists, None otherwise @rtype: {string, string}
(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 | ''' |
| 298 | Read the code templates |
| 299 | |
| 300 | @param params: Command line parameters |
| 301 | @type params: Parameters |
| 302 | |
| 303 | @return: Content of the code template files if they exists, None otherwise |
| 304 | @rtype: {string, string} |
| 305 | ''' |
| 306 | |
| 307 | templates = {} |
| 308 | |
| 309 | try: |
| 310 | template_file_path = os.path.join(params.templates_dir, "types", "enum_header.template.j2") |
| 311 | template_file = open(template_file_path, "rt") |
| 312 | templates["enum_header"] = template_file.read() |
| 313 | |
| 314 | template_file_path = os.path.join(params.templates_dir, "types", "enum_impl.template.j2") |
| 315 | template_file = open(template_file_path, "rt") |
| 316 | templates["enum_impl"] = template_file.read() |
| 317 | |
| 318 | template_file_path = os.path.join(params.templates_dir, "types", "type_header.template.j2") |
| 319 | template_file = open(template_file_path, "rt") |
| 320 | templates["type_header"] = template_file.read() |
| 321 | |
| 322 | template_file_path = os.path.join(params.templates_dir, "types", "type_impl.template.j2") |
| 323 | template_file = open(template_file_path, "rt") |
| 324 | templates["type_impl"] = template_file.read() |
| 325 | |
| 326 | template_file_path = os.path.join(params.templates_dir, "messages", "msg_header.template.j2") |
| 327 | template_file = open(template_file_path, "rt") |
| 328 | templates["msg_header"] = template_file.read() |
| 329 | |
| 330 | template_file_path = os.path.join(params.templates_dir, "messages", "msg_impl.template.j2") |
| 331 | template_file = open(template_file_path, "rt") |
| 332 | templates["msg_impl"] = template_file.read() |
| 333 | |
| 334 | template_file_path = os.path.join(params.templates_dir, "messages", "MessagesConverter.cpp.j2") |
| 335 | template_file = open(template_file_path, "rt") |
| 336 | templates["msg_converter_impl"] = template_file.read() |
| 337 | |
| 338 | template_file_path = os.path.join(params.templates_dir, "messages", "MessagesValidator.cpp.j2") |
| 339 | template_file = open(template_file_path, "rt") |
| 340 | templates["msg_validator_impl"] = template_file.read() |
| 341 | |
| 342 | |
| 343 | template_file_path = os.path.join(params.templates_dir, "chargepoint", "IChargePoint.h.j2") |
| 344 | template_file = open(template_file_path, "rt") |
| 345 | templates["cs_ichargepoint"] = template_file.read() |
| 346 | |
| 347 | template_file_path = os.path.join(params.templates_dir, "chargepoint", "IChargePointEventsHandler.h.j2") |
| 348 | template_file = open(template_file_path, "rt") |
| 349 | templates["cs_ichargepointeventshandler"] = template_file.read() |
| 350 | |
| 351 | |
| 352 | template_file_path = os.path.join(params.templates_dir, "centralsystem", "ICentralSystem.h.j2") |
| 353 | template_file = open(template_file_path, "rt") |