feat: better check toml empty
This commit is contained in:
parent
d819847e8a
commit
4ad897392e
|
|
@ -12,6 +12,16 @@ from joj3_config_generator.models.common import Memory, Time
|
|||
from joj3_config_generator.utils.logger import logger
|
||||
|
||||
|
||||
def is_toml_empty(toml_path: Path) -> bool:
|
||||
if toml_path.stat().st_size == 0:
|
||||
return True
|
||||
try:
|
||||
data = tomli.loads(toml_path.read_text())
|
||||
return not data
|
||||
except tomli.TOMLDecodeError:
|
||||
return False
|
||||
|
||||
|
||||
def load_joj3_task_toml_answers() -> answer.Answers:
|
||||
name = inquirer.text("What's the task name?", default="hw0")
|
||||
language = inquirer.list_input(
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ from joj3_config_generator.generator import (
|
|||
create_joj3_task_conf,
|
||||
)
|
||||
from joj3_config_generator.loader import (
|
||||
is_toml_empty,
|
||||
load_joj1_yaml,
|
||||
load_joj3_task_toml_answers,
|
||||
load_joj3_toml,
|
||||
|
|
@ -106,7 +107,7 @@ def convert(
|
|||
for task_toml_path in repo_toml_path.parent.glob("**/*.toml"):
|
||||
if repo_toml_path == task_toml_path:
|
||||
continue
|
||||
if len(task_toml_path.read_bytes()) == 0:
|
||||
if is_toml_empty(task_toml_path):
|
||||
logger.info(f"Skipping empty task toml file {task_toml_path}")
|
||||
continue
|
||||
toml_name = task_toml_path.name.removesuffix(".toml")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user