Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid IndexError with empty source dir #498

Merged
merged 1 commit into from Sep 7, 2023

Conversation

jraby
Copy link
Contributor

@jraby jraby commented Sep 7, 2023

When running with an empty source directory, sigal would crash with the following error:

$ touch empty.py
$ mkdir emptydir
$ sigal build -c empty.py  emptydir/
Collecting albums, done.
  Sorting albums  [####################################]  100%
   Sorting media  [####################################]  100%
WARNING: No albums found.
Traceback (most recent call last):
  File "/home/jean/ws/src/sigal/env/bin/sigal", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/jean/ws/src/sigal/env/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jean/ws/src/sigal/env/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/jean/ws/src/sigal/env/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jean/ws/src/sigal/env/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jean/ws/src/sigal/env/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jean/ws/src/sigal/src/sigal/__main__.py", line 215, in build
    stats_str += f"{format_stats(types[-1])}"
                                 ~~~~~^^^^
IndexError: list index out of range

This PR avoids printing stats when none have been gathered.

@codecov
Copy link

codecov bot commented Sep 7, 2023

Codecov Report

Merging #498 (b8815bd) into main (c15d543) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #498   +/-   ##
=======================================
  Coverage   88.70%   88.70%           
=======================================
  Files          25       25           
  Lines        2062     2062           
=======================================
  Hits         1829     1829           
  Misses        233      233           
Files Changed Coverage Δ
src/sigal/__main__.py 89.18% <100.00%> (ø)

@saimn
Copy link
Owner

saimn commented Sep 7, 2023

Thanks!

@saimn saimn merged commit 69bd554 into saimn:main Sep 7, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants