Skip to content
Snippets Groups Projects

utils.grouper: Improve implementation

1 unresolved thread

Loader-tar defines a slightly different utils.grouper to deal with iterable of tuples. This improves the generic definition to deal with that case. That allows to remove some code in the loader-tar.

Related swh-environment#1411 (closed)

Test Plan

tox


Migrated from D793 (view on Phabricator)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
31 31
32 def test_grouper_with_stop_value(self):
33 # given
34 actual_data = utils.grouper(((i, i+1) for i in range(0, 9)), 2)
35
36 out = []
37 for d in actual_data:
38 out.append(list(d)) # force generator resolution for checks
39
40 self.assertEqual(out, [
41 [(0, 1), (1, 2)],
42 [(2, 3), (3, 4)],
43 [(4, 5), (5, 6)],
44 [(6, 7), (7, 8)],
45 [(8, 9)]])
46
  • Merge request was returned for changes

    • utils.grouper: Rename fillvalue to stop_value and fix docstring
    • utils.grouper: Avoid potential bug of input data matching stop_value
  • vlorentz mentioned in merge request swh-loader-tar!9 (closed)

    mentioned in merge request swh-loader-tar!9 (closed)

  • Merge request was accepted

  • vlorentz approved this merge request

    approved this merge request

  • Merge request was merged

  • Please register or sign in to reply
    Loading