Skip to content

Commit

Permalink
清理 fs_util
Browse files Browse the repository at this point in the history
  • Loading branch information
TakWolf committed Jul 7, 2024
1 parent c1af5a2 commit 8143bc5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
4 changes: 2 additions & 2 deletions tools/configs/font.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import tomllib
from pathlib import Path

from pixel_font_builder import WeightName, SerifStyle, SlantStyle, WidthStyle

from tools.configs import path_define
from tools.utils import fs_util

_DEFAULT_PREVIEW_TEXT = '''
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Expand All @@ -21,7 +21,7 @@ def load() -> dict[str, 'FontConfig']:
file_path = file_dir.joinpath('config.toml')
if not file_path.is_file():
continue
config_data = fs_util.read_toml(file_path)['font']
config_data = tomllib.loads(file_path.read_text('utf-8'))['font']
name = config_data['name']
weight_name = WeightName(config_data['weight_name'])
serif_style = SerifStyle(config_data['serif_style'])
Expand Down
11 changes: 9 additions & 2 deletions tools/services/font_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
from tools import configs
from tools.configs import path_define
from tools.configs.font import FontConfig
from tools.utils import fs_util


def _is_empty_dir(path: Path) -> bool:
for item_path in path.iterdir():
if item_path.name == '.DS_Store':
continue
return False
return True


class GlyphFile:
Expand Down Expand Up @@ -109,7 +116,7 @@ def format_glyph_files(font_config: FontConfig, glyph_files: list[GlyphFile]):
logger.info("Standardize glyph file path: '{}'", glyph_file.file_path)

for file_dir, _, _ in root_dir.walk(top_down=False):
if fs_util.is_empty_dir(file_dir):
if _is_empty_dir(file_dir):
shutil.rmtree(file_dir)


Expand Down
Empty file removed tools/utils/__init__.py
Empty file.
16 changes: 0 additions & 16 deletions tools/utils/fs_util.py

This file was deleted.

0 comments on commit 8143bc5

Please sign in to comment.