Skip to content

Commit

Permalink
feat: add text UI (#33)
Browse files Browse the repository at this point in the history
fixed: #25
  • Loading branch information
cntvc committed Nov 27, 2023
1 parent f19e1aa commit edadaf2
Show file tree
Hide file tree
Showing 87 changed files with 4,272 additions and 3,846 deletions.
6 changes: 0 additions & 6 deletions .coveragerc

This file was deleted.

3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ max-line-length = 100
# F401: unused import.
# F403: cannot detect unused vars if we use starred import
# F405: may be undefined, or defined from star imports
# E402: module level import not at top of file
per-file-ignores =
**/__init__.py: F401, F403, F405
**/__init__.py: F401, F403, F405, E402
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:

- name: Package
run: |
poetry run pyinstaller --clean ./main_d.spec
poetry run pyinstaller --clean ./main_f.spec
poetry run pyinstaller --clean ./main_d.spec --noconfirm
poetry run pyinstaller --clean ./main_f.spec --noconfirm
- name: Generate package name
run: |
Expand Down
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
args: ["--maxkb=1024"]
- id: check-case-conflict

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.11.0
hooks:
- id: black
args: ["star_rail", "tests"]
Expand All @@ -24,7 +25,7 @@ repos:
args: ["star_rail", "tests"]

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
args: ["star_rail", "tests"]
19 changes: 12 additions & 7 deletions main_d.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,33 @@ dir_name = "StarRailTools"

src_root_dir = "star_rail"

def find_py_files(folder_path):
def find_files(folder_path, ext_type:str):
py_files = []
for root, dirs, files in os.walk(folder_path):
for file in files:
if file.endswith('.py'):
if file.endswith(ext_type):
py_files.append(os.path.join(root, file))
return py_files

file_list = find_py_files(src_root_dir)
# code file
file_list = find_files(src_root_dir, '.py')

# ui file
tcss_path = src_root_dir + "/tui"+"/tcss"
tcss_file = find_files(tcss_path, ".tcss")
ui_tuple_list = [(file, tcss_path) for file in tcss_file]


icon_path = "resource/hsr.ico"

data_list = [
(icon_path, "resource"),
]
data_list = ui_tuple_list

a = Analysis(
file_list,
pathex=[],
binaries=[],
datas=data_list,
hiddenimports=[],
hiddenimports=["textual.widgets._tab_pane"],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
Expand Down
20 changes: 12 additions & 8 deletions main_f.spec
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,32 @@ exe_name = "StarRailTools"

src_root_dir = "star_rail"

def find_py_files(folder_path):
def find_files(folder_path, ext_type:str):
py_files = []
for root, dirs, files in os.walk(folder_path):
for file in files:
if file.endswith('.py'):
if file.endswith(ext_type):
py_files.append(os.path.join(root, file))
return py_files

file_list = find_py_files(src_root_dir)

src_list = find_files(src_root_dir, '.py')


tcss_path = src_root_dir + "/tui"+"/tcss"
tcss_file = find_files(tcss_path, ".tcss")
ui_res_list = [(file, tcss_path) for file in tcss_file]

icon_path = "resource/hsr.ico"

data_list = [
(icon_path, "resource"),
]
data_list = ui_res_list

a = Analysis(
file_list,
src_list,
pathex=[],
binaries=[],
datas=data_list,
hiddenimports=[],
hiddenimports=["textual.widgets._tab_pane"],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
Expand Down
918 changes: 594 additions & 324 deletions poetry.lock

Large diffs are not rendered by default.

39 changes: 27 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "star_rail"
version = "2.1.1"
description = "Honkai: Star Rail Gacha Record Export Tools"
version = "3.0.0"
description = "Honkai: Star Rail Toolkit"
authors = ["Charlie Brown <[email protected]>"]
license = "GPLv3"
readme = "README.md"
Expand All @@ -10,31 +10,34 @@ packages = [{include = "star_rail"}]


[tool.poetry.dependencies]
python = ">=3.11,<3.13"
python = ">=3.11,<3.13" # pyinstaller requires ">=3.11,<3.13"
loguru = "^0.7.2"
requests = "^2.31.0"
xlsxwriter = "^3.1.7"
pydantic = "^2.4.2"
pydantic = "^2.5.1"
aiohttp = "^3.9.0"
yarl = "^1.9.2" # subdependencies for aiohttp
aiosqlite = "^0.19.0"
pyperclip = "^1.8.2"
yarl = "^1.9.2"
rich = "^13.6.0"
xlsxwriter = "^3.1.9"
textual = "^0.41.0"
pycryptodome = "^3.19.0"


[tool.poetry.group.dev.dependencies]
isort = "^5.12.0"
black = "^23.9.1"
black = "^23.11.0"
flake8 = "^6.1.0"
pre-commit = "^3.4.0"
pre-commit = "^3.5.0"
textual-dev = "^1.2.1"


[tool.poetry.group.test.dependencies]
pytest = "^7.4.2"
pytest = "^7.4.3"
pytest-cov = "^4.1.0"
pytest-asyncio = "^0.21.1"


[tool.poetry.group.release.dependencies]
pyinstaller = "^6.0.0"
pyinstaller = "^6.2.0"


[build-system]
Expand All @@ -49,3 +52,15 @@ profile = "black"

[tool.black]
line-length = 100

[tool.pytest.ini_options]
addopts = ["-vs"]
asyncio_mode = "auto"

[tool.coverage.run]
omit = [
"**/__init__.py",
"**/mapper.py",
"exceptions.py",
"main.py",
]
108 changes: 0 additions & 108 deletions star_rail/client.py

This file was deleted.

4 changes: 1 addition & 3 deletions star_rail/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from .settings import *

__all__ = ["settings"]
from .settings import settings
48 changes: 14 additions & 34 deletions star_rail/config/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import typing

from pydantic import BaseModel, ConfigDict, Field

Expand All @@ -11,31 +10,7 @@
_default_config_path = os.path.join(constants.CONFIG_PATH, "settings.json")


class Settings(BaseModel):
FLAG_AUTO_UPDATE: bool = True
"""自动更新"""

FLAG_UPDATED_COMPLETE: bool = False

UPDATE_SOURCE: typing.Literal["Github", "Coding"] = "Github"
"""更新源"""

OLD_EXE_NAME: str = ""
"""旧版本程序文件名,用于在更新版本后删除该文件"""

DEFAULT_UID: str = ""

SALT: str = ""
"""加密 salt"""

LANGUAGE: str = ""

DISPLAY_STARTER_WARP: bool = False
"""显示新手池"""

GACHA_RECORD_DESC_MOD: typing.Literal["table", "tree"] = "tree"
"""抽卡记录详情的显示模式"""

class BaseSetting(BaseModel):
config_path: str = Field(exclude=True)

model_config = ConfigDict(extra="ignore")
Expand All @@ -57,14 +32,19 @@ def refresh_config(self, path: str):
return
self.update_config(load_json(path))

def model_dump(self, mode: typing.Literal["log", "default"] = "default", *args, **kwargs):
if mode == "log":
"""部分参数值会隐藏"""
config_dict = super().model_dump()
config_dict["SALT"] = "***"
return config_dict
elif mode == "default":
return super().model_dump()

class Settings(BaseSetting):
CHECK_UPDATE: bool = True

DEFAULT_UID: str = ""

ENCRYPT_KEY: str = ""
"""加密 key"""

LANGUAGE: str = ""

DISPLAY_STARTER_WARP: bool = True
"""显示新手池"""


settings = Settings(config_path=_default_config_path)
Loading

0 comments on commit edadaf2

Please sign in to comment.