Skip to content

[next-major] Remove metadata conversion from python-libzim #188

Closed

Description

@benoit74

When adding metadatas, the python-libzim is doing a conversion for some types.

This should be removed because:

  • the python-libzim is meant to be only a thin wrapper around the C libzim
  • not all types are handled which is confusing (for instance we missed the conversion of tags list to a string)

This would need a major release since it is a breaking change.

Activity

  1. added
    good first issue
    on Feb 8, 2024
  2. changed the title [-]Remove metadata conversion from python-libzim[/-] [+][next-major] Remove metadata conversion from python-libzim[/+] on Oct 15, 2024
  3. siddheshwar-9897 commented on Feb 23, 2025

    @siddheshwar-9897

    sir is this issue still open

  4. siddheshwar-9897 commented on Feb 23, 2025

    @siddheshwar-9897

    As per the issue, the current implementation in python-libzim automatically converts certain types of metadata (such as datetime.date and datetime.datetime objects) when they are added. The conversion includes:

    Converting dates to a YYYY-MM-DD string and encoding in UTF-8.
    Automatically encoding strings in UTF-8.
    This leads to two main problems:

    Inconsistent Type Handling: Not all types are handled consistently, such as lists (e.g., tags) not being converted to strings.
    Unnecessary Conversion: The conversion is not required, as libzim itself is likely capable of handling the raw metadata types.
    Suggested Solution:
    I propose we remove the automatic conversion logic entirely, which would simplify the code and avoid the inconsistencies. Specifically:

    Remove date conversion: Stop automatically converting datetime.date and datetime.datetime objects into strings.
    Remove string encoding: Stop automatically encoding strings into UTF-8 bytes.
    Let libzim handle types directly: Allow libzim to handle the metadata content as it expects, letting users handle any necessary conversions on their own.

    **This will:

    Make python-libzim a more straightforward wrapper that doesn’t enforce unnecessary transformations.
    Avoid confusion or issues with inconsistent conversions (like missing list-to-string handling).
    Give users more flexibility and control over their metadata, ensuring they're working with the exact data format they need.
    Since this would be a breaking change (as it removes the automatic conversion behavior), I suggest we plan for a major release and update the documentation accordingly to inform users of the change.**

    Let me know your thoughts or if you'd like to discuss further.

    Best regards,
    Siddheshwar Kadm

  5. benoit74 commented on Feb 23, 2025

    @benoit74
    ContributorAuthor

    I'm sorry, but I won't read your comment. This is way too long/verbose and using way too much emphasis for something as straightforward as removing few lines of code.

    Propose a PR, but please be sharp.

  6. rgaudin commented on Feb 24, 2025

    @rgaudin
    Member

    I believe we have a PR already that's ready and awaits that next major

  7. benoit74 commented on Feb 24, 2025

    @benoit74
    ContributorAuthor

    I believe we have a PR already that's ready and awaits that next major

    Indeed ! @aryanA101a PR is ready

  8. self-assigned this
    on Feb 24, 2025
  9. benoit74 commented on Feb 24, 2025

    @benoit74
    ContributorAuthor

    Cannot assign aryanA101a so assigning myself so that it is clear

  10. added this to the 4.0.0 milestone on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

good first issue

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions