diff options
author | Aleksandr Mishchenko <AMishchenko@luxoft.com> | 2020-03-25 18:00:54 +0100 |
---|---|---|
committer | Aleksandr Mishchenko <AMishchenko@luxoft.com> | 2020-03-25 18:00:54 +0100 |
commit | ede8a54d8f35cbb6a7985a1e04a87a2b842fe5cb (patch) | |
tree | 8141d2689015c1f441d8e28a947d05862486f202 | |
parent | 9a0d9f6c8b0d2c553125880410dcf4db01f85115 (diff) | |
download | sdl_ios-ede8a54d8f35cbb6a7985a1e04a87a2b842fe5cb.tar.gz |
Apply suggestions from code review
-rw-r--r-- | generator/generator.py | 17 | ||||
-rw-r--r-- | generator/templates/SDLRPCFunctionNames.h | 3 | ||||
-rw-r--r-- | generator/transformers/functions_producer.py | 4 |
3 files changed, 4 insertions, 20 deletions
diff --git a/generator/generator.py b/generator/generator.py index fbef269e7..058484645 100644 --- a/generator/generator.py +++ b/generator/generator.py @@ -2,7 +2,6 @@ Generator """ import asyncio -import json import logging import re import sys @@ -10,7 +9,6 @@ from argparse import ArgumentParser from collections import namedtuple, OrderedDict from datetime import datetime, date from inspect import getfile -from json import JSONDecodeError from os.path import basename, join from pathlib import Path from re import findall @@ -32,7 +30,6 @@ try: from transformers.structs_producer import StructsProducer except ImportError as error: print('%s.\nprobably you did not initialize submodule', error) - ParseError = Parser = Interface = Common = EnumsProducer = FunctionsProducer = StructsProducer = None sys.exit(1) @@ -280,20 +277,6 @@ class Generator: return self.paths_named(**data) - async def get_mappings(self, file: Path = ROOT.joinpath('mapping.json')): - """ - The key name in *.json is equal to property named in jinja2 templates - :param file: path to file with manual mappings - :return: dictionary with custom manual mappings - """ - try: - with file.open('r') as handler: - content = handler.readlines() - return json.loads(''.join(content)) - except (FileNotFoundError, JSONDecodeError) as error1: - self.logger.error('Failure to get mappings %s', error1) - return OrderedDict() - def write_file(self, file: Path, templates: list, data: dict): """ Calling producer/transformer instance to transform initial Model to dict used in jinja2 templates. diff --git a/generator/templates/SDLRPCFunctionNames.h b/generator/templates/SDLRPCFunctionNames.h index 39a6e27d8..3126c8169 100644 --- a/generator/templates/SDLRPCFunctionNames.h +++ b/generator/templates/SDLRPCFunctionNames.h @@ -8,7 +8,8 @@ */ typedef SDLEnum SDLRPCFunctionName SDL_SWIFT_ENUM; {% for param in params %} -# Create inline documentation for the parameter if there's a `since` variable and / or a description +{#- description if exist in source xml, will be putted here + since if exist in source xml, will be putted here -#} {%- if param.description or param.since %} /** {%- if param.description %} diff --git a/generator/transformers/functions_producer.py b/generator/transformers/functions_producer.py index 01110ac18..bad4d0f0f 100644 --- a/generator/transformers/functions_producer.py +++ b/generator/transformers/functions_producer.py @@ -109,5 +109,5 @@ class FunctionsProducer(InterfaceProducerCommon): render.update(self.evaluate(struct)) for param in struct.members.values(): render.update(self.evaluate(param)) - - return {'params': sorted(render.values(), key=lambda a: a.name)} + unique = dict(zip(list(map(lambda l: l.name, render.values())), render.values())) + return {'params': sorted(unique.values(), key=lambda a: a.name)} |