diff --git a/masque/file/dxf.py b/masque/file/dxf.py index 56b0bc5..07eb1db 100644 --- a/masque/file/dxf.py +++ b/masque/file/dxf.py @@ -370,17 +370,18 @@ def disambiguate_pattern_names(patterns, i += 1 if sanitized_name == '': - logger.warning('Empty pattern name saved as "{}"'.format(suffixed_name)) + logger.warning(f'Empty pattern name saved as "{suffixed_name}"') elif suffixed_name != sanitized_name: if dup_warn_filter is None or dup_warn_filter(pat.name): - logger.warning('Pattern name "{}" ({}) appears multiple times;\n renaming to "{}"'.format( - pat.name, sanitized_name, suffixed_name)) + logger.warning(f'Pattern name "{pat.name}" ({sanitized_name}) appears multiple times;\n' + + f' renaming to "{suffixed_name}"') if len(suffixed_name) == 0: # Should never happen since zero-length names are replaced - raise PatternError('Zero-length name after sanitize,\n originally "{}"'.format(pat.name)) + raise PatternError(f'Zero-length name after sanitize,\n originally "{pat.name}"') if len(suffixed_name) > max_name_length: - raise PatternError('Pattern name "{!r}" length > {} after encode,\n originally "{}"'.format(suffixed_name, max_name_length, pat.name)) + raise PatternError(f'Pattern name "{suffixed_name!r}" length > {max_name_length} after encode,\n' + + f' originally "{pat.name}"') pat.name = suffixed_name used_names.append(suffixed_name) diff --git a/masque/file/gdsii.py b/masque/file/gdsii.py index 6e2eda0..b7885ac 100644 --- a/masque/file/gdsii.py +++ b/masque/file/gdsii.py @@ -484,8 +484,8 @@ def disambiguate_pattern_names(patterns: Sequence[Pattern], # Shorten names which already exceed max-length if len(pat.name) > max_name_length: shortened_name = pat.name[:max_name_length - suffix_length] - logger.warning('Pattern name "{}" is too long ({}/{} chars),\n'.format(pat.name, len(pat.name), max_name_length) + - ' shortening to "{}" before generating suffix'.format(shortened_name)) + logger.warning(f'Pattern name "{pat.name}" is too long ({len(pat.name)}/{max_name_length} chars),\n' + + f' shortening to "{shortened_name}" before generating suffix') else: shortened_name = pat.name @@ -502,19 +502,20 @@ def disambiguate_pattern_names(patterns: Sequence[Pattern], i += 1 if sanitized_name == '': - logger.warning('Empty pattern name saved as "{}"'.format(suffixed_name)) + logger.warning(f'Empty pattern name saved as "{suffixed_name}"') elif suffixed_name != sanitized_name: if dup_warn_filter is None or dup_warn_filter(pat.name): - logger.warning('Pattern name "{}" ({}) appears multiple times;\n renaming to "{}"'.format( - pat.name, sanitized_name, suffixed_name)) + logger.warning(f'Pattern name "{pat.name}" ({sanitized_name}) appears multiple times;\n' + + f' renaming to "{suffixed_name}"') # Encode into a byte-string and perform some final checks encoded_name = suffixed_name.encode('ASCII') if len(encoded_name) == 0: # Should never happen since zero-length names are replaced - raise PatternError('Zero-length name after sanitize+encode,\n originally "{}"'.format(pat.name)) + raise PatternError(f'Zero-length name after sanitize+encode,\n originally "{pat.name}"') if len(encoded_name) > max_name_length: - raise PatternError('Pattern name "{!r}" length > {} after encode,\n originally "{}"'.format(encoded_name, max_name_length, pat.name)) + raise PatternError(f'Pattern name "{encoded_name!r}" length > {max_name_length} after encode,\n' + + f' originally "{pat.name}"') pat.name = suffixed_name used_names.append(suffixed_name) diff --git a/masque/file/oasis.py b/masque/file/oasis.py index fa93388..9a27a9f 100644 --- a/masque/file/oasis.py +++ b/masque/file/oasis.py @@ -593,15 +593,15 @@ def disambiguate_pattern_names(patterns, i += 1 if sanitized_name == '': - logger.warning('Empty pattern name saved as "{}"'.format(suffixed_name)) + logger.warning(f'Empty pattern name saved as "{suffixed_name}"') elif suffixed_name != sanitized_name: if dup_warn_filter is None or dup_warn_filter(pat.name): - logger.warning('Pattern name "{}" ({}) appears multiple times;\n renaming to "{}"'.format( - pat.name, sanitized_name, suffixed_name)) + logger.warning(f'Pattern name "{pat.name}" ({sanitized_name}) appears multiple times;\n' + + f' renaming to "{suffixed_name}"') if len(suffixed_name) == 0: # Should never happen since zero-length names are replaced - raise PatternError('Zero-length name after sanitize+encode,\n originally "{}"'.format(pat.name)) + raise PatternError(f'Zero-length name after sanitize+encode,\n originally "{pat.name}"') pat.name = suffixed_name used_names.append(suffixed_name) diff --git a/masque/file/svg.py b/masque/file/svg.py index deef59a..fb49b5b 100644 --- a/masque/file/svg.py +++ b/masque/file/svg.py @@ -79,8 +79,7 @@ def writefile(pattern: Pattern, for subpat in pat.subpatterns: if subpat.pattern is None: continue - transform = 'scale({:g}) rotate({:g}) translate({:g},{:g})'.format( - subpat.scale, subpat.rotation, subpat.offset[0], subpat.offset[1]) + transform = f'scale({subpat.scale:g}) rotate({subpat.rotation:g}) translate({subpat.offset[0]:g},{subpat.offset[1]:g})' use = svg.use(href='#' + mangle_name(subpat.pattern), transform=transform) if custom_attributes: use['pattern_dose'] = subpat.dose diff --git a/masque/shapes/path.py b/masque/shapes/path.py index 3f2f72f..7570c7c 100644 --- a/masque/shapes/path.py +++ b/masque/shapes/path.py @@ -322,7 +322,7 @@ class Path(Shape, metaclass=AutoSlots): bounds[0, :] = numpy.minimum(bounds[0, :], poly_bounds[0, :]) bounds[1, :] = numpy.maximum(bounds[1, :], poly_bounds[1, :]) else: - raise PatternError('get_bounds() not implemented for endcaps: {}'.format(self.cap)) + raise PatternError(f'get_bounds() not implemented for endcaps: {self.cap}') return bounds diff --git a/masque/subpattern.py b/masque/subpattern.py index 41facd1..ebd6876 100644 --- a/masque/subpattern.py +++ b/masque/subpattern.py @@ -104,7 +104,7 @@ class SubPattern(PositionableImpl, DoseableImpl, RotatableImpl, ScalableImpl, Mi def pattern(self, val: Optional['Pattern']): from .pattern import Pattern if val is not None and not isinstance(val, Pattern): - raise PatternError('Provided pattern {} is not a Pattern object or None!'.format(val)) + raise PatternError(f'Provided pattern {val} is not a Pattern object or None!') self._pattern = val # Mirrored property