Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum newline break at wrong position. #30

Closed
ewoudwerkman opened this issue Nov 23, 2020 · 2 comments
Closed

Enum newline break at wrong position. #30

ewoudwerkman opened this issue Nov 23, 2020 · 2 comments

Comments

@ewoudwerkman
Copy link

Hi!

In our model we have an EEnum with quite a lot of options and in the latest version of pyecoregen the generated python code cannot compile due to a wrong line break.
It generates the following output (scroll to the right):

PhysicalQuantityEnum = EEnum('PhysicalQuantityEnum', literals=['UNDEFINED', 'ENERGY', 'POWER', 'VOLTAGE', 'PRESSURE', 'TEMPERATURE', 'EMISSION', 'COST', 'TIME', 'LENGTH', 'DISTANCE', 'IRRADIANCE', 'SPEED', 'STATE_OF_CHARGE', 'VOLUME', 'AREA', 'POWER_REACTIVE', 'COMPOSITION', 'FLOW', 'STATE', 'HEAD', 'POSITION', 'COEFFICIENT', 'WEIGHT', 'FORCE
                                                               ', 'CURRENT'])

It breaks before the ' instead of after the ,.

A different EEnum in our model has even more options, but is OK:

ProfileTypeEnum = EEnum('ProfileTypeEnum', literals=['UNDEFINED', 'SOLARIRRADIANCE_IN_W_PER_M2', 'WINDSPEED_IN_M_PER_S', 'STATEOFCHARGE_IN_WS', 'ENERGY_IN_WH', 'ENERGY_IN_KWH', 'ENERGY_IN_MWH', 'ENERGY_IN_GWH', 'ENERGY_IN_J', 'ENERGY_IN_KJ', 'ENERGY_IN_MJ', 'ENERGY_IN_GJ', 'ENERGY_IN_TJ',
                                                     'ENERGY_IN_PJ', 'TEMPERATURE_IN_C', 'TEMPERATURE_IN_K', 'POWER_IN_W', 'POWER_IN_KW', 'POWER_IN_MW', 'POWER_IN_GW', 'POWER_IN_TW', 'MONEY_IN_EUR', 'MONEY_IN_KEUR', 'MONEY_IN_MEUR', 'PERCENTAGE', 'MONEY_IN_EUR_PER_KW', 'MONEY_IN_EUR_PER_KWH', 'VOLUME_IN_M3', 'VOLUME_IN_LITERS'])

Any idea what causes this?
Thanks!

@aranega
Copy link
Member

aranega commented Nov 26, 2020

Hi @ewoudwerkman ,

Thanks for the issue, I will investigate on that. At the moment, I don't have really any idea why this behavior happend. By change, is there any case that a trailing \n would appear in your EnumLiteral name? It's really unlikely, but just in case.

Sorry about this...

@ewoudwerkman
Copy link
Author

Good catch!
I checked the ecore model and I found this:

  <eLiterals name="FORCE&#xD;&#xA;" value="24"/>

Thanks for your swift reaction!

@aranega aranega closed this as completed Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants