From 9a3cd280b8281fed030feee6b325305429e80fd0 Mon Sep 17 00:00:00 2001 From: Steven Maude Date: Fri, 12 Dec 2025 15:22:05 +0000 Subject: [PATCH] Run `pyupgrade --py310-plus` --- scraperwiki/sql.py | 14 +++++++------- scraperwiki/utils.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scraperwiki/sql.py b/scraperwiki/sql.py index 15d1316..367ca5d 100644 --- a/scraperwiki/sql.py +++ b/scraperwiki/sql.py @@ -17,7 +17,7 @@ DATABASE_TIMEOUT = float(os.environ.get("SCRAPERWIKI_DATABASE_TIMEOUT", 300)) SECONDS_BETWEEN_COMMIT = 2 -unicode = type(u'') +unicode = str # The scraperwiki.sqlite.SqliteError exception SqliteError = sqlalchemy.exc.SQLAlchemyError @@ -28,7 +28,7 @@ class Blob(bytes): Represents a blob as a string. """ PYTHON_SQLITE_TYPE_MAP = { - six.text_type: sqlalchemy.types.Text, + str: sqlalchemy.types.Text, str: sqlalchemy.types.Text, int: sqlalchemy.types.BigInteger, bool: sqlalchemy.types.Boolean, @@ -50,7 +50,7 @@ class Blob(bytes): pass -class _State(object): +class _State: """ This class maintains global state relating to the database such as @@ -105,7 +105,7 @@ def check_last_committed(cls): cls.new_transaction() -class Transaction(object): +class Transaction: """ This context manager must be used when other services need @@ -159,9 +159,9 @@ def execute(query, data=None): pass if not result.returns_rows: - return {u'data': [], u'keys': []} + return {'data': [], 'keys': []} - return {u'data': result.fetchall(), u'keys': list(result.keys())} + return {'data': result.fetchall(), 'keys': list(result.keys())} def select(query, data=None): @@ -310,7 +310,7 @@ def get_var(name, default=None): # This is to do the variable type conversion through the SQL engine execute = connection.execute - execute("CREATE TEMPORARY TABLE _sw_tmp ('value' {})".format(result.type)) + execute(f"CREATE TEMPORARY TABLE _sw_tmp ('value' {result.type})") execute("INSERT INTO _sw_tmp VALUES (:value)", value=result.value_blob) var = execute('SELECT value FROM _sw_tmp').fetchone().value execute("DROP TABLE _sw_tmp") diff --git a/scraperwiki/utils.py b/scraperwiki/utils.py index 4c2eeda..2eed864 100644 --- a/scraperwiki/utils.py +++ b/scraperwiki/utils.py @@ -45,7 +45,7 @@ def pdftoxml(pdfdata, options=""): xmlin = tempfile.NamedTemporaryFile(mode='r', suffix='.xml') tmpxml = xmlin.name # "temph.xml" - cmd = 'pdftohtml -xml -nodrm -zoom 1.5 -enc UTF-8 -noframes %s "%s" "%s"' % ( + cmd = 'pdftohtml -xml -nodrm -zoom 1.5 -enc UTF-8 -noframes {} "{}" "{}"'.format( options, pdffout.name, os.path.splitext(tmpxml)[0]) # can't turn off output, so throw away even stderr yeuch cmd = cmd + " >/dev/null 2>&1"