docstring stuff
This commit is contained in:
@@ -7,7 +7,6 @@ import regex
|
||||
import logging
|
||||
import sys
|
||||
import traceback
|
||||
import asyncio
|
||||
sys.path.insert(1,'..')
|
||||
sys.path.insert(1,'.')
|
||||
from typing import Optional, Any
|
||||
@@ -29,9 +28,6 @@ class Cache:
|
||||
"cached_lyrics.db")
|
||||
self.redis_cache = redis_cache.RedisCache()
|
||||
|
||||
asyncio.get_event_loop().create_task(
|
||||
self.redis_cache.create_index())
|
||||
|
||||
self.cache_pre_query: str = "pragma journal_mode = WAL; pragma synchronous = normal;\
|
||||
pragma temp_store = memory; pragma mmap_size = 30000000000;"
|
||||
self.sqlite_exts: list[str] = ['/usr/local/lib/python3.11/dist-packages/spellfix1.cpython-311-x86_64-linux-gnu.so']
|
||||
@@ -39,7 +35,16 @@ class Cache:
|
||||
|
||||
def get_matched(self, matched_candidate: tuple, confidence: int,
|
||||
sqlite_rows: list[sqlite3.Row] = None, redis_results: Any = None) -> Optional[LyricsResult]:
|
||||
"""Get Matched Result"""
|
||||
"""
|
||||
Get Matched Result
|
||||
Args:
|
||||
matched_candidate (tuple): the correctly matched candidate returned by matcher.best_match
|
||||
confidence (int): % confidence
|
||||
sqlite_rows (list[sqlite3.Row]|None): List of returned rows from SQLite DB, or None if Redis
|
||||
redis_results (Any): List of Redis returned data, or None if SQLite
|
||||
Returns:
|
||||
LyricsResult|None: The result, if found - None otherwise.
|
||||
"""
|
||||
matched_id: int = matched_candidate[0]
|
||||
if redis_results:
|
||||
for res in redis_results:
|
||||
@@ -68,7 +73,10 @@ class Cache:
|
||||
async def check_existence(self, artistsong: str) -> Optional[bool]:
|
||||
"""
|
||||
Check whether lyrics are already stored for track
|
||||
@artistsong: artist and song in artist\nsong format
|
||||
Args:
|
||||
artistsong (str): artist and song in artist\\nsong format
|
||||
Returns:
|
||||
bool: Whether track was found in cache
|
||||
"""
|
||||
logging.debug("Checking whether %s is already stored",
|
||||
artistsong.replace("\n", " - "))
|
||||
@@ -88,8 +96,11 @@ class Cache:
|
||||
|
||||
async def store(self, lyr_result: LyricsResult) -> None:
|
||||
"""
|
||||
store
|
||||
@lyr_result: the returned lyrics to cache
|
||||
Store lyrics to cache
|
||||
Args:
|
||||
lyr_result: the returned lyrics to cache
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
|
||||
logging.info("Storing %s",
|
||||
@@ -127,11 +138,12 @@ class Cache:
|
||||
# pylint: disable=unused-argument
|
||||
async def search(self, artist: str, song: str, **kwargs) -> Optional[LyricsResult]:
|
||||
"""
|
||||
search
|
||||
@artist: the artist to search
|
||||
@song: the song to search
|
||||
Cache Search
|
||||
Args:
|
||||
artist: the artist to search
|
||||
song: the song to search
|
||||
Returns:
|
||||
- LyricsResult corresponding to nearest match found (if found), **None** otherwise
|
||||
LyricsResult|None: The result, if found - None otherwise.
|
||||
"""
|
||||
try:
|
||||
# pylint: enable=unused-argument
|
||||
|
||||
Reference in New Issue
Block a user