From fef04c75ae2a71ced11c19beb78c27bced7ca973 Mon Sep 17 00:00:00 2001 From: Karoly Lorentey Date: Wed, 22 Sep 2021 19:20:36 -0700 Subject: [PATCH] [Utilities] Upgrade gyb to Python 3 --- Sources/Atomics/IntegerConformances.swift.gyb | 4 ++-- Utilities/gyb | 2 +- Utilities/gyb.py | 19 +++---------------- Utilities/gyb_utils.py | 2 +- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/Sources/Atomics/IntegerConformances.swift.gyb b/Sources/Atomics/IntegerConformances.swift.gyb index f62d122..76a5137 100644 --- a/Sources/Atomics/IntegerConformances.swift.gyb +++ b/Sources/Atomics/IntegerConformances.swift.gyb @@ -228,12 +228,12 @@ extension ${swiftType}.AtomicRepresentation: AtomicStorage { } } -% if swiftType <> "DoubleWord": +% if swiftType != "DoubleWord": extension ${swiftType}: AtomicInteger {} extension ${swiftType}.AtomicRepresentation: AtomicIntegerStorage { % for (name, cname, op, label, doc) in integerOperations: -% defaultValue = " = 1" if label <> "" else "" +% defaultValue = " = 1" if label != "" else "" @_semantics("atomics.requires_constant_orderings") @_transparent @_alwaysEmitIntoClient @discardableResult diff --git a/Utilities/gyb b/Utilities/gyb index dece788..8206bd8 100755 --- a/Utilities/gyb +++ b/Utilities/gyb @@ -1,3 +1,3 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 import gyb gyb.main() diff --git a/Utilities/gyb.py b/Utilities/gyb.py index 2df9a03..e3af0b7 100755 --- a/Utilities/gyb.py +++ b/Utilities/gyb.py @@ -2,26 +2,13 @@ # GYB: Generate Your Boilerplate (improved names welcome; at least # this one's short). See -h output for instructions -from __future__ import print_function - import os import re import sys import textwrap import tokenize from bisect import bisect - - -try: - from cStringIO import StringIO -except ImportError: - from io import StringIO - - -try: - basestring -except NameError: - basestring = str +from io import StringIO def get_line_starts(s): @@ -243,7 +230,7 @@ def tokenize_template(template_text): # pull out the one matched key (ignoring internal patterns starting # with _) ((kind, text), ) = ( - (kind, text) for (kind, text) in m.groupdict().items() + (kind, text) for (kind, text) in list(m.groupdict().items()) if text is not None and kind[0] != '_') if kind in ('literal', 'symbol'): @@ -731,7 +718,7 @@ class Code(ASTNode): # If we got a result, the code was an expression, so append # its value if result is not None \ - or (isinstance(result, basestring) and result != ''): + or (isinstance(result, str) and result != ''): from numbers import Number, Integral result_string = None if isinstance(result, Number) and not isinstance(result, Integral): diff --git a/Utilities/gyb_utils.py b/Utilities/gyb_utils.py index 00ccbae..49dfe4f 100644 --- a/Utilities/gyb_utils.py +++ b/Utilities/gyb_utils.py @@ -81,5 +81,5 @@ def lowerFirst(str): return str[:1].lower() + str[1:] if str else "" def argLabel(label): - return label + ": " if label <> "_" else "" + return label + ": " if label != "_" else ""