PythonScript icon indicating copy to clipboard operation
PythonScript copied to clipboard

Fix invalid enums

Open tooruu opened this issue 1 year ago • 3 comments

The following enums are invalid. Please change the attribute names to valid identifiers. https://github.com/bruderstein/PythonScript/blob/52f7d7b3745ebd629ff4549365b13aac4c813c95/docs/source/enums.rst?plain=1#L1349 https://github.com/bruderstein/PythonScript/blob/52f7d7b3745ebd629ff4549365b13aac4c813c95/docs/source/enums.rst?plain=1#L1351 https://github.com/bruderstein/PythonScript/blob/52f7d7b3745ebd629ff4549365b13aac4c813c95/docs/source/enums.rst?plain=1#L1587

tooruu avatar Jul 09 '24 07:07 tooruu

Why do you think they are invalid? They are created from the header, they might be outdated, but ... invalid?

Ekopalypse avatar Jul 11 '24 12:07 Ekopalypse

Why do you think they are invalid? They are created from the header, they might be outdated, but ... invalid?

In the header the enums are prefixed with WV_, making them valid identifiers. However, names cannot start with a number according to the docs. We can use str.isidentifier method to see if a string is a valid identifier.

>>> WINVER.WIN10.name
'WIN10'
>>> WINVER.95.name
  File "<console>", line 1
    WINVER.95.name
          ^^^
SyntaxError: invalid syntax
>>> [name for name in WINVER.names if not name.isidentifier()]
['95', '98']

tooruu avatar Jul 11 '24 13:07 tooruu

I see, thanks for the clarification.

Ekopalypse avatar Jul 11 '24 13:07 Ekopalypse