refactor: update project code
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Dict, Iterable, List, Optional
|
||||
from typing import Iterable
|
||||
|
||||
from .command import CommandExecutor
|
||||
|
||||
@@ -23,18 +23,18 @@ class Entry:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
tasks: Dict[str, List[str]],
|
||||
tasks: dict[str, list[str]],
|
||||
basepath: Path,
|
||||
):
|
||||
self._tasks = tasks
|
||||
self._basepath = basepath
|
||||
|
||||
def show(self):
|
||||
self._logger.info(f"{self}")
|
||||
self._logger.info("%s", self)
|
||||
for task_name, commands in self._tasks.items():
|
||||
self._logger.info(f" {task_name}")
|
||||
self._logger.info(" %s", task_name)
|
||||
for command in commands:
|
||||
self._logger.debug(f" {command}")
|
||||
self._logger.debug(" %s", command)
|
||||
|
||||
def run_task(self, task_name: str):
|
||||
if task_name == "show":
|
||||
@@ -42,7 +42,7 @@ class Entry:
|
||||
return
|
||||
if task_name not in self._tasks:
|
||||
raise EntryTaskNotImplementedError(task_name)
|
||||
self._logger.info(f"{task_name} {self}")
|
||||
self._logger.info("%s %s", task_name, self)
|
||||
for command in self._tasks[task_name]:
|
||||
CommandExecutor(command).run(self._basepath)
|
||||
|
||||
@@ -51,12 +51,12 @@ class Entry:
|
||||
|
||||
|
||||
class EntryDetector:
|
||||
def detect_entry(self, basepath: Path) -> Optional["Entry"]:
|
||||
raise NotImplemented
|
||||
def detect_entry(self, basepath: Path) -> Entry | None:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class EntryResolver:
|
||||
def __init__(self, detector: EntryDetector, ignore: List[str]):
|
||||
def __init__(self, detector: EntryDetector, ignore: list[str]):
|
||||
self._detector = detector
|
||||
self._ignore = ignore
|
||||
|
||||
|
||||
Reference in New Issue
Block a user