Fix/pylint cleanup (#8)
* Fix pylint warnings across all 24 Python files in web_server - Add module, class, and function docstrings (C0114, C0115, C0116) - Fix import ordering: stdlib before third-party before local (C0411) - Replace wildcard imports with explicit named imports (W0401) - Remove trailing whitespace and add missing final newlines (C0303, C0304) - Replace dict() with dict literals (R1735) - Remove unused imports and variables (W0611, W0612) - Narrow broad Exception catches to specific exceptions (W0718) - Replace f-string logging with lazy % formatting (W1203) - Fix variable naming: UPPER_CASE for constants, snake_case for locals (C0103) - Add pylint disable comments for necessary global statements (W0603) - Fix no-else-return, simplifiable-if-expression, singleton-comparison - Fix bad indentation in stripe.py (W0311) - Add encoding="utf-8" to open() calls (W1514) - Add check=True to subprocess.run() calls (W1510) - Register Celery task modules via conf.include * Update `package-lock.json` add peer dependencies
This commit is contained in:
committed by
GitHub
parent
fed1a2f288
commit
2758be8680
@@ -1,8 +1,11 @@
|
||||
"""Description: This file contains the PathManager class which is responsible for managing the paths of the stream data."""
|
||||
"""File system path management for user streams, VODs, and profile pictures."""
|
||||
|
||||
import os
|
||||
|
||||
|
||||
class PathManager():
|
||||
"""Manages paths for user stream data, VODs, and profile pictures."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.root_path = "user_data"
|
||||
self.vod_directory_name = "vods"
|
||||
@@ -26,7 +29,7 @@ class PathManager():
|
||||
self._create_directory(os.path.join(self.root_path, username))
|
||||
vods_path = self.get_vods_path(username)
|
||||
stream_path = self.get_stream_path(username)
|
||||
|
||||
|
||||
self._create_directory(vods_path)
|
||||
self._create_directory(stream_path)
|
||||
|
||||
@@ -39,25 +42,33 @@ class PathManager():
|
||||
os.rmdir(user_path)
|
||||
|
||||
def get_user_path(self, username):
|
||||
"""Returns the base path for a user's data directory."""
|
||||
return os.path.join(self.root_path, username)
|
||||
|
||||
def get_vods_path(self, username):
|
||||
"""Returns the path to a user's VODs directory."""
|
||||
return os.path.join(self.root_path, username, self.vod_directory_name)
|
||||
|
||||
|
||||
def get_stream_path(self, username):
|
||||
"""Returns the path to a user's stream directory."""
|
||||
return os.path.join(self.root_path, username, self.stream_directory_name)
|
||||
|
||||
|
||||
def get_stream_file_path(self, username):
|
||||
"""Returns the path to a user's stream index file."""
|
||||
return os.path.join(self.get_stream_path(username), "index.m3u8")
|
||||
|
||||
|
||||
def get_current_stream_thumbnail_file_path(self, username):
|
||||
"""Returns the path to a user's current stream thumbnail."""
|
||||
return os.path.join(self.get_stream_path(username), "index.png")
|
||||
|
||||
|
||||
def get_vod_file_path(self, username, vod_id):
|
||||
"""Returns the path to a specific VOD file."""
|
||||
return os.path.join(self.get_vods_path(username), f"{vod_id}.mp4")
|
||||
|
||||
|
||||
def get_vod_thumbnail_file_path(self, username, vod_id):
|
||||
"""Returns the path to a specific VOD thumbnail."""
|
||||
return os.path.join(self.get_vods_path(username), f"{vod_id}.png")
|
||||
|
||||
|
||||
def get_profile_picture_file_path(self, username):
|
||||
return os.path.join(self.root_path, username, self.profile_picture_name)
|
||||
"""Returns the path to a user's profile picture."""
|
||||
return os.path.join(self.root_path, username, self.profile_picture_name)
|
||||
|
||||
Reference in New Issue
Block a user