Page MenuHomeSoftware Heritage

Add a bencode encoder.
AbandonedPublic

Authored by vlorentz on Sep 20 2019, 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 7914
Build 11392: tox-on-jenkinsJenkins
Build 11391: arc lint + arc unit

Event Timeline

better error in case of invalid type.

douardda added a subscriber: douardda.
douardda added inline comments.
swh/core/bencode.py
5

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.

54

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

swh/core/tests/test_bencode.py
12

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

This revision now requires changes to proceed.Sep 23 2019, 9:58 AM

rewrite with generators

swh/core/bencode.py
5

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

54

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
12

I use assertRaises.

better error message on dict key type