mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-23 21:46:44 +00:00
Fixes for ruff check
in utils.py
This commit is contained in:
parent
35d2aa7b2d
commit
58ed18519a
@ -84,14 +84,11 @@ def parse_database_connection_string(database_connection_string):
|
|||||||
f'invalid driver, must be one of {valid_drivers}')
|
f'invalid driver, must be one of {valid_drivers}')
|
||||||
django_driver = django_backends.get(driver)
|
django_driver = django_backends.get(driver)
|
||||||
host_parts = user_pass_host_port.split('@')
|
host_parts = user_pass_host_port.split('@')
|
||||||
if len(host_parts) != 2:
|
user_pass_parts = host_parts[0].split(':')
|
||||||
raise DatabaseConnectionError(f'Database connection string netloc must be in '
|
if len(host_parts) != 2 or len(user_pass_parts) != 2:
|
||||||
f'the format of user:pass@host')
|
raise DatabaseConnectionError('Database connection string netloc must be in '
|
||||||
|
'the format of user:pass@host')
|
||||||
user_pass, host_port = host_parts
|
user_pass, host_port = host_parts
|
||||||
user_pass_parts = user_pass.split(':')
|
|
||||||
if len(user_pass_parts) != 2:
|
|
||||||
raise DatabaseConnectionError(f'Database connection string netloc must be in '
|
|
||||||
f'the format of user:pass@host')
|
|
||||||
username, password = user_pass_parts
|
username, password = user_pass_parts
|
||||||
host_port_parts = host_port.split(':')
|
host_port_parts = host_port.split(':')
|
||||||
if len(host_port_parts) == 1:
|
if len(host_port_parts) == 1:
|
||||||
@ -113,13 +110,13 @@ def parse_database_connection_string(database_connection_string):
|
|||||||
f'65535, got {port}')
|
f'65535, got {port}')
|
||||||
else:
|
else:
|
||||||
# Malformed
|
# Malformed
|
||||||
raise DatabaseConnectionError(f'Database connection host must be a hostname or '
|
raise DatabaseConnectionError('Database connection host must be a hostname or '
|
||||||
f'a hostname:port combination')
|
'a hostname:port combination')
|
||||||
if database.startswith('/'):
|
if database.startswith('/'):
|
||||||
database = database[1:]
|
database = database[1:]
|
||||||
if not database:
|
if not database:
|
||||||
raise DatabaseConnectionError(f'Database connection string path must be a '
|
raise DatabaseConnectionError('Database connection string path must be a '
|
||||||
f'string in the format of /databasename')
|
'string in the format of /databasename')
|
||||||
if '/' in database:
|
if '/' in database:
|
||||||
raise DatabaseConnectionError(f'Database connection string path can only '
|
raise DatabaseConnectionError(f'Database connection string path can only '
|
||||||
f'contain a single string name, got: {database}')
|
f'contain a single string name, got: {database}')
|
||||||
|
Loading…
Reference in New Issue
Block a user