Skip to content

Commit

Permalink
清理 config 类
Browse files Browse the repository at this point in the history
  • Loading branch information
TakWolf committed Jul 2, 2024
1 parent 87045fd commit 752bcac
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 43 deletions.
7 changes: 0 additions & 7 deletions tools/configs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from tools.configs.source import GithubSourceConfig, GitSourceType

font_version = '2024.05.12'

Expand Down Expand Up @@ -49,9 +48,3 @@
'galmuri',
],
}

ark_pixel_config = GithubSourceConfig(
repository_name='TakWolf/ark-pixel-font',
source_type=GitSourceType.TAG,
source_name=None,
)
23 changes: 0 additions & 23 deletions tools/configs/source.py

This file was deleted.

30 changes: 17 additions & 13 deletions tools/services/update_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,38 @@
import zipfile

from tools import configs
from tools.configs import path_define, ark_pixel_config, GitSourceType
from tools.configs import path_define
from tools.configs.update import UpdateConfig
from tools.utils import fs_util, github_api, download_util

logger = logging.getLogger(__name__)


def update_ark_pixel_glyphs_version():
if ark_pixel_config.source_type == GitSourceType.TAG:
tag_name = ark_pixel_config.source_name
repository_name = 'TakWolf/ark-pixel-font'
source_type = 'tag'
source_name = None

if source_type == 'tag':
tag_name = source_name
if tag_name is None:
tag_name = github_api.get_releases_latest_tag_name(ark_pixel_config.repository_name)
sha = github_api.get_tag_sha(ark_pixel_config.repository_name, tag_name)
tag_name = github_api.get_releases_latest_tag_name(repository_name)
sha = github_api.get_tag_sha(repository_name, tag_name)
version = tag_name
elif ark_pixel_config.source_type == GitSourceType.BRANCH:
branch_name = ark_pixel_config.source_name
sha = github_api.get_branch_latest_commit_sha(ark_pixel_config.repository_name, branch_name)
elif source_type == 'branch':
branch_name = source_name
sha = github_api.get_branch_latest_commit_sha(repository_name, branch_name)
version = branch_name
elif ark_pixel_config.source_type == GitSourceType.COMMIT:
sha = ark_pixel_config.source_name
elif source_type == 'commit':
sha = source_name
version = sha
else:
raise Exception(f"Unknown source type: '{ark_pixel_config.source_type}'")
raise Exception(f"Unknown source type: '{source_type}'")
version_info = {
'sha': sha,
'version': version,
'version_url': f'https://github.com/{ark_pixel_config.repository_name}/tree/{version}',
'asset_url': f'https://github.com/{ark_pixel_config.repository_name}/archive/{sha}.zip',
'version_url': f'https://github.com/{repository_name}/tree/{version}',
'asset_url': f'https://github.com/{repository_name}/archive/{sha}.zip',
}
file_dir = path_define.fonts_dir.joinpath('ark-pixel')
file_dir.mkdir(parents=True, exist_ok=True)
Expand Down

0 comments on commit 752bcac

Please sign in to comment.