Skip to content

Commit

Permalink
Use f-strings
Browse files Browse the repository at this point in the history
  • Loading branch information
moyogo committed Feb 28, 2021
1 parent 8a2d838 commit 69a9df6
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions Lib/glyphsLib/builder/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,13 @@ def to_ufo_layer(self, glyph, layer):
ufo_layer = ufo_font.newLayer(layer.name)
elif layer.name in ufo_font.layers and glyph.name in ufo_font.layers[layer.name]:
self.logger.warning(
"%s %s: Glyph %s, layer %s: Duplicate glyph layer name",
ufo_font.info.familyName,
ufo_font.info.styleName,
glyph.name,
layer.name,
f"{ufo_font.info.familyName} {ufo_font.info.styleName}: "
f"Glyph {glyph.name}, layer {layer.name}: Duplicate glyph layer name",
)
n = 1
new_layer_name = layer.name
while new_layer_name in ufo_font.layers:
new_layer_name = layer.name + " #" + repr(n)
new_layer_name = f"{layer.name} #{n!r}"
n += 1
ufo_layer = ufo_font.newLayer(new_layer_name)
else:
Expand All @@ -54,22 +51,19 @@ def to_ufo_background_layer(self, glyph, layer):
if layer.associatedMasterId == layer.layerId:
layer_name = "public.background"
else:
layer_name = layer.name + ".background"
layer_name = f"{layer.name}.background"

if layer_name not in ufo_font.layers:
background_layer = ufo_font.newLayer(layer_name)
elif layer_name in ufo_font.layers and glyph.name in ufo_font.layers[layer_name]:
self.logger.warning(
"%s %s: Glyph %s, layer %s: Duplicate glyph layer name",
ufo_font.info.familyName,
ufo_font.info.styleName,
glyph.name,
layer_name,
f"{ufo_font.info.familyName} {ufo_font.info.styleName}: "
f"Glyph {glyph.name}, layer {layer_name}: Duplicate glyph layer name",
)
n = 1
new_layer_name = layer_name
while new_layer_name in ufo_font.layers:
new_layer_name = layer.name + " #" + repr(n) + ".background"
new_layer_name = f"{layer.name} #{n!r}.background"
n += 1
background_layer = ufo_font.newLayer(new_layer_name)
else:
Expand Down

0 comments on commit 69a9df6

Please sign in to comment.