Skip to content

Fix disable_metadata_checks behavior and fix StaticItem support of bytes content #136

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

Merged
merged 4 commits into from
Feb 14, 2024

Conversation

benoit74
Copy link
Collaborator

@benoit74 benoit74 commented Feb 14, 2024

Rationale

  • libzim StringProvider supports both bytes and str types as content but StaticItem accepted only str in its type hint
    • this was detected while migrating add_item_for to use new StaticItem parameters
  • last PR Relax metadata check #135 was incorrect 🤦🏻
  • using main code on kolibri showed an issue when the content passed to add_item_for/StaticItem is an empty string "" ; content is not set and StaticItem fails to know which content provider has to be used

Changes

  • accept both bytes and str types as content in StaticItem
  • accept both bytes and str types as content in scraperlib StringProvider
  • check at runtime that content type is correct before passing it to the StringProvider
  • reverse/fix logic of disable_metadata_checks
  • always set item attributes when passed, even if 'False'/empty/whatever
  • add sufficient tests, including the addition of a non-UTF8 item into the ZIM (as bytes) and its decoding

@benoit74 benoit74 self-assigned this Feb 14, 2024
Copy link

codecov bot commented Feb 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a25ec60) 100.00% compared to head (d180e35) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #136   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           32        32           
  Lines         1373      1374    +1     
  Branches       239       240    +1     
=========================================
+ Hits          1373      1374    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@benoit74 benoit74 changed the title Fix disable_metadata_checks behavior and use StaticItem new parameters Fix disable_metadata_checks behavior and fix StaticItem support of bytes content Feb 14, 2024
@benoit74 benoit74 marked this pull request as ready for review February 14, 2024 07:53
@benoit74 benoit74 requested a review from rgaudin February 14, 2024 07:54
@rgaudin rgaudin merged commit 604e16d into main Feb 14, 2024
@rgaudin rgaudin deleted the small_fixes branch February 14, 2024 08:55
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.

2 participants