fix(lib/cli): relative paths, empty slides, and tests (#223)

* fix(lib/cli): relative paths, empty slides, and tests

This fixes two issues:

1. Empty slides are now reported as error, to prevent indexing error;
2. Changing the folder path will now produce an absolute path to slides, which was not the case before and would lead to a "file does not exist error".

A few tests were also added to cover those

* fix(lib): fix from_file, remove useless field, and more

* chore(tests): remove print

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Jérome Eertmans
2023-07-24 13:58:54 +02:00
committed by GitHub
parent 2b6240c4d3
commit 529a6c534f
14 changed files with 200 additions and 18 deletions

View File

@ -786,7 +786,7 @@ def _list_scenes(folder: Path) -> List[str]:
for filepath in folder.glob("*.json"):
try:
_ = PresentationConfig.parse_file(filepath)
_ = PresentationConfig.from_file(filepath)
scenes.append(filepath.stem)
except (
Exception
@ -851,7 +851,7 @@ def get_scenes_presentation_config(
f"File {config_file} does not exist, check the scene name and make sure to use Slide as your scene base class"
)
try:
presentation_configs.append(PresentationConfig.parse_file(config_file))
presentation_configs.append(PresentationConfig.from_file(config_file))
except ValidationError as e:
raise click.UsageError(str(e))
@ -1047,7 +1047,7 @@ def present(
if config_path.exists():
try:
config = Config.parse_file(config_path)
config = Config.from_file(config_path)
except ValidationError as e:
raise click.UsageError(str(e))
else:
@ -1070,7 +1070,11 @@ def present(
if start_at[2]:
start_at_animation_number = start_at[2]
app = QApplication(sys.argv)
if not QApplication.instance():
app = QApplication(sys.argv)
else:
app = QApplication.instance()
app.setApplicationName("Manim Slides")
a = App(
presentations,