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

Handling of empty markdown or missing meta-data #120

merged 1 commit into from
Oct 15, 2014


Copy link

Respect markdown files which do not contain any meta-data.

Respect markdown files which do not contain any meta-data.
Copy link

saimn commented Oct 14, 2014

I fail to reproduce an error with this code, could you give more details ?

Copy link
Contributor Author


Of course...

Create an empty file or one without meta-data header in your gallery and initiate a 'sigal build' and enjoy the exception:

Traceback (most recent call last):
File "/usr/local/bin/sigal", line 9, in
load_entry_point('sigal==0.8.1', 'console_scripts', 'sigal')()
File "/usr/local/lib/python2.7/dist-packages/click-3.3-py2.7.egg/click/", line 610, in call
return self.main(_args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/click-3.3-py2.7.egg/click/", line 590, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click-3.3-py2.7.egg/click/", line 936, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python2.7/dist-packages/click-3.3-py2.7.egg/click/", line 782, in invoke
return ctx.invoke(self.callback, *_ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click-3.3-py2.7.egg/click/", line 416, in invoke
return callback(_args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/sigal-0.8.1-py2.7.egg/sigal/", line 132, in build
gal = Gallery(settings, ncpu=ncpu)
File "/usr/local/lib/python2.7/dist-packages/sigal-0.8.1-py2.7.egg/sigal/", line 462, in init
album = Album(relpath, settings, dirs, files, self)
File "/usr/local/lib/python2.7/dist-packages/sigal-0.8.1-py2.7.egg/sigal/", line 198, in init
File "/usr/local/lib/python2.7/dist-packages/sigal-0.8.1-py2.7.egg/sigal/", line 268, in _get_metadata
meta = read_markdown(descfile)
File "/usr/local/lib/python2.7/dist-packages/sigal-0.8.1-py2.7.egg/sigal/", line 67, in read_markdown
'title': md.Meta.get('title', [''])[0],
AttributeError: 'Markdown' object has no attribute 'Meta'

Some details about our usage scenario: We are using Sigal as our internal intranet event gallery. There we do host tens of thousands of photos of our events. The photos are managed by our marketing department and some other administrative staff.
They can upload the image using SFTP to our server and then initiate the build process of Sigal using some helper scripts on the console.
During this process of uploading images and markdown files it occurs that we have empty markdown files or markdown files without any meta-data.

Your implementation of read_markdown() does rely on existing meta-data in these files. So the result is an exception and cancelled gallery build.
My fix does only read meta-data from the markdown file if present, returning 'None' in case no meta-data or title is given.

Copy link
Contributor Author

I have two lines of additional print() debug in my method. So you should see line 65 in your exception while reproducing this problem.

Copy link

saimn commented Oct 15, 2014

Thanks for the details. I can reproduce if the file is empty (I didn't test this yesterday), but not if there the file contains a text and no metadata (in this case md.Meta is always set, whereas when the file is empty the meta extension is probably not called).
Returning None is not enough as it will set the title to None. I will check how to handle this correctly.

@saimn saimn merged commit 594ed88 into saimn:master Oct 15, 2014
saimn added a commit that referenced this pull request Oct 15, 2014
@kfricke-hacon kfricke-hacon deleted the patch-1 branch January 9, 2015 10:26
@saimn saimn modified the milestone: 0.9 Aug 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants