Page MenuHomeSoftware Heritage

Add a bencode encoder.
Changes PlannedPublic

Authored by vlorentz on Fri, Sep 20, 4:27 PM.

Details

Reviewers
olasd
douardda
Group Reviewers
Reviewers
Summary

It will be used to get a canonical id for use in message keys
in Kafka.

Diff Detail

Repository
rDCORE Foundations and core functionalities
Branch
bencode-encoder
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 7916
Build 11396: tox-on-jenkinsJenkins
Build 11395: arc lint + arc unit

Event Timeline

vlorentz created this revision.Fri, Sep 20, 4:27 PM
vlorentz updated this revision to Diff 6792.Fri, Sep 20, 5:22 PM

better error in case of invalid type.

douardda requested changes to this revision.Mon, Sep 23, 9:58 AM
douardda added a subscriber: douardda.
douardda added inline comments.
swh/core/bencode.py
6

It really misses a docstring at module level to explain what it is and how to use it, and how are basic types serialized by this encoder.

55

I don't get the list used to gather results here. Why isn't this just a generator?

swh/core/tests/test_bencode.py
13

why not using pytest's test functions here? What's the value of using a TestCase?

This revision now requires changes to proceed.Mon, Sep 23, 9:58 AM
vlorentz updated this revision to Diff 6800.Mon, Sep 23, 10:30 AM

rewrite with generators

swh/core/bencode.py
6

I'm not sure what to write here; there's a single public function, and it's already documented.

55

Because I didn't think of using a generator.

I just rewrote it to use a generator, the code is almost the same (although generators are slightly slower), so I don't really care either way * shrug *

swh/core/tests/test_bencode.py
13

I use assertRaises.

vlorentz updated this revision to Diff 6801.Mon, Sep 23, 1:43 PM

rewrite tests for pytest

vlorentz updated this revision to Diff 6802.Mon, Sep 23, 3:06 PM

better error message on dict key type

vlorentz planned changes to this revision.Mon, Oct 7, 1:50 PM