1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-22 08:56:17 +00:00

Add Python 3.12 support

This commit is contained in:
Alban Féron 2024-05-19 15:59:40 +02:00
parent 4a0437b5e2
commit f12e403c67
No known key found for this signature in database
GPG Key ID: 8CE0313646D16165
3 changed files with 35 additions and 7 deletions

View File

@ -29,7 +29,8 @@ jobs:
- 3.8
- 3.9
- "3.10"
- 3.11
- "3.11"
- "3.12"
fail-fast: false
steps:
- name: Checkout

View File

@ -46,6 +46,7 @@ classifiers =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Topic :: Multimedia :: Sound/Audio
[options]

View File

@ -1,14 +1,14 @@
# This file is part of Supysonic.
# Supysonic is a Python implementation of the Subsonic server API.
#
# Copyright (C) 2013-2023 Alban 'spl0k' Féron
# Copyright (C) 2013-2024 Alban 'spl0k' Féron
#
# Distributed under terms of the GNU AGPLv3 license.
import importlib
import mimetypes
import os.path
import pkg_resources
import sys
import time
from datetime import datetime
@ -616,8 +616,36 @@ class RadioStation(_Model):
return info
if sys.version_info < (3, 9):
import pkg_resources
def get_resource_text(respath):
return pkg_resources.resource_string(__package__, respath).decode("utf-8")
def list_migrations(provider):
return pkg_resources.resource_listdir(
__package__, f"schema/migration/{provider}"
)
else:
import importlib.resources
def get_resource_text(respath):
return (
importlib.resources.files(__package__).joinpath(respath).read_text("utf-8")
)
def list_migrations(provider):
return (
e.name
for e in importlib.resources.files(__package__)
.joinpath(f"schema/migration/{provider}")
.iterdir()
)
def execute_sql_resource_script(respath):
sql = pkg_resources.resource_string(__package__, respath).decode("utf-8")
sql = get_resource_text(respath)
for statement in sql.split(";"):
statement = statement.strip()
if statement and not statement.startswith("--"):
@ -655,9 +683,7 @@ def init_database(database_uri):
version = Meta["schema_version"]
if version.value < SCHEMA_VERSION:
args.pop("pragmas", ())
migrations = sorted(
pkg_resources.resource_listdir(__package__, f"schema/migration/{provider}")
)
migrations = sorted(list_migrations(provider))
for migration in migrations:
if migration[0] in ("_", "."):
continue