Skip to content

Commit

Permalink
name-parser: Fix unify_style_names()
Browse files Browse the repository at this point in the history
[why]
The code is obviously wrong. No effect has been seen, though.

First we check if a certain string is a key in the dict.
If it is, we retrieve the value with the string lower-cased as key.

This does not make sense.

[how]
All the keys are lower case anyhow, so the code seems unneeded. Maybe it
is a leftover. The styles that go into it _and are in the dict_ all come
from a regex-enabled search and thus are lower-cased.

Whatever, to have the correct code we use the lower-cased string for
both, checking for existance and retrieving the value - this is the only
sane approach.
Also change to dict.get() method instead of a self made if code.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
  • Loading branch information
Finii committed May 26, 2023
1 parent 2e7e8b5 commit 30d7317
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions bin/scripts/name_parser/FontnameTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ def unify_style_names(style_name):
#'semibold': 'Demi',
'normal': 'Regular',
}
if style_name in known_names:
return known_names[style_name.lower()]
return style_name
return known_names.get(style_name.lower(), style_name)

@staticmethod
def find_in_dicts(key, dicts):
Expand Down

0 comments on commit 30d7317

Please sign in to comment.