Skip to content

Commit

Permalink
name-parser: Fix Python2 compatibility
Browse files Browse the repository at this point in the history
[why]
The naming has bizarre blanks strewn in sometimes,
or is all caps. For example
`C a s k a y d i a   C o v e` or
`CASKAYDIACOVE-Regular`

[how]
When run under Python2 all strings are unicode strings because
`unicode_literals` is imported by `font-patcher`.
Unfortunately the code checks for type str; but that will all become
type unicode with the import.

One check is suboptimal anyhow and can be dropped, while the other is
turned around.

Signed-off-by: Fini Jastrow <[email protected]>
  • Loading branch information
Finii committed Aug 20, 2022
1 parent d21ab2e commit 45ce832
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bin/scripts/name_parser/FontnameParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def enable_short_families(self, camelcase_name, prefix):
"""Enable short styles in Family when (original) font name starts with prefix; enable CamelCase basename in (Typog.) Family"""
# camelcase_name is boolean
# prefix is either a string or False
if type(prefix) == str:
if prefix:
prefix = self._basename.startswith(prefix)
self.use_short_families = ( camelcase_name, prefix )
return self
Expand Down
2 changes: 1 addition & 1 deletion bin/scripts/name_parser/FontnameTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def concat(*all_things):
"""Flatten list of (strings or lists of strings) to a blank-separated string"""
all = []
for thing in all_things:
if type(thing) == str:
if type(thing) is not list:
all.append(thing)
else:
all += thing
Expand Down

0 comments on commit 45ce832

Please sign in to comment.