mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 00:46:18 +00:00
Add Python 3.12 support
This commit is contained in:
parent
4a0437b5e2
commit
f12e403c67
3
.github/workflows/tests.yaml
vendored
3
.github/workflows/tests.yaml
vendored
@ -29,7 +29,8 @@ jobs:
|
||||
- 3.8
|
||||
- 3.9
|
||||
- "3.10"
|
||||
- 3.11
|
||||
- "3.11"
|
||||
- "3.12"
|
||||
fail-fast: false
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user