mirror of
https://github.com/shadoll/moma.git
synced 2026-08-28 11:33:25 +00:00
chore: Bump version to 0.6.1 and update decorators to use new cache system
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
"""Date formatting decorators.
|
||||
|
||||
Provides decorator versions of DateFormatter methods for cleaner code:
|
||||
|
||||
@date_decorators.year()
|
||||
def get_year(self):
|
||||
return self.extractor.get('year')
|
||||
"""
|
||||
|
||||
from functools import wraps
|
||||
from typing import Callable
|
||||
from .date_formatter import DateFormatter
|
||||
|
||||
|
||||
class DateDecorators:
|
||||
"""Date and time formatting decorators."""
|
||||
|
||||
@staticmethod
|
||||
def modification_date() -> Callable:
|
||||
"""Decorator to format modification dates.
|
||||
|
||||
Usage:
|
||||
@date_decorators.modification_date()
|
||||
def get_mtime(self):
|
||||
return self.file_path.stat().st_mtime
|
||||
"""
|
||||
def decorator(func: Callable) -> Callable:
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs) -> str:
|
||||
result = func(*args, **kwargs)
|
||||
return DateFormatter.format_modification_date(result)
|
||||
return wrapper
|
||||
return decorator
|
||||
|
||||
|
||||
# Singleton instance
|
||||
date_decorators = DateDecorators()
|
||||
Reference in New Issue
Block a user