/
githubmirror
/
LeetCodeAnimation
Обзор
Документация
Войти
/
githubmirror
/
LeetCodeAnimation
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
tools/anima/model.py
47 строк
1 KB
吴师兄
docs: streamline repository root layout
10 июн 2026, 11:06
10 июн 2026, 11:06
e3001f4
Код
Авторство
О чём код?
import re from dataclasses import dataclass from pathlib import Path @dataclass class ProblemInfo: id: int title: str def title_slug(self): title_parts = re.split(r'\s+', self.title) return f'{self.id:04d}-' + '-'.join(title_parts) @dataclass class Solution: problem: ProblemInfo path: Path @classmethod def create(cls, problem: ProblemInfo, path: Path): solution = Solution(problem, path) solution._create_dirs() return solution def _create_dirs(self): self.animation_path().mkdir() self.article_path().mkdir() self.code_path().mkdir() (self.animation_path() / 'Animation.m4v').touch() (self.animation_path() / 'Animation.gif').touch() def _path_to(self, s: str) -> Path: return self.path / s def animation_path(self) -> Path: return self.path / 'Animation' def article_path(self) -> Path: return self.path / 'Article' def doc_path(self) -> Path: return self.article_path() / (self.problem.title_slug() + '.md') def code_path(self) -> Path: return self.path / 'Code'