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
Add new plugin to allow one to disable ZIP generation on a per album basis #368
Conversation
…basis * Heavily inspired by the '.nomedia' file
Codecov Report
@@ Coverage Diff @@
## master #368 +/- ##
==========================================
- Coverage 87.38% 86.62% -0.77%
==========================================
Files 18 19 +1
Lines 1443 1458 +15
==========================================
+ Hits 1261 1263 +2
- Misses 182 195 +13
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #368 +/- ##
==========================================
+ Coverage 87.38% 87.58% +0.19%
==========================================
Files 18 19 +1
Lines 1443 1466 +23
==========================================
+ Hits 1261 1284 +23
Misses 182 182
Continue to review full report at Codecov.
|
Note: Another solution would have been to rely on the album I've chosen to use a |
Hi, |
* ZIP generation logic is now self contained in a plugin * '.nozip_gallery' file logic is now contained in the same plugin that managed the zip generation
Hi, my turn to take a long time to respond, sorry about that. I've made some modifications and moved the whole zip generation logic to a About the unit tests, I'll see if I can find some time to write them. Before going further, I want to be sure that we're on the same page about the zip logic modifications that I've made in fc14de3 |
BTW @saimn , just noticed that you're from Lyon. If you want to meet and discuss further in real life next to a beer or so, I'd be glad |
sigal/plugins/zip_gallery.py
Outdated
".nozip_gallery file", album.name) | ||
zip_method = noop_zip_method | ||
|
||
album.__class__.zip = cached_property(zip_method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the property is set on the class, it will be used for all the Album objects (the last will win). So instead I think that you can check for the "nozip" file directly in generate_album_zip_method
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right, this was too naive. I've switched to a single function that does all the checks and contains all the logic.
archive.close() | ||
self.logger.debug('Created ZIP archive %s', archive_path) | ||
return zip_gallery | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if having the placeholder method is necessary? Jinja evaluates missing attributes to an empty string - I think, so it should be fine if the .zip
method is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is necessary. I just thought this can make the code easier to read.
For the reader, this placeholder may give a hint on where the actual implementation of the zip property is made. (I'm not a huge fan of magic properties that just appears you don't know where from even if python allows it
Anyway, If you'd like me to remove the placeholder, no problem for me. I can simply replace it with a comment to help future readers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point about the magic aspect and agree in general, but on the other side it is weird to have some unrelated zip stuff here, since this is now an independent feature. And the implementation will be easy to find in the zip plugin.
Thanks @riton , I think this is a very nice improvement! |
* One single entry point for the 'zip' property
@saimn I've made some quick modifications following your suggestions. Still no unit tests for now. |
docs/plugins.rst
Outdated
@@ -119,6 +119,11 @@ Nomedia plugin | |||
|
|||
.. automodule:: sigal.plugins.nomedia | |||
|
|||
No ZIP Gallery plugin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No ZIP Gallery plugin | |
ZIP Gallery plugin |
The plugin is more general now ;)
archive.close() | ||
self.logger.debug('Created ZIP archive %s', archive_path) | ||
return zip_gallery | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point about the magic aspect and agree in general, but on the other side it is weird to have some unrelated zip stuff here, since this is now an independent feature. And the implementation will be easy to find in the zip plugin.
sigal/plugins/zip_gallery.py
Outdated
Album.zip = cached_property(generate_album_zip) | ||
|
||
def register(settings): | ||
signals.album_initialized.connect(nozip_galery_file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
galery -> gallery (and the same above)
sigal/plugins/zip_gallery.py
Outdated
album.logger.warn('Failed to add %s to the ZIP: %s', p, e) | ||
|
||
archive.close() | ||
album.logger.debug('Created ZIP archive %s', archive_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the logger
defined at the top of the module instead of album.logger
.
@riton - Could you have a look at the test to see why it is failing ? |
Hi @riton , |
Add new plugin to allow one to disable ZIP generation on a per album basis
Heavily inspired by the
.nomedia
file, this patch introduces a new plugin callednozip_gallery
.If
zip_gallery
is enabled, this plugin allows to control on a per album basis if a ZIP file should be generated or not.It currently uses a
.nozip_gallery
file (empty or not) to achieve such behavior.The motivation behind this plugin is: