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:
parent
4a0437b5e2
commit
f12e403c67
3
.github/workflows/tests.yaml
vendored
3
.github/workflows/tests.yaml
vendored
@ -29,7 +29,8 @@ jobs:
|
|||||||
- 3.8
|
- 3.8
|
||||||
- 3.9
|
- 3.9
|
||||||
- "3.10"
|
- "3.10"
|
||||||
- 3.11
|
- "3.11"
|
||||||
|
- "3.12"
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
@ -46,6 +46,7 @@ classifiers =
|
|||||||
Programming Language :: Python :: 3.9
|
Programming Language :: Python :: 3.9
|
||||||
Programming Language :: Python :: 3.10
|
Programming Language :: Python :: 3.10
|
||||||
Programming Language :: Python :: 3.11
|
Programming Language :: Python :: 3.11
|
||||||
|
Programming Language :: Python :: 3.12
|
||||||
Topic :: Multimedia :: Sound/Audio
|
Topic :: Multimedia :: Sound/Audio
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
# This file is part of Supysonic.
|
# This file is part of Supysonic.
|
||||||
# Supysonic is a Python implementation of the Subsonic server API.
|
# 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.
|
# Distributed under terms of the GNU AGPLv3 license.
|
||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os.path
|
import os.path
|
||||||
import pkg_resources
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -616,8 +616,36 @@ class RadioStation(_Model):
|
|||||||
return info
|
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):
|
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(";"):
|
for statement in sql.split(";"):
|
||||||
statement = statement.strip()
|
statement = statement.strip()
|
||||||
if statement and not statement.startswith("--"):
|
if statement and not statement.startswith("--"):
|
||||||
@ -655,9 +683,7 @@ def init_database(database_uri):
|
|||||||
version = Meta["schema_version"]
|
version = Meta["schema_version"]
|
||||||
if version.value < SCHEMA_VERSION:
|
if version.value < SCHEMA_VERSION:
|
||||||
args.pop("pragmas", ())
|
args.pop("pragmas", ())
|
||||||
migrations = sorted(
|
migrations = sorted(list_migrations(provider))
|
||||||
pkg_resources.resource_listdir(__package__, f"schema/migration/{provider}")
|
|
||||||
)
|
|
||||||
for migration in migrations:
|
for migration in migrations:
|
||||||
if migration[0] in ("_", "."):
|
if migration[0] in ("_", "."):
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user