python-libzim icon indicating copy to clipboard operation
python-libzim copied to clipboard

Support iterators

Open rgaudin opened this issue 4 years ago • 18 comments

Archive needs support for a few iterators:

  • Archive.iterByPath()
  • Archive.iterByTitle()
  • Archive.iterEfficient() (arguable)
  • Archive.findByPath(path)
  • Archive.findByTitle(title)

rgaudin avatar Jan 21 '21 09:01 rgaudin

Awaiting this to remove Archive.get_entry_by_id(), Entry.index and Item.index as it's the only way to loop over the zim content at the moment and we use it in tests.

rgaudin avatar Jan 21 '21 09:01 rgaudin

It would be nice to have a "default" iterator (iterEfficient?) on Archive itself.

This way we could iterate over archive with :

archive = Archive("foo.zim")
for entry in archive:
    print(entry.title)

mgautierfr avatar Jan 21 '21 10:01 mgautierfr

absolutely 👍

rgaudin avatar Jan 21 '21 10:01 rgaudin

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

stale[bot] avatar Dec 09 '21 01:12 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

stale[bot] avatar Mar 02 '22 09:03 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

stale[bot] avatar Jul 10 '22 14:07 stale[bot]

Turns out zim-tools can list all the articles you need

ZIM Articles List

dentropy avatar Oct 29 '23 21:10 dentropy

This feature is not directly of interest for us but is a MUST for people using python-libzim to ready/inspect ZIM files. How much effort would be needed to implement it?

kelson42 avatar Nov 04 '23 16:11 kelson42

It is of interest to us. We're using the workaround. I can't do it on my own in a reasonable time but I think it would be easy for @mgautierfr

rgaudin avatar Nov 04 '23 16:11 rgaudin

@mgautierfr How much work woukd be needed to get this feature implemented?

kelson42 avatar Nov 05 '23 20:11 kelson42

Should be pretty straightforward. Few hours, a day at most.

mgautierfr avatar Nov 06 '23 08:11 mgautierfr

It is of interest to us. We're using the workaround. I can't do it on my own in a reasonable time but I think it would be easy for @mgautierfr

What's the work around?

traverseda avatar Nov 26 '23 13:11 traverseda

It is of interest to us. We're using the workaround. I can't do it on my own in a reasonable time but I think it would be easy for @mgautierfr

What's the work around?

I suppose is referring to this

SrGnis avatar Nov 26 '23 14:11 SrGnis

Thanks for the very quick response! Here's what that looks like in practice, in case this feature isn't added soon.

  zim = Archive(os.path.expanduser("~/test.zim"))                                                                                       
                                                                                                                                                                 
  for i in range(0,zim.all_entry_count):                                                                                                                         
      entry = zim._get_entry_by_id(i)                                                                                                                            
      print(entry)                                                                                                                                                                 
  

traverseda avatar Nov 26 '23 14:11 traverseda

We will implement it soon

kelson42 avatar Nov 26 '23 15:11 kelson42