-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: change data storage to SQLite (#19)
### What this PR does / why we need it: - change data storage to SQLite - refactor code - remove setting item: FLAG_GENERATE_SRGF, FLAG_GENERATE_XLSX - bump version from 1.1.2 to 2.0.0
- Loading branch information
Showing
42 changed files
with
1,551 additions
and
1,410 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from star_rail.utils.version import get_version | ||
|
||
VERSION = (1, 1, 2) | ||
VERSION = (2, 0, 0) | ||
|
||
__version__ = get_version(VERSION) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,81 @@ | ||
import functools | ||
|
||
from star_rail import exceptions as error | ||
from star_rail.config import ConfigClient, settings | ||
from star_rail.i18n import i18n | ||
from star_rail.module.mihoyo.account import UserManager | ||
from star_rail.module.month.client import MonthClient | ||
from star_rail.module.month.mapper import MonthInfoMapper | ||
from star_rail.module import AccountManager, GachaClient, MonthClient | ||
from star_rail.utils import functional | ||
|
||
__all__ = ["refresh_month_info", "show_month_info"] | ||
|
||
_lang = i18n.client | ||
############################################################## | ||
# 跃迁记录 | ||
############################################################## | ||
|
||
|
||
def refresh_month_info(): | ||
user = UserManager().user | ||
if None is user: | ||
print(functional.color_str(_lang.no_account, "yellow")) | ||
return | ||
if not user.cookie.verify_cookie_token(): | ||
print(functional.color_str(_lang.empty_cookie, "yellow")) | ||
return | ||
month_client = MonthClient(user) | ||
month_client.refresh_month_info() | ||
month_client.visualization(MonthInfoMapper.query(user.uid, None, 6)) | ||
|
||
|
||
def show_month_info(): | ||
user = UserManager().user | ||
if None is user: | ||
print(functional.color_str(_lang.no_account, "yellow")) | ||
return | ||
month_client = MonthClient(user) | ||
month_client.visualization(MonthInfoMapper.query(user.uid, None, 6)) | ||
|
||
__all__ = ["HSRClient"] | ||
|
||
|
||
class HSRClient(GachaClient, MonthClient, ConfigClient): | ||
def __init__(self) -> None: | ||
self.setting = settings | ||
self.user = AccountManager().user | ||
|
||
def check_user(func): | ||
@functools.wraps(func) | ||
def wrapper(self, *args, **kwargs): | ||
self.user = AccountManager().user | ||
if self.user is None: | ||
print(functional.color_str(_lang.no_account, "yellow")) | ||
return | ||
return func(self, *args, **kwargs) | ||
|
||
return wrapper | ||
|
||
@error.exec_catch() | ||
@check_user | ||
def refresh_month_info(self): | ||
# TODO 支持国际服 | ||
from star_rail.module.mihoyo import GameBiz | ||
|
||
if GameBiz.get_by_uid(self.user.uid) == GameBiz.GLOBAL: | ||
raise error.HsrException("该功能尚未支持国际服账号") | ||
if not self.user.cookie.verify_cookie_token(): | ||
print(functional.color_str(_lang.empty_cookie, "yellow")) | ||
return | ||
super().refresh_month_info() | ||
super().show_month_info() | ||
|
||
@error.exec_catch() | ||
@check_user | ||
def show_month_info(self): | ||
super().show_month_info() | ||
|
||
@error.exec_catch() | ||
@check_user | ||
def refresh_record_by_user_cache(self): | ||
super().refresh_record_by_user_cache() | ||
|
||
@error.exec_catch() | ||
@check_user | ||
def refresh_record_by_game_cache(self): | ||
super().refresh_record_by_game_cache() | ||
|
||
@error.exec_catch() | ||
def refresh_record_by_clipboard(self): | ||
super().refresh_record_by_clipboard() | ||
|
||
@error.exec_catch() | ||
@check_user | ||
def show_analyze_result(self): | ||
super().show_analyze_result() | ||
|
||
@error.exec_catch() | ||
@check_user | ||
def import_gacha_record(self): | ||
super().import_gacha_record() | ||
|
||
@error.exec_catch() | ||
@check_user | ||
def export_record_to_xlsx(self): | ||
super().export_record_to_xlsx() | ||
|
||
@error.exec_catch() | ||
@check_user | ||
def export_record_to_srgf(self): | ||
super().export_record_to_srgf() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
from .settings import * # noqa | ||
from .client import * | ||
from .settings import * | ||
|
||
__all__ = ["settings", "ConfigClient"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from star_rail.utils import functional | ||
from star_rail.utils.log import logger | ||
|
||
from .settings import Settings, settings | ||
|
||
__all__ = ["ConfigClient"] | ||
|
||
|
||
class ConfigClient: | ||
def __init__(self, setting: Settings = settings) -> None: | ||
self.setting = setting | ||
|
||
def get_config_status(self, key): | ||
if not hasattr(self.setting, key): | ||
return | ||
from star_rail.i18n import i18n | ||
|
||
return "{}: {}".format( | ||
i18n.config.settings.current_status, | ||
functional.color_str(i18n.common.open, "green") | ||
if settings.get(key) | ||
else functional.color_str(i18n.common.close, "red"), | ||
) | ||
|
||
def open_setting(self, key: str): | ||
if not hasattr(self.setting, key): | ||
return | ||
from star_rail.i18n import i18n | ||
|
||
self.setting.set_and_save(key, True) | ||
logger.success(i18n.config.settings.open_success) | ||
|
||
def close_setting(self, key: str): | ||
if not hasattr(self.setting, key): | ||
return | ||
from star_rail.i18n import i18n | ||
|
||
self.setting.set_and_save(key, False) | ||
logger.success(i18n.config.settings.close_success) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.